Explorar el Código

fix: 修改bug12。23

100011797 hace 3 años
padre
commit
4b4639a364

+ 5 - 1
src/components/FIndicators/index.tsx

@@ -86,7 +86,11 @@ const FIndicators = (props: Props) => {
           <DatePicker1
             showTime
             allowClear={false}
-            value={value?.value ? moment(value.value[0], 'YYYY-MM-DD HH:mm:ss') : ''}
+            value={
+              value?.value && value.value?.[0]
+                ? moment(value.value[0], 'YYYY-MM-DD HH:mm:ss')
+                : undefined
+            }
             onChange={(_: any, date: string) => {
               onChange({
                 ...value,

+ 1 - 1
src/components/Metadata/EditTable/index.tsx

@@ -155,7 +155,7 @@ Editable.Popover = observer((props) => {
   if ((field.title === '配置参数' || field.title === '指标数据') && !props.title) {
     const filterKeys = ['config', 'edit'];
     const path = field.path.segments.filter((key: any) => !filterKeys.includes(key));
-    console.log('EditTable', path, field.form.values);
+    // console.log('EditTable', path, field.form.values);
     const value = get(field.form.values, path)?.name;
     title = value || '配置参数';
   }

+ 3 - 3
src/pages/device/Instance/Detail/Functions/AdvancedMode.tsx

@@ -3,11 +3,11 @@ import { useCallback, useEffect, useRef, useState } from 'react';
 import { Button, Input } from 'antd';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import { InstanceModel, service } from '@/pages/device/Instance';
-import MonacoEditor from 'react-monaco-editor';
 import { isObject } from 'lodash';
 
 import './index.less';
 import { MetaDataJsonHandle } from '@/components/FormItems/MetadataJsonInput';
+import { JMonacoEditor } from '@/components/FMonacoEditor';
 
 type FunctionProps = {
   data: FunctionMetadata;
@@ -94,13 +94,13 @@ export default (props: FunctionProps) => {
     <div className="device-function-content">
       <div className="left">
         <div style={{ marginBottom: 12 }}>
-          <MonacoEditor
+          <JMonacoEditor
             width={'100%'}
             height={400}
             theme="vs-dark"
             language={'json'}
             value={value}
-            onChange={(newValue) => {
+            onChange={(newValue: any) => {
               setValue(newValue);
             }}
             editorDidMount={editorDidMountHandle}

+ 3 - 2
src/pages/device/Instance/Detail/MetadataLog/Property/index.tsx

@@ -450,8 +450,9 @@ const PropertyLog = (props: Props) => {
           activeKey={tab}
           onChange={(key: string) => {
             setTab(key);
-            if (key === 'charts' && !!data.valueType?.type) {
-              if (list.includes(data.valueType?.type)) {
+            if (key === 'charts') {
+              if (!!data.valueType?.type && list.includes(data.valueType?.type)) {
+                setCycle('*');
                 queryChartsList(start, end);
               } else {
                 setCycle('1m');

+ 15 - 0
src/pages/device/Instance/Detail/Running/Property/Indicators.less

@@ -0,0 +1,15 @@
+.indicators {
+  :global {
+    .ant-formily-array-items-item {
+      height: 80px;
+    }
+  }
+  .indicators-asterisk {
+    :global {
+      .ant-formily-item-asterisk {
+        //display: none;
+        color: white;
+      }
+    }
+  }
+}

+ 37 - 21
src/pages/device/Instance/Detail/Running/Property/Indicators.tsx

@@ -16,7 +16,7 @@ import type { PropertyMetadata } from '@/pages/device/Product/typings';
 import { useEffect, useState } from 'react';
 import { InstanceModel, service } from '@/pages/device/Instance';
 import { onlyMessage } from '@/utils/util';
-
+import styles from './Indicators.less';
 interface Props {
   data: Partial<PropertyMetadata>;
   onCancel: () => void;
@@ -101,45 +101,45 @@ const Indicators = (props: Props) => {
             },
             space: {
               type: 'void',
-              title: '指标值',
               'x-decorator': 'FormItem',
               'x-component': 'FormGrid',
-              'x-decorator-props': {
-                labelAlign: 'left',
-                layout: 'vertical',
-              },
               'x-component-props': {
                 maxColumns: 12,
                 minColumns: 12,
               },
-              'x-reactions': [
-                {
-                  dependencies: ['.name'],
-                  fulfill: {
-                    state: {
-                      title: '{{$deps[0]}}',
-                    },
-                  },
-                },
-              ],
               properties: {
                 'value[0]': {
                   'x-decorator': 'FormItem',
+                  title: '指标值',
                   'x-component': componentMap[data.valueType?.type || ''] || 'Input',
                   'x-reactions': [
                     {
-                      dependencies: ['..range', data.valueType?.type],
+                      dependencies: ['..range', data.valueType?.type, '..name'],
                       fulfill: {
                         state: {
                           decoratorProps: {
-                            gridSpan: '{{!!$deps[0]?5:$deps[1]==="boolean"?12:10}}',
+                            gridSpan: '{{!!$deps[0]?6:12}}',
                           },
+                          title: '{{$deps[2]}}',
                         },
                       },
                     },
                   ],
+                  required: true,
+                  'x-validator': [
+                    {
+                      required: true,
+                      message: `请${
+                        ['date', 'boolean'].includes(data?.valueType?.type as string)
+                          ? '选择'
+                          : '输入'
+                      }指标值`,
+                    },
+                  ],
                   'x-decorator-props': {
-                    gridSpan: 5,
+                    gridSpan: 6,
+                    labelAlign: 'left',
+                    layout: 'vertical',
                   },
                 },
                 'value[1]': {
@@ -156,8 +156,24 @@ const Indicators = (props: Props) => {
                       },
                     },
                   ],
+                  required: true,
+                  'x-validator': [
+                    {
+                      required: true,
+                      message: `请${
+                        ['date', 'boolean'].includes(data?.valueType?.type as string)
+                          ? '选择'
+                          : '输入'
+                      }指标值`,
+                    },
+                  ],
                   'x-decorator-props': {
-                    gridSpan: 5,
+                    gridSpan: 6,
+                    style: {
+                      marginTop: 30,
+                      color: 'white',
+                    },
+                    className: styles['indicators-asterisk'],
                   },
                 },
                 range: {
@@ -243,7 +259,7 @@ const Indicators = (props: Props) => {
       >
         场景联动页面可引用指标配置触发条件
       </div>
-      <div style={{ marginTop: '30px' }}>
+      <div style={{ marginTop: '30px' }} className={styles['indicators']}>
         <Form form={form} layout="vertical">
           <SchemaField schema={schema} />
         </Form>

+ 17 - 0
src/pages/device/components/Metadata/Base/Edit/index.tsx

@@ -760,6 +760,23 @@ const Edit = observer((props: Props) => {
             'x-decorator-props': {
               tooltip: '场景联动页面可引用指标配置作为触发条件',
             },
+            'x-validator': [
+              {
+                triggerType: 'onBlur',
+                validator: (value: any[]) => {
+                  return new Promise((resolve) => {
+                    const flag = value.every((item) => {
+                      return item.id && item.name && item.value;
+                    });
+                    if (flag) {
+                      resolve('');
+                    } else {
+                      resolve('请输入指标配置');
+                    }
+                  });
+                },
+              },
+            ],
             // 'x-visible': props.type === 'product',
             items: {
               type: 'object',

+ 4 - 9
src/pages/device/components/Metadata/Import/index.tsx

@@ -303,17 +303,12 @@ const Import = (props: Props) => {
       props.close();
     } else {
       try {
+        const _object = JSON.parse(data[props?.type === 'device' ? 'import' : data?.type] || '{}');
         const params = {
           id: param.id,
-          metadata: JSON.stringify(
-            operateLimits(
-              JSON.parse(data[props?.type === 'device' ? 'import' : data?.type] || '{}'),
-            ),
-          ),
+          metadata: JSON.stringify(operateLimits(_object as DeviceMetadata)),
         };
-        const paramsDevice = JSON.stringify(
-          operateLimits(JSON.parse(data[props?.type === 'device' ? 'import' : data?.type] || '{}')),
-        );
+        const paramsDevice = JSON.stringify(operateLimits(_object as DeviceMetadata));
         let resp: any = undefined;
         if (props?.type === 'device') {
           resp = await deviceService.saveMetadata(param.id, paramsDevice);
@@ -334,7 +329,7 @@ const Import = (props: Props) => {
         Store.set(SystemConst.GET_METADATA, true);
         Store.set(SystemConst.REFRESH_METADATA_TABLE, true);
         props.close();
-      } catch (err) {
+      } catch (e) {
         onlyMessage('请上传正确的json格式文件', 'error');
       }
     }