|
@@ -375,7 +375,7 @@ import Refers from '@/components/Refers/refers.vue'
|
|
|
import TreeRefers from '@/components/Refers/treeRefer.vue'
|
|
|
import popDialog from '@/components/PopDialog/index.vue'
|
|
|
import CollapseTransition from '@/components/MyCollapse/collapse.vue'
|
|
|
-import {getSummaryList, auditSummary, confirmSummary , cancelSummary , shutDownSummary, editSummaryList } from '@/api/purchase/DemandSummary.js'
|
|
|
+import {getSummaryList, auditSummary, confirmSummary , cancelSummary , shutDownSummary, editSummaryList, exportList, exportItems } from '@/api/purchase/DemandSummary.js'
|
|
|
export default {
|
|
|
name: 'demandSummary',
|
|
|
dicts: ['sys_row_status', 'predictive_classify', 'sys_period_unit', 'sys_business', 'sys_bill_source'],
|
|
@@ -577,7 +577,53 @@ export default {
|
|
|
console.log('选中数组', this.ids.join())
|
|
|
},
|
|
|
handleCommand(command) {
|
|
|
- alert(command)
|
|
|
+ if(command == 'Excel导出') {
|
|
|
+ if(this.allSelection.length == 0) {
|
|
|
+ this.$modal.msgWarning("请选中至少一条数据");
|
|
|
+ } else {
|
|
|
+ exportList(this.allSelection).then(res => {
|
|
|
+ const blob = new Blob([res], {
|
|
|
+ type: "application/vnd.ms-excel;charset=UTF-8",
|
|
|
+ });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
|
|
|
+ const downloadElement = document.createElement("a"); //创建a标签
|
|
|
+ const href = window.URL.createObjectURL(blob); // 创建下载的链接
|
|
|
+ // var temp = res.headers["content-disposition"];
|
|
|
+ // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
|
|
|
+ // var name = fileName.split(";")[0]; //切割成文件名
|
|
|
+ downloadElement.href = href; //下载地址
|
|
|
+ downloadElement.download = '导出Excel'; // 下载后文件名
|
|
|
+ document.body.appendChild(downloadElement);
|
|
|
+ downloadElement.click(); // 点击下载
|
|
|
+ document.body.removeChild(downloadElement); // 下载完成移除元素
|
|
|
+ window.URL.revokeObjectURL(href); // 释放blob对象
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (command == '导出明细') {
|
|
|
+ if (this.allSelection.length == 0 || this.allSelection.length > 1) {
|
|
|
+ this.$modal.msgWarning("明细只能进行单条导出!");
|
|
|
+ } else {
|
|
|
+ let param = this.queryParams
|
|
|
+ param.sumFlag = this.allSelection[0].sumFlag
|
|
|
+ exportItems(param).then(res => {
|
|
|
+ const blob = new Blob([res], {
|
|
|
+ type: "application/vnd.ms-excel;charset=UTF-8",
|
|
|
+ });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
|
|
|
+ const downloadElement = document.createElement("a"); //创建a标签
|
|
|
+ const href = window.URL.createObjectURL(blob); // 创建下载的链接
|
|
|
+ // var temp = res.headers["content-disposition"];
|
|
|
+ // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
|
|
|
+ // var name = fileName.split(";")[0]; //切割成文件名
|
|
|
+ downloadElement.href = href; //下载地址
|
|
|
+ downloadElement.download = '导出明细'; // 下载后文件名
|
|
|
+ document.body.appendChild(downloadElement);
|
|
|
+ downloadElement.click(); // 点击下载
|
|
|
+ document.body.removeChild(downloadElement); // 下载完成移除元素
|
|
|
+ window.URL.revokeObjectURL(href); // 释放blob对象
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
check(row) {
|
|
|
this.isList = false
|
|
@@ -620,8 +666,10 @@ export default {
|
|
|
this.$modal.msgWarning("请选中至少一条数据");
|
|
|
} else {
|
|
|
confirmSummary(this.allSelection).then(res => {
|
|
|
- this.$modal.msgSuccess("确认成功");
|
|
|
- this.getList(this.queryParams)
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$modal.msgSuccess("确认成功");
|
|
|
+ this.getList(this.queryParams)
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
},
|