瀏覽代碼

feat: merge

xieyonghong 3 年之前
父節點
當前提交
31d3a36278

+ 21 - 0
src/global.less

@@ -160,6 +160,7 @@ input[type='tel'] {
 #driver-page-overlay {
   opacity: 0.35 !important;
 }
+
 .ant-pagination-mini .ant-pagination-jump-prev,
 .ant-pagination-mini .ant-pagination-jump-next {
   display: none;
@@ -169,3 +170,23 @@ input[type='tel'] {
   display: flex;
   justify-content: flex-end;
 }
+
+.ant-formily-array-table
+  .ant-table
+  td
+  .ant-formily-item:not(.ant-formily-item-feedback-layout-popover)
+  .ant-formily-item-help {
+  position: inherit;
+  top: 100%;
+  z-index: 1;
+  width: 100%;
+  margin-top: 3px;
+  padding: 3px;
+  font-size: 12px;
+  background: #fff;
+  border-radius: 3px;
+  box-shadow: 0 0 10px #eee;
+  transform: translateY(0);
+  opacity: 1;
+  animation: none;
+}

+ 24 - 6
src/pages/device/Instance/Detail/MapChannel/index.tsx

@@ -1,7 +1,7 @@
 import useDomFullHeight from '@/hooks/document/useDomFullHeight';
 import { createForm, Field, FormPath, onFieldReact } from '@formily/core';
 import { FormProvider, createSchemaField } from '@formily/react';
-import { Badge, Button, Card, Tooltip } from 'antd';
+import { Badge, Button, Card, Spin, Tooltip } from 'antd';
 import { useEffect, useState } from 'react';
 import { FormItem, ArrayTable, Editable, Select } from '@formily/antd';
 import PermissionButton from '@/components/PermissionButton';
@@ -28,6 +28,7 @@ const MapChannel = (props: Props) => {
   const [properties, setProperties] = useState<any>([]);
   const [channelList, setChannelList] = useState<any>([]);
   const [visible, setVisible] = useState<boolean>(false);
+  const [loading, setLoading] = useState<boolean>(false);
 
   const Render = (propsName: any) => {
     const text = properties.find((item: any) => item.metadataId === propsName.value);
@@ -62,6 +63,7 @@ const MapChannel = (props: Props) => {
           title: '确认解绑',
           disabled: !record(index)?.id,
           onConfirm: async () => {
+            setLoading(true);
             remove(record(index)?.id);
           },
         }}
@@ -369,6 +371,7 @@ const MapChannel = (props: Props) => {
   };
 
   useEffect(() => {
+    setLoading(true);
     service
       .getChannel({
         paging: false,
@@ -418,14 +421,23 @@ const MapChannel = (props: Props) => {
           //删除物模型
           const items = array.filter((item: any) => item.metadataName);
           setProperties(items);
+          setTimeout(() => {
+            setLoading(false);
+          }, 500);
           const delList = array.filter((a: any) => !a.metadataName).map((b: any) => b.id);
           //删除后解绑
           if (delList && delList.length !== 0) {
             service.removeMap('device', data.id, delList);
+            setTimeout(() => {
+              setLoading(false);
+            }, 500);
           }
         }
       });
     } else {
+      setTimeout(() => {
+        setLoading(false);
+      }, 500);
       setEmpty(true);
     }
   }, [reload]);
@@ -448,6 +460,7 @@ const MapChannel = (props: Props) => {
             <Button
               type="primary"
               onClick={async () => {
+                setLoading(true);
                 const value: any = await form.submit();
                 const arr = value.requestList.filter((i: any) => i.channelId);
                 if (arr && arr.length !== 0) {
@@ -459,11 +472,16 @@ const MapChannel = (props: Props) => {
               保存
             </Button>
           </div>
-          <div className="array-table">
-            <FormProvider form={form}>
-              <SchemaField schema={schema} scope={{ useAsyncDataSource, getCollector, getPoint }} />
-            </FormProvider>
-          </div>
+          <Spin spinning={loading}>
+            <div className="array-table">
+              <FormProvider form={form}>
+                <SchemaField
+                  schema={schema}
+                  scope={{ useAsyncDataSource, getCollector, getPoint }}
+                />
+              </FormProvider>
+            </div>
+          </Spin>
         </>
       )}
       {visible && (

+ 1 - 1
src/pages/device/components/Metadata/Base/index.tsx

@@ -179,7 +179,7 @@ const BaseMetadata = observer((props: Props) => {
         }}
         toolbar={{
           search: {
-            placeholder: '请输入标识',
+            placeholder: '请输入名称',
             allowClear: true,
             onSearch: handleSearch,
           },

+ 4 - 1
src/pages/rule-engine/Scene/Save/action/DeviceOutput/actions/TypeModel.tsx

@@ -132,7 +132,6 @@ export default observer((props: Props) => {
             fieldNames={{ label: 'text', value: 'value' }}
             placeholder={'请选择'}
             onChange={(e, options: any) => {
-              console.log(options?.text);
               setValue(e);
               setLabelValue(options?.text);
               // DeviceModel.propertiesValue = options?.text
@@ -162,6 +161,10 @@ export default observer((props: Props) => {
         return (
           <Input
             value={value}
+            readOnly
+            onClick={() => {
+              setVisible(true);
+            }}
             style={{ width: '100%', textAlign: 'left' }}
             addonAfter={
               <EnvironmentOutlined

+ 2 - 2
src/pages/rule-engine/Scene/Save/action/DeviceOutput/actions/WriteProperty.tsx

@@ -63,7 +63,7 @@ export default (props: Props) => {
   }, [props.properties]);
 
   useEffect(() => {
-    if (props.onChange && propertiesValue) {
+    if (props.onChange) {
       const obj = {
         [propertiesId || 0]: {
           value: propertiesValue,
@@ -127,7 +127,7 @@ export default (props: Props) => {
             }}
             onChange={(value, sources, text) => {
               // console.log(value, sources);
-              console.log(text);
+              // console.log(text);
               ref.current = text;
               setPropertiesValue(value);
               setSource(sources);

+ 2 - 4
src/pages/rule-engine/Scene/Save/action/DeviceOutput/actions/index.tsx

@@ -174,6 +174,7 @@ export default observer((props: Props) => {
               () => ({
                 validator(_, value) {
                   const isValue = Object.values(value)?.[0];
+                  // console.log('-------',isValue,value)
                   if (isValue) {
                     return Promise.resolve();
                   }
@@ -188,19 +189,16 @@ export default observer((props: Props) => {
               branchGroup={props.branchGroup}
               thenName={props.thenName}
               onColumns={(col, text) => {
-                // console.log('col',col,[col])
                 DeviceModel.columns = [col];
                 DeviceModel.actionName = text;
-                // console.log(text)
               }}
               onChange={(value, text, valueLable) => {
                 const item = value[Object.keys(value)?.[0]]?.value;
-                // console.log(`valueLable`,valueLable)
                 DeviceModel.propertiesName = text;
                 if (valueLable) {
                   DeviceModel.propertiesValue = valueLable;
                 } else {
-                  DeviceModel.propertiesValue = item;
+                  DeviceModel.propertiesValue = `${item}`;
                 }
               }}
               onRest={(value: any) => {

+ 19 - 9
src/pages/rule-engine/Scene/Save/action/DeviceOutput/device/index.tsx

@@ -39,6 +39,7 @@ export default observer((props: Props) => {
   const [tagList, setTagList] = useState([]);
   const [list, setList] = useState<any>([]);
   const [isFirst, setIsFirst] = useState(true);
+  const [oldRowKey] = useState(DeviceModel.deviceId);
 
   const TypeList = [
     {
@@ -270,10 +271,9 @@ export default observer((props: Props) => {
     return nodes.filter((it) => {
       if (
         it.children.find(
-          (item: any) =>
-            item.id.indexOf('deviceId' || 'device_id' || 'device_Id') > -1 &&
-            item.type === 'string',
-        )
+          (item: any) => item.id.indexOf('deviceId' || 'device_id' || 'device_Id') > -1,
+        ) &&
+        !it.children.find((item: any) => item.id.indexOf('bolaen') > -1)
       ) {
         return true;
       }
@@ -292,6 +292,7 @@ export default observer((props: Props) => {
       if (res.status === 200) {
         const _data = BuiltInParamsHandleTreeData(res.result);
         const array = filterTree(_data);
+        console.log('--------', array);
         setBuiltInList(array);
       }
     });
@@ -387,12 +388,21 @@ export default observer((props: Props) => {
                     }
                   },
                 }}
-                request={(params) =>
-                  service.query({
+                request={(params) => {
+                  const sorts: any = [{ name: 'createTime', order: 'desc' }];
+
+                  if (oldRowKey) {
+                    sorts.push({
+                      name: 'id',
+                      value: oldRowKey,
+                    });
+                  }
+
+                  return service.query({
                     ...params,
-                    sorts: [{ name: 'createTime', order: 'desc' }],
-                  })
-                }
+                    sorts: sorts,
+                  });
+                }}
                 params={searchParam}
                 cardRender={(record) => (
                   <SceneDeviceCard showBindBtn={false} showTool={false} {...record} />

+ 13 - 5
src/pages/rule-engine/Scene/Save/action/DeviceOutput/index.tsx

@@ -9,6 +9,7 @@ import './index.less';
 import DeviceModel from './model';
 import { onlyMessage } from '@/utils/util';
 import { ActionsDeviceProps } from '../../../typings';
+import { service as api } from '@/pages/device/Instance/index';
 
 export const service = new Service<any>('');
 
@@ -112,17 +113,14 @@ export default observer((props: Props) => {
     const _type = value.message.messageType;
     if (_type === 'INVOKE_FUNCTION') {
       _options.type = '执行';
-      // _options.properties = value.message.functionId;
       _options.properties = DeviceModel.propertiesName;
     }
     if (_type === 'READ_PROPERTY') {
       _options.type = '读取';
       _options.properties = DeviceModel.propertiesName;
-      // _options.name = DeviceModel.selectorValues[0].name;
     }
     if (_type === 'WRITE_PROPERTY') {
       _options.type = '设置';
-      // _options.properties = Object.keys(value.message.properties)?.[0];
       _options.properties = DeviceModel.propertiesName;
       _options.propertiesValue = DeviceModel.propertiesValue;
       _options.columns = DeviceModel.columns;
@@ -140,13 +138,13 @@ export default observer((props: Props) => {
       }));
       // console.log(_options.taglist, 'taglist')
     }
-    // console.log(DeviceModel.propertiesValue,_options);
+    console.log(DeviceModel.propertiesValue, _options);
     props.save(item, _options);
     init();
   };
 
   useEffect(() => {
-    console.log(props.value);
+    // console.log(props.value);
     if (props.value) {
       DeviceModel.selector = props.value.selector;
       DeviceModel.productId = props.value.productId;
@@ -158,6 +156,9 @@ export default observer((props: Props) => {
           ? props.value.selectorValues?.map((item: any) => item.value)[0]
           : 'deviceId';
     }
+    return () => {
+      init();
+    };
   }, [props.value]);
 
   return (
@@ -216,6 +217,13 @@ export default observer((props: Props) => {
                 ? (DeviceModel.current = 1)
                 : onlyMessage('请选择产品', 'error');
             } else if (value === 2) {
+              if (DeviceModel.deviceId) {
+                api.detail(DeviceModel.deviceId).then((res) => {
+                  if (res.status === 200) {
+                    DeviceModel.deviceDetail = res.result || {};
+                  }
+                });
+              }
               return DeviceModel.deviceId
                 ? (DeviceModel.current = 2)
                 : onlyMessage('请选择设备', 'error');

+ 1 - 1
src/pages/rule-engine/Scene/Save/action/DeviceOutput/model.ts

@@ -23,7 +23,7 @@ type ModelType = {
   relationName: string;
   message: any;
   propertiesName: string;
-  propertiesValue: string;
+  propertiesValue: string | any;
   columns: string[];
   actionName: string;
 };

+ 15 - 5
src/pages/rule-engine/Scene/Save/action/DeviceOutput/product/index.tsx

@@ -20,6 +20,7 @@ export default observer((props: Props) => {
   const actionRef = useRef<ActionType>();
   const intl = useIntl();
   const [searchParam, setSearchParam] = useState({});
+  const [oldRowKey] = useState(props.productId);
 
   const columns: ProColumns<ProductItem>[] = [
     {
@@ -239,12 +240,21 @@ export default observer((props: Props) => {
               DeviceModel.deviceId = '';
             },
           }}
-          request={(params) =>
-            service.query({
+          request={(params) => {
+            const sorts: any = [{ name: 'createTime', order: 'desc' }];
+
+            if (oldRowKey) {
+              sorts.push({
+                name: 'id',
+                value: oldRowKey,
+              });
+            }
+
+            return service.query({
               ...params,
-              sorts: [{ name: 'createTime', order: 'desc' }],
-            })
-          }
+              sorts: sorts,
+            });
+          }}
           params={searchParam}
           cardRender={(record) => (
             <SceneProductCard showBindBtn={false} showTool={false} {...record} />

+ 4 - 0
src/pages/rule-engine/Scene/Save/action/notify/index.tsx

@@ -63,6 +63,10 @@ export default observer((props: Props) => {
       ...props.value,
       options: { ...props.options },
     };
+    return () => {
+      NotifyModel.current = 0;
+      NotifyModel.notify = {};
+    };
   }, [props.value, props.options]);
 
   const renderComponent = (type: string) => {

+ 12 - 13
src/pages/system/Apply/Save/index.tsx

@@ -248,22 +248,18 @@ const Save = () => {
       });
       onFieldReact('apiServer.ipWhiteList', (field: any) => {
         const value = (field as Field).value;
-        console.log(value);
         const pattern =
           /((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/;
         if (value) {
           const str = value?.split(/[\n,]/g).filter((i: any) => i && i.trim());
-          console.log(str);
-          str.forEach((item: any) => {
-            const ip = pattern.test(item);
-            console.log(ip);
-            if (!ip) {
-              field.selfErrors = `[${item}]不是正确的IP地址`;
-              return;
-            } else {
-              field.selfErrors = '';
-            }
-          });
+          // console.log(str);
+          const NoIP = str.find((item: any) => !pattern.test(item));
+          console.log(NoIP);
+          if (NoIP) {
+            field.selfErrors = `[${NoIP}]不是正确的IP地址`;
+          } else {
+            field.selfErrors = '';
+          }
         } else {
           field.selfErrors = '';
         }
@@ -675,6 +671,9 @@ const Save = () => {
         labelAlign: 'left',
       },
       'x-component': 'UploadImage',
+      'x-component-props': {
+        errorMessage: '请上传.jpg.png.jfif.pjp.pjpeg.jpeg格式的图片',
+      },
     },
     'sso.configuration.oauth2.userInfoUrl': {
       type: 'string',
@@ -1625,7 +1624,7 @@ const Save = () => {
                 default: [{}],
                 title: '参数',
                 'x-decorator': 'FormItem',
-                required: true,
+                // required: true,
                 'x-component': 'ArrayTable',
                 'x-reactions': {
                   dependencies: ['provider'],