|
|
@@ -113,6 +113,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="'truck:check:list:history'" v-if="record.checkState === 4">
|
|
|
<a @click="showImproveGZ(record)">整改</a>
|
|
|
<a-divider type="vertical" />
|
|
|
@@ -168,7 +172,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',
|
|
|
mixins: [JeecgListMixin],
|
|
|
@@ -365,6 +370,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();
|
|
|
+ });
|
|
|
+ },
|
|
|
// 整改
|
|
|
showImproveGZ(record) {
|
|
|
this.$router.push({path: '/truckCheck/modules/TaskCheckAudit', query: {id: record.id}});
|