sunyize %!s(int64=2) %!d(string=hai) anos
pai
achega
bce80ccc10
Modificáronse 2 ficheiros con 83 adicións e 0 borrados
  1. 2 0
      package.json
  2. 81 0
      src/views/smscheck/modules/TaskCheckList.vue

+ 2 - 0
package.json

@@ -26,8 +26,10 @@
     "dayjs": "^1.8.0",
     "dom-align": "1.12.0",
     "enquire.js": "^2.1.6",
+    "file-saver": "^2.0.5",
     "install": "^0.13.0",
     "js-cookie": "^2.2.0",
+    "jszip": "^3.10.1",
     "lodash.get": "^4.4.2",
     "lodash.pick": "^4.4.0",
     "md5": "^2.2.1",

+ 81 - 0
src/views/smscheck/modules/TaskCheckList.vue

@@ -127,6 +127,10 @@
               <a @click="selectData(record)">查看数据</a>
               <a-divider type="vertical" />
             </span>
+            <span v-has="'task:check:list:selectDataDown'">
+              <a @click="getFileUrls(record)">下载资料</a>
+              <a-divider type="vertical" />
+            </span>
             <span v-has="'task:check:list:notice'" v-if="record.checkState != 2 && record.checkState != 3 && record.checkState != 5">
               <a @click="noticeDeal(record)">催办</a>
               <a-divider type="vertical" />
@@ -175,6 +179,8 @@
 import { postAction, getAction, httpAction, deleteAction } from '@api/manage'
 import '@/assets/less/TableExpand.less'
 import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+import JSZip from 'jszip'
+import FileSaver from 'file-saver'
 
 export default {
   name: 'TaskCheckList',
@@ -185,6 +191,17 @@ export default {
     return {
       queryParam:{
       },
+      fileInfoList:[
+        {
+          fileStaticUrl:"http://223.223.177.220:9001/default/截屏2023-10-2311.04.07_1700125245908.png",
+          fileId:"xxx"
+        },
+        {
+          fileStaticUrl:"http://223.223.177.220:9001/default/截屏2023-10-2311.04.07_1700125245908.png",
+          fileId:"yyyy"
+        }
+      ],
+      dataListSelections:'',
       description: '稽核详情页面',
       currentTab: 'all',
       currentCheckState: null,
@@ -358,6 +375,70 @@ export default {
     }
   },
   methods: {
+    getFileUrls(data) {
+      let url = '/smsCheck/customerInfo/queryUrlById';
+      let params = {
+        id: data.id
+      }
+      let that = this;
+      getAction(url, params).then(res => {
+        if (res.success) {
+          that.fileInfoList = res.result
+          this.filesToRar(this.fileInfoList, '客户:'+data.customerNo+'资料下载');
+        }
+      })
+    },
+    /**文件打包* arrImages:文件list:[{fileUrl:文件url,renameFileName:文件名}]* filename 压缩包名* */
+    filesToRar(arrImages, filename) {
+      let _this = this;
+      let zip = new JSZip();
+      let cache = {};
+      let promises = [];
+      _this.title = '正在加载压缩文件';
+     // const loading = this.$loading({lock: true,text: '正在加载压缩文件',spinner: 'el-icon-loading',background: 'rgba(0, 0, 0, 0.7)'});
+      for (let item of arrImages) {
+        for (let url of item.fileStaticUrl) {
+
+          console.log("item",item)
+          // 下载文件, 并存成ArrayBuffer对象
+          const promise = this.getImgArrayBuffer(url.fileStaticUrl).then(data => {
+            var testZip = zip.folder(item.fileId);
+            // 获取文件名
+            const file_name = url.fileName
+            // 逐个添加文件
+            testZip.file(file_name, data, { binary: true })
+            //testZip.file(file_name,item.fileId)
+            cache[file_name] = data})
+            promises.push(promise);
+        }
+      }
+      Promise.all(promises)
+        // 生成二进制流
+        .then(() => {zip.generateAsync({ type: "blob" })
+          .then(content => {_this.title = '正在压缩';
+            // 利用file-saver保存文件  自定义文件名
+            FileSaver.saveAs(content, filename);
+            _this.title = '压缩完成';}
+          );
+        }).catch(res=>{
+        _this.$message.error('文件压缩失败');
+      });
+    },
+    getImgArrayBuffer(url) {
+      return new Promise((resolve, reject) => {
+        //通过请求获取文件blob格式
+        let xmlhttp = new XMLHttpRequest();
+        xmlhttp.open("GET", url, true);
+        xmlhttp.responseType = "blob";
+        xmlhttp.onload = function () {
+          if (this.status == 200) {
+            resolve(this.response);
+          } else {
+            reject(this.status);
+          }};
+        xmlhttp.send();
+      });
+    },
     // 返回上一级
     goBack() {
       this.$router.go(-1);