Просмотр исходного кода

fix: 修改物模型规则问题

100011797 3 лет назад
Родитель
Сommit
452a214770

+ 1 - 1
src/components/FMonacoEditor/index.tsx

@@ -12,7 +12,7 @@ export const JMonacoEditor = (props: Props) => {
   const monacoEditorRef = useRef<any>();
 
   const editorFormat = (editor: any) => {
-    editor.getAction('editor.action.formatDocument').run();
+    editor.getAction('editor.action.formatDocument')?.run();
   };
 
   useEffect(() => {

+ 8 - 1
src/pages/device/Firmware/Save/index.tsx

@@ -24,6 +24,7 @@ interface Props {
 const Save = (props: Props) => {
   const { data, close, visible } = props;
   const fileInfo = useRef<any>({});
+  // const disabled = useRef<boolean>(false);
   const signMethod = useRef<'md5' | 'sha256'>('md5');
 
   const form = createForm({
@@ -32,6 +33,12 @@ const Save = (props: Props) => {
     effects: () => {
       onFormInit(async (form1) => {
         if (!data?.id) return;
+        // const resp = await service.task({terms: [{ column: 'firmwareId', value: data?.id }]})
+        // if(resp.status === 200 && resp.result?.total){
+        //   disabled.current = true
+        // } else {
+        //   disabled.current = false
+        // }
         form1.setInitialValues({ ...data, upload: { url: data?.url } });
       });
       onFieldValueChange('signMethod', (field, f) => {
@@ -424,7 +431,7 @@ const Save = (props: Props) => {
             terms: [{ terms: [{ column: 'firmwareId', value: data.id }] }],
           });
           if (res.status === 200 && res.result.data && res.result.data.length !== 0) {
-            onlyMessage('该固件有升级任务,不可编辑', 'warning');
+            onlyMessage('该固件有升级任务,不可编辑', 'error');
           } else {
             save();
           }

+ 1 - 1
src/pages/device/Firmware/Task/Save/SelectDevices.tsx

@@ -60,7 +60,7 @@ const SelectDevices = observer((props: Props) => {
       title: '固件版本',
       dataIndex: 'firmwareInfo',
       ellipsis: true,
-      render: (text: any, record: any) => record?.version || '',
+      render: (text: any, record: any) => record?.firmwareInfo?.version || '',
     },
     {
       title: intl.formatMessage({

+ 4 - 2
src/pages/device/Instance/Detail/Diagnose/Status/index.tsx

@@ -82,6 +82,7 @@ const Status = observer((props: Props) => {
   const modifyArrayList = (oldList: ListProps[], item: ListProps, index?: number) => {
     let newList: ListProps[] = [];
     if (index !== 0 && !index) {
+      // 添加
       for (let i = 0; i < oldList.length; i++) {
         const dt = oldList[i];
         if (item.key === dt.key) {
@@ -91,6 +92,7 @@ const Status = observer((props: Props) => {
         }
       }
     } else {
+      // 修改
       oldList.splice(index, 0, item);
       newList = [...oldList];
     }
@@ -875,9 +877,9 @@ const Status = observer((props: Props) => {
         const response = await queryProductConfigRun(device.productId);
         if (response.status === 200 && response.result.length > 0) {
           DiagnoseStatusModel.configuration.product = response.result;
-          const list = [...DiagnoseStatusModel.list];
           const configuration = DiagnoseStatusModel.product?.configuration || {};
           response.result.map((item: any, i: number) => {
+            const list = [...DiagnoseStatusModel.list];
             if (!_.map(list, 'key').includes(`product-auth${i}`)) {
               DiagnoseStatusModel.list = modifyArrayList(
                 DiagnoseStatusModel.list,
@@ -1039,9 +1041,9 @@ const Status = observer((props: Props) => {
         const response = await queryDeviceConfigRun(device.id);
         if (response.status === 200 && response.result.length > 0) {
           DiagnoseStatusModel.configuration.device = response.result;
-          const list = [...DiagnoseStatusModel.list];
           const configuration = device?.configuration || {};
           response.result.map((item: any, i: number) => {
+            const list = [...DiagnoseStatusModel.list];
             if (!_.map(list, 'key').includes(`device-auth${i}`)) {
               DiagnoseStatusModel.list = modifyArrayList(
                 DiagnoseStatusModel.list,

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

@@ -114,6 +114,9 @@ const Info = observer(() => {
           >
             {InstanceModel.detail?.deviceType?.text}
           </Descriptions.Item>
+          <Descriptions.Item label={'固件版本'}>
+            {InstanceModel.detail?.firmwareInfo?.version || ''}
+          </Descriptions.Item>
           <Descriptions.Item
             label={intl.formatMessage({
               id: 'pages.device.instanceDetail.transportProtocol',

+ 3 - 0
src/pages/device/Instance/typings.d.ts

@@ -45,6 +45,9 @@ export type DeviceInstance = {
   features?: any[];
   parentId?: string;
   classifiedName?: string;
+  firmwareInfo?: {
+    version?: string;
+  };
 };
 
 type Unit = {

+ 88 - 29
src/pages/device/components/Metadata/Base/Edit/index.tsx

@@ -22,6 +22,7 @@ import {
   Radio,
   Select,
   Space,
+  Switch,
 } from '@formily/antd';
 import type { ISchema } from '@formily/json-schema';
 import {
@@ -170,6 +171,7 @@ const Edit = observer((props: Props) => {
       Checkbox,
       FormGrid,
       DatePicker,
+      Switch,
       FIndicators,
     },
     scope: {
@@ -608,11 +610,12 @@ const Edit = observer((props: Props) => {
             type: 'object',
             title: '规则配置',
             'x-visible': false,
-            'x-component': 'Editable.Popover',
+            // 'x-component': 'Editable.Popover',
             'x-reactions': {
               dependencies: ['.source'],
               fulfill: {
                 state: {
+                  // visible: '{{$deps[0]}}',
                   visible: '{{$deps[0]==="rule"}}',
                 },
               },
@@ -636,16 +639,37 @@ const Edit = observer((props: Props) => {
               //     },
               //   ],
               // },
-
+              isVirtualRule: {
+                type: 'boolean',
+                title: '规则配置',
+                'x-decorator': 'FormItem',
+                'x-component': 'Switch',
+              },
               windowType: {
                 type: 'string',
                 title: '窗口',
                 'x-decorator': 'FormItem',
                 'x-component': 'Select',
+                required: true,
+                'x-validator': [
+                  {
+                    required: true,
+                    message: `请选择窗口`,
+                  },
+                ],
                 enum: [
                   { label: '时间窗口', value: 'time' },
                   { label: '次数窗口', value: 'num' },
                 ],
+                'x-visible': false,
+                'x-reactions': {
+                  dependencies: ['.isVirtualRule'],
+                  fulfill: {
+                    state: {
+                      visible: '{{$deps[0]}}',
+                    },
+                  },
+                },
                 'x-component-props': {
                   allowClear: true,
                 },
@@ -668,29 +692,60 @@ const Edit = observer((props: Props) => {
                 title: '聚合函数',
                 'x-decorator': 'FormItem',
                 'x-component': 'Select',
-                'x-reactions': '{{useAsyncDataSource(getStreamingAggType)}}',
+                required: true,
+                'x-visible': false,
+                'x-validator': [
+                  {
+                    required: true,
+                    message: `请选择聚合函数`,
+                  },
+                ],
+                'x-reactions': [
+                  {
+                    dependencies: ['.isVirtualRule'],
+                    fulfill: {
+                      state: {
+                        visible: '{{$deps[0]}}',
+                      },
+                    },
+                  },
+                  '{{useAsyncDataSource(getStreamingAggType)}}',
+                ],
               },
               window: {
                 type: 'object',
+                'x-visible': false,
+                'x-reactions': {
+                  dependencies: ['.isVirtualRule'],
+                  fulfill: {
+                    state: {
+                      visible: '{{$deps[0]}}',
+                    },
+                  },
+                },
                 properties: {
                   span: {
                     title: '窗口长度',
-                    'x-component': 'Input',
+                    'x-component': 'NumberPicker',
                     'x-decorator': 'FormItem',
-                    format: 'number',
+                    required: true,
+                    'x-component-props': {
+                      style: {
+                        width: '100%',
+                      },
+                    },
                     'x-validator': [
                       {
-                        // triggerType: 'onBlur',
-                        validator: (value: any[]) => {
-                          return new Promise((resolve) => {
-                            const number = Number(value);
-                            if (number <= 0 || value.length > 64 || /[.]/.test(value)) {
-                              resolve('请输入非0正整数,最多可输入64个字符');
-                            } else {
-                              resolve('');
-                            }
-                          });
-                        },
+                        required: true,
+                        message: `请输入窗口长度`,
+                      },
+                      {
+                        format: 'integer',
+                        message: '请输入正整数',
+                      },
+                      {
+                        min: 1,
+                        message: '请输入正整数',
                       },
                     ],
                     'x-reactions': [
@@ -725,22 +780,26 @@ const Edit = observer((props: Props) => {
                   },
                   every: {
                     title: '步长',
-                    'x-component': 'Input',
+                    'x-component': 'NumberPicker',
                     'x-decorator': 'FormItem',
-                    format: 'number',
+                    required: true,
+                    'x-component-props': {
+                      style: {
+                        width: '100%',
+                      },
+                    },
                     'x-validator': [
                       {
-                        // triggerType: 'onBlur',
-                        validator: (value: any[]) => {
-                          return new Promise((resolve) => {
-                            const number = Number(value);
-                            if (number <= 0 || value.length > 64 || /[.]/.test(value)) {
-                              resolve('请输入非0正整数,最多可输入64个字符');
-                            } else {
-                              resolve('');
-                            }
-                          });
-                        },
+                        required: true,
+                        message: `请输入步长`,
+                      },
+                      {
+                        format: 'integer',
+                        message: '请输入正整数',
+                      },
+                      {
+                        min: 1,
+                        message: '请输入正整数',
                       },
                     ],
                     'x-reactions': [

+ 1 - 1
src/pages/link/DashBoard/index.tsx

@@ -260,7 +260,7 @@ export default () => {
         type: 'value',
       },
       grid: {
-        left: 50,
+        left: 60,
         right: 0,
         top: 10,
         bottom: 20,