Browse Source

导出问题解决

luohailiang 2 years ago
parent
commit
aa6d6f9849
5 changed files with 121 additions and 184 deletions
  1. 1 1
      public/config.js
  2. 69 166
      src/stores/user.js
  3. 26 7
      src/views/wypj/dyewm/index.vue
  4. 0 1
      src/views/wypj/wypj/index.vue
  5. 25 9
      src/views/wypj/xsewm/index.vue

+ 1 - 1
public/config.js

@@ -24,7 +24,7 @@ const production = {
 
 function isWhich() {
   if (window.location.href.includes('localhost')) {
-    return production
+    return local
   } else if (window.location.href.includes('bozedu')) {
     return development
   } else {

File diff suppressed because it is too large
+ 69 - 166
src/stores/user.js


+ 26 - 7
src/views/wypj/dyewm/index.vue

@@ -3,6 +3,7 @@
     <el-form :inline="true" :model="firstForm">
       <el-form-item class="mr10" label="德育维度:">
         <el-select v-model="firstForm.dywd" placeholder="请选择维度" @change="getListData">
+          <el-option value="">全部</el-option>
           <el-option
             v-for="item in wdList"
             :label="item.xdww_name"
@@ -13,6 +14,7 @@
       </el-form-item>
       <el-form-item class="mr10" label="使用状态:">
         <el-select v-model="firstForm.syzt" placeholder="请选择状态" @change="getListData">
+          <el-option value="">全部</el-option>
           <el-option
 
             v-for="item in ztList"
@@ -27,11 +29,12 @@
       </el-form-item>
       <el-button type="primary" @click="getListData">搜索</el-button>
     </el-form>
-    <el-button type="primary">导出</el-button>
+    <el-button type="primary" @click="exportAll" :disabled="tableData.length === 0">导出</el-button>
     <el-table
       :data="tableData"
       tooltip-effect="dark"
       class="mt20"
+      @selection-change="handleSelectionChange"
       style="width: 100%"
     >
       <el-table-column type="selection" align="center" width="55">
@@ -121,8 +124,9 @@ export default {
       loading: false,
       logoSrc: '',
       appSrc: '',
-      dialogVisible:false
-    };
+      dialogVisible:false,
+      multipleSelection: []
+    }
   },
   methods: {
     getWdList() {
@@ -158,16 +162,31 @@ export default {
     },
 
     exportAll() {
-      let link =
-        window.globalVariables.api +
-        "/xddy/dygl_wypj_dyewm/index?api=xls&page=1&limit=10000&token=" +
-        token;
+      let link = '';
+      if(this.multipleSelection.length === 0) {
+        link =
+            window.globalVariables.api +
+            "/xddy/dygl_wypj_dyewm/index?api=xls&page=1&limit=10000&token=" +
+            token;
+      } else {
+        link =
+            window.globalVariables.api +
+            "/xddy/dygl_wypj_dyewm/index?api=xls&page=1&limit=10000&token=" +
+            token + '&xdww_id='+this.multipleSelection.join(',');
+      }
       window.open(link, "_blank");
     },
     showQr(item) {
       this.appSrc = 'dy,'+item.xdww_id + ','+ item.xdwx_xsxh+ ','+ item.dept_id;
       this.dialogVisible = true;
     },
+    handleSelectionChange(val) {
+      this.multipleSelection = [];
+      for(let i in val) {
+        this.multipleSelection.push(val[i].xdww_id);
+      }
+
+    }
 
   },
   mounted() {

+ 0 - 1
src/views/wypj/wypj/index.vue

@@ -17,7 +17,6 @@
               v-for="item in gradeList"
               :label="item.grade_name"
               :value="item.grade_id"
-              :key="item.grade_id"
             ></el-option>
           </el-select>
         </div>

+ 25 - 9
src/views/wypj/xsewm/index.vue

@@ -11,7 +11,6 @@
             v-for="item in gradeList"
             :label="item.grade_name"
             :value="item.grade_id"
-            :key="item.grade_id"
           ></el-option>
         </el-select>
       </el-form-item>
@@ -26,7 +25,6 @@
             v-for="item in classList"
             :label="item.class_name"
             :value="item.class_id"
-            :key="item.class_id"
           ></el-option>
         </el-select>
       </el-form-item>
@@ -44,12 +42,13 @@
       </el-form-item>
       <el-button type="primary">搜索</el-button>
     </el-form>
-    <el-button type="primary">导出</el-button>
+    <el-button type="primary" @click="exportAll" :disabled="tableData.length === 0">导出</el-button>
     <el-table
       :data="tableData"
       tooltip-effect="dark"
       class="mt20"
       style="width: 100%"
+      @selection-change="handleSelectionChange"
     >
       <el-table-column type="selection" align="center" width="55">
       </el-table-column>
@@ -139,8 +138,9 @@ export default {
       loading: false,
       logoSrc: '',
       appSrc: '',
-      dialogVisible:false
-    };
+      dialogVisible:false,
+      multipleSelection: []
+    }
   },
   methods: {
     handleCurrentChange(val) {
@@ -198,10 +198,19 @@ export default {
       });
     },
     exportAll() {
-      let link =
-        window.globalVariables.api +
-        "/xddy/dygl_wypj_xsewm/index?api=xls&page=1&limit=10000&token=" +
-        token;
+      let link = '';
+      if(this.multipleSelection.length === 0) {
+        link =
+            window.globalVariables.api +
+            "/xddy/dygl_wypj_xsewm/index?api=xls&page=1&limit=10000&token=" +
+            token;
+      } else {
+        link =
+            window.globalVariables.api +
+            "/xddy/dygl_wypj_xsewm/index?api=xls&page=1&limit=10000&token=" +
+            token+'&xdwx_id='+ this.multipleSelection.join(',');
+      }
+
       window.open(link, "_blank");
     },
     clearData() {
@@ -215,6 +224,13 @@ export default {
     switchGrade() {
       this.classListData();
       this.getListData();
+    },
+    handleSelectionChange(val) {
+      this.multipleSelection = [];
+      for(let i in val) {
+        this.multipleSelection.push(val[i].xdwx_id);
+      }
+
     }
   },
   mounted() {