Bläddra i källkod

fix: bug#8658、8662、8628

xieyonghong 3 år sedan
förälder
incheckning
b413c59dbf

+ 11 - 3
src/components/Metadata/JsonParam/index.tsx

@@ -15,6 +15,7 @@ import Editable from '../EditTable';
 // 不算是自定义组件。只是抽离了JSONSchema
 interface Props {
   keys?: string;
+  isFunction?: boolean;
 }
 
 const JsonParam = observer((props: Props) => {
@@ -255,7 +256,9 @@ const JsonParam = observer((props: Props) => {
                           dependencies: ['..valueType.type'],
                           fulfill: {
                             state: {
-                              visible: "{{['int','float','long','double'].includes($deps[0])}}",
+                              visible:
+                                !props.isFunction &&
+                                "{{['int','float','long','double'].includes($deps[0])}}",
                             },
                           },
                         },
@@ -318,7 +321,9 @@ const JsonParam = observer((props: Props) => {
                             dependencies: ['..type'],
                             fulfill: {
                               state: {
-                                visible: "{{['string','password'].includes($deps[0])}}",
+                                visible:
+                                  !props.isFunction &&
+                                  "{{['string','password'].includes($deps[0])}}",
                               },
                             },
                           },
@@ -354,7 +359,7 @@ const JsonParam = observer((props: Props) => {
                     dependencies: ['..valueType.type'],
                     fulfill: {
                       state: {
-                        visible: "{{['float','double'].includes($deps[0])}}",
+                        visible: !props.isFunction && "{{['float','double'].includes($deps[0])}}",
                       },
                     },
                   },
@@ -365,6 +370,9 @@ const JsonParam = observer((props: Props) => {
                   'x-visible': false,
                   'x-decorator': 'FormItem',
                   'x-component': 'JsonParam',
+                  'x-component-props': {
+                    isFunction: props.isFunction,
+                  },
                   'x-reactions': {
                     dependencies: ['.valueType.type'],
                     fulfill: {

+ 13 - 8
src/components/SearchComponent/index.tsx

@@ -601,6 +601,9 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
       // 展开高级搜索
       setExpand(false);
       handleForm(true);
+    } else {
+      setExpand(true);
+      handleForm(false);
     }
     const params = new URLSearchParams(_location.search);
     params.delete('q');
@@ -663,15 +666,17 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
     <Menu className={styles.history}>
       {history.length > 0 ? (
         history.map((item: SearchHistory) => (
-          <Menu.Item
-            key={item.id || randomString(9)}
-            onClick={() => {
-              handleHistory(item);
-              handleSearch();
-            }}
-          >
+          <Menu.Item key={item.id || randomString(9)}>
             <div className={styles.list}>
-              <Typography.Text className={styles['list-text']} ellipsis={{ tooltip: item.name }}>
+              <Typography.Text
+                className={styles['list-text']}
+                ellipsis={{ tooltip: item.name }}
+                onClick={(e) => {
+                  e.stopPropagation();
+                  handleHistory(item);
+                  handleSearch();
+                }}
+              >
                 {item.name}
               </Typography.Text>
               <Popconfirm

+ 2 - 3
src/pages/device/Product/index.tsx

@@ -254,7 +254,7 @@ const Product = observer(() => {
     {
       title: '名称',
       dataIndex: 'name',
-      width: 200,
+      width: 220,
       ellipsis: true,
     },
     {
@@ -291,7 +291,7 @@ const Product = observer(() => {
     {
       title: '接入方式',
       dataIndex: 'accessName',
-      width: 150,
+      width: 220,
       ellipsis: true,
       valueType: 'select',
       // render: (_, row) => {
@@ -363,7 +363,6 @@ const Product = observer(() => {
         defaultMessage: '说明',
       }),
       ellipsis: true,
-      width: 300,
       // hideInSearch: true,
     },
     {

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

@@ -1173,6 +1173,9 @@ const Edit = observer((props: Props) => {
         }),
         'x-decorator': 'FormItem',
         'x-component': 'JsonParam',
+        'x-component-props': {
+          isFunction: true,
+        },
         'x-reactions': (field) => {
           field.setComponentProps({ keys: 'inputs' });
         },

+ 1 - 1
src/pages/media/Device/Save/SaveProduct.tsx

@@ -57,7 +57,7 @@ export default (props: SaveProps) => {
         setLoading(false);
         if (deployResp.status === 200) {
           if (reload) {
-            reload(resp.result.id, resp.result.name);
+            reload(resp.result.id, resp.result);
           }
           onClose();
         } else {

+ 16 - 4
src/pages/media/Device/Save/index.tsx

@@ -24,6 +24,8 @@ const Save = () => {
   const [accessType, setAccessType] = useState(DefaultAccessType);
   const [productList, setProductList] = useState<any[]>([]);
   const [oldPassword, setOldPassword] = useState('');
+  const [loading, setLoading] = useState(false);
+
   const img1 = require('/public/images/media/doc1.png');
   const img2 = require('/public/images/media/doc2.png');
   const img3 = require('/public/images/media/doc3.png');
@@ -81,9 +83,11 @@ const Save = () => {
       if (formData.id === '') {
         delete extraFormData.id;
       }
+      setLoading(true);
       const resp = id
         ? await service.updateData(channel, id, { ...extraFormData, channel })
         : await service.saveData(channel, { ...extraFormData, channel });
+      setLoading(false);
       if (resp.status === 200) {
         form.resetFields();
         onlyMessage('操作成功');
@@ -265,7 +269,9 @@ const Save = () => {
                           onSelect={(_: any, node: any) => {
                             const pwd = node.configuration ? node.configuration.access_pwd : '';
                             form.setFieldsValue({
-                              password: pwd,
+                              others: {
+                                access_pwd: pwd,
+                              },
                             });
                           }}
                         />
@@ -379,7 +385,7 @@ const Save = () => {
                 </Form.Item>
                 <Col span={24}>
                   <Form.Item>
-                    <Button type="primary" htmlType="submit">
+                    <Button type="primary" htmlType="submit" loading={loading}>
                       保存
                     </Button>
                   </Form.Item>
@@ -462,11 +468,17 @@ const Save = () => {
           close={() => {
             setProductVisible(false);
           }}
-          reload={(productId: string, name: string) => {
+          reload={(productId: string, data: any) => {
             form.setFieldsValue({ productId });
             productList.push({
               id: productId,
-              name,
+              name: data.name,
+            });
+            const pwd = data.configuration ? data.configuration.access_pwd : '';
+            form.setFieldsValue({
+              others: {
+                access_pwd: pwd,
+              },
             });
             setProductList([...productList]);
           }}

+ 3 - 7
src/pages/rule-engine/Scene/Save/components/DatePickerFormat/index.tsx

@@ -22,13 +22,9 @@ export default (props: DatePickerFormat) => {
     v: DatePickerProps['value'],
     f: DatePickerProps['format'],
   ): moment.Moment => {
-    if (f === 'string') {
-      const _format = handleFormat(f);
-      return moment(moment(v, defaultFormat), _format).utc();
-    } else {
-      const _format = handleFormat(f);
-      return moment(moment(v, defaultFormat), _format);
-    }
+    console.log(v);
+    const _format = handleFormat(f);
+    return moment(v, _format);
   };
 
   return (