XieYongHong 3 лет назад
Родитель
Сommit
b381356254

+ 6 - 6
config/proxy.ts

@@ -9,14 +9,14 @@
 export default {
   dev: {
     '/api': {
-      // target: 'http://192.168.32.8:8844/',
-      // ws: 'ws://192.168.32.8:8844/',
+      // target: 'http://192.168.32.28:8844/',
+      // ws: 'ws://192.168.32.28:8844/',
       // 开发环境
-      target: 'http://120.79.18.123:8844/',
-      ws: 'ws://120.79.18.123:8844/',
+      // target: 'http://120.79.18.123:8844/',
+      // ws: 'ws://120.79.18.123:8844/',
       // 测试环境
-      // target: 'http://120.77.179.54:8844/',
-      // ws: 'ws://120.77.179.54:8844/',
+      target: 'http://120.77.179.54:8844/',
+      ws: 'ws://120.77.179.54:8844/',
       // target: 'http://192.168.66.5:8844/',
       // ws: 'ws://192.168.66.5:8844/',
       // ws: 'ws://demo.jetlinks.cn/jetlinks',

+ 16 - 3
src/pages/account/Center/index.tsx

@@ -23,8 +23,9 @@ import Service from '@/pages/account/Center/service';
 import moment from 'moment';
 import { useModel } from 'umi';
 import usePermissions from '@/hooks/permission';
-import { PermissionButton } from '@/components';
+import { Ellipsis, PermissionButton } from '@/components';
 import { onlyMessage } from '@/utils/util';
+import AccountInit from '@/pages/home/init/accountInit';
 
 export const service = new Service();
 
@@ -129,7 +130,6 @@ const Center = () => {
   }, []);
 
   useEffect(() => {
-    console.log(data);
     if (data?.name) {
       const item = {
         ...initialState?.currentUser?.user,
@@ -168,7 +168,9 @@ const Center = () => {
           <div className={styles.content}>
             <Descriptions column={4} layout="vertical" labelStyle={{ fontWeight: 600 }}>
               <Descriptions.Item label="登录账号">{data?.username}</Descriptions.Item>
-              <Descriptions.Item label="账号ID">{data?.id}</Descriptions.Item>
+              <Descriptions.Item label="账号ID">
+                <Ellipsis title={data?.id} tooltip={{ placement: 'topLeft' }} maxWidth={'90%'} />
+              </Descriptions.Item>
               <Descriptions.Item label="注册时间">
                 {moment(data?.createTime).format('YYYY-MM-DD HH:mm:ss')}
               </Descriptions.Item>
@@ -310,6 +312,17 @@ const Center = () => {
           ))}
         </Row>
       </Card>
+      <Card
+        style={{ marginTop: 15 }}
+        title={
+          <div style={{ fontSize: '22px' }}>
+            <Divider type="vertical" style={{ backgroundColor: '#2F54EB', width: 3 }} />
+            首页视图
+          </div>
+        }
+      >
+        <AccountInit />,
+      </Card>
       {infos && (
         <InfoEdit
           data={data}

+ 64 - 55
src/pages/device/Instance/Detail/Modbus/index.tsx

@@ -1,7 +1,7 @@
 import { FormItem, ArrayTable, Editable, Select, NumberPicker } from '@formily/antd';
 import { createForm, Field, onFieldReact, FormPath, onFieldChange } from '@formily/core';
 import { FormProvider, createSchemaField } from '@formily/react';
-import { Badge, Card, Input, Tooltip } from 'antd';
+import { Badge, Card, Empty, Input, Tooltip } from 'antd';
 import { action } from '@formily/reactive';
 import type { Response } from '@/utils/typings';
 import './index.less';
@@ -25,6 +25,7 @@ export default (props: Props) => {
   const [masterList, setMasterList] = useState<any>([]);
   const [typeList, setTypeList] = useState<any>([]);
   const [reload, setReload] = useState<string>('');
+  const [empty, setEmpty] = useState<boolean>(false);
 
   //数据类型长度
   const lengthMap = new Map();
@@ -212,7 +213,6 @@ export default (props: Props) => {
       });
     service.dataType().then((res) => {
       if (res.status === 200) {
-        console.log(res.result);
         const items = res.result.map((item: any) => ({
           label: item.name,
           value: item.id,
@@ -227,22 +227,26 @@ export default (props: Props) => {
       metadataName: `${item.name}(${item.id})`,
       metadataType: 'property',
     }));
-    service.getDevicePoint(data.id).then((res) => {
-      if (res.status === 200) {
-        // console.log(res.result)
-        const array = res.result.reduce((x: any, y: any) => {
-          const metadataId = metadata.find((item: any) => item.metadataId === y.metadataId);
-          if (metadataId) {
-            Object.assign(metadataId, y);
-          } else {
-            x.push(y);
-          }
-          return x;
-        }, metadata);
-        setProperties(array);
-        setFilterList(array);
-      }
-    });
+    if (metadata && metadata.length !== 0) {
+      service.getDevicePoint(data.id).then((res) => {
+        if (res.status === 200) {
+          // console.log(res.result)
+          const array = res.result.reduce((x: any, y: any) => {
+            const metadataId = metadata.find((item: any) => item.metadataId === y.metadataId);
+            if (metadataId) {
+              Object.assign(metadataId, y);
+            } else {
+              x.push(y);
+            }
+            return x;
+          }, metadata);
+          setProperties(array);
+          setFilterList(array);
+        }
+      });
+    } else {
+      setEmpty(true);
+    }
   }, [reload]);
 
   const SchemaField = createSchemaField({
@@ -500,43 +504,48 @@ export default (props: Props) => {
 
   return (
     <Card className="modbus" style={{ minHeight }}>
-      <div className="edit-top">
-        <Input.Search
-          placeholder="请输入属性"
-          allowClear
-          style={{ width: 190 }}
-          onSearch={(value) => {
-            console.log(value);
-            if (value) {
-              const items = properties.filter((item: any) => item.metadataId.match(value));
-              setFilterList(items);
-            } else {
-              setFilterList(properties);
-            }
-          }}
-        />
-        <PermissionButton
-          onClick={async () => {
-            const value: any = await form.submit();
-            const items = value.array.filter((item: any) => item.collectorId);
-            save(items);
-          }}
-          isPermission={permission.add}
-          key="add"
-          type="primary"
-          style={{ marginRight: 10 }}
-        >
-          保存
-        </PermissionButton>
-      </div>
-      <div className="edit-table">
-        <FormProvider form={form}>
-          <SchemaField
-            schema={schema}
-            scope={{ useAsyncDataSource, getName, getMaster, getQuantity, useAsync }}
-          />
-        </FormProvider>
-      </div>
+      {empty ? (
+        <Empty description={'暂无数据,请配置物模型'} />
+      ) : (
+        <>
+          <div className="edit-top">
+            <Input.Search
+              placeholder="请输入属性ID"
+              allowClear
+              style={{ width: 190 }}
+              onSearch={(value) => {
+                if (value) {
+                  const items = properties.filter((item: any) => item.metadataId.match(value));
+                  setFilterList(items);
+                } else {
+                  setFilterList(properties);
+                }
+              }}
+            />
+            <PermissionButton
+              onClick={async () => {
+                const value: any = await form.submit();
+                const items = value.array.filter((item: any) => item.collectorId);
+                save(items);
+              }}
+              isPermission={permission.add}
+              key="add"
+              type="primary"
+              style={{ marginRight: 10 }}
+            >
+              保存
+            </PermissionButton>
+          </div>
+          <div className="edit-table">
+            <FormProvider form={form}>
+              <SchemaField
+                schema={schema}
+                scope={{ useAsyncDataSource, getName, getMaster, getQuantity, useAsync }}
+              />
+            </FormProvider>
+          </div>
+        </>
+      )}
     </Card>
   );
 };

+ 30 - 36
src/pages/device/Product/Detail/index.tsx

@@ -102,7 +102,7 @@ const ProductDetail = observer(() => {
     'mqtt-server-gateway',
     'tcp-server-gateway',
   ];
-  const [list, setList] = useState<any[]>([...initList]);
+  const [list, setList] = useState<any[]>([]);
 
   const { minHeight } = useDomFullHeight('.product-detail-body');
 
@@ -152,46 +152,40 @@ const ProductDetail = observer(() => {
       });
     });
   };
-
-  useEffect(() => {
-    if (productModel.current?.messageProtocol) {
-      service.getProtocolDetail(productModel.current?.messageProtocol).then((res) => {
-        if (res.status === 200) {
-          const paring = res.result?.transports[0]?.features?.find(
-            (item: any) => item.id === 'transparentCodec',
-          );
-          // console.log(paring)
-          if (paring) {
-            setList([
-              ...initList,
-              {
-                key: 'parsing',
-                tab: intl.formatMessage({
-                  id: 'pages.device.instanceDetail.parsing',
-                  defaultMessage: '数据解析',
-                }),
-                component: <Parsing tag="product" data={productModel.current} />,
-              },
-            ]);
-          }
-        }
-      });
-    }
+  const getDetail = async () => {
     if (
       productModel.current?.accessProvider &&
       pList.includes(productModel.current?.accessProvider)
     ) {
-      setList([
-        ...initList,
-        {
-          key: 'metadata-map',
-          tab: '物模型映射',
-          component: <MetadataMap type="product" />,
-        },
-      ]);
-    } else {
-      setList([...initList]);
+      initList.push({
+        key: 'metadata-map',
+        tab: '物模型映射',
+        component: <MetadataMap type="product" />,
+      });
     }
+    if (productModel.current?.messageProtocol) {
+      const res = await service.getProtocolDetail(productModel.current?.messageProtocol);
+      if (res.status === 200) {
+        const paring = res.result?.transports[0]?.features?.find(
+          (item: any) => item.id === 'transparentCodec',
+        );
+        // console.log(paring)
+        if (paring) {
+          initList.push({
+            key: 'parsing',
+            tab: intl.formatMessage({
+              id: 'pages.device.instanceDetail.parsing',
+              defaultMessage: '数据解析',
+            }),
+            component: <Parsing tag="product" data={productModel.current} />,
+          });
+        }
+      }
+    }
+    setList(initList);
+  };
+  useEffect(() => {
+    getDetail();
   }, [productModel.current]);
 
   useEffect(() => {

+ 18 - 13
src/pages/home/index.tsx

@@ -22,18 +22,19 @@ const Home = () => {
     comprehensive: <Comprehensive />,
   };
 
-  // useEffect(() => {
-  //   service.queryView().then((resp) => {
-  //     // setLoading(false);
-  //     if (resp.status === 200) {
-  //       if (resp.result.length == 0) {
-  //         setCurrent('init');
-  //       } else {
-  //         setCurrent(resp.result[0]?.content);
-  //       }
-  //     }
-  //   });
-  // }, []);
+  const adminView = () => {
+    service
+      .setView({
+        name: 'view',
+        content: 'comprehensive',
+      })
+      .then((res) => {
+        if (res.status === 200) {
+          setCurrent('comprehensive');
+        }
+      });
+  };
+
   useEffect(() => {
     service.userDetail().then((res) => {
       if (res.status === 200) {
@@ -53,7 +54,11 @@ const Home = () => {
                 setLoading(false);
                 if (resp.status === 200) {
                   if (resp.result.length == 0) {
-                    setCurrent('init');
+                    if (response.result.username === 'admin') {
+                      adminView();
+                    } else {
+                      setCurrent('init');
+                    }
                   } else {
                     setCurrent(resp.result[0]?.content);
                   }

+ 76 - 0
src/pages/home/init/accountInit.tsx

@@ -0,0 +1,76 @@
+import { onlyMessage } from '@/utils/util';
+import { Button, Col, Row } from 'antd';
+import classNames from 'classnames';
+import { useEffect, useState } from 'react';
+import { service } from '..';
+import styles from './index.less';
+
+const AccountInit = () => {
+  const [value, setValue] = useState<string>('');
+
+  const viewMap = [
+    {
+      title: '设备接入视图',
+      img: require('/public/images/home/device.png'),
+      value: 'device',
+    },
+    {
+      title: '运维管理视图',
+      img: require('/public/images/home/ops.png'),
+      value: 'ops',
+    },
+    {
+      title: '综合管理视图',
+      img: require('/public/images/home/comprehensive.png'),
+      value: 'comprehensive',
+    },
+  ];
+  useEffect(() => {
+    service.queryView().then((res) => {
+      if (res.status === 200) {
+        setValue(res.result[0]?.content);
+      }
+    });
+  }, []);
+
+  return (
+    <div className={styles.homeBox} style={{ height: '100%', width: '90%' }}>
+      <Row gutter={24}>
+        {viewMap.map((item) => (
+          <Col
+            span={6}
+            key={item.value}
+            onClick={() => {
+              setValue(item.value);
+            }}
+          >
+            <div className={classNames(styles.item, value === item.value ? styles.active : {})}>
+              <img src={item.img} className={styles.item} />
+            </div>
+          </Col>
+        ))}
+      </Row>
+
+      <div style={{ marginTop: 48, marginRight: '25%' }}>
+        <Button
+          type="primary"
+          onClick={() => {
+            service
+              .setView({
+                name: 'view',
+                content: value,
+              })
+              .then((resp) => {
+                if (resp.status === 200) {
+                  onlyMessage('保存成功');
+                }
+              });
+          }}
+        >
+          确定
+        </Button>
+      </div>
+    </div>
+  );
+};
+export default AccountInit;

+ 23 - 15
src/pages/link/Channel/Modbus/index.tsx

@@ -26,6 +26,7 @@ import { onlyMessage } from '@/utils/util';
 import Export from './Export';
 import useSendWebsocketMessage from '@/hooks/websocket/useSendWebsocketMessage';
 import { map } from 'rxjs/operators';
+import Ellipsis from '@/components/Ellipsis';
 
 export const service = new Service('');
 
@@ -113,21 +114,29 @@ const NewModbus = () => {
     {
       title: '当前数据',
       search: false,
+      // ellipsis: true,
+      width: 150,
       render: (record: any) => (
         <a
           onClick={() => {
-            Modal.info({
-              title: '当前数据',
-              content: (
-                <div>
-                  <div>寄存器1:{record.number}</div>
-                </div>
-              ),
-              onOk() {},
-            });
+            if (currentData[record?.id]) {
+              const arr = currentData[record?.id].match(/[\S]{1,4}/g);
+              Modal.info({
+                title: '当前数据',
+                content: (
+                  <div style={{ display: 'flex', flexDirection: 'column' }}>
+                    {arr.map((item: any, index: number) => (
+                      <div>
+                        寄存器{index + 1}: {item}
+                      </div>
+                    ))}
+                  </div>
+                ),
+              });
+            }
           }}
         >
-          {currentData[record?.id] || '-'}
+          <Ellipsis title={currentData[record?.id] || '-'} />
         </a>
       ),
     },
@@ -150,8 +159,7 @@ const NewModbus = () => {
                   onClick={() => {
                     Modal.error({
                       title: '失败原因',
-                      content: <div>111111</div>,
-                      onOk() {},
+                      content: <div>{record.errorReason}</div>,
                     });
                   }}
                 />
@@ -337,8 +345,8 @@ const NewModbus = () => {
     })
       ?.pipe(map((res: any) => res.payload))
       .subscribe((payload: any) => {
-        const { pointId, nativeData } = payload;
-        current[pointId] = nativeData;
+        const { pointId, hex } = payload;
+        current[pointId] = hex;
         setCurrentData({ ...current });
         console.log(current);
       });
@@ -472,7 +480,7 @@ const NewModbus = () => {
               columns={columns}
               rowKey="id"
               // dataSource={dataSoure}
-              // scroll={{ x: 1000 }}
+              scroll={{ x: 200 }}
               search={false}
               headerTitle={
                 <>

+ 1 - 0
src/pages/link/Channel/index.less

@@ -26,6 +26,7 @@
   }
 
   .item-right {
+    width: 100%;
     .ant-card-body {
       padding-top: 0;
       padding-left: 0;

+ 3 - 3
src/pages/notice/Config/Detail/index.tsx

@@ -304,7 +304,7 @@ const Detail = observer(() => {
             'x-visible': id === 'voice' || id === 'sms',
             properties: {
               regionId: {
-                title: 'regionId',
+                title: 'RegionId',
                 required: true,
                 'x-component-props': {
                   placeholder: '请输入regionId',
@@ -313,7 +313,7 @@ const Detail = observer(() => {
                 'x-decorator': 'FormItem',
               },
               accessKeyId: {
-                title: 'accessKeyId',
+                title: 'AccessKeyId',
                 required: true,
                 'x-component-props': {
                   placeholder: '请输入accessKeyId',
@@ -322,7 +322,7 @@ const Detail = observer(() => {
                 'x-decorator': 'FormItem',
               },
               secret: {
-                title: 'secret',
+                title: 'Secret',
                 required: true,
                 'x-component-props': {
                   placeholder: '请输入secret',