wangxy 2 недель назад
Родитель
Сommit
6553450572
1 измененных файлов с 50 добавлено и 19 удалено
  1. 50 19
      src/views/his/user/index.vue

+ 50 - 19
src/views/his/user/index.vue

@@ -282,6 +282,24 @@
         <el-button @click="cancelAddPoint">取 消</el-button>
       </div>
     </el-dialog>
+    <el-dialog title="选择项目" :visible.sync="projectSelectDialogVisible" width="400px">
+      <el-form :model="exportParams" style="margin-top: 15px;">
+        <el-form-item label="选择项目" :label-width="100">
+          <el-select v-model="exportParams.projectId" placeholder="请选择项目(可选)" style="width: 100%">
+            <el-option
+              v-for="option in projectOptions"
+              :key="option.dictValue"
+              :label="option.dictLabel"
+              :value="option.dictValue">
+            </el-option>
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="projectSelectDialogVisible = false">取 消</el-button>
+        <el-button type="primary" @click="confirmExportWithProject">确 定</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -303,10 +321,15 @@ export default {
       companyUserNickName: null,
       companyOptions: [],
       companyUserOptions: [],
+      projectOptions: [],
       show:{
               title:"用户详情",
               open:false,
             },
+      projectSelectDialogVisible: false,
+      exportParams: {
+        projectId: null
+      },
       userOptions: [],
       // 用户等级
       userLevelOptions:[],
@@ -412,6 +435,10 @@ export default {
     this.getDicts("user_is_promoter").then((response) => {
       this.userIsPromoterOptions = response.data;
     });
+    // 获取项目字典
+    this.getDicts("sys_course_project").then(response => {
+      this.projectOptions = response.data;
+    });
 
   },
   methods: {
@@ -598,31 +625,35 @@ export default {
     },
     /** 导出服务号用户OPENID */
     handleExportOpenId() {
-      this.$confirm('是否确认导出服务号用户OPENID数据?', "警告", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "warning"
-      }).then(() => {
-        this.exportOpenIdLoading = true;
+      this.exportParams.projectId = null; // 重置项目选择
+      this.projectSelectDialogVisible = true;
+    },
+    // 确认导出方法
+    confirmExportWithProject() {
+      this.projectSelectDialogVisible = false;
 
-        // 直接使用axios发起请求,绕过响应拦截器
-        return axios({
-          url: process.env.VUE_APP_BASE_API + '/his/user/exportOpenId',
-          method: 'post',
-          responseType: 'blob', // 重要:设置响应类型为blob
-          headers: {
-            'Authorization': 'Bearer ' + getToken(),
-            'X-Frontend-Type': 'admin'
-          }
-        });
+      this.exportOpenIdLoading = true;
+
+      // 构建URL参数
+      let url = process.env.VUE_APP_BASE_API + '/his/user/exportOpenId';
+      if (this.exportParams.projectId) {
+        url += `?projectId=${this.exportParams.projectId}`;
+      }
+
+      // 直接使用axios发起请求,绕过响应拦截器
+      axios({
+        url: url,
+        method: 'post',
+        responseType: 'blob',
+        headers: {
+          'Authorization': 'Bearer ' + getToken(),
+          'X-Frontend-Type': 'admin'
+        }
       }).then(response => {
         // 处理文件流下载
         const blob = new Blob([response.data], { type: 'application/vnd.ms-excel' });
-
-        // 直接使用默认文件名,因为后端没有返回
         const fileName = '用户openId数据.xlsx';
 
-        // 创建下载链接
         const url = window.URL.createObjectURL(blob);
         const link = document.createElement('a');
         link.href = url;