Przeglądaj źródła

fix: resset 1.5

wzyyy 3 lat temu
rodzic
commit
c54b19ea71

+ 1 - 27
src/pages/device/Category/index.tsx

@@ -13,8 +13,6 @@ import SearchComponent from '@/components/SearchComponent';
 import { PermissionButton } from '@/components';
 import { useDomFullHeight } from '@/hooks';
 import { onlyMessage } from '@/utils/util';
-import { service as api } from '@/pages/device/Product';
-import { Spin } from 'antd';
 
 export const service = new Service('device/category');
 
@@ -57,8 +55,6 @@ const Category = observer(() => {
   const permissionCode = 'device/Category';
   const { permission } = PermissionButton.usePermission(permissionCode);
   const { minHeight } = useDomFullHeight(`.device-category`, 24);
-  const [loading, setLoading] = useState<boolean>(true);
-  const [title, setTitle] = useState<string>('');
 
   const intl = useIntl();
 
@@ -139,30 +135,8 @@ const Category = observer(() => {
           type="link"
           key="delete"
           style={{ padding: 0 }}
-          onClick={async () => {
-            const res: any = await api.queryNoPagingPost({
-              terms: [{ terms: [{ column: 'classifiedId', value: record.id }] }],
-            });
-            if (res.status === 200) {
-              if (res.result.length === 0) {
-                setTitle('确定删除?');
-              } else {
-                setTitle('该数据已被产品引用,确定删除?');
-              }
-              setLoading(false);
-            } else {
-              setLoading(false);
-            }
-          }}
           popConfirm={{
-            title: <>{loading ? <Spin /> : title}</>,
-            okButtonProps: {
-              loading: loading,
-            },
-            onCancel: () => {
-              setTitle('');
-              setLoading(true);
-            },
+            title: '确定删除?',
             onConfirm: async () => {
               const resp = (await service.remove(record.id)) as Response<any>;
               if (resp.status === 200) {

+ 1 - 1
src/pages/device/Instance/Detail/EdgeMap/mapTable/index.tsx

@@ -446,8 +446,8 @@ const MapTable = (props: Props) => {
           批量映射
         </PermissionButton>
         <PermissionButton
-          isPermission={permission.update}
           type="primary"
+          isPermission={permission.update}
           onClick={async () => {
             if (props.formRef) {
               add();

+ 12 - 12
src/pages/iot-card/CardManagement/SaveModal.tsx

@@ -85,17 +85,6 @@ const Save = (props: SaveType) => {
           rules={[
             { required: true, message: '请输入卡号' },
             { max: 64, message: '最多可输入64个字符' },
-          ]}
-        >
-          <Input placeholder={'请输入卡号'} disabled={props.type === 'edit'} />
-        </Form.Item>
-        <Form.Item
-          label={'ICCID'}
-          name={'iccId'}
-          required
-          rules={[
-            { required: true, message: '请输入ICCID' },
-            { max: 64, message: '最多可输入64个字符' },
             () => ({
               async validator(_, value) {
                 if (value) {
@@ -106,12 +95,23 @@ const Save = (props: SaveType) => {
                     return Promise.reject(new Error(`${validateId}`));
                   }
                 } else {
-                  return Promise.reject(new Error('请输入输入正确的ICCID'));
+                  return Promise.reject(new Error('请输入输入正确的卡号'));
                 }
               },
             }),
           ]}
         >
+          <Input placeholder={'请输入卡号'} disabled={props.type === 'edit'} />
+        </Form.Item>
+        <Form.Item
+          label={'ICCID'}
+          name={'iccId'}
+          required
+          rules={[
+            { required: true, message: '请输入ICCID' },
+            { max: 64, message: '最多可输入64个字符' },
+          ]}
+        >
           <Input placeholder={'请输入ICCID'} disabled={props.type === 'edit'} />
         </Form.Item>
         <Form.Item

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

@@ -44,12 +44,21 @@ export default observer((props: Props) => {
   ];
 
   useEffect(() => {
+    // console.log('-----------',DeviceModel.deviceDetail)
     if (DeviceModel.productDetail) {
-      const metadata = JSON.parse(DeviceModel.productDetail?.metadata || '{}');
-      setProperties(metadata.properties);
-      setFunctions(metadata.functions);
+      if (DeviceModel.selector === 'fixed') {
+        const metadata = JSON.parse(
+          DeviceModel.deviceDetail?.metadata || DeviceModel.deviceDetail?.deriveMetadata || '{}',
+        );
+        setProperties(metadata.properties);
+        setFunctions(metadata.functions);
+      } else {
+        const metadata = JSON.parse(DeviceModel.productDetail?.metadata || '{}');
+        setProperties(metadata.properties);
+        setFunctions(metadata.functions);
+      }
     }
-  }, [DeviceModel.productDetail]);
+  }, [DeviceModel.productDetail, DeviceModel.deviceDetail]);
 
   useEffect(() => {
     if (functionId && functions.length !== 0) {

+ 12 - 2
src/pages/rule-engine/Scene/Save/action/DeviceOutput/device/Tag.tsx

@@ -7,7 +7,7 @@ import './index.less';
 interface TagModalProps {
   tagData: any[];
   value?: any[];
-  onChange?: (value: any[]) => void;
+  onChange?: (value: any[], OptionTag?: any[]) => void;
   id?: string;
 }
 
@@ -39,8 +39,18 @@ export default (props: TagModalProps) => {
           value: item.value,
         };
       });
+    const arr = tagList
+      .filter((item) => !!item.value)
+      .map((item: any) => {
+        return {
+          column: item.name,
+          type: item.type,
+          value: item.value,
+        };
+      });
+    console.log('----taglist---', tagList);
     if (props.onChange) {
-      props.onChange([{ value: newValue, name: '标签' }]);
+      props.onChange([{ value: newValue, name: '标签' }], arr);
     }
   };
 

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

@@ -408,13 +408,16 @@ export default observer((props: Props) => {
           <Form.Item name="selectorValues" rules={[{ required: true, message: '请选择标签' }]}>
             <Tag
               tagData={tagList}
-              onChange={(value) => {
-                console.log(value);
+              onChange={(value, arr) => {
+                console.log(value, arr);
                 if (value) {
                   DeviceModel.deviceId = 'deviceId';
                   DeviceModel.source = 'fixed';
                   DeviceModel.selectorValues = value;
                 }
+                if (arr) {
+                  DeviceModel.tagList = arr;
+                }
               }}
             />
           </Form.Item>
@@ -442,7 +445,6 @@ export default observer((props: Props) => {
   };
 
   useEffect(() => {
-    console.log(DeviceModel.selectorValues, '--------');
     if (form) {
       form.setFieldsValue({ selector: DeviceModel.selector });
       if (DeviceModel.selectorValues) {

+ 8 - 3
src/pages/rule-engine/Scene/Save/action/DeviceOutput/index.tsx

@@ -71,7 +71,7 @@ export default observer((props: Props) => {
       (DeviceModel.current === 0 && DeviceModel.productId) ||
       (DeviceModel.current === 1 && (DeviceModel.deviceId || DeviceModel.selector === 'tag'))
     ) {
-      if (DeviceModel.selector === 'tag') {
+      if (DeviceModel.selector === 'tag' && DeviceModel.current === 1) {
         const value = await tagFormRef.current?.validateFields();
         if (value) {
           return (DeviceModel.current += 1);
@@ -154,7 +154,12 @@ export default observer((props: Props) => {
       }
     }
     if (_options.selector === 'tag') {
-      _options.taglist = DeviceModel.selectorValues?.[0]?.value.map((it: any) => ({
+      // _options.taglist = DeviceModel.selectorValues?.[0]?.value.map((it: any) => ({
+      //   name: it.column || it.name,
+      //   type: it.type ? (it.type === 'and' ? '并且' : '或者') : '',
+      //   value: it.value,
+      // }));
+      _options.taglist = DeviceModel.tagList.map((it) => ({
         name: it.column || it.name,
         type: it.type ? (it.type === 'and' ? '并且' : '或者') : '',
         value: it.value,
@@ -163,7 +168,7 @@ export default observer((props: Props) => {
     if (_options.selector === 'variable') {
       _options.name = DeviceModel.selectorValues?.[0]?.name;
     }
-    // console.log("----------",item,_options)
+    console.log('----------', item, _options);
     props.save(item, _options);
     init();
   };

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

@@ -26,6 +26,7 @@ type ModelType = {
   propertiesValue: string | any;
   columns: string[];
   actionName: string;
+  tagList: any[];
 };
 
 const DeviceModel = model<ModelType>({
@@ -47,6 +48,7 @@ const DeviceModel = model<ModelType>({
   propertiesValue: '',
   columns: [],
   actionName: '',
+  tagList: [],
 });
 
 export default DeviceModel;

+ 2 - 3
src/pages/rule-engine/Scene/Save/action/ListItem/Item.tsx

@@ -249,11 +249,10 @@ export default (props: ItemProps) => {
             {data.options?.taglist?.map((item: any) => (
               <span>
                 {item.type}
-                {item.name}
-                {item.value}
+                {item.name}为{item.value}
               </span>
             ))}
-            {data?.options?.productName}
+            {data?.options?.productName}
             {data?.options?.properties}
           </div>
         );

+ 50 - 0
src/pages/rule-engine/Scene/Save/action/device/ObjInput.tsx

@@ -0,0 +1,50 @@
+import { EditOutlined } from '@ant-design/icons';
+import { Input } from 'antd';
+import { useState } from 'react';
+import ObjModel from '../DeviceOutput/actions/ObjModel';
+
+interface Props {
+  value: any;
+  onChange?: (data: any) => void;
+}
+
+export default (props: Props) => {
+  const [objVisiable, setObjVisable] = useState<boolean>(false);
+  const [value, setValue] = useState<any>(JSON.stringify(props.value) || undefined);
+  return (
+    <>
+      <Input
+        value={value}
+        style={{ width: '100%', textAlign: 'left' }}
+        readOnly
+        onClick={() => {
+          setObjVisable(true);
+        }}
+        addonAfter={
+          <EditOutlined
+            onClick={() => {
+              setObjVisable(true);
+            }}
+          />
+        }
+        placeholder={'请选择'}
+      />
+      {objVisiable && (
+        <ObjModel
+          value={value}
+          close={() => {
+            setObjVisable(false);
+          }}
+          ok={(param) => {
+            // console.log('------', param);
+            if (props.onChange) {
+              props.onChange(JSON.parse(param));
+            }
+            setValue(param);
+            setObjVisable(false);
+          }}
+        />
+      )}
+    </>
+  );
+};

+ 0 - 0
src/pages/rule-engine/Scene/Save/action/device/TypeTime.tsx


+ 34 - 9
src/pages/rule-engine/Scene/Save/action/device/functionCall.tsx

@@ -4,7 +4,9 @@ import { Input, InputNumber, Select } from 'antd';
 import React, { useEffect, useRef, useState } from 'react';
 import type { ProFormInstance } from '@ant-design/pro-form';
 import ProForm from '@ant-design/pro-form';
-import { DatePickerFormat } from '@/pages/rule-engine/Scene/Save/components';
+import ObjModel from '../DeviceOutput/actions/ObjModel';
+import ObjInput from './ObjInput';
+import TypeTime from './TypeTime';
 
 type FunctionTableDataType = {
   id: string;
@@ -23,6 +25,8 @@ interface FunctionCallProps {
 export default (props: FunctionCallProps) => {
   const [editableKeys, setEditableRowKeys] = useState<React.Key[]>([]);
   const formRef = useRef<ProFormInstance<any>>();
+  const [objVisiable, setObjVisable] = useState<boolean>(false);
+  const [value, setValue] = useState<any>();
 
   useEffect(() => {
     if (props.functionData && props.functionData.length) {
@@ -59,7 +63,7 @@ export default (props: FunctionCallProps) => {
     }
   }, [props.productId]);
 
-  const getItemNode = (record: any, config: any) => {
+  const getItemNode = (record: any) => {
     const type = record.type;
     const name = record.name;
 
@@ -99,13 +103,16 @@ export default (props: FunctionCallProps) => {
         );
       case 'date':
         return (
-          <DatePickerFormat
-            {...config}
-            value={record.value}
-            format={record.format || 'YYYY-MM-DD HH:mm:ss'}
-            style={{ width: '100%' }}
-          />
+          // <DatePickerFormat
+          //   {...config}
+          //   value={record.value}
+          //   format={record.format || 'YYYY-MM-DD HH:mm:ss'}
+          //   style={{ width: '100%' }}
+          // />
+          <TypeTime type={record.type === 'yyyy-MM-dd' ? 'time' : 'date'} value={record.value} />
         );
+      case 'object':
+        return <ObjInput value={record.value} />;
       default:
         return <Input value={record.value} placeholder={'请输入' + name} />;
     }
@@ -130,11 +137,15 @@ export default (props: FunctionCallProps) => {
       align: 'center',
       width: 260,
       renderFormItem: (_, row) => {
-        return getItemNode(row.record, row);
+        return getItemNode(row.record);
       },
     },
   ];
 
+  useEffect(() => {
+    console.log(value);
+  }, [value]);
+
   return (
     <ProForm<{ table: FunctionTableDataType[] }>
       formRef={formRef}
@@ -142,6 +153,7 @@ export default (props: FunctionCallProps) => {
       submitter={false}
       onValuesChange={() => {
         const values = formRef.current?.getFieldsValue();
+        console.log('---values---', values);
         if (props.onChange) {
           props.onChange(
             values.table.map((item: any) => ({
@@ -164,6 +176,19 @@ export default (props: FunctionCallProps) => {
           onChange: setEditableRowKeys,
         }}
       />
+      {objVisiable && (
+        <ObjModel
+          value={value}
+          close={() => {
+            setObjVisable(false);
+          }}
+          ok={(param) => {
+            console.log('------', param);
+            setValue(param);
+            setObjVisable(false);
+          }}
+        />
+      )}
     </ProForm>
   );
 };

+ 16 - 1
src/pages/rule-engine/Scene/Save/device/addModel.tsx

@@ -4,7 +4,7 @@ import { observable } from '@formily/reactive';
 import { useEffect, useRef, useState } from 'react';
 import { onlyMessage } from '@/utils/util';
 import type { TriggerDevice, TriggerDeviceOptions } from '@/pages/rule-engine/Scene/typings';
-import Product from './product';
+import Product, { handleMetadata } from './product';
 import Device from './device';
 import Type from './type';
 import { timeUnitEnum } from '../components/TimingTrigger';
@@ -12,6 +12,7 @@ import { Store } from 'jetlinks-store';
 import { FormModel } from '@/pages/rule-engine/Scene/Save';
 import { isEqual } from 'lodash';
 import { continuousValue } from '@/pages/rule-engine/Scene/Save/timer/TimerTrigger';
+import { service as api } from '@/pages/device/Instance/index';
 
 interface AddProps {
   options?: any;
@@ -227,6 +228,7 @@ export default observer((props: AddProps) => {
       }
     } else if (TriggerDeviceModel.stepNumber === 1) {
       if (TriggerDeviceModel.selector === 'fixed' && !TriggerDeviceModel.selectorValues?.length) {
+        // handleMetadata(TriggerDeviceModel.productDetail?.metadata);
         onlyMessage('请选择设备', 'error');
         return;
       } else if (
@@ -236,6 +238,18 @@ export default observer((props: AddProps) => {
         onlyMessage('请选择部门', 'error');
         return;
       }
+      if (
+        TriggerDeviceModel.selector === 'fixed' &&
+        TriggerDeviceModel.selectorValues?.length === 1
+      ) {
+        console.log('---TriggerDeviceModel.selectorValues----', TriggerDeviceModel.selectorValues);
+        const res = await api.detail(TriggerDeviceModel.selectorValues?.[0]?.value);
+        if (res.status === 200) {
+          // console.log(res.result.metadata)
+          handleMetadata(res.result.metadata);
+        }
+      }
+
       TriggerDeviceModel.stepNumber = 2;
     } else if (TriggerDeviceModel.stepNumber === 2) {
       // TODO 验证类型数据
@@ -256,6 +270,7 @@ export default observer((props: AddProps) => {
         Store.set('TriggerDeviceModel', {
           update: !isUpdate,
         });
+        console.log('-----------', operationData);
         props.onSave?.(saveData, _options);
       }
     }

+ 1 - 18
src/pages/rule-engine/Scene/index.tsx

@@ -1,5 +1,5 @@
 import { PageContainer } from '@ant-design/pro-layout';
-import React, { useEffect, useRef, useState } from 'react';
+import React, { useRef, useState } from 'react';
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import type { SceneItem } from '@/pages/rule-engine/Scene/typings';
 import {
@@ -31,8 +31,6 @@ const Scene = () => {
   const [visible, setVisible] = useState<boolean>(false);
   const [current, setCurrent] = useState<Partial<SceneItem>>({});
   const history = useHistory();
-  const [loading, setLoading] = useState<boolean>(true);
-  const [title, setTitle] = useState<string>('');
 
   const deleteById = async (id: string) => {
     // const alarmResp = await service.sceneByAlarm(id);
@@ -46,13 +44,6 @@ const Scene = () => {
     // }
   };
 
-  useEffect(() => {
-    console.log('----------', title, loading);
-    if (title) {
-      setLoading(false);
-    }
-  }, [title]);
-
   const Tools = (record: SceneItem): React.ReactNode[] => {
     return [
       <PermissionButton
@@ -157,14 +148,6 @@ const Scene = () => {
         style={{ padding: 0 }}
         isPermission={permission.delete}
         disabled={record.state.value === 'started'}
-        onClick={async () => {
-          const res = await service.sceneByAlarm(record.id);
-          if (res.status === 200 && res.result.data.length !== 0) {
-            setTitle('该场景已绑定告警,确定删除?');
-          } else {
-            setTitle('确定删除?');
-          }
-        }}
         popConfirm={{
           // title: loading ? <Spin /> : title,
           // okButtonProps: {

+ 2 - 2
src/pages/system/Department/Assets/deivce/index.tsx

@@ -239,8 +239,8 @@ export default observer((props: { parentId: string }) => {
     Models.unBindKeys = [];
     AssetsModel.params = {};
   };
-  const getSelectedRowsKey = (selectedRows) => {
-    return selectedRows.map((item) => item?.id).filter((item2) => !!item2 !== false);
+  const getSelectedRowsKey = (selectedRows: any) => {
+    return selectedRows.map((item: any) => item?.id).filter((item2: any) => !!item2 !== false);
   };
 
   const getData = (params: any, parentId: string) => {