Browse Source

fix: merge next

wzyyy 3 years atrás
parent
commit
6c331e613f

+ 1 - 1
package.json

@@ -58,7 +58,7 @@
     "@ant-design/pro-card": "^1.16.2",
     "@ant-design/pro-descriptions": "^1.6.8",
     "@ant-design/pro-form": "^1.18.3",
-    "@ant-design/pro-layout": "^6.36.0",
+    "@ant-design/pro-layout": "^6.27.2",
     "@ant-design/pro-list": "^1.21.61",
     "@formily/antd": "2.1.6",
     "@formily/core": "2.1.6",

+ 6 - 3
src/pages/device/Instance/Detail/Info/index.tsx

@@ -120,7 +120,9 @@ const Info = observer(() => {
               defaultMessage: '创建时间',
             })}
           >
-            {moment(InstanceModel.detail?.createTime).format('YYYY-MM-DD HH:mm:ss')}
+            {InstanceModel.detail?.createTime
+              ? moment(InstanceModel.detail?.createTime).format('YYYY-MM-DD HH:mm:ss')
+              : ''}
           </Descriptions.Item>
           <Descriptions.Item
             label={intl.formatMessage({
@@ -128,8 +130,9 @@ const Info = observer(() => {
               defaultMessage: '注册时间',
             })}
           >
-            {InstanceModel.detail?.registerTime &&
-              moment(InstanceModel.detail?.registerTime).format('YYYY-MM-DD HH:mm:ss')}
+            {InstanceModel.detail?.registerTime
+              ? moment(InstanceModel.detail?.registerTime).format('YYYY-MM-DD HH:mm:ss')
+              : ''}
           </Descriptions.Item>
           <Descriptions.Item
             label={intl.formatMessage({

+ 4 - 8
src/pages/init-home/components/data/save/index.tsx

@@ -94,15 +94,11 @@ const Save = (props: Props) => {
             'x-validator': [
               {
                 max: 65535,
-                message: '请输入1-65535之间的整数',
+                message: '请输入1-65535之间的整数',
               },
               {
                 min: 1,
-                message: '请输入1-65535之间的整数',
-              },
-              {
-                required: true,
-                message: '请输入本地端口',
+                message: '请输入1-65535之间的正整数',
               },
             ],
           },
@@ -149,11 +145,11 @@ const Save = (props: Props) => {
             'x-validator': [
               {
                 max: 65535,
-                message: '请输入1-65535之间的整数',
+                message: '请输入1-65535之间的整数',
               },
               {
                 min: 1,
-                message: '请输入1-65535之间的整数',
+                message: '请输入1-65535之间的整数',
               },
               {
                 required: true,

+ 18 - 0
src/pages/iot-card/CardManagement/Detail/index.less

@@ -1,3 +1,21 @@
+.iot-card-detail-total {
+  display: flex;
+  gap: 24px;
+
+  .iot-card-detail-total-left {
+    display: flex;
+    flex-grow: 1;
+    min-width: 0;
+  }
+
+  .iot-card-detail-total-right {
+    display: flex;
+    flex-basis: 600px;
+    padding: 24px;
+    background-color: #fff;
+  }
+}
+
 .iot-card-detail-total-item {
   padding: 20px;
   color: rgba(0, 0, 0, 0.64);

+ 74 - 66
src/pages/iot-card/CardManagement/Detail/index.tsx

@@ -360,8 +360,8 @@ const CardDetail = () => {
           </Card>
         </Col>
         <Col span={24}>
-          <Row gutter={24}>
-            <Col flex={'auto'}>
+          <div className={'iot-card-detail-total'}>
+            <div className={'iot-card-detail-total-left'}>
               <DashBoard
                 ref={echartsRef}
                 title={'流量统计'}
@@ -377,70 +377,78 @@ const CardDetail = () => {
                 height={500}
                 onParamsChange={getEcharts}
               />
-            </Col>
-            <Col flex={'550px'}>
-              <Card>
-                <div
-                  style={{
-                    marginBottom: 20,
-                    color: '#323130',
-                    fontSize: 16,
-                    fontWeight: 600,
-                  }}
-                >
-                  数据统计
-                </div>
-                <div className={'iot-card-detail-total-item'}>
-                  <Row>
-                    <Col flex={'auto'}>
-                      <div className={'detail-total-item-name'}>昨日流量消耗</div>
-                      <div className={'detail-total-item-content'}>
-                        <span className={'detail-total-item-value'}>{dayTotal}</span>
-                        <span>M</span>
-                      </div>
-                    </Col>
-                    <Col flex={'240px'}>
-                      <div style={{ height: 83 }}>
-                        <Echarts options={dayOptions} />
-                      </div>
-                    </Col>
-                  </Row>
-                </div>
-                <div className={'iot-card-detail-total-item'}>
-                  <Row>
-                    <Col flex={'auto'}>
-                      <div className={'detail-total-item-name'}>当月流量消耗</div>
-                      <div className={'detail-total-item-content'}>
-                        <span className={'detail-total-item-value'}>{monthTotal}</span>
-                        <span>M</span>
-                      </div>
-                    </Col>
-                    <Col flex={'240px'}>
-                      <div style={{ height: 83 }}>
-                        <Echarts options={monthOptions} />
-                      </div>
-                    </Col>
-                  </Row>
-                </div>
-                <div className={'iot-card-detail-total-item'}>
-                  <Row>
-                    <Col flex={'auto'}>
-                      <div className={'detail-total-item-name'}>本年流量消耗</div>
-                      <div className={'detail-total-item-content'}>
-                        <span className={'detail-total-item-value'}>{yearTotal}</span>
-                        <span>M</span>
-                      </div>
-                    </Col>
-                    <Col flex={'240px'}>
-                      <div style={{ height: 84 }}>
-                        <Echarts options={yearOptions} />
-                      </div>
-                    </Col>
-                  </Row>
-                </div>
-              </Card>
-            </Col>
-          </Row>
+            </div>
+            <div className={'iot-card-detail-total-right'}>
+              <div
+                style={{
+                  marginBottom: 20,
+                  color: '#323130',
+                  fontSize: 16,
+                  fontWeight: 600,
+                }}
+              >
+                数据统计
+              </div>
+              <div className={'iot-card-detail-total-item'}>
+                <Row>
+                  <Col flex={'auto'}>
+                    <div className={'detail-total-item-name'}>昨日流量消耗</div>
+                    <div className={'detail-total-item-content'}>
+                      <span className={'detail-total-item-value'}>{dayTotal}</span>
+                      <span>M</span>
+                    </div>
+                  </Col>
+                  <Col flex={'240px'}>
+                    <div style={{ height: 83 }}>
+                      <Echarts options={dayOptions} />
+                    </div>
+                  </Col>
+                </Row>
+              </div>
+              <div className={'iot-card-detail-total-item'}>
+                <Row>
+                  <Col flex={'auto'}>
+                    <div className={'detail-total-item-name'}>当月流量消耗</div>
+                    <div className={'detail-total-item-content'}>
+                      <span className={'detail-total-item-value'}>{monthTotal}</span>
+                      <span>M</span>
+                    </div>
+                  </Col>
+                  <Col flex={'240px'}>
+                    <div style={{ height: 83 }}>
+                      <Echarts options={monthOptions} />
+                    </div>
+                  </Col>
+                </Row>
+              </div>
+              <div className={'iot-card-detail-total-item'}>
+                <Row>
+                  <Col flex={'auto'}>
+                    <div className={'detail-total-item-name'}>本年流量消耗</div>
+                    <div className={'detail-total-item-content'}>
+                      <span className={'detail-total-item-value'}>{yearTotal}</span>
+                      <span>M</span>
+                    </div>
+                  </Col>
+                  <Col flex={'240px'}>
+                    <div style={{ height: 84 }}>
+                      <Echarts options={yearOptions} />
+                    </div>
+                  </Col>
+                </Row>
+              </div>
+            </div>
+          </div>
+          {/*<Row gutter={24}>*/}
+          {/*  <Col flex={'auto'}>*/}
+          {/*    */}
+          {/*  </Col>*/}
+          {/*  <Col flex={'550px'}>*/}
+          {/*    <Card>*/}
+          {/*      */}
+          {/*    </Card>*/}
+          {/*  </Col>*/}
+          {/*</Row>*/}
         </Col>
       </Row>
     </PageContainer>

+ 16 - 10
src/pages/iot-card/CardManagement/index.tsx

@@ -49,6 +49,7 @@ const CardManagementNode = () => {
   const intl = useIntl();
   const history = useHistory();
   const location = useLocation();
+  const deleteItems = useRef<any>(new Map());
 
   useEffect(() => {
     const { state } = location;
@@ -464,9 +465,11 @@ const CardManagementNode = () => {
             popConfirm={{
               title: '确认删除吗?',
               onConfirm: async () => {
-                service.removeCards(bindKeys).then((res) => {
+                console.log(deleteItems.current.values());
+                service.removeCards([...deleteItems.current.values()]).then((res) => {
                   if (res.status === 200) {
                     setBindKeys([]);
+                    deleteItems.current.clear();
                     message.success('操作成功');
                     actionRef?.current?.reload();
                   }
@@ -566,6 +569,7 @@ const CardManagementNode = () => {
             <a
               onClick={() => {
                 setBindKeys([]);
+                deleteItems.current.clear();
               }}
             >
               取消选择
@@ -578,25 +582,27 @@ const CardManagementNode = () => {
           onChange: (selectedRowKeys) => {
             setBindKeys(selectedRowKeys);
           },
-          onSelect: (_, selected) => {
+          onSelect: (record, selected) => {
             if (selected) {
-              // InstanceModel.selectedRows.set(record.id, record?.state?.value);
+              deleteItems.current.set(record.id, record);
             } else {
-              // InstanceModel.selectedRows.delete(record.id);
+              deleteItems.current.delete(record.id);
             }
-            // setBindKeys([...InstanceModel.selectedRows.keys()]);
+            console.log(deleteItems.current.values());
+            setBindKeys([...deleteItems.current.keys()]);
+            console.log(deleteItems.current.values());
           },
           onSelectAll: (selected, _, changeRows) => {
             if (selected) {
-              changeRows.forEach(() => {
-                // InstanceModel.selectedRows.set(item.id, item?.state?.value);
+              changeRows.forEach((item: any) => {
+                deleteItems.current.set(item.id, item);
               });
             } else {
-              changeRows.forEach(() => {
-                // InstanceModel.selectedRows.delete(item.id);
+              changeRows.forEach((item: any) => {
+                deleteItems.current.delete(item.id);
               });
             }
-            // setBindKeys([...InstanceModel.selectedRows.keys()]);
+            setBindKeys([...deleteItems.current.keys()]);
           },
         }}
         headerTitle={[

+ 7 - 2
src/pages/link/DataCollect/DataGathering/index.tsx

@@ -6,6 +6,7 @@ import { observer } from '@formily/reactive-react';
 import { model } from '@formily/reactive';
 import Device from '../components/Device';
 import Point from '../components/Point';
+import { Empty } from '@/components';
 
 const DataCollectModel = model<{
   id: Partial<string>;
@@ -21,7 +22,7 @@ const DataCollectModel = model<{
 
 export default observer(() => {
   const obj = {
-    channel: <Device type={false} id={DataCollectModel.id} />,
+    channel: <Device type={false} id={DataCollectModel.id} provider={DataCollectModel.provider} />,
     device: (
       <Point type={false} provider={DataCollectModel.provider} data={DataCollectModel.data} />
     ),
@@ -40,7 +41,11 @@ export default observer(() => {
               }}
             />
           </div>
-          <div className={styles.right}>{obj[DataCollectModel.type]}</div>
+          {DataCollectModel?.id ? (
+            <div className={styles.right}>{obj[DataCollectModel.type]}</div>
+          ) : (
+            <Empty style={{ marginTop: 100 }} />
+          )}
         </div>
       </Card>
     </PageContainer>

+ 84 - 27
src/pages/link/DataCollect/components/Channel/Save/index.tsx

@@ -1,12 +1,12 @@
 import { Button, Modal } from 'antd';
-import { createForm, Field } from '@formily/core';
+import { createForm, Field, registerValidateRules } from '@formily/core';
 import { createSchemaField } from '@formily/react';
 import React, { useEffect, useState } from 'react';
 import * as ICONS from '@ant-design/icons';
 import { Form, FormGrid, FormItem, Input, Select, NumberPicker, Password } from '@formily/antd';
 import type { ISchema } from '@formily/json-schema';
 import service from '@/pages/link/DataCollect/service';
-import { onlyMessage } from '@/utils/util';
+import { onlyMessage, testDomain, testIP, testIPv6 } from '@/utils/util';
 import { action } from '@formily/reactive';
 
 interface Props {
@@ -17,7 +17,7 @@ interface Props {
 
 export default (props: Props) => {
   const [data, setData] = useState<Partial<ChannelItem>>(props.data);
-  const [loading, setLoading] = useState<boolean>(false);
+  // const [loading, setLoading] = useState<boolean>(false);
 
   useEffect(() => {
     if (props.data?.id) {
@@ -35,14 +35,15 @@ export default (props: Props) => {
   });
 
   const getSecurityPolicyList = () => service.querySecurityPolicyList({});
+  const getAuthTypeList = () => service.queryAuthTypeList({});
 
   const useAsyncDataSource = (services: (arg0: Field) => Promise<any>) => (field: Field) => {
     field.loading = true;
     services(field).then(
       action.bound!((resp: any) => {
         field.dataSource = (resp?.result || []).map((item: any) => ({
-          label: item.name,
-          value: item.id,
+          label: item?.text || item,
+          value: item?.value || item,
         }));
         field.loading = false;
       }),
@@ -65,6 +66,19 @@ export default (props: Props) => {
     },
   });
 
+  registerValidateRules({
+    testHost(val: string) {
+      if (val) return '';
+      if (!testIP(val) || !testIPv6(val) || !testDomain(val)) {
+        return {
+          type: 'error',
+          message: '请输入正确格式的IP地址',
+        };
+      }
+      return '';
+    },
+  });
+
   const schema: ISchema = {
     type: 'object',
     properties: {
@@ -108,6 +122,7 @@ export default (props: Props) => {
             'x-component-props': {
               placeholder: '请选择通讯协议',
             },
+            'x-disabled': props.data?.id,
             enum: [
               { label: 'OPC_UA', value: 'OPC_UA' },
               { label: 'MODBUS_TCP', value: 'MODBUS_TCP' },
@@ -134,6 +149,9 @@ export default (props: Props) => {
                 required: true,
                 message: '请输入Modbus主机IP',
               },
+              {
+                testHost: true,
+              },
             ],
             'x-reactions': {
               dependencies: ['..provider'],
@@ -162,11 +180,11 @@ export default (props: Props) => {
               },
               {
                 max: 65535,
-                message: '请输入0-65535之间的整数',
+                message: '请输入0-65535之间的整数',
               },
               {
                 min: 0,
-                message: '请输入0-65535之间的整数',
+                message: '请输入0-65535之间的整数',
               },
             ],
             'x-reactions': {
@@ -231,6 +249,34 @@ export default (props: Props) => {
               },
             ],
           },
+          'configuration.authType': {
+            title: '权限认证',
+            'x-component': 'Select',
+            'x-decorator': 'FormItem',
+            'x-decorator-props': {
+              gridSpan: 2,
+            },
+            'x-component-props': {
+              placeholder: '请选择权限认证',
+            },
+            'x-validator': [
+              {
+                required: true,
+                message: '请选择权限认证',
+              },
+            ],
+            'x-reactions': [
+              '{{useAsyncDataSource(getAuthTypeList)}}',
+              {
+                dependencies: ['..provider'],
+                fulfill: {
+                  state: {
+                    visible: '{{$deps[0]==="OPC_UA"}}',
+                  },
+                },
+              },
+            ],
+          },
           'configuration.username': {
             title: '用户名',
             'x-component': 'Input',
@@ -241,17 +287,21 @@ export default (props: Props) => {
             'x-component-props': {
               placeholder: '请输入用户名',
             },
-            // 'x-validator': [
-            //   {
-            //     required: true,
-            //     message: '请输入用户名',
-            //   },
-            // ],
+            'x-validator': [
+              {
+                required: true,
+                message: '请输入用户名',
+              },
+              {
+                max: 64,
+                message: '最多可输入64个字符',
+              },
+            ],
             'x-reactions': {
-              dependencies: ['..provider'],
+              dependencies: ['.authType'],
               fulfill: {
                 state: {
-                  visible: '{{$deps[0]==="OPC_UA"}}',
+                  visible: '{{$deps[0]==="username"}}',
                 },
               },
             },
@@ -266,17 +316,21 @@ export default (props: Props) => {
             'x-component-props': {
               placeholder: '请输入密码',
             },
-            // 'x-validator': [
-            //   {
-            //     required: true,
-            //     message: '请输入密码',
-            //   },
-            // ],
+            'x-validator': [
+              {
+                required: true,
+                message: '请输入密码',
+              },
+              {
+                max: 64,
+                message: '最多可输入64个字符',
+              },
+            ],
             'x-reactions': {
-              dependencies: ['..provider'],
+              dependencies: ['.authType'],
               fulfill: {
                 state: {
-                  visible: '{{$deps[0]==="OPC_UA"}}',
+                  visible: '{{$deps[0]==="username"}}',
                 },
               },
             },
@@ -302,11 +356,11 @@ export default (props: Props) => {
 
   const save = async () => {
     const value = await form.submit<ChannelItem>();
-    setLoading(true);
+    // setLoading(true);
     const response: any = props.data?.id
       ? await service.updateChannel(props.data?.id, { ...props.data, ...value })
       : await service.saveChannel({ ...props.data, ...value });
-    setLoading(false);
+    // setLoading(false);
     if (response && response?.status === 200) {
       onlyMessage('操作成功');
       props.reload();
@@ -330,14 +384,17 @@ export default (props: Props) => {
           onClick={() => {
             save();
           }}
-          loading={loading}
+          // loading={loading}
         >
           确定
         </Button>,
       ]}
     >
       <Form form={form} layout="vertical">
-        <SchemaField schema={schema} scope={{ useAsyncDataSource, getSecurityPolicyList }} />
+        <SchemaField
+          schema={schema}
+          scope={{ useAsyncDataSource, getSecurityPolicyList, getAuthTypeList }}
+        />
       </Form>
     </Modal>
   );

+ 8 - 12
src/pages/link/DataCollect/components/Device/Save/index.tsx

@@ -13,6 +13,7 @@ interface Props {
   data: Partial<CollectorItem>;
   close: () => void;
   reload: () => void;
+  provider?: 'OPC_UA' | 'MODBUS_TCP';
 }
 
 export default (props: Props) => {
@@ -86,14 +87,7 @@ export default (props: Props) => {
             'x-component-props': {
               placeholder: '请输入从机地址',
             },
-            'x-reactions': {
-              dependencies: ['..provider'],
-              fulfill: {
-                state: {
-                  visible: '{{$deps[0]==="MODBUS_TCP"}}',
-                },
-              },
-            },
+            'x-visible': props.provider === 'MODBUS_TCP',
             'x-validator': [
               {
                 required: true,
@@ -101,11 +95,11 @@ export default (props: Props) => {
               },
               {
                 max: 255,
-                message: '请输入0-255之间的整数',
+                message: '请输入0-255之间的整数',
               },
               {
                 min: 0,
-                message: '请输入0-255之间的整数',
+                message: '请输入0-255之间的整数',
               },
             ],
           },
@@ -163,8 +157,10 @@ export default (props: Props) => {
           const obj = {
             ...value,
             provider: resp.result.provider,
-            channelId: resp.result.channelId,
-            configuration: {},
+            channelId: props.channelId,
+            configuration: {
+              ...value.configuration,
+            },
           };
           response = await service.saveCollector({ ...obj });
         }

+ 2 - 0
src/pages/link/DataCollect/components/Device/index.tsx

@@ -16,6 +16,7 @@ import Save from '@/pages/link/DataCollect/components/Device/Save/index';
 interface Props {
   type: boolean; // true: 综合查询  false: 数据采集
   id?: any;
+  provider?: 'OPC_UA' | 'MODBUS_TCP';
 }
 
 const CollectorModel = model<{
@@ -292,6 +293,7 @@ export default observer((props: Props) => {
         <Save
           data={CollectorModel.current}
           channelId={props.id}
+          provider={props.provider}
           close={() => {
             CollectorModel.visible = false;
           }}

+ 1 - 1
src/pages/link/DataCollect/components/Tree/index.tsx

@@ -75,7 +75,6 @@ export default observer((props: Props) => {
       <div style={{ margin: '16px 0' }}>
         <Button
           type="primary"
-          ghost
           style={{ width: '100%' }}
           icon={<PlusOutlined />}
           onClick={() => {
@@ -166,6 +165,7 @@ export default observer((props: Props) => {
           }}
           reload={() => {
             TreeModel.visible = false;
+            handleSearch(TreeModel.param);
           }}
         />
       )}

+ 11 - 4
src/pages/link/DataCollect/service.ts

@@ -104,11 +104,18 @@ class Service {
       method: 'POST',
       data: params,
     });
-  public querySecurityPolicyList = (params: any) =>
-    request(`/${SystemConst.API_BASE}/edge/operations/local/opcua-security-policies/invoke`, {
-      method: 'POST',
-      data: params,
+  public querySecurityPolicyList = (params?: any) =>
+    request(`/${SystemConst.API_BASE}/data-collect/opc/security-policies`, {
+      method: 'GET',
+      params,
     });
+
+  public queryAuthTypeList = (params?: any) =>
+    request(`/${SystemConst.API_BASE}/data-collect/opc/auth-types`, {
+      method: 'GET',
+      params,
+    });
+
   public scanOpcUAList = (params: any) =>
     request(
       `/${SystemConst.API_BASE}/data-collect/opc/channel/${params.id}/nodes?nodeId=${

+ 4 - 4
src/pages/link/Type/Detail/index.tsx

@@ -337,11 +337,11 @@ const Save = observer(() => {
         'x-validator': [
           {
             max: 65535,
-            message: '请输入1-65535之间的整数',
+            message: '请输入1-65535之间的整数',
           },
           {
             min: 1,
-            message: '请输入1-65535之间的整数',
+            message: '请输入1-65535之间的整数',
           },
         ],
       },
@@ -404,11 +404,11 @@ const Save = observer(() => {
         'x-validator': [
           {
             max: 65535,
-            message: '请输入1-65535之间的整数',
+            message: '请输入1-65535之间的整数',
           },
           {
             min: 1,
-            message: '请输入1-65535之间的整数',
+            message: '请输入1-65535之间的整数',
           },
         ],
       },

+ 1 - 1
src/pages/media/Device/Channel/index.tsx

@@ -116,7 +116,7 @@ export default () => {
           status: 'online',
         },
         offline: {
-          text: '离线',
+          text: '未连接',
           status: 'offline',
         },
       },

File diff suppressed because it is too large
+ 11 - 0
src/utils/util.ts