wzyyy 3 лет назад
Родитель
Сommit
b5fa17ece6

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

@@ -6,7 +6,7 @@ import { createForm, Field, FormPath, onFieldReact } from '@formily/core';
 import type { Response } from '@/utils/typings';
 import { FormProvider, createSchemaField } from '@formily/react';
 import { action } from '@formily/reactive';
-import { Badge, Button, Tooltip } from 'antd';
+import { Badge, Tooltip } from 'antd';
 import { useEffect, useState } from 'react';
 import MapTree from '../mapTree';
 import './index.less';
@@ -29,6 +29,7 @@ const MapTable = (props: Props) => {
   const [visible, setVisible] = useState<boolean>(false);
   const [channelList, setChannelList] = useState<any>([]);
   const [deviceData, setDeviceData] = useState<any>({});
+  const { permission } = PermissionButton.usePermission('device/Instance');
 
   const remove = async (params: any) => {
     const res = await service.removeMap(edgeId, {
@@ -61,7 +62,7 @@ const MapTable = (props: Props) => {
     const index = ArrayTable.useIndex?.();
     return (
       <PermissionButton
-        isPermission={true}
+        isPermission={permission.update}
         style={{ padding: 0 }}
         disabled={!record(index)?.id}
         tooltip={{
@@ -411,7 +412,7 @@ const MapTable = (props: Props) => {
     // console.log(metaData, 1111111);
     service.edgeChannel(edgeId).then((res) => {
       if (res.status === 200) {
-        const list = res.result?.[0].map((item: any) => ({
+        const list = res.result?.[0]?.map((item: any) => ({
           label: item.name,
           value: item.id,
           provider: item.provider,
@@ -425,8 +426,9 @@ const MapTable = (props: Props) => {
     <div>
       <div className="top-button">
         {props.title && <TitleComponent data={props.title} />}
-        <Button
+        <PermissionButton
           style={{ marginRight: 10 }}
+          isPermission={permission.update}
           onClick={async () => {
             setVisible(true);
             const value = await props.formRef?.validateFields();
@@ -442,8 +444,8 @@ const MapTable = (props: Props) => {
           }}
         >
           批量映射
-        </Button>
-        <Button
+        </PermissionButton>
+        <PermissionButton
           type="primary"
           onClick={async () => {
             if (props.formRef) {
@@ -461,7 +463,7 @@ const MapTable = (props: Props) => {
           }}
         >
           保存
-        </Button>
+        </PermissionButton>
       </div>
       <div>
         <FormProvider form={form}>

+ 4 - 3
src/pages/device/Instance/Detail/EdgeMap/mapTree/index.tsx

@@ -60,10 +60,11 @@ const MapTree = (props: Props) => {
         metadataId: metaData.find((i: any) => i.name === element.name)?.metadataId,
         provider: data.find((it: any) => it.id === item.parentId).provider,
       }));
-      params.push(...array);
+      if (array) {
+        params.push(...array);
+      }
     });
     const filterParms = params.filter((item) => !!item.metadataId);
-    console.log(metaData);
     console.log('filterParms', filterParms);
     if (deviceId) {
       if (filterParms && filterParms.length !== 0) {
@@ -104,7 +105,7 @@ const MapTree = (props: Props) => {
       if (res.status === 200) {
         // console.log(res.result?.[0], 'data');
         setData(res.result?.[0]);
-        setExpandedKey([res.result?.[0].id]);
+        setExpandedKey([res.result?.[0]?.id]);
       }
     });
   }, []);

+ 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, Spin, Tooltip } from 'antd';
+import { Badge, Card, Spin, Tooltip } from 'antd';
 import { useEffect, useState } from 'react';
 import { FormItem, ArrayTable, Editable, Select } from '@formily/antd';
 import PermissionButton from '@/components/PermissionButton';
@@ -21,6 +21,7 @@ interface Props {
 export const service = new Service();
 
 const MapChannel = (props: Props) => {
+  const { permission } = PermissionButton.usePermission('device/Instance');
   const { data, type } = props;
   const { minHeight } = useDomFullHeight('.metadataMap');
   const [empty, setEmpty] = useState<boolean>(false);
@@ -53,7 +54,7 @@ const MapChannel = (props: Props) => {
     const index = ArrayTable.useIndex?.();
     return (
       <PermissionButton
-        isPermission={true}
+        isPermission={permission.update}
         style={{ padding: 0 }}
         disabled={!record(index)?.id}
         tooltip={{
@@ -449,15 +450,16 @@ const MapChannel = (props: Props) => {
       ) : (
         <>
           <div className="top-button">
-            <Button
+            <PermissionButton
               style={{ marginRight: 10 }}
+              isPermission={permission.update}
               onClick={async () => {
                 setVisible(true);
               }}
             >
               批量映射
-            </Button>
-            <Button
+            </PermissionButton>
+            <PermissionButton
               type="primary"
               onClick={async () => {
                 setLoading(true);
@@ -468,9 +470,25 @@ const MapChannel = (props: Props) => {
                   save(array);
                 }
               }}
+              key={'edit'}
+              isPermission={permission.update}
             >
               保存
-            </Button>
+            </PermissionButton>
+            {/* <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) {
+                  const array = value.requestList.filter((item: any) => item.channelId);
+                  save(array);
+                }
+              }}
+            >
+              保存
+            </Button> */}
           </div>
           <Spin spinning={loading}>
             <div className="array-table">

+ 8 - 4
src/pages/device/Instance/Detail/Parsing/index.tsx

@@ -185,26 +185,30 @@ const Parsing = (props: Props) => {
                   {topTitle === 'rest' ? (
                     <>
                       当前数据解析内容已脱离产品影响,
-                      <a
+                      <PermissionButton
+                        type="link"
+                        isPermission={permission.update}
                         onClick={() => {
                           rest(props.data.productId, props.data.id);
                         }}
                       >
                         重置
-                      </a>
+                      </PermissionButton>
                       后将继承产品数据解析内容
                     </>
                   ) : (
                     <>
                       当前数据解析内容继承自产品,
-                      <a
+                      <PermissionButton
+                        type="link"
+                        isPermission={permission.update}
                         style={readOnly ? {} : { color: '#a6a6a6' }}
                         onClick={() => {
                           setReadOnly(false);
                         }}
                       >
                         修改
-                      </a>
+                      </PermissionButton>
                       后将脱离产品影响。
                     </>
                   )}

+ 30 - 0
src/pages/iot-card/CardManagement/SaveModal.tsx

@@ -35,8 +35,10 @@ const Save = (props: SaveType) => {
 
   const submit = async () => {
     const formData = await form.validateFields();
+
     if (formData) {
       setLoading(true);
+
       const resp =
         props.type === 'add' ? await service.add(formData) : await service.edit(formData);
       setLoading(false);
@@ -46,6 +48,20 @@ const Save = (props: SaveType) => {
       }
     }
   };
+
+  const isValidateId = async (id: string) => {
+    const res = await service.validateId(id);
+    if (res.status === 200) {
+      if (res.result?.passed) {
+        return '';
+      } else {
+        return res.result.reason;
+      }
+    } else {
+      return '请输入输入正确的ICCID';
+    }
+  };
+
   return (
     <Modal
       title={props.type === 'add' ? '新增' : '编辑'}
@@ -80,6 +96,20 @@ const Save = (props: SaveType) => {
           rules={[
             { required: true, message: '请输入ICCID' },
             { max: 64, message: '最多可输入64个字符' },
+            () => ({
+              async validator(_, value) {
+                if (value) {
+                  const validateId = await isValidateId(value);
+                  if (validateId === '') {
+                    return Promise.resolve();
+                  } else {
+                    return Promise.reject(new Error(`${validateId}`));
+                  }
+                } else {
+                  return Promise.reject(new Error('请输入输入正确的ICCID'));
+                }
+              },
+            }),
           ]}
         >
           <Input placeholder={'请输入ICCID'} disabled={props.type === 'edit'} />

+ 2 - 2
src/pages/iot-card/CardManagement/index.tsx

@@ -205,7 +205,7 @@ const CardManagementNode = () => {
           <PermissionButton
             style={{ padding: 0 }}
             type="link"
-            isPermission={true}
+            isPermission={permission.view}
             key="view"
             onClick={() => {
               const url = getMenuPathByParams('iot-card/CardManagement/Detail', record.id);
@@ -221,7 +221,7 @@ const CardManagementNode = () => {
             type="link"
             key="bindDevice"
             style={{ padding: 0 }}
-            isPermission={permission.delete}
+            isPermission={permission.bind}
             tooltip={{ title: record.deviceId ? '解绑设备' : '绑定设备' }}
             popConfirm={
               record.deviceId

+ 2 - 0
src/pages/iot-card/CardManagement/service.ts

@@ -74,6 +74,8 @@ class Service extends BaseService<CardManagement> {
     this.POST(`${basePath}/network/flow/_query/${beginTime}/${endTime}`, data);
   // 查询对应状态物联卡数量
   queryState = (status: string) => this.GET(`${this.uri}/${status}/state/_count`);
+  //验证iccid
+  validateId = (id: string) => this.GET(`${this.uri}/id/_validate?id=${id}`);
 }
 
 export default Service;

+ 12 - 3
src/pages/iot-card/Platform/index.tsx

@@ -203,9 +203,18 @@ const Platform = () => {
             </PermissionButton>
           </>
         }
-        request={async (params) =>
-          service.getList({ ...params, sorts: [{ name: 'createTime', order: 'desc' }] })
-        }
+        request={async (params: any) => {
+          delete params?.total;
+          const res = await service.getList({
+            ...params,
+            sorts: [{ name: 'createTime', order: 'desc' }],
+          });
+          return {
+            code: res.status,
+            result: res.result,
+            status: res.status,
+          };
+        }}
       />
     </PageContainer>
   );

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

@@ -24,8 +24,7 @@ export default (props: Props) => {
       zIndex={1050}
       onCancel={() => props.close()}
       onOk={() => {
-        props.ok(JSON.parse(value));
-        console.log(value, JSON.parse(value));
+        props.ok(value);
       }}
     >
       <div

+ 5 - 0
src/pages/rule-engine/Scene/Save/action/DeviceOutput/actions/ReadProperty.tsx

@@ -20,6 +20,11 @@ export default (props: ReadPropertyProps) => {
         return false;
       })}
       fieldNames={{ label: 'name', value: 'id' }}
+      filterOption={(input: string, option: any) =>
+        option.name.toLowerCase().indexOf(input.toLowerCase()) >= 0
+      }
+      showSearch
+      allowClear
       style={{ width: '100%' }}
       onSelect={(key: any, option: any) => {
         // console.log(key,option)

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

@@ -325,10 +325,11 @@ export default observer((props: Props) => {
             setObjVisable(false);
           }}
           ok={(param) => {
+            console.log('------', param);
             if (props.onChange) {
-              props.onChange(JSON.stringify(param));
+              props.onChange(JSON.parse(param));
             }
-            setValue(JSON.stringify(param));
+            setValue(param);
             setObjVisable(false);
           }}
         />

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

@@ -18,7 +18,7 @@ interface Props {
 
 export default (props: Props) => {
   const [propertiesId, setPropertiesId] = useState<string | undefined>(undefined);
-  const [propertiesValue, setPropertiesValue] = useState(undefined);
+  const [propertiesValue, setPropertiesValue] = useState<any>(undefined);
   const [propertiesType, setPropertiesType] = useState('');
   const [source, setSource] = useState<string>('fixed');
   const textRef = useRef<any>('');
@@ -92,6 +92,11 @@ export default (props: Props) => {
             return false;
           })}
           fieldNames={{ label: 'name', value: 'id' }}
+          filterOption={(input: string, option: any) =>
+            option.name.toLowerCase().indexOf(input.toLowerCase()) >= 0
+          }
+          showSearch
+          allowClear
           style={{ width: '100%' }}
           placeholder={'请选择属性'}
           onChange={(e, option) => {
@@ -111,7 +116,11 @@ export default (props: Props) => {
       {propertiesId && (
         <Col span={12}>
           <TypeModel
-            value={propertiesValue}
+            value={
+              typeof propertiesValue === 'object'
+                ? JSON.stringify(propertiesValue)
+                : propertiesValue
+            }
             label={label}
             type={propertiesType}
             name={props.name}

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

@@ -142,7 +142,10 @@ export default observer((props: Props) => {
     if (_type === 'WRITE_PROPERTY') {
       _options.type = '设置';
       _options.properties = DeviceModel.propertiesName;
-      _options.propertiesValue = DeviceModel.propertiesValue;
+      _options.propertiesValue =
+        typeof DeviceModel.propertiesValue === 'object'
+          ? JSON.stringify(DeviceModel.propertiesValue)
+          : DeviceModel.propertiesValue;
       _options.columns = DeviceModel.columns;
       _options.otherColumns = DeviceModel.columns;
       const cur: any = Object.values(value.message.properties)?.[0];

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

@@ -201,7 +201,7 @@ export default observer((props: { parentId: string }) => {
             setPermissions(record.grantedPermissions!);
             setUpdateVisible(true);
           }}
-          isPermission={permission.edit}
+          isPermission={permission.assert}
         >
           <EditOutlined />
         </PermissionButton>,
@@ -434,8 +434,7 @@ export default observer((props: { parentId: string }) => {
                 onClick={(e) => {
                   e?.stopPropagation();
                 }}
-                // isPermission={permission.bind}
-                isPermission={permission.assert}
+                isPermission={permission.bind}
               >
                 <DisconnectOutlined />
               </PermissionButton>,
@@ -475,7 +474,7 @@ export default observer((props: { parentId: string }) => {
                 defaultMessage: '批量解绑',
               }),
             }}
-            isPermission={permission.assert}
+            isPermission={permission.bind}
           >
             {intl.formatMessage({
               id: 'pages.system.role.option.unBindUser',

+ 4 - 4
src/pages/system/Department/Assets/product/index.tsx

@@ -184,8 +184,7 @@ export default observer((props: { parentId: string }) => {
               singleUnBind(record.id);
             },
           }}
-          // isPermission={permission.bind}
-          isPermission={permission.assert}
+          isPermission={permission.bind}
         >
           <DisconnectOutlined />
         </PermissionButton>,
@@ -415,7 +414,8 @@ export default observer((props: { parentId: string }) => {
                   setPermissions(record.grantedPermissions!);
                   setUpdateVisible(true);
                 }}
-                isPermission={permission.edit}
+                // isPermission={permission.edit}
+                isPermission={permission.assert}
               >
                 <EditOutlined />
               </PermissionButton>,
@@ -477,7 +477,7 @@ export default observer((props: { parentId: string }) => {
                 defaultMessage: '批量解绑',
               }),
             }}
-            isPermission={permission.assert}
+            isPermission={permission.bind}
           >
             {intl.formatMessage({
               id: 'pages.system.role.option.unBindUser',