优化订单导出功能
This commit is contained in:
parent
3bfa99f578
commit
92559ca9e7
@ -78,6 +78,11 @@ export const getOrderList = (params) => {
|
|||||||
return getRequest(`/order/order`, params)
|
return getRequest(`/order/order`, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 导出订单列表
|
||||||
|
export const exportOrder = (params) => {
|
||||||
|
return getRequest(`/order/order/queryExportOrder`, params,'blob')
|
||||||
|
}
|
||||||
|
|
||||||
// 订单付款
|
// 订单付款
|
||||||
export const orderPay = (sn) => {
|
export const orderPay = (sn) => {
|
||||||
return postRequest(`/order/order/${sn}/pay`)
|
return postRequest(`/order/order/${sn}/pay`)
|
||||||
|
@ -79,15 +79,7 @@
|
|||||||
>
|
>
|
||||||
</Form>
|
</Form>
|
||||||
<div>
|
<div>
|
||||||
<download-excel
|
<Button @click="exportOrder" type="info" class="export">导出订单</Button>
|
||||||
class="export-excel-wrapper"
|
|
||||||
:data="data"
|
|
||||||
:fields="fields"
|
|
||||||
:fetch="exportOrder"
|
|
||||||
name="商品订单.xls"
|
|
||||||
>
|
|
||||||
<Button type="info" class="export"> 导出订单 </Button>
|
|
||||||
</download-excel>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="order-tab">
|
<div class="order-tab">
|
||||||
@ -391,20 +383,35 @@ export default {
|
|||||||
},
|
},
|
||||||
// 导出订单
|
// 导出订单
|
||||||
async exportOrder() {
|
async exportOrder() {
|
||||||
const params = JSON.parse(JSON.stringify(this.searchForm));
|
if(this.searchForm.startDate==""||this.searchForm.endDate==""){
|
||||||
params.pageNumber = 1;
|
this.$Message.error("必须选择时间范围,搜索后进行导出!");
|
||||||
params.pageSize = 10000;
|
}else{
|
||||||
const result = await API_Order.getOrderList(params);
|
API_Order.exportOrder(this.searchForm)
|
||||||
if (result.success) {
|
.then((res) => {
|
||||||
if (result.result.records.length === 0) {
|
const blob = new Blob([res], {
|
||||||
this.$Message.warning("暂无待发货订单");
|
type: "application/vnd.ms-excel;charset=utf-8",
|
||||||
return [];
|
});
|
||||||
|
//对于<a>标签,只有 Firefox 和 Chrome(内核) 支持 download 属性
|
||||||
|
//IE10以上支持blob但是依然不支持download
|
||||||
|
if ("download" in document.createElement("a")) {
|
||||||
|
//支持a标签download的浏览器
|
||||||
|
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 {
|
} else {
|
||||||
return result.result.records;
|
navigator.msSaveBlob(blob, fileName);
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
this.$Message.warning("导出订单失败,请重试");
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
// 订单筛选
|
// 订单筛选
|
||||||
orderStatusClick(item) {
|
orderStatusClick(item) {
|
||||||
|
@ -32,6 +32,11 @@ export const getOrderList = params => {
|
|||||||
return getRequest(`/order/order`, params);
|
return getRequest(`/order/order`, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 导出订单列表
|
||||||
|
export const exportOrder = (params) => {
|
||||||
|
return getRequest(`/order/order/queryExportOrder`, params,'blob')
|
||||||
|
};
|
||||||
|
|
||||||
// 获取普通订单详细信息
|
// 获取普通订单详细信息
|
||||||
export const getOrderDetail = sn => {
|
export const getOrderDetail = sn => {
|
||||||
return getRequest(`/order/order/${sn}`);
|
return getRequest(`/order/order/${sn}`);
|
||||||
|
@ -73,18 +73,20 @@
|
|||||||
<Button @click="handleReset" class="search-btn">重置</Button>
|
<Button @click="handleReset" class="search-btn">重置</Button>
|
||||||
</Form>
|
</Form>
|
||||||
<div class="export">
|
<div class="export">
|
||||||
<Button type="primary" class="mr_10" @click="expressOrderDeliver">
|
<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>
|
</Button>
|
||||||
<download-excel
|
<div class="api" slot="content">
|
||||||
style="display: inline-block"
|
<h2>核验码</h2>
|
||||||
:data="data"
|
<div style="margin:10px 0;">
|
||||||
:fields="excelColumns"
|
<Input v-model="orderCode" style="width:300px; margin-right:10px;" />
|
||||||
:fetch="exportOrder"
|
<Button style="primary" @click="orderVerification">核验</Button>
|
||||||
name="待发货订单.xls"
|
</div>
|
||||||
>
|
</div>
|
||||||
<Button>导出待发货订单</Button>
|
</Poptip>
|
||||||
</download-excel>
|
|
||||||
</div>
|
</div>
|
||||||
<Table
|
<Table
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
@ -115,6 +117,7 @@
|
|||||||
import * as API_Order from "@/api/order";
|
import * as API_Order from "@/api/order";
|
||||||
import JsonExcel from "vue-json-excel";
|
import JsonExcel from "vue-json-excel";
|
||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
|
import {verificationCode} from "@/api/order";
|
||||||
export default {
|
export default {
|
||||||
name: "orderList",
|
name: "orderList",
|
||||||
components: {
|
components: {
|
||||||
@ -306,6 +309,19 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
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() {
|
async exportOrder() {
|
||||||
let userInfo = JSON.parse(Cookies.get("userInfoSeller"));
|
if(this.searchForm.startDate==""||this.searchForm.endDate==""){
|
||||||
const params = {
|
this.$Message.error("必须选择时间范围,搜索后进行导出!");
|
||||||
// 搜索框初始化对象
|
}else{
|
||||||
pageNumber: 1, // 当前页数
|
API_Order.exportOrder(this.searchForm)
|
||||||
pageSize: 10000, // 页面大小
|
.then((res) => {
|
||||||
sort: "startDate", // 默认排序字段
|
const blob = new Blob([res], {
|
||||||
order: "desc", // 默认排序方式
|
type: "application/vnd.ms-excel;charset=utf-8",
|
||||||
startDate: "", // 起始时间
|
});
|
||||||
endDate: "", // 终止时间
|
//对于<a>标签,只有 Firefox 和 Chrome(内核) 支持 download 属性
|
||||||
orderSn: "",
|
//IE10以上支持blob但是依然不支持download
|
||||||
buyerName: "",
|
if ("download" in document.createElement("a")) {
|
||||||
tag: "WAIT_SHIP",
|
//支持a标签download的浏览器
|
||||||
orderType: "NORMAL",
|
const link = document.createElement("a"); //创建a标签
|
||||||
storeId: userInfo.id,
|
link.download = "订单列表.xlsx"; //a标签添加属性
|
||||||
};
|
link.style.display = "none";
|
||||||
const res = await API_Order.queryExportOrder(params);
|
link.href = URL.createObjectURL(blob);
|
||||||
if (res.success) {
|
document.body.appendChild(link);
|
||||||
if (res.result.length === 0) {
|
link.click(); //执行下载
|
||||||
this.$Message.warning("暂无待发货订单");
|
URL.revokeObjectURL(link.href); //释放url
|
||||||
return [];
|
document.body.removeChild(link); //释放标签
|
||||||
}
|
|
||||||
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 {
|
} else {
|
||||||
this.$Message.warning("导出订单失败,请重试");
|
navigator.msSaveBlob(blob, fileName);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
// 查看订单详情
|
// 查看订单详情
|
||||||
detail(v) {
|
detail(v) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user