静态台账导出

main
liuyiliang 1 year ago
parent 9d44c173d9
commit 1c56033a3e
  1. 20
      src/util/exportUtil.js
  2. 6
      src/views/leger/equipmentledger.vue

@ -0,0 +1,20 @@
export default {
excelExport : function (url, search, colArr) {
var filteredSearch = Object.keys(search)
.filter(key => !key.startsWith('$'))
.reduce((obj, key) => {
obj[key] = search[key];
return obj;
}, {});
var formStr = Object.keys(filteredSearch).map(key => {
let value = filteredSearch[key];
if (colArr.includes(key)) {
return `${encodeURIComponent(key)}_equal=${encodeURIComponent(value)}`;
} else {
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
}
}).join('&');
window.open(`${url}&${formStr}`);
}
}

@ -47,7 +47,7 @@
<el-button type="primary"
size="small"
plain
@click="handleExport">导出
@click="handleExport()">导出
</el-button>
</template>
<template #menu="{row,index,size}">
@ -63,6 +63,7 @@ import {getList, getDetail, add, update, remove, reject, auditing} from "@/api/l
import {mapGetters} from "vuex";
import website from "@/config/website";
import {getToken} from "@/util/auth";
import expUtil from "@/util/exportUtil";
export default {
data() {
@ -633,8 +634,7 @@ import {getList, getDetail, add, update, remove, reject, auditing} from "@/api/l
cancelButtonText: "取消",
type: "warning"
}).then(() => {
var formStr = Object.keys(this.search).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(this.search[key])}`).join('&');
window.open(`/api/equipmentledger/export?daf-auth=${getToken()}&${formStr}`);
expUtil.excelExport(`/api/equipmentledger/export?daf-auth=${getToken()}`, this.search, ['station', 'userStatus']);
});
},
beforeOpen(done, type) {

Loading…
Cancel
Save