扫描记录查询页的导出功能完成

This commit is contained in:
liuyp 2024-06-19 15:38:20 +08:00
parent 19cd003bbc
commit d4484268d8

View File

@ -93,17 +93,18 @@
</el-form> </el-form>
<xd-table v-loading="loading" <xd-table v-loading="loading"
border stripe ref="dataTable"
size="small" border stripe
:data="emisElectronicPagApplyList" size="small"
:showSearch.sync="showSearch" :data="emisElectronicPagApplyList"
:queryParams="queryParams" :showSearch.sync="showSearch"
:total="total" :queryParams="queryParams"
@queryTable="getList" :total="total"
@selection-change="handleSelectionChange" @queryTable="getList"
@sort-change="handleSortChange" @selection-change="handleSelectionChange"
v-if="tableHeight" :max-height="tableHeight + 'px'" @sort-change="handleSortChange"
> v-if="tableHeight" :max-height="tableHeight + 'px'"
>
<div slot="toolbar"> <div slot="toolbar">
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
@ -138,7 +139,7 @@
type="primary" type="primary"
plain plain
size="mini" size="mini"
@click="getList" @click="handleExport"
>导出</el-button> >导出</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
@ -154,7 +155,7 @@
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column :label="$t('单号')" align="center" prop="queryType" min-width="170"> <el-table-column :label="$t('单号')" align="center" prop="billCode" min-width="170">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{scope.row.queryType=="1"?scope.row.billCode:scope.row.orderSN}}</span> <span>{{scope.row.queryType=="1"?scope.row.billCode:scope.row.orderSN}}</span>
</template> </template>
@ -658,71 +659,72 @@ export default {
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
// this.download('emis/emisElectronicPagApply/export', { let that = this;
// ...this.queryParams const loadingInstance = this.$loading({
// }, `emisElectronicPagApply_${new Date().getTime()}.xlsx`) text: '正在导出...'
const loadingInstance = this.$loading({ })
text: '正在导出...' var qParam = {...this.queryParams};
}) qParam.pageNum=1;
var qParam = {...this.queryParams}; qParam.pageSize=20;
qParam.pageNum=1; if (null != this.dateTimeRange && '' != this.dateTimeRange) {
qParam.pageSize=5000; qParam.params.beginScanDate = dateToStr(new Date(this.dateTimeRange[0]));
if (null != this.dateTimeRange && '' != this.dateTimeRange) { qParam.params.endScanDate = dateToStr(new Date(this.dateTimeRange[1]));
this.queryParams.params["beginScanDate"] = dateToStr(this.dateTimeRange[0]); }else{
this.queryParams.params["endScanDate"] = dateToStr(this.dateTimeRange[1]); qParam.params.beginScanDate = null;
qParam.params.endScanDate = null;
} }
this.queryParams.params["queryType"] = this.queryParams.queryType;//1:yd;2:dd; qParam.params.queryType = this.queryParams.queryType;//1:yd;2:dd;
this.queryParams.params["isSubBill"] = this.queryParams.isSubBill;//1:子单;0:主单 qParam.params.isSubBill = this.queryParams.isSubBill;//1:子单;0:主单
listEmisTmsScanRecord(this.queryParams).then(response => { let queryType = this.queryParams.queryType;
this.downloadLoading = false if(queryType == "1"){
qParam.orderSN=null;
}else if(queryType == "0"){
qParam.orderSN=this.queryParams.billCode;
qParam.billCode=null;
}
listEmisTmsScanRecord(qParam).then(response => {
this.loadingInstance = false
if (response.code === 200) { if (response.code === 200) {
const curList = [] const curList = []
for (let index = 0; index < response.rows.length; index++) { for (let index = 0; index < response.rows.length; index++) {
let scanRstItem = response.rows[index]; let scanRstItem = response.rows[index];
let record =Object.assign({}, scanRstItem) let record =Object.assign({}, scanRstItem)
record.orderType = this.queryParams.orderType; if(this.queryParams.queryType!="1"){
record.scanSiteName = this.queryParams.scanSiteName || record.scanSiteName; record.billCode = qParam.orderSN;
record.preOrNextStation = this.queryParams.preOrNextStation || scanRstItem.preOrNextStation; }
curList.push(record); record.scanSiteName = this.queryParams.scanSiteName || record.scanSiteName;
} record.preOrNextStation = this.queryParams.preOrNextStation || scanRstItem.preOrNextStation;
import('@/vendor/Export2Excel').then(excel => { record.scanDate = parseTime(record.scanDate);
const tHeader = ['id','单号','单号类型','车牌号','扫描时间','扫描类型','扫描网点','上/下一网点','扫描员','录入时间','扫描重量']; record.createTime = parseTime(record.createTime);
const filterVal = ['id','billCode','orderType','carNo','scanDate','scanType','scanSite','preOrNextStation','scanMan','createTime','scanWeight']; debugger
const data = this.formatJson(filterVal, curList, curList) console.log(that)
excel.export_json_to_excel({ record.scanType = that.dict.label.emis_scan_type[record.scanType];
header: tHeader, curList.push(record);
data, }
filename: '网点电子面单申请', let tHeader = [];// ['id','单号','单号类型','车牌号','扫描时间','扫描类型','扫描网点','上/下一网点','扫描员','录入时间','扫描重量'];
autoWidth: true let filterVal = [];// ['id','billCode','orderType','carNo','scanDate','scanType','scanSite','preOrNextStation','scanMan','createTime','scanWeight'];
})
loadingInstance.close() for(let sl = 0; sl < this.$refs.dataTable.storageList.length; sl++){
}) if(this.$refs.dataTable.storageList[sl].show){
tHeader.push(this.$refs.dataTable.storageList[sl].label);
filterVal.push(this.$refs.dataTable.storageList[sl].prop);
}
}
debugger
import('@/vendor/Export2Excel').then(excel => {
const data = this.formatJson(filterVal, curList, curList)
excel.export_json_to_excel({
header: tHeader,
data,
filename: '扫描记录查询',
autoWidth: true
})
loadingInstance.close()
})
} }
}); });
// listEmisTmsScanRecord(this.addDateRange(qParam, this.dateTimeRange)).then(response => {
// this.emisElectronicPagApplyList = [];
// this.loading = false;
// let rows = response.rows;
// this.total = response.total;
// if(!rows || rows.length == 0){
// this.$message.error("未查到单号");
// return;
// }
// for (let index = 0; index < rows.length; index++) {
// let scanRstItem = rows[index];
// console.log(scanRstItem);
// let record =Object.assign({}, scanRstItem)
// record.orderType = this.queryParams.orderType;
// record.scanSiteName = this.queryParams.scanSiteName || record.scanSiteName;
// record.preOrNextStation = this.queryParams.preOrNextStation || scanRstItem.preOrNextStation;
// this.emisElectronicPagApplyList.push(record);
// }
// });
}, },
formatJson(filterVal, jsonData, resData) { formatJson(filterVal, jsonData, resData) {
let index = 0 let index = 0