Source/UBCS-WEB/src/components/Master/MasterTransfer.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Source/UBCS-WEB/src/util/func.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Source/UBCS-WEB/src/components/Master/MasterTransfer.vue
@@ -120,6 +120,22 @@ mounted() { }, methods: { handlerFile(res){ let reader = new FileReader(); reader.readAsText(res.data); reader.onload = (result) =>{ try { let resData = JSON.parse(result.target.result); // 解析对象成功 if (resData.code != 200) { this.$message.error(resData.msg); } } catch (err) { // console.log("err",err)// 解析成对象失败,说明是正常的文件流 func.downloadFileByBlobHandler(res); this.$message.success('下载成功,请查看!'); } }; }, escHandler() { this.$emit('update:visible', false); this.value = []; @@ -157,10 +173,8 @@ 'conditionMap[oid]': this.ids, ...this.exportArrTwo, limit: -1 }).then(res => { if (res) { func.downloadFileByBlobHandler(res); this.escHandler() } this.handlerFile(res); this.escHandler(); }) } else { @@ -169,10 +183,9 @@ 'conditionMap[oid]': this.ids, ...this.exportArr }).then(res => { // console.log('res',res) if (res) { func.downloadFileByBlobHandler(res); this.escHandler() } this.handlerFile(res); this.escHandler(); }) } @@ -186,15 +199,13 @@ exportCode({codeClassifyOid: this.codeClassifyOid, ...this.exportArrTwo, limit: -1}).then(res => { if (res) { func.downloadFileByBlobHandler(res); this.escHandler() this.escHandler(); } }) } else { exportCode({codeClassifyOid: this.codeClassifyOid, ...this.exportArr, limit: -1}).then(res => { if (res) { func.downloadFileByBlobHandler(res); this.escHandler() } this.handlerFile(res); this.escHandler(); }) } } else if (this.radio === 2) { @@ -230,10 +241,9 @@ endPage: end }).then((res) => { // console.log('res',res) if (res) { func.downloadFileByBlobHandler(res); this.escHandler() } this.handlerFile(res); this.escHandler(); }); } else { this.tableHeadData.map(item => item.prop) @@ -246,11 +256,9 @@ page: start, endPage: end }).then(res => { // console.log('res',res) if (res) { func.downloadFileByBlobHandler(res); this.escHandler() } console.log('res',res) this.handlerFile(res); this.escHandler(); }) } } Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue
@@ -578,19 +578,25 @@ exportGroupCodeExcel({ codeClassifyOid: this.codeClassifyOid, }).then(res => { console.log(res) if (res) { func.downloadFileByBlobHandler(res); this.$message.success('下载成功,请查看!'); this.isLoading = false; } }).catch(error => { console.log(error) if (error) { this.$message.error('请查看下载的错误文件!'); } this.isLoading = false; }) let reader = new FileReader(); reader.readAsText(res.data) reader.onload = (result) =>{ try { let resData = JSON.parse(result.target.result); // 解析对象成功 if (!resData.success) { console.log("resData",resData) this.$message.error(resData.msg); this.isLoading = false; } } catch (err) { // console.log("err",err)// 解析成对象失败,说明是正常的文件流 func.downloadFileByBlobHandler(res); this.$message.success('下载成功,请查看!'); this.isLoading = false; } }; }); }, //标准申请 codeApplyHandler() { Source/UBCS-WEB/src/util/func.js
@@ -75,8 +75,8 @@ /** * ts日期格式处理 * @param {要处理的日期} thisDate * @returns * @param {要处理的日期} thisDate * @returns */ static formattedDateTime(thisDate) { const date = new Date(thisDate); @@ -133,20 +133,22 @@ * @returns {Boolean} */ static downloadFileByBlobHandler(res) { const fileNames = res.headers['content-disposition'].split(";"); let characterSet = fileNames[2].split("filename*=")[1]; let fileName = decodeURI(fileNames[1].split("filename=")[1],characterSet); // 下载的文件名 let blob = new Blob([res.data], { type: res.data.type + ";charset=utf-8", }); const url = URL.createObjectURL(blob); // 生成下载链接 const link = document.createElement("a"); link.href = url; link.download = fileName; // 指定文件名和格式 document.body.appendChild(link); // 添加下载链接到页面 link.click(); // 触发下载 document.body.removeChild(link); //删除下载 window.URL.revokeObjectURL(url); //释放掉blob对象 if(res.headers['content-disposition']){ const fileNames = res.headers['content-disposition'].split(";"); let characterSet = fileNames[2].split("filename*=")[1]; let fileName = decodeURI(fileNames[1].split("filename=")[1],characterSet); // 下载的文件名 let blob = new Blob([res.data], { type: res.data.type + ";charset=utf-8", }); const url = URL.createObjectURL(blob); // 生成下载链接 const link = document.createElement("a"); link.href = url; link.download = fileName; // 指定文件名和格式 document.body.appendChild(link); // 添加下载链接到页面 link.click(); // 触发下载 document.body.removeChild(link); //删除下载 window.URL.revokeObjectURL(url); //释放掉blob对象 } } /** @@ -166,9 +168,9 @@ /** * 将数组中的属性拼接成字符串 * @param {数组} array * @param {属性} attr * @returns * @param {数组} array * @param {属性} attr * @returns */ static joinedString(array,attr) { return array.reduce((accumulator, item) => { @@ -178,8 +180,8 @@ /** * 比对数组中的对象的某个属性是否全部一致 * @param {数组} array * @param {属性} attr * @param {数组} array * @param {属性} attr * @returns 一致返回fasle,不一致返回true */ static isAttrInconsistent(array,attr) {