Explorar o código

feat: (staff) 新增头像字段

gemercheung %!s(int64=3) %!d(string=hai) anos
pai
achega
10fff156bd
Modificáronse 2 ficheiros con 43 adicións e 18 borrados
  1. 14 1
      src/api/staff/list.ts
  2. 29 17
      src/views/staff/detailsModal.vue

+ 14 - 1
src/api/staff/list.ts

@@ -1,6 +1,6 @@
 import { defHttp } from '/@/utils/http/axios';
 import { PageParams, ListGetResultModel, DelParams, roleParams } from './model';
-import { Result } from '/#/axios';
+import { Result, UploadFileParams } from '/#/axios';
 
 enum Api {
   pageList = '/zfb-api/zfb/shop/sys/user/staffList',
@@ -13,6 +13,7 @@ enum Api {
   deleteStaff = '/zfb-api/zfb/shop/sys/user/deleteStaff',
   getNumByStaff = '/zfb-api/zfb/shop/sys/user/getNumByStaff',
   clean = '/zfb-api/zfb/loginOutByUser',
+  upload = '/zfb-api/zfb/sys/oss/upload',
 }
 
 /**
@@ -126,3 +127,15 @@ export const updateApi = (params) =>
       ignoreCancelToken: true,
     },
   });
+export function uploadApi(
+  params: UploadFileParams,
+  // onUploadProgress: (progressEvent: ProgressEvent) => void,
+) {
+  return defHttp.uploadFile<Result>(
+    {
+      url: Api.upload,
+      // onUploadProgress,
+    },
+    params,
+  );
+}

+ 29 - 17
src/views/staff/detailsModal.vue

@@ -13,7 +13,13 @@
 </template>
 <script lang="ts">
   import { defineComponent, ref, computed } from 'vue';
-  import { checkUserApi, saveApi, updateApi, getRoleListByParam } from '/@/api/staff/list'; //roleLIstApi
+  import {
+    checkUserApi,
+    saveApi,
+    updateApi,
+    getRoleListByParam,
+    uploadApi,
+  } from '/@/api/staff/list'; //roleLIstApi
   import { getAllList } from '/@/api/rightsEnterprises/list';
   import { BasicModal, useModalInner } from '/@/components/Modal';
   import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
@@ -201,22 +207,27 @@
             required: true,
           },
         },
-        // {
-        //   field: 'status',
-        //   label: '状态',
-        //   component: 'RadioButtonGroup',
-        //   required: true,
-        //   defaultValue: 1,
-        //   itemProps: {
-        //     validateTrigger: 'blur',
-        //   },
-        //   componentProps: {
-        //     options: [
-        //       { label: '是', value: 1 },
-        //       { label: '否', value: 0 },
-        //     ],
-        //   },
-        // },
+        {
+          field: 'head',
+          label: '员工头像',
+          component: 'Upload',
+          required: true,
+          // defaultValue: 1,
+          itemProps: {
+            validateTrigger: 'blur',
+          },
+          helpMessage: '推荐大小:400 * 400 像素',
+          componentProps: {
+            api: uploadApi,
+            maxNumber: 1,
+            accept: ['jpg', 'jpeg', 'gif', 'png'],
+            afterFetch: function (data) {
+              console.log('data', data);
+              Reflect.set(data, 'url', data.message);
+              return data;
+            },
+          },
+        },
         // {
         //   field: 'avatar',
         //   component: 'Upload',
@@ -333,6 +344,7 @@
         let res = await requestApi({
           ...data,
           userName: data.phone,
+          head: data.head[0],
           phone: data.phone,
           nickName: data.nickName,
           roleId: data.roleId,