Bladeren bron

fix:完善档案管理批量下载功能,报考数据导入加载效果,修复问题

xiexaing 1 jaar geleden
bovenliggende
commit
f30181fa6d

+ 24 - 3
src/views/education/archives/downListRW.vue

@@ -24,7 +24,7 @@
         </el-table-column>
         <el-table-column fixed="right" label="操作" width="100" align="center">
           <template slot-scope="scope">
-            <el-button type="text" size="small" @click="down(scope.row.taskPath)" v-if="scope.row.taskStatus == 3 || scope.row.taskStatus == 4"
+            <el-button type="text" size="small" @click="down(scope.row)" v-if="scope.row.taskStatus == 3 || scope.row.taskStatus == 4"
               >下载</el-button
             >
           </template>
@@ -70,8 +70,29 @@ export default {
     openBoxs() {
       this.isShow = true;
     },
-    down(i) {
-      this.$methodsTools.exportData(i,false)
+    down(row) {
+      this.handleDownFlieName(row.taskPath, row.fileName)
+    },
+    handleDownFlieName(_url, _name = '导入数据') {
+      let url = this.$methodsTools.splitImgHost(_url)
+      let xhr = new XMLHttpRequest()
+      xhr.open('get', url, true)
+      xhr.responseType = "blob"
+      xhr.onload = function() {
+        if (xhr.status == 200 ) {
+          let blob = new Blob([xhr.response])
+          let href = window.URL.createObjectURL(blob)
+          let link = document.createElement("a")
+          link.href = href
+          let fileName = _name + '.' + url.split('.').splice(-1)
+          link.download = fileName
+          document.body.appendChild(link)
+          link.click()
+          document.body.removeChild(link)
+          window.URL.revokeObjectURL(href) //释放掉blob对象
+        }
+      }
+      xhr.send()
     },
     close() {},
   },

+ 34 - 53
src/views/education/archives/fileDownload.vue

@@ -7,21 +7,12 @@
       :title="userList.length > 1 ? '档案批量下载' : '档案下载'"
       @close="close"
     >
-      <!-- <el-button
-        size="small"
-        type="primary"
-        style="margin-bottom: 14px"
-        @click="plDown"
-        >批量下载</el-button
-      > -->
       <el-table :data="tableData" style="width: 100%" border ref="table">
-        <!-- <el-table-column type="selection" width="55" align="center">
-        </el-table-column> -->
         <el-table-column prop="name" label="文件名称" align="center">
         </el-table-column>
         <el-table-column fixed="right" label="操作" width="100" align="center">
           <template slot-scope="scope">
-            <el-button type="text" size="small" @click="handleDown(scope.row.value)"
+            <el-button type="text" size="small" @click="handleDown(scope.row)"
               >下载</el-button
             >
           </template>
@@ -53,41 +44,37 @@ export default {
           name: "报名记录",
           value: 4,
         },
-        {
-          name: "学员记录",
-          value: 5,
-        },
         {
           name: "网课记录",
-          value: 6,
+          value: 5,
         },
         {
           name: "题库记录",
-          value: 7,
+          value: 6,
         },
         {
           name: "直播记录",
-          value: 8,
+          value: 7,
         },
         {
           name: "资料记录",
-          value: 9,
+          value: 8,
         },
         {
           name: "约考记录",
-          value: 10,
+          value: 9,
         },
         {
           name: "考试记录",
-          value: 11,
+          value: 10,
         },
         {
           name: "证书/证明",
-          value: 12,
+          value: 11,
         },
         {
           name: "承诺书",
-          value: 13,
+          value: 12,
         },
       ],
       userList: [],
@@ -98,8 +85,8 @@ export default {
       this.userList = item || [];
       this.isShow = true;
     },
-    handleDown(val) {
-      const isDownRecord = [6, 7, 8].includes(val)
+    handleDown(row) {
+      const isDownRecord = [5, 6, 7].includes(row.value)
       this.$confirm(`${ isDownRecord ? "文件过大,需到下载记录完成下载。" : "确定下载吗?"}`, "提示", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
@@ -109,43 +96,37 @@ export default {
           this.$api
             .userdangAndatadownload({
               userIds: this.userList,
-              types: [val],
+              types: [row.value],
             })
             .then((res) => {
               this.$message.success("操作成功,正在下载");
-              if (!isDownRecord) this.$methodsTools.exportData(res.msg, false)
+              if (!isDownRecord) this.handleDownFlieName(res.msg, row.name)
               this.$store.dispatch("downloadlist", true);
             });
         })
         .catch(() => {});
     },
-    // plDown() {
-    //   let len = this.$refs.table.selection;
-    //   if (len.length > 0) {
-    //     this.down(len.map((i) => i.value));
-    //   } else {
-    //     this.$message.error("请勾选需要下载的选项");
-    //   }
-    // },
-    // down(i) {
-    //   this.$confirm(`确定${i.length > 1 ? "批量" : ""}下载吗?`, "提示", {
-    //     confirmButtonText: "确定",
-    //     cancelButtonText: "取消",
-    //     type: "warning",
-    //   })
-    //     .then(() => {
-    //       this.$api
-    //         .userdangAndatadownload({
-    //           userIds: this.userList,
-    //           types: i,
-    //         })
-    //         .then((res) => {
-    //           this.$message.success("操作成功,正在下载");
-    //           this.$store.dispatch("downloadlist", true);
-    //         });
-    //     })
-    //     .catch(() => {});
-    // },
+    handleDownFlieName(_url, _name = '导入数据') {
+      let url = this.$methodsTools.splitImgHost(_url)
+      let xhr = new XMLHttpRequest()
+      xhr.open('get', url, true)
+      xhr.responseType = "blob"
+      xhr.onload = function() {
+        if (xhr.status == 200 ) {
+          let blob = new Blob([xhr.response])
+          let href = window.URL.createObjectURL(blob)
+          let link = document.createElement("a")
+          link.href = href
+          let fileName = _name + '.' + url.split('.').splice(-1)
+          link.download = fileName
+          document.body.appendChild(link)
+          link.click()
+          document.body.removeChild(link)
+          window.URL.revokeObjectURL(href) //释放掉blob对象
+        }
+      }
+      xhr.send()
+    },
     close() {
       this.$refs.table.clearSelection();
     },

+ 1 - 1
src/views/education/classManageMent/classList/trainee/index.vue

@@ -51,7 +51,7 @@
             }}
           </p>
           <p>专业:{{ props.scope.row.categoryName }}</p>
-          <p>年份:{{ props.scope.row.year }}</p>
+          <p>年份:{{ props.scope.row.sevenYear }}</p>
         </div>
       </template>
       <template slot="classInfo" slot-scope="props">

+ 5 - 2
src/views/education/examManagement/applicationData/bulkImportPlan/newRegister.vue

@@ -91,7 +91,7 @@
         >
       </el-badge>
     </div>
-    <div v-show="active === 1" class="exportBox">
+    <div v-show="active === 1" class="exportBox" v-loading="loading">
       <h4 class="h4Sty">
         成功导入<strong style="color: red">{{ tableDataSuccess.length }}</strong
         >人
@@ -125,7 +125,7 @@
         </af-table-column>
       </el-table>
     </div>
-    <div v-show="active === 2" class="exportBox">
+    <div v-show="active === 2" class="exportBox" v-loading="loading">
       <h4 class="h4Sty">
         失败导入<strong style="color: red">{{ tableDataError.length }}</strong
         >人
@@ -224,6 +224,7 @@ import { mapGetters } from "vuex";
 export default {
   data() {
     return {
+      loading: false, // 加载效果
       dialogPLS: false,
       active: 1,
       marSty: { marginRight: "10px" },
@@ -343,6 +344,7 @@ export default {
       }
     },
     importMobleadd(e) {
+      this.loading = true
       var file = e.target.files[0];
       let formData = new FormData();
       formData.append("file", file);
@@ -355,6 +357,7 @@ export default {
         })
         .finally(() => {
           e.target.value = "";
+          this.loading = false
         });
     },
     advanced() {

+ 7 - 2
src/views/education/examManagement/applicationData/bulkImportPlan/newYY.vue

@@ -116,7 +116,7 @@
         >
       </el-badge>
     </div>
-    <div v-show="active === 1" class="exportBox">
+    <div v-show="active === 1" class="exportBox" v-loading="loading">
       <h4 class="h4Sty">
         成功导入<strong style="color: red">{{ tableDataSuccess.length }}</strong
         >人
@@ -150,7 +150,7 @@
         </af-table-column>
       </el-table>
     </div>
-    <div v-show="active === 2" class="exportBox">
+    <div v-show="active === 2" class="exportBox"  v-loading="loading">
       <h4 class="h4Sty">
         失败导入<strong style="color: red">{{ tableDataError.length }}</strong
         >人
@@ -204,6 +204,7 @@ import { mapGetters } from "vuex";
 export default {
   data() {
     return {
+      loading: false, // 加载效果
       typeInt: 1,
       active: 1,
       marSty: { marginRight: "10px" },
@@ -423,6 +424,7 @@ export default {
      * @param {event} e 不含考培导入模板
      */
     importMobleadd(e) {
+      this.loading = true
       var file = e.target.files[0];
       let formData = new FormData();
       formData.append("file", file);
@@ -436,6 +438,7 @@ export default {
         })
         .finally(() => {
           e.target.value = "";
+          this.loading = false
         });
     },
     /**
@@ -443,6 +446,7 @@ export default {
      * @param {event} e 含考培导入模板
      */
     importMobleaddtrain(e) {
+      this.loading = true
       var file = e.target.files[0];
       let formData = new FormData();
       formData.append("file", file);
@@ -456,6 +460,7 @@ export default {
         })
         .finally(() => {
           e.target.value = "";
+          this.loading = false
         });
     },
   },