Prechádzať zdrojové kódy

feat(api): update api 33

gemercheung 3 rokov pred
rodič
commit
06f1082d2f

+ 12 - 3
src/api/device/list.ts

@@ -1,12 +1,12 @@
 import { defHttp } from '/@/utils/http/axios';
-import { PageParams, RentListGetResultModel, addCamerParams } from './model';
+import { PageParams, RentListGetResultModel, addCameraParams } from './model';
 
 enum Api {
   // pageList = '/zfb-api/zfb/camera/pageList',
   pageList = '/kankan-api/api/manager/camera/list',
   // addCamera = '/zfb-api/zfb/camera/add',
   addCamera = '/kankan-api/api/manager/camera/add',
-
+  editCamera = '/kankan-api/api/manager/camera/update',
   allCompany = '/kankan-api/api/manager/company/listAll',
 }
 
@@ -44,7 +44,7 @@ export const allCompanyApi = (params: PageParams) =>
     },
   });
 
-export const addCameraApi = (params: addCamerParams) =>
+export const addCameraApi = (params: addCameraParams) =>
   defHttp.post<RentListGetResultModel>({
     url: Api.addCamera,
     params,
@@ -53,3 +53,12 @@ export const addCameraApi = (params: addCamerParams) =>
       ignoreCancelToken: true,
     },
   });
+export const editCameraApi = (params: addCameraParams) =>
+  defHttp.post<RentListGetResultModel>({
+    url: Api.editCamera,
+    params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });

+ 2 - 2
src/api/device/model.ts

@@ -4,9 +4,9 @@ import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
  */
 export type PageParams = BasicPageParams;
 
-export interface addCamerParams {
+export interface addCameraParams {
   address: string;
-  balance: string;
+  balance?: string;
   cameraType: string;
   childName: string;
   companyId?: string;

+ 4 - 4
src/layouts/default/header/components/user-dropdown/index.vue

@@ -11,19 +11,19 @@
 
     <template #overlay>
       <Menu @click="handleMenuClick">
-        <!-- <MenuItem
+        <MenuItem
           key="setting"
           :text="t('layout.header.personalSetting')"
           icon="ion:document-text-outline"
           v-if="getShowDoc"
-        /> -->
+        />
         <MenuDivider v-if="getShowDoc" />
-        <MenuItem
+        <!-- <MenuItem
           v-if="getUseLockPage"
           key="lock"
           :text="t('layout.header.tooltipLock')"
           icon="ion:lock-closed-outline"
-        />
+        /> -->
         <MenuItem
           key="logout"
           :text="t('layout.header.dropdownItemLoginOut')"

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

@@ -12,6 +12,7 @@ export default {
   orderSn: '订单号',
   own: '出库类型',
   addCamera: '添加相机',
+  editCamera: '编辑相机',
   type: '设备类型',
   wifiName: 'wifi名称',
   normalSales: '正常销售',

+ 4 - 0
src/locales/lang/zh-CN/routes/personalSetting.ts

@@ -0,0 +1,4 @@
+export default {
+  account: '个人设置',
+  accountSetting: '账户设置',
+};

+ 2 - 2
src/router/routes/modules/personalSetting.ts

@@ -10,7 +10,7 @@ const account: AppRouteModule = {
   redirect: '/account/index',
   meta: {
     icon: 'medical-icon:care-staff-area',
-    title: t('routes.demo.page.account'),
+    title: t('routes.personalSetting.account'),
     orderNo: 102,
     hideChildrenInMenu: true,
     hideMenu: true,
@@ -21,7 +21,7 @@ const account: AppRouteModule = {
       name: 'AccountSettingPage',
       component: () => import('/@/views/setting/index.vue'),
       meta: {
-        title: t('routes.demo.page.accountSetting'),
+        title: t('routes.personalSetting.accountSetting'),
       },
     },
   ],

+ 29 - 28
src/views/devices/AddModal.vue

@@ -16,7 +16,8 @@
   import { BasicModal, useModalInner } from '/@/components/Modal';
   import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
   import { useMessage } from '/@/hooks/web/useMessage';
-  import { allCompanyApi, addCameraApi } from '/@/api/device/list';
+  // allCompanyApi
+  import { addCameraApi } from '/@/api/device/list';
   import { useI18n } from '/@/hooks/web/useI18n';
   //   address: "11111"
   // balance: "111"
@@ -127,14 +128,14 @@
             span: 24,
           },
         },
-        {
-          field: 'balance',
-          component: 'Input',
-          label: t('routes.devices.balance'),
-          colProps: {
-            span: 24,
-          },
-        },
+        // {
+        //   field: 'balance',
+        //   component: 'Input',
+        //   label: t('routes.devices.balance'),
+        //   colProps: {
+        //     span: 24,
+        //   },
+        // },
         // {
         //   field: 'orderSn',
         //   component: 'Input',
@@ -144,25 +145,25 @@
         //   },
         //   required: true,
         // },
-        {
-          field: 'companyId',
-          component: 'ApiSelect',
-          label: t('routes.devices.companyId'),
-          componentProps: {
-            api: allCompanyApi,
-            numberToString: true,
-            labelField: 'companyName',
-            valueField: 'id',
-            immediate: true,
-            params: {
-              page: 1,
-              limit: 1000,
-            },
-          },
-          colProps: {
-            span: 24,
-          },
-        },
+        // {
+        //   field: 'companyId',
+        //   component: 'ApiSelect',
+        //   label: t('routes.devices.companyId'),
+        //   componentProps: {
+        //     api: allCompanyApi,
+        //     numberToString: true,
+        //     labelField: 'companyName',
+        //     valueField: 'id',
+        //     immediate: true,
+        //     params: {
+        //       page: 1,
+        //       limit: 1000,
+        //     },
+        //   },
+        //   colProps: {
+        //     span: 24,
+        //   },
+        // },
       ];
       const [
         registerForm,

+ 64 - 51
src/views/devices/editModal.vue

@@ -2,12 +2,12 @@
   <BasicModal
     v-bind="$attrs"
     @register="register"
-    :title="t('routes.devices.addCamera')"
+    :title="t('routes.devices.editCamera')"
     @visible-change="handleVisibleChange"
     @ok="handleSubmit"
   >
     <div class="pt-2px pr-3px">
-      <BasicForm @register="registerForm" :model="model" />
+      <BasicForm @register="registerForm" />
     </div>
   </BasicModal>
 </template>
@@ -16,8 +16,10 @@
   import { BasicModal, useModalInner } from '/@/components/Modal';
   import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
   import { useMessage } from '/@/hooks/web/useMessage';
-  import { allCompanyApi, addCameraApi } from '/@/api/device/list';
+  // allCompanyApi
+  import { editCameraApi } from '/@/api/device/list';
   import { useI18n } from '/@/hooks/web/useI18n';
+
   //   address: "11111"
   // balance: "111"
   // cameraType: "4"
@@ -39,6 +41,12 @@
       const { createMessage } = useMessage();
       const schemas: FormSchema[] = [
         {
+          field: 'id',
+          component: 'Input',
+          label: 'id',
+          show: false,
+        },
+        {
           field: 'own',
           component: 'Select',
           label: t('routes.devices.own'),
@@ -46,6 +54,7 @@
             span: 24,
           },
           componentProps: {
+            // disabled: true,
             options: [0, 2, 1, 3].map((ele) => {
               return { value: ele, key: ele, label: renderOwnTypeLabel(ele) };
             }),
@@ -56,6 +65,7 @@
           field: 'cameraType',
           component: 'Select',
           label: t('routes.devices.cameraType'),
+
           required: true,
           colProps: {
             span: 24,
@@ -94,12 +104,18 @@
           colProps: {
             span: 24,
           },
+          componentProps: {
+            disabled: true,
+          },
         },
         {
           field: 'wifiName',
           component: 'Input',
           label: t('routes.devices.wifiName'),
           required: true,
+          componentProps: {
+            disabled: true,
+          },
           colProps: {
             span: 24,
           },
@@ -109,6 +125,7 @@
           component: 'Input',
           required: true,
           label: t('routes.devices.address'),
+          disabled: true,
           colProps: {
             span: 24,
           },
@@ -118,6 +135,9 @@
           component: 'Input',
           label: t('routes.devices.snCode'),
           required: true,
+          componentProps: {
+            disabled: true,
+          },
           ifShow: ({ model }) => {
             console.log('record', model.cameraType);
 
@@ -127,51 +147,44 @@
             span: 24,
           },
         },
-        {
-          field: 'balance',
-          component: 'Input',
-          label: t('routes.devices.balance'),
-          colProps: {
-            span: 24,
-          },
-        },
         // {
-        //   field: 'orderSn',
+        //   field: 'balance',
         //   component: 'Input',
-        //   label: t('routes.devices.orderSn'),
+        //   label: t('routes.devices.balance'),
+        //   colProps: {
+        //     span: 24,
+        //   },
+        // },
+
+        // {
+        //   field: 'companyId',
+        //   component: 'ApiSelect',
+        //   label: t('routes.devices.companyId'),
+        //   componentProps: {
+        //     api: allCompanyApi,
+        //     numberToString: true,
+        //     labelField: 'companyName',
+        //     valueField: 'id',
+        //     immediate: true,
+        //     params: {
+        //       page: 1,
+        //       limit: 1000,
+        //     },
+        //   },
         //   colProps: {
         //     span: 24,
         //   },
-        //   required: true,
         // },
-        {
-          field: 'companyId',
-          component: 'ApiSelect',
-          label: t('routes.devices.companyId'),
-          componentProps: {
-            api: allCompanyApi,
-            numberToString: true,
-            labelField: 'companyName',
-            valueField: 'id',
-            immediate: true,
-            params: {
-              page: 1,
-              limit: 1000,
-            },
-          },
-          colProps: {
-            span: 24,
-          },
-        },
       ];
       const [
         registerForm,
         {
-          getFieldsValue,
-          validateFields,
+          // getFieldsValue,
+          // validateFields,
           // appendSchemaByField,
           // removeSchemaByFiled,
-          // setFieldsValue,
+          setFieldsValue,
+          validate,
           // setProps
         },
       ] = useForm({
@@ -219,24 +232,24 @@
       }
       function onDataReceive(data) {
         console.log('Data Received', data);
-        const { addList } = data;
-        if (typeof addList === 'function') {
-          //是函数    其中 FunName 为函数名称
-          addListFunc = addList;
-        }
+        setFieldsValue({
+          ...data,
+          cameraType: Number(data.cameraType),
+        });
       }
       const handleSubmit = async () => {
-        console.log('getFieldsValue()', getFieldsValue());
+        // console.log('getFieldsValue()', getFieldsValue());
         try {
-          const data = await validateFields();
-          const param = await getFieldsValue();
-          let res = await addCameraApi(param);
-          console.log('getFieldsValue()', res, data, param);
-          if (res.code) {
-            createMessage.error(res.error || t('common.optFail'));
-          } else {
-            emit('getList');
-            closeModal();
+          const values = await validate();
+          console.log('values', values);
+          if (values) {
+            const res = await editCameraApi(values);
+            if (res.code) {
+              createMessage.error(res.error || t('common.optFail'));
+            } else {
+              emit('update');
+              closeModal();
+            }
           }
         } catch (error) {
           console.log('not passing', error);

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

@@ -27,6 +27,7 @@
       </template>
     </BasicTable>
     <AddModal @get-list="reload" @register="registerAddModal" />
+    <EditModal @register="registerEditModal" />
   </div>
 </template>
 <script lang="ts">
@@ -37,14 +38,16 @@
   import { useModal } from '/@/components/Modal';
   import { ListApi } from '/@/api/device/list';
   import AddModal from './AddModal.vue';
+  import EditModal from './EditModal.vue';
   import { useI18n } from '/@/hooks/web/useI18n';
   const { t } = useI18n();
   // param type 0
   export default defineComponent({
-    components: { BasicTable, TableAction, Tag, AddModal },
+    components: { BasicTable, TableAction, Tag, AddModal, EditModal },
     setup() {
       const { createMessage } = useMessage();
       const [registerAddModal, { openModal: openAddModal }] = useModal();
+      const [registerEditModal, { openModal: openEditModal }] = useModal();
       const columns: BasicColumn[] = [
         {
           title: t('routes.devices.childName'),
@@ -174,8 +177,9 @@
             return '';
         }
       }
-      function handleEditScenes(record: recordable) {
+      function handleEditScenes(record: Recordable) {
         console.log('record', record);
+        openEditModal(true, record);
       }
       return {
         registerTable,
@@ -187,6 +191,7 @@
         t,
         reload,
         handleEditScenes,
+        registerEditModal,
       };
     },
   });

+ 4 - 4
src/views/setting/BaseSetting.vue

@@ -4,7 +4,7 @@
       <a-col :span="14">
         <BasicForm @register="register" />
       </a-col>
-      <a-col :span="10">
+      <!-- <a-col :span="10">
         <div class="change-avatar">
           <div class="mb-2">头像</div>
           <CropperAvatar
@@ -16,7 +16,7 @@
             width="150"
           />
         </div>
-      </a-col>
+      </a-col> -->
     </a-row>
     <Button type="primary" @click="handleSubmit"> 更新基本信息 </Button>
   </CollapseContainer>
@@ -26,7 +26,7 @@
   import { computed, defineComponent, onMounted } from 'vue';
   import { BasicForm, useForm } from '/@/components/Form/index';
   import { CollapseContainer } from '/@/components/Container';
-  import { CropperAvatar } from '/@/components/Cropper';
+  // import { CropperAvatar } from '/@/components/Cropper';
 
   import { useMessage } from '/@/hooks/web/useMessage';
 
@@ -43,7 +43,7 @@
       Button,
       ARow: Row,
       ACol: Col,
-      CropperAvatar,
+      // CropperAvatar,
     },
     setup() {
       const { createMessage } = useMessage();

+ 15 - 15
src/views/setting/data.ts

@@ -16,21 +16,21 @@ export const settingList = [
     name: '基本设置',
     component: 'BaseSetting',
   },
-  {
-    key: '2',
-    name: '安全设置',
-    component: 'SecureSetting',
-  },
-  {
-    key: '3',
-    name: '账号绑定',
-    component: 'AccountBind',
-  },
-  {
-    key: '4',
-    name: '新消息通知',
-    component: 'MsgNotify',
-  },
+  // {
+  //   key: '2',
+  //   name: '安全设置',
+  //   component: 'SecureSetting',
+  // },
+  // {
+  //   key: '3',
+  //   name: '账号绑定',
+  //   component: 'AccountBind',
+  // },
+  // {
+  //   key: '4',
+  //   name: '新消息通知',
+  //   component: 'MsgNotify',
+  // },
 ];
 
 // 基础设置 form

+ 7 - 7
src/views/staff/list.vue

@@ -8,9 +8,9 @@
       <template #status="{ record }">
         {{ renderStatus(record.status) }}
       </template>
-      <template #createTime="{ record }">
-        <Time :value="record.createTime" mode="datetime" />
-      </template>
+      <!-- <template #createTime="{ record }">
+        <Time v-if="record.createTime" :value="record.createTime" mode="datetime" />
+      </template> -->
       <template #action="{ record }">
         <TableAction
           :actions="[
@@ -46,7 +46,7 @@
   import { useI18n } from '/@/hooks/web/useI18n';
   // import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
   import { useGo } from '/@/hooks/web/usePage';
-  import { Time } from '/@/components/Time';
+  // import { Time } from '/@/components/Time';
 
   //   appid: null
   // companyId: 1107
@@ -73,7 +73,7 @@
   // userPassword: "2a22bac40f44af4d3b5fdc20ea706fc5"
 
   export default defineComponent({
-    components: { BasicTable, TableAction, Time },
+    components: { BasicTable, TableAction },
     setup() {
       const { createMessage } = useMessage();
       const go = useGo();
@@ -117,8 +117,8 @@
 
         {
           title: t('routes.staff.createTime'),
-          dataIndex: 'createTime',
-          slots: { customRender: 'createTime' },
+          dataIndex: 'registerTime',
+          // slots: { customRender: 'createTime' },
           width: 130,
         },
         // {