|
@@ -288,8 +288,8 @@
|
|
<!-- :span-method="objectSpanMethod" -->
|
|
<!-- :span-method="objectSpanMethod" -->
|
|
<el-table
|
|
<el-table
|
|
ref="multipleTable"
|
|
ref="multipleTable"
|
|
- v-loading="loading"
|
|
|
|
:span-method="objectSpanMethod"
|
|
:span-method="objectSpanMethod"
|
|
|
|
+ v-loading="loading"
|
|
:data="spuList"
|
|
:data="spuList"
|
|
@selection-change="handleSelectionChange"
|
|
@selection-change="handleSelectionChange"
|
|
row-key="id"
|
|
row-key="id"
|
|
@@ -833,7 +833,7 @@ export default {
|
|
sn: "",
|
|
sn: "",
|
|
},
|
|
},
|
|
column: [
|
|
column: [
|
|
- { header: "订单编号", key: "userOrderSn", width: 20 },
|
|
|
|
|
|
+ { header: "订单编号", key: "carPayNo", width: 20 },
|
|
{ header: "买家姓名", key: "userNick", width: 20 },
|
|
{ header: "买家姓名", key: "userNick", width: 20 },
|
|
{ header: "买家手机号", key: "userPhone", width: 20 },
|
|
{ header: "买家手机号", key: "userPhone", width: 20 },
|
|
{ header: "商品名称", key: "skuName", width: 20 },
|
|
{ header: "商品名称", key: "skuName", width: 20 },
|
|
@@ -996,74 +996,94 @@ export default {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
- /** 查询参数列表 */
|
|
|
|
getList() {
|
|
getList() {
|
|
this.selectList = [];
|
|
this.selectList = [];
|
|
this.loading = true;
|
|
this.loading = true;
|
|
queryUserOrderByShopId(
|
|
queryUserOrderByShopId(
|
|
this.addDateRange(this.queryParams, this.dateRange)
|
|
this.addDateRange(this.queryParams, this.dateRange)
|
|
).then((response) => {
|
|
).then((response) => {
|
|
- if (response.code == 200) {
|
|
|
|
- let list = response.data.records;
|
|
|
|
- let infoList = [];
|
|
|
|
- for (let index = 0; index < list.length; index++) {
|
|
|
|
- let e = list[index];
|
|
|
|
- if (e.dxUserOrderVOList) {
|
|
|
|
- for (let i = 0; i < e.dxUserOrderVOList.length; i++) {
|
|
|
|
- let a = e.dxUserOrderVOList[i];
|
|
|
|
- let c = { ...e, ...a };
|
|
|
|
- infoList.push(c);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- infoList.push(e);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- let totalList = [];
|
|
|
|
- for (let index = 0; index < infoList.length; index++) {
|
|
|
|
- let e = infoList[index];
|
|
|
|
- if (e.goodsInfo) {
|
|
|
|
|
|
+ if (response.code !== 200) {
|
|
|
|
+ this.loading = false;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ // 扁平化嵌套结构
|
|
|
|
+ const flattenedList = this.flattenOrderItems(response.data.records);
|
|
|
|
+ console.log("flattenedList", flattenedList);
|
|
|
|
+
|
|
|
|
+ // 处理商品信息和规格
|
|
|
|
+ const processedList = flattenedList.map((item) => {
|
|
|
|
+ const processedItem = { ...item };
|
|
|
|
+
|
|
|
|
+ // 解析并合并商品信息
|
|
|
|
+ if (item.goodsInfo) {
|
|
try {
|
|
try {
|
|
- var goods = JSON.parse(e.goodsInfo);
|
|
|
|
- e = { ...e, ...goods[0] };
|
|
|
|
|
|
+ const goods = JSON.parse(item.goodsInfo);
|
|
|
|
+ if (Array.isArray(goods) && goods.length > 0) {
|
|
|
|
+ // 合并第一个商品的信息
|
|
|
|
+ Object.assign(processedItem, goods[0]);
|
|
|
|
+
|
|
|
|
+ processedItem.specsName = goods
|
|
|
|
+ .map((good) => `${good.specsValue?.[0]?.specsName}`)
|
|
|
|
+ .toString();
|
|
|
|
+ processedItem.specsValue = goods
|
|
|
|
+ .map((good) => `${good.specsValue?.[0]?.specsValue}`)
|
|
|
|
+ .toString();
|
|
|
|
+ // 生成商品详情字符串
|
|
|
|
+ processedItem.goodsDetails = goods
|
|
|
|
+ .map(
|
|
|
|
+ (good) =>
|
|
|
|
+ `${good.skuName}(${
|
|
|
|
+ good.specsValue?.[0]?.specsName || ""
|
|
|
|
+ })-数量:${good.quantity}${good.unit}`
|
|
|
|
+ )
|
|
|
|
+ .join(";");
|
|
|
|
+ }
|
|
} catch (error) {
|
|
} catch (error) {
|
|
- console.error("解析 JSON 时出错:", error);
|
|
|
|
- // 跳出当前循环,继续处理下一个元素
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (e.specsValue) {
|
|
|
|
- for (let i = 0; i < e.specsValue.length; i++) {
|
|
|
|
- let a = e.specsValue[i];
|
|
|
|
- e = { ...e, ...a };
|
|
|
|
|
|
+ console.error("解析商品信息失败:", error);
|
|
|
|
+ processedItem.goodsDetails = "商品信息解析失败";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- totalList.push(e);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- totalList.forEach((e) => {
|
|
|
|
- try {
|
|
|
|
- let goos = JSON.parse(e.goodsInfo);
|
|
|
|
- let detail = "";
|
|
|
|
- if (goos && goos.length > 0) {
|
|
|
|
- // 检查 goos 是否为空
|
|
|
|
- goos.forEach((a) => {
|
|
|
|
- detail += `${a.skuName}(${a.specsValue[0]?.specsName})-数量:${a.quantity}${a.unit};`;
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- e.goodsDetails = detail;
|
|
|
|
- } catch (error) {
|
|
|
|
- console.error("解析 goodsInfo 时出错:", error);
|
|
|
|
|
|
+ // 合并规格信息
|
|
|
|
+ if (Array.isArray(item.specsValue)) {
|
|
|
|
+ item.specsValue.forEach((spec) => {
|
|
|
|
+ Object.assign(processedItem, spec);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ return processedItem;
|
|
});
|
|
});
|
|
|
|
|
|
- this.spuList = totalList;
|
|
|
|
|
|
+ console.log("12312312", processedList);
|
|
|
|
+
|
|
|
|
+ this.spuList = processedList;
|
|
this.total = response.data.total;
|
|
this.total = response.data.total;
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error("处理订单数据失败:", error);
|
|
|
|
+ this.spuList = [];
|
|
|
|
+ this.total = 0;
|
|
|
|
+ } finally {
|
|
this.loading = false;
|
|
this.loading = false;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ // 扁平化订单项目
|
|
|
|
+ flattenOrderItems(records) {
|
|
|
|
+ return records.flatMap((record) => {
|
|
|
|
+ if (
|
|
|
|
+ Array.isArray(record.dxUserOrderVOList) &&
|
|
|
|
+ record.dxUserOrderVOList.length > 0
|
|
|
|
+ ) {
|
|
|
|
+ return record.dxUserOrderVOList.map((item) => ({
|
|
|
|
+ ...record,
|
|
|
|
+ ...item,
|
|
|
|
+ }));
|
|
|
|
+ }
|
|
|
|
+ return [record];
|
|
|
|
+ });
|
|
|
|
+ },
|
|
// 取消按钮
|
|
// 取消按钮
|
|
cancel() {
|
|
cancel() {
|
|
this.open = false;
|
|
this.open = false;
|
|
@@ -1107,13 +1127,25 @@ export default {
|
|
handleSelectionChange(selection) {
|
|
handleSelectionChange(selection) {
|
|
console.log("selection", selection);
|
|
console.log("selection", selection);
|
|
this.selectList = selection.map((item) => item.carPayNo);
|
|
this.selectList = selection.map((item) => item.carPayNo);
|
|
- this.selectListDC = selection.map((item) => item);
|
|
|
|
- // this.ids = Array.from(new Set(this.selectList));
|
|
|
|
|
|
+ const payNoMap = {};
|
|
|
|
+ selection.forEach((row) => {
|
|
|
|
+ const carPayNo = row.carPayNo;
|
|
|
|
+ if (!payNoMap[carPayNo]) {
|
|
|
|
+ // 找到spuList中所有相同carPayNo的行
|
|
|
|
+ payNoMap[carPayNo] = this.spuList.filter(
|
|
|
|
+ (item) => item.carPayNo === carPayNo
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ // 将所有找到的行展平到selectListDC
|
|
|
|
+ this.selectListDC = Object.values(payNoMap).flat();
|
|
|
|
+ console.log(this.selectListDC);
|
|
},
|
|
},
|
|
|
|
|
|
/** 导出按钮操作 */
|
|
/** 导出按钮操作 */
|
|
handleExport() {
|
|
handleExport() {
|
|
let lists = [];
|
|
let lists = [];
|
|
|
|
+
|
|
for (let index = 0; index < this.spuList.length; index++) {
|
|
for (let index = 0; index < this.spuList.length; index++) {
|
|
for (let a = 0; a < this.selectListDC.length; a++) {
|
|
for (let a = 0; a < this.selectListDC.length; a++) {
|
|
if (this.spuList[index].id == this.selectListDC[a].id) {
|
|
if (this.spuList[index].id == this.selectListDC[a].id) {
|
|
@@ -1121,6 +1153,47 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // 定义订单状态映射表
|
|
|
|
+ const ORDER_STATUS_MAP = {
|
|
|
|
+ 0: "待商家确认修改运费",
|
|
|
|
+ 10: "等待买家支付",
|
|
|
|
+ 20: "等待商家发布货运信息",
|
|
|
|
+ 30: "司机已到达,等待买家签收",
|
|
|
|
+ 40: "买家已收货",
|
|
|
|
+ 50: "已取消",
|
|
|
|
+ 60: "退款中",
|
|
|
|
+ 70: "退款成功",
|
|
|
|
+ 80: "退款失败",
|
|
|
|
+ 90: "等待司机接单",
|
|
|
|
+ 100: "等待司机支付保证金",
|
|
|
|
+ 110: "等待司机装货",
|
|
|
|
+ 120: "已装货,运输中",
|
|
|
|
+ 130: "待处理售后",
|
|
|
|
+ 140: "已处理售后",
|
|
|
|
+ };
|
|
|
|
+ const AFTER_SALE_STATUS_MAP = {
|
|
|
|
+ 0: "未申请",
|
|
|
|
+ 1: "已申请",
|
|
|
|
+ 2: "审核失败",
|
|
|
|
+ 3: "审核成功(退款中)",
|
|
|
|
+ 4: "退款成功",
|
|
|
|
+ 5: "退款失败(联系客服解决)",
|
|
|
|
+ };
|
|
|
|
+ // 处理订单状态
|
|
|
|
+ lists.forEach((e) => {
|
|
|
|
+ // 订单状态处理(使用映射表)
|
|
|
|
+ if (AFTER_SALE_STATUS_MAP.hasOwnProperty(e.afterSaleStatus)) {
|
|
|
|
+ e.afterSaleStatus = AFTER_SALE_STATUS_MAP[e.afterSaleStatus];
|
|
|
|
+ } else {
|
|
|
|
+ e.afterSaleStatus = "未知状态"; // 处理未知状态
|
|
|
|
+ }
|
|
|
|
+ // 订单状态处理(使用映射表)
|
|
|
|
+ if (ORDER_STATUS_MAP.hasOwnProperty(e.orderStatus)) {
|
|
|
|
+ e.orderStatus = ORDER_STATUS_MAP[e.orderStatus];
|
|
|
|
+ } else {
|
|
|
|
+ e.orderStatus = "未知状态"; // 处理未知状态
|
|
|
|
+ }
|
|
|
|
+ });
|
|
console.log(lists);
|
|
console.log(lists);
|
|
Utils.exportExcel(this.column, lists, "订单列表"); //导出方法
|
|
Utils.exportExcel(this.column, lists, "订单列表"); //导出方法
|
|
},
|
|
},
|