| | |
| | | import {mapGetters} from "vuex"; |
| | | import {dateFormat} from "@/util/date"; |
| | | import {validatenull} from "@/util/validate"; |
| | | import func from "@/util/func"; |
| | | |
| | | export default { |
| | | props: ["options","visible","ownbizOid"], |
| | |
| | | let data=new FormData(); |
| | | if(row && row.oid){ |
| | | data.append('fileOids',row.oid) |
| | | download(data) |
| | | this.downloadFile(data); |
| | | }else{ |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning("请选择至少一条数据"); |
| | | return; |
| | | } |
| | | data.append('fileOids',this.oids) |
| | | download(data); |
| | | this.downloadFile(data); |
| | | } |
| | | }, |
| | | downloadFile(data){ |
| | | download(data).then(res=>{ |
| | | // console.log(res); |
| | | if(res){ |
| | | const fileNames = res.headers['content-disposition'].split(";"); |
| | | let characterSet = fileNames[2].split("filename*=")[1]; |
| | | let fileName = decodeURI(fileNames[1].split("filename=")[1],characterSet); |
| | | // console.log(fileName) |
| | | let blob = new Blob([res.data], { |
| | | type: res.data.type + ";charset=utf-8", |
| | | }); |
| | | let src = window.URL.createObjectURL(blob); |
| | | if (src) { |
| | | let link = document.createElement("a"); |
| | | link.style.display = "none"; |
| | | link.href = src; |
| | | link.setAttribute("download", fileName); |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); //下载完成移除元素 |
| | | window.URL.revokeObjectURL(src); //释放掉blob对象 |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | rowDel(row) { |
| | | this.$confirm("确定将选择文件删除?", { |
| | | confirmButtonText: "确定", |