ソースを参照

feat(device): device

gemercheung 3 年 前
コミット
e8ad783787

+ 21 - 0
src/api/device/list.ts

@@ -3,6 +3,8 @@ import { PageParams, RentListGetResultModel } from './model';
 
 enum Api {
   pageList = '/zfb-api/zfb/camera/pageList',
+  addCamera = '/zfb-api/zfb/camera/add',
+  allCompany = '/zfb-api/zfb/company/listAll',
 }
 
 /**
@@ -18,3 +20,22 @@ export const ListApi = (params: PageParams) =>
       ignoreCancelToken: true,
     },
   });
+export const allCompanyApi = (params: PageParams) =>
+  defHttp.post<RentListGetResultModel>({
+    url: Api.allCompany,
+    params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });
+
+export const addCameraApi = (params: PageParams) =>
+  defHttp.post<RentListGetResultModel>({
+    url: Api.addCamera,
+    params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });

+ 3 - 0
src/enums/carmeraEnum.ts

@@ -0,0 +1,3 @@
+export enum CameraType {
+  PAGE_NOT_ACCESS = 403,
+}

BIN
src/locales/lang/zh-CN.zip


+ 12 - 0
src/locales/lang/zh-CN/routes/devices.ts

@@ -0,0 +1,12 @@
+export default {
+  deviceList: '设备列表',
+  address: '物理地址',
+  balance: '初始点数',
+  cameraType: '相机类型',
+  childName: '设备ID',
+  companyId: '客户名称',
+  orderSn: '订单号',
+  own: '出库类型',
+  snCode: '1111',
+  wifiName: 'wifi名称',
+};

+ 193 - 0
src/views/devices/AddModal.vue

@@ -0,0 +1,193 @@
+<template>
+  <BasicModal
+    v-bind="$attrs"
+    @register="register"
+    title="新增子账号"
+    @visible-change="handleVisibleChange"
+    @ok="handleSubmit"
+  >
+    <div class="pt-2px pr-3px">
+      <BasicForm @register="registerForm" :model="model" />
+    </div>
+  </BasicModal>
+</template>
+<script lang="ts">
+  import { defineComponent, ref, nextTick } from 'vue';
+  import { BasicModal, useModalInner } from '/@/components/Modal';
+  import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
+  import { useMessage } from '/@/hooks/web/useMessage';
+  import { checkUserAddAble } from '/@/api/corporation/modal';
+  import { useI18n } from '/@/hooks/web/useI18n';
+  //   address: "11111"
+  // balance: "111"
+  // cameraType: "4"
+  // childName: "11111"
+  // companyId: 1146
+  // orderSn: "1111"
+  // own: "0"
+  // rnd: 0.9923218970879999
+  // snCode: "1111"
+  // wifiName: "1111"
+  const { t } = useI18n();
+  const schemas: FormSchema[] = [
+    {
+      field: 'own',
+      component: 'Input',
+      label: t('routes.devices.own'),
+      colProps: {
+        span: 24,
+      },
+      componentProps: {
+        options: [
+          {
+            label: '全部',
+            value: '1',
+            key: '1',
+          },
+          {
+            label: '正常',
+            value: '2',
+            key: '2',
+          },
+          {
+            label: '已关闭',
+            value: '2',
+            key: '2',
+          },
+        ],
+      },
+      required: true,
+    },
+    {
+      field: 'cameraType',
+      component: 'Select',
+      label: t('routes.devices.cameraType'),
+      required: true,
+      colProps: {
+        span: 24,
+      },
+    },
+    {
+      field: 'childName',
+      component: 'Input',
+      label: t('routes.devices.childName'),
+      required: true,
+      colProps: {
+        span: 24,
+      },
+    },
+    {
+      field: 'wifiName',
+      component: 'Input',
+      label: t('routes.devices.wifiName'),
+      colProps: {
+        span: 24,
+      },
+    },
+    {
+      field: 'address',
+      component: 'Input',
+      label: t('routes.devices.address'),
+      colProps: {
+        span: 24,
+      },
+    },
+    {
+      field: 'balance',
+      component: 'Input',
+      label: t('routes.devices.balance'),
+      colProps: {
+        span: 24,
+      },
+    },
+    {
+      field: 'orderSn',
+      component: 'Input',
+      label: t('routes.devices.orderSn'),
+      colProps: {
+        span: 24,
+      },
+      required: true,
+    },
+    {
+      field: 'companyId',
+      component: 'Input',
+      label: t('routes.devices.companyId'),
+      colProps: {
+        span: 24,
+      },
+    },
+  ];
+  export default defineComponent({
+    components: { BasicModal, BasicForm },
+    props: {
+      userData: { type: Object },
+    },
+    setup(props) {
+      const modelRef = ref({});
+      const { createMessage } = useMessage();
+      const [
+        registerForm,
+        {
+          getFieldsValue,
+          // setFieldsValue,
+          // setProps
+        },
+      ] = useForm({
+        labelWidth: 120,
+        schemas,
+        showActionButtonGroup: false,
+        actionColOptions: {
+          span: 24,
+        },
+      });
+      let addListFunc = () => {};
+      const [register, { closeModal }] = useModalInner((data) => {
+        data && onDataReceive(data);
+      });
+
+      function onDataReceive(data) {
+        console.log('Data Received', data);
+        const { addList } = data;
+        if (typeof addList === 'function') {
+          //是函数    其中 FunName 为函数名称
+          addListFunc = addList;
+        }
+      }
+      const handleSubmit = async () => {
+        console.log('getFieldsValue()', getFieldsValue());
+        var reg_tel =
+          /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
+        let { phone, memoName } = getFieldsValue();
+        if (phone == '') {
+          createMessage.error('请填写您的手机号码!');
+          return false;
+        } else if (!reg_tel.test(phone)) {
+          createMessage.error('请正确填写您的手机号码!');
+          return false;
+        }
+        let res = await checkUserAddAble({ phone });
+        if (res.result == false) {
+          addListFunc({ phone, memoName });
+          closeModal();
+        } else {
+          createMessage.error('子账号已被该企业绑定');
+        }
+      };
+      function handleVisibleChange(v) {
+        v && props.userData && nextTick(() => onDataReceive(props.userData));
+      }
+
+      return {
+        register,
+        schemas,
+        registerForm,
+        model: modelRef,
+        handleVisibleChange,
+        handleSubmit,
+        addListFunc,
+        closeModal,
+      };
+    },
+  });
+</script>

+ 14 - 2
src/views/devices/list.vue

@@ -1,7 +1,9 @@
 <template>
   <div class="p-4">
     <BasicTable @register="registerTable">
-      <template #toolbar> </template>
+      <template #toolbar>
+        <a-button type="primary" @click="openAddModal">添加相机</a-button>
+      </template>
 
       <template #cameraType="{ record }">
         <Tag color="green">{{ rendercameraTypeLabel(record.cameraType) }} </Tag></template
@@ -35,6 +37,7 @@
         />
       </template>
     </BasicTable>
+    <AddModal @register="registerAddModal" />
   </div>
 </template>
 <script lang="ts">
@@ -42,12 +45,18 @@
   import { BasicTable, useTable, BasicColumn, FormProps, TableAction } from '/@/components/Table';
   import { useMessage } from '/@/hooks/web/useMessage';
   import { Tag } from 'ant-design-vue';
+  import { useModal } from '/@/components/Modal';
   import { ListApi } from '/@/api/device/list';
+  import AddModal from './AddModal.vue';
+  import { useI18n } from '/@/hooks/web/useI18n';
+
   // param type 0
   export default defineComponent({
-    components: { BasicTable, TableAction, Tag },
+    components: { BasicTable, TableAction, Tag, AddModal },
     setup() {
       const { createMessage } = useMessage();
+      const [registerAddModal, { openModal: openAddModal }] = useModal();
+      const { t } = useI18n();
       const columns: BasicColumn[] = [
         {
           title: '设备ID',
@@ -198,6 +207,9 @@
         createMessage,
         rendercameraTypeLabel,
         renderOwnTypeLabel,
+        registerAddModal,
+        openAddModal,
+        t,
       };
     },
   });

+ 21 - 6
src/views/system/role/role.data.ts

@@ -3,6 +3,7 @@ import { FormSchema } from '/@/components/Table';
 import { h } from 'vue';
 import { Switch } from 'ant-design-vue';
 import { Time } from '/@/components/Time';
+import { ListApi } from '/@/api/corporation/list';
 // import { setRoleStatus } from '/@/api/system/system';
 // import { useMessage } from '/@/hooks/web/useMessage';
 
@@ -104,12 +105,26 @@ export const formSchema: FormSchema[] = [
     required: true,
     component: 'Input',
   },
-  // {
-  //   field: 'roleValue',
-  //   label: '角色值',
-  //   required: true,
-  //   component: 'Input',
-  // },
+  {
+    field: 'companyId',
+    label: '部门',
+    component: 'ApiSelect',
+    componentProps: {
+      api: ListApi,
+      resultField: 'list',
+      labelField: 'name',
+      valueField: 'id',
+      immediate: true,
+      onChange: function () {
+        // Reflect.set(modalRecord, 'shippingName', opt.label);
+      },
+      params: {
+        page: 1,
+        limit: 1000,
+      },
+      required: true,
+    },
+  },
   {
     field: 'status',
     label: '状态',