Browse Source

fix: 设备管理及组织管理

wzyyy 3 years ago
parent
commit
6097e62bda

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

@@ -14,7 +14,8 @@ import Editable from '../EditTable';
 // 不算是自定义组件。只是抽离了JSONSchema
 interface Props {
   keys?: string;
-  isFunction?: boolean;
+  // isFunction?: boolean;
+  isFilter?: string;
 }
 
 const JsonParam = observer((props: Props) => {
@@ -208,7 +209,13 @@ const JsonParam = observer((props: Props) => {
                       //     item.value,
                       //   ),
                       // ),
-                      enum: DataTypeList,
+                      enum:
+                        props.isFilter === 'yes'
+                          ? DataTypeList.filter(
+                              (item) => item.value !== 'array' && item.value !== 'object',
+                            )
+                          : DataTypeList,
+                      // enum: DataTypeList,
                       'x-validator': [
                         {
                           required: true,
@@ -255,7 +262,7 @@ const JsonParam = observer((props: Props) => {
                       'x-decorator': 'FormItem',
                       'x-component': 'ArrayParam',
                       'x-component-props': {
-                        isFunction: props.isFunction,
+                        // isFunction: props.isFunction,
                       },
                       'x-reactions': {
                         dependencies: ['..valueType.type'],
@@ -302,9 +309,7 @@ const JsonParam = observer((props: Props) => {
                           dependencies: ['..valueType.type'],
                           fulfill: {
                             state: {
-                              visible:
-                                !props.isFunction &&
-                                "{{['int','float','long','double'].includes($deps[0])}}",
+                              visible: "{{['int','float','long','double'].includes($deps[0])}}",
                             },
                           },
                         },
@@ -368,9 +373,7 @@ const JsonParam = observer((props: Props) => {
                             dependencies: ['..type'],
                             fulfill: {
                               state: {
-                                visible:
-                                  !props.isFunction &&
-                                  "{{['string','password'].includes($deps[0])}}",
+                                visible: "{{['string','password'].includes($deps[0])}}",
                               },
                             },
                           },
@@ -406,7 +409,7 @@ const JsonParam = observer((props: Props) => {
                     dependencies: ['..valueType.type'],
                     fulfill: {
                       state: {
-                        visible: !props.isFunction && "{{['float','double'].includes($deps[0])}}",
+                        visible: "{{['float','double'].includes($deps[0])}}",
                       },
                     },
                   },
@@ -418,7 +421,8 @@ const JsonParam = observer((props: Props) => {
                   'x-decorator': 'FormItem',
                   'x-component': 'JsonParam',
                   'x-component-props': {
-                    isFunction: props.isFunction,
+                    // isFunction: props.isFunction,
+                    isFilter: 'yes',
                   },
                   'x-reactions': {
                     dependencies: ['.valueType.type'],

+ 36 - 1
src/pages/device/Instance/Detail/Config/Edit.tsx

@@ -1,4 +1,4 @@
-import { createForm } from '@formily/core';
+import { createForm, onFormInit } from '@formily/core';
 import { createSchemaField } from '@formily/react';
 import { InstanceModel, service } from '@/pages/device/Instance';
 import type { ISchema } from '@formily/json-schema';
@@ -21,12 +21,47 @@ interface Props {
 
 const Edit = (props: Props) => {
   const { metadata } = props;
+  console.log(metadata);
   const params = useParams<{ id: string }>();
   const id = InstanceModel.detail?.id || params?.id;
 
   const form = createForm({
     validateFirst: true,
     initialValues: InstanceModel.detail?.configuration,
+    effects: () => {
+      onFormInit((f) => {
+        if (InstanceModel.detail.accessProvider === 'OneNet') {
+          metadata?.[0].properties?.forEach((item: any) => {
+            f.setFieldState(item.property, (state) => {
+              state.validator = [
+                {
+                  required: true,
+                  message: `请输入${item.name}`,
+                },
+              ];
+            });
+          });
+        }
+        if (InstanceModel.detail.accessProvider === 'Ctwing') {
+          f.setFieldState('ctwing_imei', (state) => {
+            state.validator = [
+              {
+                required: true,
+                message: `请输入IMEI`,
+              },
+            ];
+          });
+          f.setFieldState('ctwing_sn', (state) => {
+            state.validator = [
+              {
+                required: true,
+                message: `请输入SN`,
+              },
+            ];
+          });
+        }
+      });
+    },
   });
 
   const SchemaField = createSchemaField({

+ 2 - 2
src/pages/device/Instance/Detail/Info/index.tsx

@@ -123,7 +123,7 @@ const Info = observer(() => {
               defaultMessage: '连接协议',
             })}
           >
-            {InstanceModel.detail?.protocolName}
+            {InstanceModel.detail?.transport}
           </Descriptions.Item>
           <Descriptions.Item
             label={intl.formatMessage({
@@ -131,7 +131,7 @@ const Info = observer(() => {
               defaultMessage: '消息协议',
             })}
           >
-            {InstanceModel.detail?.transport}
+            {InstanceModel.detail?.protocolName}
           </Descriptions.Item>
           <Descriptions.Item
             label={intl.formatMessage({

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

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

+ 4 - 0
src/pages/iot-card/CardManagement/Detail/index.tsx

@@ -328,6 +328,10 @@ const CardDetail = () => {
               <Descriptions.Item label={'卡号'}>{detail.id}</Descriptions.Item>
               <Descriptions.Item label={'ICCID'}>{detail.iccId}</Descriptions.Item>
               <Descriptions.Item label={'绑定设备'}>{detail.deviceName}</Descriptions.Item>
+              <Descriptions.Item label={'平台类型'}>
+                {detail.operatorPlatformType?.text}
+              </Descriptions.Item>
+              <Descriptions.Item label={'平台名称'}>{detail.platformConfigName}</Descriptions.Item>
               <Descriptions.Item label={'运营商'}>{detail.operatorName}</Descriptions.Item>
               <Descriptions.Item label={'类型'}>{detail.cardType?.text}</Descriptions.Item>
               <Descriptions.Item label={'激活日期'}>

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

@@ -88,7 +88,7 @@ const Save = (props: SaveType) => {
             () => ({
               async validator(_, value) {
                 if (value) {
-                  const validateId = await isValidateId(value);
+                  const validateId = props.type === 'add' ? await isValidateId(value) : '';
                   if (validateId === '') {
                     return Promise.resolve();
                   } else {

+ 3 - 0
src/pages/iot-card/CardManagement/typing.d.ts

@@ -13,5 +13,8 @@ export type CardManagement = {
   activationDate: string;
   updateTime: string;
   cardStateType: any;
+  cardState: any;
   describe: string;
+  platformConfigName: string;
+  operatorPlatformType: any;
 };

+ 4 - 0
src/pages/media/Device/Channel/Save.tsx

@@ -153,6 +153,10 @@ const Save = (props: SaveModalProps) => {
                 message: '请输入视频地址',
               },
               {
+                max: 128,
+                message: '最多可输入128个字符',
+              },
+              {
                 validator: (value: string) => {
                   const reg = /(http|https|rtsp|rtmp):\/\/([\w.]+\/?)\S*/;
                   return new Promise((resolve) => {

+ 46 - 1
src/pages/system/Department/Assets/product/bind.tsx

@@ -37,7 +37,7 @@ const Bind = observer((props: Props) => {
   const [isAll, setIsAll] = useState<boolean>(false);
   const bindChecks = useRef(new Map());
 
-  const columns: ProColumns<ProductItem>[] = [
+  const columns: ProColumns<any>[] = [
     {
       dataIndex: 'id',
       title: 'ID',
@@ -54,6 +54,49 @@ const Bind = observer((props: Props) => {
       // },
     },
     {
+      title: '资产权限',
+      render: (_, record) => {
+        let disabled = true;
+        let disabledAll = true;
+        const assetsOptions =
+          props.assetsType && record.permissionInfoList
+            ? props.assetsType.filter((item: any) =>
+                record.permissionInfoList!.some((pItem: any) => pItem.id === item.value),
+              )
+            : [];
+        if (isAll && Models.bindKeys.includes(record.id)) {
+          disabled = true;
+          disabledAll = true;
+        } else if (!isAll && Models.bindKeys.includes(record.id)) {
+          disabled = false;
+          disabledAll = false;
+        } else {
+          disabled = true;
+          disabledAll = true;
+        }
+
+        return (
+          <Checkbox.Group
+            options={assetsOptions?.map((item: any) => {
+              return {
+                ...item,
+                disabled: item.disabled !== true ? disabled : item.disabled,
+              };
+            })}
+            value={checkAssets}
+            onChange={(e: any) => {
+              setCheckAssets(e);
+              if (!disabledAll) {
+                if (bindChecks.current.has(record.id)) {
+                  bindChecks.current.set(record.id, e);
+                }
+              }
+            }}
+          />
+        );
+      },
+    },
+    {
       dataIndex: 'describe',
       title: intl.formatMessage({
         id: 'pages.system.description',
@@ -61,6 +104,7 @@ const Bind = observer((props: Props) => {
       }),
       hideInSearch: true,
     },
+
     {
       title: '状态',
       dataIndex: 'state',
@@ -317,6 +361,7 @@ const Bind = observer((props: Props) => {
                     }
                     return x;
                   }, assetsResp.result);
+                  console.log('--------', newData);
                 }
               }
 

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

@@ -119,7 +119,7 @@ export default observer((props: { parentId: string }) => {
       dataIndex: 'grantedPermissions',
       hideInSearch: true,
       render: (_, row) => {
-        return handlePermissionsMap(row.grantedPermissions, assetsType);
+        return handlePermissionsMap(row.grantedPermissions);
       },
       width: 80,
     },