Browse Source

feat: (staff-avatar) 更换组件

gemercheung 2 years ago
parent
commit
d4028098b9

+ 20 - 0
src/api/dashboard/analysis.ts

@@ -44,3 +44,23 @@ export const bulletChatStaticsApi = (params: BasicStaticsParams) =>
       ignoreCancelToken: true,
     },
   });
+
+export const bulletChatExportApi = (params: BasicStaticsParams) =>
+  defHttp.post<Blob>({
+    url: Api.bulletChatExport,
+    params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });
+
+export const companyChatExportApi = (params: BasicStaticsParams) =>
+  defHttp.post<Blob>({
+    url: Api.bulletChatExport,
+    params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });

+ 17 - 1
src/views/dashboard/analysis/enterprise.vue

@@ -3,7 +3,7 @@
     <!-- <GrowCard :loading="loading" class="enter-y" /> -->
     <BasicTable @register="registerTable">
       <template #toolbar>
-        <a-button type="primary">导出数据</a-button>
+        <a-button type="primary" @click="handleExport">导出数据</a-button>
       </template>
     </BasicTable>
     <!-- <div class="md:flex enter-y">
@@ -32,6 +32,7 @@
     // bulletChatApi,
     userStaticsApi,
     bulletChatStaticsApi,
+    companyChatExportApi,
   } from '../../../api/dashboard/analysis';
   import { formatToDate } from '/@/utils/dateUtil';
   import dayjs from 'dayjs';
@@ -164,6 +165,21 @@
   onMounted(async () => {
     await userStaticsApi(searchInfo);
   });
+  async function handleExport() {
+    await companyChatExportApi(searchInfo);
+    // const downloadBlob = new Blob([data], {
+    //   type: 'text/csv',
+    // });
+    // const url = URL.createObjectURL(downloadBlob);
+    // const a: HTMLAnchorElement = document.createElement('a');
+    // document.body.appendChild(a);
+    // a.style.display = 'none';
+    // a.href = url;
+    // const name = new Date().getTime();
+    // a.download = `${name}.csv`;
+    // a.click();
+    // window.URL.revokeObjectURL(url);
+  }
 
   setTimeout(() => {
     loading.value = false;

+ 22 - 5
src/views/dashboard/analysis/index.vue

@@ -17,7 +17,7 @@
         </div>
       </template>
       <template #toolbar>
-        <a-button type="primary">导出数据</a-button>
+        <a-button type="primary" @click="handleExport">导出数据</a-button>
       </template>
     </BasicTable>
     <!-- <div class="md:flex enter-y">
@@ -49,7 +49,8 @@
     // bulletChatApi,
     userStaticsApi,
     bulletChatStaticsApi,
-  } from '../../../api/dashboard/analysis';
+    bulletChatExportApi,
+  } from '/@/api/dashboard/analysis';
   import { formatToDate } from '/@/utils/dateUtil';
   import dayjs from 'dayjs';
 
@@ -92,9 +93,9 @@
     labelWidth: 100,
     schemas: [
       {
-        field: 'name',
-        label: '房间名称',
-        component: 'Input',
+        field: 'liveRoomId',
+        label: '全部房间',
+        component: 'ApiSelect',
         colProps: {
           xl: 5,
           xxl: 5,
@@ -146,6 +147,22 @@
     await userStaticsApi(searchInfo);
   });
 
+  async function handleExport() {
+    await bulletChatExportApi(searchInfo);
+    // const downloadBlob = new Blob([data], {
+    //   type: 'text/csv',
+    // });
+    // const url = URL.createObjectURL(downloadBlob);
+    // const a: HTMLAnchorElement = document.createElement('a');
+    // document.body.appendChild(a);
+    // a.style.display = 'none';
+    // a.href = url;
+    // const name = new Date().getTime();
+    // a.download = `${name}.csv`;
+    // a.click();
+    // window.URL.revokeObjectURL(url);
+  }
+
   setTimeout(() => {
     loading.value = false;
   }, 1500);

+ 30 - 12
src/views/staff/detailsModal.vue

@@ -12,7 +12,7 @@
   </BasicModal>
 </template>
 <script lang="ts">
-  import { defineComponent, ref, computed } from 'vue';
+  import { defineComponent, ref, computed, h } from 'vue';
   import {
     checkUserApi,
     saveApi,
@@ -27,6 +27,8 @@
   import { useI18n } from '/@/hooks/web/useI18n';
   import { useMessage } from '/@/hooks/web/useMessage';
   import { useUserStore } from '/@/store/modules/user';
+  import { CropperAvatar } from '/@/components/Cropper';
+  import { Result } from '/#/axios';
   const { t } = useI18n();
   export default defineComponent({
     components: { BasicModal, BasicForm },
@@ -211,22 +213,37 @@
           field: 'head',
           label: '员工头像',
           component: 'Upload',
-          required: true,
+          required: false,
           // 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;
-            },
+          render: ({ model, field }) => {
+            return h(CropperAvatar, {
+              value: model[field],
+              maxlength: 200,
+              uploadApi: uploadApi,
+              showBtn: false,
+              maxNumber: 1,
+              accept: ['jpg', 'jpeg', 'gif', 'png'],
+              onChange: (_, source: Result) => {
+                console.log('onChange', source.message);
+                model[field] = source.message;
+              },
+              showImageUpload: true,
+            });
           },
+          // 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',
@@ -278,6 +295,7 @@
       function onDataReceive(data) {
         // 方式1;
         console.log('useModalInner', data);
+        resetFields();
         setFieldsValue({
           ...data,
           roleId: data.roleId != 2 ? data.roleId : '',
@@ -351,7 +369,7 @@
         let res = await requestApi({
           ...data,
           userName: data.phone,
-          head: data.head[0],
+          head: data.head,
           phone: data.phone,
           nickName: data.nickName,
           roleId: data.roleId,