tangning 1 year ago
parent
commit
e76ca53896
3 changed files with 133 additions and 82 deletions
  1. 13 1
      src/api/account/index.ts
  2. 63 24
      src/views/device/editModal.vue
  3. 57 57
      src/views/device/index.vue

+ 13 - 1
src/api/account/index.ts

@@ -12,7 +12,8 @@ enum Api {
   getCameraDetail = '/service/manage/user/getCameraDetail',
   unbindCamera = '/service/manage/user/unbindCamera',
   allList = '/service/manage/incrementType/allList',
-  cameraAllType = '/service/manage/cameraType',
+  cameraAllType = '/service/manage/cameraType/allList',
+  wifiPrefixAll = '/service/manage/cameraWifiPrefix/allList',
   incrementUseTypeList = '/service/manage/incrementUseType/allList',
 }
 
@@ -142,3 +143,14 @@ export const cameraAllType = (params: PageParams) =>
       ignoreCancelToken: true,
     },
   });
+
+//wifi前缀字典
+export const wifiPrefixAll = (params: PageParams) =>
+  defHttp.get<userList>({
+    url: Api.wifiPrefixAll,
+    params: params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });

+ 63 - 24
src/views/device/editModal.vue

@@ -27,6 +27,7 @@
   import { updateCameraType } from '/@/api/device';
   import { agentNewList } from '/@/api/dealer';
   import { CameraList } from '/@/api/order';
+  import { cameraAllType, wifiPrefixAll } from '/@/api/account';
   import { useI18n } from '/@/hooks/web/useI18n';
   import dayjs from 'dayjs';
   const { t } = useI18n();
@@ -54,39 +55,74 @@
         },
         {
           field: 'cameraType',
-          component: 'Select',
+          component: 'ApiSelect',
           label: '设备类型',
           required: true,
           colProps: {
             span: 18,
           },
           componentProps: {
-            options: [
-              {
-                label: t('routes.product.type.1'),
-                value: '1',
-                key: '1',
-              },
-              {
-                label: t('routes.product.type.9'),
-                value: '9',
-                key: '9',
-              },
-              {
-                label: t('routes.product.type.10'),
-                value: '10',
-                key: '10',
-              },
-              {
-                label: t('routes.product.type.11'),
-                value: '11',
-                key: '1',
-              },
-            ],
+            api: cameraAllType,
+            numberToString: true,
+            labelField: 'name',
+            valueField: 'cameraType',
+            immediate: true,
+            params: {
+              agentName: '',
+            },
+            onChange: (value) => {
+              console.log('onChange', value);
+              updateSchema([
+                { field: 'wifiNamePrefix', ifShow: value == 1, },
+              ]);
+            },
+            // options: [
+            //   {
+            //     label: t('routes.product.type.1'),
+            //     value: '1',
+            //     key: '1',
+            //   },
+            //   {
+            //     label: t('routes.product.type.9'),
+            //     value: '9',
+            //     key: '9',
+            //   },
+            //   {
+            //     label: t('routes.product.type.10'),
+            //     value: '10',
+            //     key: '10',
+            //   },
+            //   {
+            //     label: t('routes.product.type.11'),
+            //     value: '11',
+            //     key: '1',
+            //   },
+            // ],
+          },
+        },
+        {
+          field: 'wifiNamePrefix',
+          component: 'ApiSelect',
+          label: 'wifi前缀',
+          required: true,
+          colProps: {
+            span: 18,
+          },
+          componentProps: {
+            api: wifiPrefixAll,
+            labelField: 'wifiNamePrefix',
+            // numberToString: false,
+            valueField: 'id',
+            params: {
+              cameraType: '1',
+            },
+            onChange: (value) => {
+              console.log('onChange', value);
+            },
           },
         },
       ];
-      const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({
+      const [registerForm, { validate, resetFields, setFieldsValue, updateSchema }] = useForm({
         labelWidth: 120,
         schemas,
         showActionButtonGroup: false,
@@ -103,10 +139,13 @@
 
       function onDataReceive(data) {
         modelRef.value = data;
+        let wifiNamePrefix = data.wifiName.indexOf('YUNPRO_') != -1 ? 8 : 2;
         const { type } = data;
         resetFields();
+        updateSchema([{ field: 'wifiNamePrefix', ifShow: type == 1 }]);
         setFieldsValue({
           ...data,
+          wifiNamePrefix,
           cameraType: type,
         });
       }

+ 57 - 57
src/views/device/index.vue

@@ -120,7 +120,7 @@ import { lte } from 'lodash';
           title: '设备类型',
           dataIndex: 'typeStr',
           ellipsis: false,
-          width: 80,
+          width: 100,
           // customRender: ({ record }) => {
           //   let typeObj ={
           //     '0':'旧双目相机',
@@ -214,55 +214,8 @@ import { lte } from 'lodash';
             },
           },{
             field: 'type',
-            component: 'Select',
-            label: '设备类型',
-            colProps: {
-              xl: 6,
-              xxl: 6,
-            },
-            componentProps: {
-              options: [
-                {
-                  label: t('routes.product.type.0'),
-                  value: 0,
-                  key: '0',
-                },{
-                  label: t('routes.product.type.1'),
-                  value: 1,
-                  key: '1',
-                },{
-                  label: t('routes.product.type.2'),
-                  value: 9,
-                  key: '9',
-                },{
-                  label: t('routes.product.type.3'),
-                  value: 10,
-                  key: '10',
-                },{
-                  label: t('routes.product.type.11'),
-                  value: 11,
-                  key: '11',
-                },
-              ],
-            },
-          },
-          {
-            field: 'ctivated',
-            label: '激活时间',
-            component: 'RangePicker',
-            componentProps: {
-              format: 'YYYY-MM-DD',
-              valueFormat:'YYYY-MM-DD',
-            },
-            colProps: {
-              xl: 7,
-              xxl: 7,
-            },
-          },
-          {
-            field: 'outType',
             component: 'ApiSelect',
-            label: '出库类型',
+            label: '设备类型',
             colProps: {
               xl: 6,
               xxl: 6,
@@ -283,26 +236,73 @@ import { lte } from 'lodash';
               },
               // options: [
               //   {
-              //     label: t('routes.product.outType.0'),
+              //     label: t('routes.product.type.0'),
               //     value: 0,
               //     key: '0',
               //   },{
-              //     label: t('routes.product.outType.1'),
+              //     label: t('routes.product.type.1'),
               //     value: 1,
               //     key: '1',
               //   },{
-              //     label: t('routes.product.outType.2'),
-              //     value: 2,
-              //     key: '2',
+              //     label: t('routes.product.type.2'),
+              //     value: 9,
+              //     key: '9',
+              //   },{
+              //     label: t('routes.product.type.3'),
+              //     value: 10,
+              //     key: '10',
               //   },{
-              //     label: t('routes.product.outType.3'),
-              //     value: 3,
-              //     key: '3',
+              //     label: t('routes.product.type.11'),
+              //     value: 11,
+              //     key: '11',
               //   },
               // ],
             },
           },
           {
+            field: 'ctivated',
+            label: '激活时间',
+            component: 'RangePicker',
+            componentProps: {
+              format: 'YYYY-MM-DD',
+              valueFormat:'YYYY-MM-DD',
+            },
+            colProps: {
+              xl: 7,
+              xxl: 7,
+            },
+          },
+          {
+            field: 'outType',
+            component: 'Select',
+            label: '出库类型',
+            colProps: {
+              xl: 6,
+              xxl: 6,
+            },
+            componentProps: {
+              options: [
+                {
+                  label: t('routes.product.outType.0'),
+                  value: 0,
+                  key: '0',
+                },{
+                  label: t('routes.product.outType.1'),
+                  value: 1,
+                  key: '1',
+                },{
+                  label: t('routes.product.outType.2'),
+                  value: 2,
+                  key: '2',
+                },{
+                  label: t('routes.product.outType.3'),
+                  value: 3,
+                  key: '3',
+                },
+              ],
+            },
+          },
+          {
             field: 'companyName',
             label: '客户名称',
             component: 'Input',