ymz 2 дней назад
Родитель
Сommit
5b7c5f285e
2 измененных файлов с 29 добавлено и 15 удалено
  1. 4 3
      src/api/admin/user.js
  2. 25 12
      src/views/admin/user/index.vue

+ 4 - 3
src/api/admin/user.js

@@ -225,9 +225,10 @@ export function exportUserInfo(data) {
   });
 }
 
-export function getExportUserResult(data) {
+export function getExportResult(data) {
   return request({
-    url: `/admin/user/export/export-user-result`,
-    method: 'get'
+    url: `/admin/common/export/result`,
+    method: 'get',
+    params: data
   });
 }

+ 25 - 12
src/views/admin/user/index.vue

@@ -191,7 +191,7 @@ import fullTimeStaffRecordDialog from './components/fullTimeStaffRecordDialog.vu
 import communicationOfficerDialog from './components/communicationOfficerDialog.vue';
 import boundMedicinesDialog from './components/boundMedicinesDialog.vue';
 import UserCard from './components/UserCard.vue';
-import { addObj, delObj, fetchList, putObj, getUserDetails, batchChannelCert, getAuthInfo, getUserInfoApi, exportUserInfo, getExportUserResult } from '@/api/admin/user';
+import { addObj, delObj, fetchList, putObj, getUserDetails, batchChannelCert, getAuthInfo, getUserInfoApi, exportUserInfo, getExportResult } from '@/api/admin/user';
 import store from '@/store';
 import { getDictType } from '@/api/common';
 import { filterCodes, extractPaths } from '@/util/treeUtils.js';
@@ -355,24 +355,37 @@ export default {
     },
     // 获取导出状态
     async getExportInfoStatus() {
-      const res = await getExportUserResult();
+      const timer = setInterval(async () => {
+        const res = await getExportResult({
+          type: 'USER'
+        });
+
+        if (res.data.code === 0) {
+          const status = res.data.data.status;
 
-      if (res.data.code === 0) {
-        const timer = setInterval(() => {
-          if (res.data.data.status == 'GENERATED') {
+          if (status === 'GENERATING') {
+            this.exportUserInfoText = '数据生成中';
+            this.exportUserInfoDisabled = true;
+          } else if (status === 'GENERATED') {
             this.exportUrl = res.data.data.latestUrl;
             this.exportUserInfoText = '下载数据';
             this.exportUserInfoDisabled = false;
             clearInterval(timer);
-          } else if (res.data.data.status == 'GENERATING') {
-            this.exportUserInfoText = '数据生成中';
-            this.exportUserInfoDisabled = true;
-
-            this.getExportInfoStatus();
+          } else {
+            // 可选:处理其他状态
+            this.exportUserInfoText = '导出失败';
+            this.exportUserInfoDisabled = false;
+            clearInterval(timer);
           }
-        }, 5000);
-      }
+        } else {
+          // 接口报错处理
+          this.exportUserInfoText = '获取状态失败';
+          this.exportUserInfoDisabled = false;
+          clearInterval(timer);
+        }
+      }, 5000);
     },
+
     downInfo() {
       let link = document.createElement('a');
       link.style.display = 'none';