优化订单导出功能

This commit is contained in:
pikachu1995@126.com 2024-06-26 11:51:22 +08:00
parent 3bfa99f578
commit 92559ca9e7
4 changed files with 96 additions and 73 deletions

View File

@ -78,6 +78,11 @@ export const getOrderList = (params) => {
return getRequest(`/order/order`, params)
}
// 导出订单列表
export const exportOrder = (params) => {
return getRequest(`/order/order/queryExportOrder`, params,'blob')
}
// 订单付款
export const orderPay = (sn) => {
return postRequest(`/order/order/${sn}/pay`)

View File

@ -79,15 +79,7 @@
>
</Form>
<div>
<download-excel
class="export-excel-wrapper"
:data="data"
:fields="fields"
:fetch="exportOrder"
name="商品订单.xls"
>
<Button type="info" class="export"> 导出订单 </Button>
</download-excel>
<Button @click="exportOrder" type="info" class="export">导出订单</Button>
</div>
<div class="order-tab">
@ -391,20 +383,35 @@ export default {
},
//
async exportOrder() {
const params = JSON.parse(JSON.stringify(this.searchForm));
params.pageNumber = 1;
params.pageSize = 10000;
const result = await API_Order.getOrderList(params);
if (result.success) {
if (result.result.records.length === 0) {
this.$Message.warning("暂无待发货订单");
return [];
} else {
return result.result.records;
}
} else {
this.$Message.warning("导出订单失败,请重试");
if(this.searchForm.startDate==""||this.searchForm.endDate==""){
this.$Message.error("必须选择时间范围,搜索后进行导出!");
}else{
API_Order.exportOrder(this.searchForm)
.then((res) => {
const blob = new Blob([res], {
type: "application/vnd.ms-excel;charset=utf-8",
});
//<a> Firefox Chrome download
//IE10blobdownload
if ("download" in document.createElement("a")) {
//adownload
const link = document.createElement("a"); //a
link.download = "订单列表.xlsx"; //a
link.style.display = "none";
link.href = URL.createObjectURL(blob);
document.body.appendChild(link);
link.click(); //
URL.revokeObjectURL(link.href); //url
document.body.removeChild(link); //
} else {
navigator.msSaveBlob(blob, fileName);
}
})
.catch((err) => {
console.log(err);
});
}
},
//
orderStatusClick(item) {

View File

@ -32,6 +32,11 @@ export const getOrderList = params => {
return getRequest(`/order/order`, params);
};
// 导出订单列表
export const exportOrder = (params) => {
return getRequest(`/order/order/queryExportOrder`, params,'blob')
};
// 获取普通订单详细信息
export const getOrderDetail = sn => {
return getRequest(`/order/order/${sn}`);

View File

@ -73,18 +73,20 @@
<Button @click="handleReset" class="search-btn">重置</Button>
</Form>
<div class="export">
<Button type="primary" class="mr_10" @click="expressOrderDeliver">
批量发货
</Button>
<download-excel
style="display: inline-block"
:data="data"
:fields="excelColumns"
:fetch="exportOrder"
name="待发货订单.xls"
>
<Button>导出待发货订单</Button>
</download-excel>
<Button type="primary" class="mr_10" @click="expressOrderDeliver">批量发货</Button>
<Button @click="exportOrder" type="info" class="export">导出订单</Button>
<Poptip @keydown.enter.native="orderVerification" placement="bottom-start" width="400">
<Button class="export">
核验订单
</Button>
<div class="api" slot="content">
<h2>核验码</h2>
<div style="margin:10px 0;">
<Input v-model="orderCode" style="width:300px; margin-right:10px;" />
<Button style="primary" @click="orderVerification">核验</Button>
</div>
</div>
</Poptip>
</div>
<Table
:loading="loading"
@ -115,6 +117,7 @@
import * as API_Order from "@/api/order";
import JsonExcel from "vue-json-excel";
import Cookies from "js-cookie";
import {verificationCode} from "@/api/order";
export default {
name: "orderList",
components: {
@ -306,6 +309,19 @@ export default {
};
},
methods: {
/**
* 核验订单
*/
async orderVerification() {
let result = await verificationCode(this.orderCode);
if (result.success) {
this.$router.push({
name: "order-detail",
query: { sn: result.result.sn || this.orderCode },
});
}
},
/**
* 批量发货
*/
@ -364,47 +380,37 @@ export default {
}
});
},
//
//
async exportOrder() {
let userInfo = JSON.parse(Cookies.get("userInfoSeller"));
const params = {
//
pageNumber: 1, //
pageSize: 10000, //
sort: "startDate", //
order: "desc", //
startDate: "", //
endDate: "", //
orderSn: "",
buyerName: "",
tag: "WAIT_SHIP",
orderType: "NORMAL",
storeId: userInfo.id,
};
const res = await API_Order.queryExportOrder(params);
if (res.success) {
if (res.result.length === 0) {
this.$Message.warning("暂无待发货订单");
return [];
}
for (let i = 0; i < res.result.length; i++) {
res.result[i].index = i + 1;
res.result[i].consigneeAddress =
res.result[i].consigneeAddressPath.replace(/,/g, "") +
res.result[i].consigneeDetail;
res.result[i].goodsPrice = this.$options.filters.unitPrice(
res.result[i].goodsPrice,
"¥"
);
res.result[i].flowPrice = this.$options.filters.unitPrice(
res.result[i].flowPrice,
"¥"
);
}
return res.result;
} else {
this.$Message.warning("导出订单失败,请重试");
if(this.searchForm.startDate==""||this.searchForm.endDate==""){
this.$Message.error("必须选择时间范围,搜索后进行导出!");
}else{
API_Order.exportOrder(this.searchForm)
.then((res) => {
const blob = new Blob([res], {
type: "application/vnd.ms-excel;charset=utf-8",
});
//<a> Firefox Chrome download
//IE10blobdownload
if ("download" in document.createElement("a")) {
//adownload
const link = document.createElement("a"); //a
link.download = "订单列表.xlsx"; //a
link.style.display = "none";
link.href = URL.createObjectURL(blob);
document.body.appendChild(link);
link.click(); //
URL.revokeObjectURL(link.href); //url
document.body.removeChild(link); //
} else {
navigator.msSaveBlob(blob, fileName);
}
})
.catch((err) => {
console.log(err);
});
}
},
//
detail(v) {