订单分析页面修改

This commit is contained in:
yis 2025-08-19 17:03:38 +08:00
parent 9a7e2618cd
commit 92e927999d

View File

@ -141,78 +141,59 @@
<h3 class="table-title">订单数据详情</h3> <h3 class="table-title">订单数据详情</h3>
<div class="table-wrapper"> <div class="table-wrapper">
<el-table <el-table
:data="orderList" :data="processedOrderList"
style="width: 100%" style="width: 100%"
:fit="true" :fit="true"
:header-cell-style="{
'text-align': 'center',
'color': '#000000',
}"
:cell-style="{ textAlign: 'center' }" :cell-style="{ textAlign: 'center' }"
v-loading="tableLoading" v-loading="tableLoading"
stripe stripe
border border
@sort-change="handleSortChange" @sort-change="handleSortChange"
>
> <el-table-column prop="orderNo" label="订单编号" min-width="180" sortable/>
<el-table-column <el-table-column prop="customerName" label="客户名称" min-width="120"/>
prop="orderNo" <el-table-column prop="pilotName" label="飞行员名称" min-width="120" />
label="订单编号" <el-table-column prop="scenicName" label="景区名称" min-width="150" />
min-width="180" <el-table-column prop="phone" label="联系电话" min-width="150"/>
sortable <el-table-column prop="routeNames" label="配送路线" min-width="150" />
/> <el-table-column prop="totalAmount" label="总金额(元)" min-width="140" sortable align="right">
<el-table-column
prop="orderInitiatorId"
label="客户ID"
min-width="150"
/>
<el-table-column
prop="attractionId"
label="景点ID"
min-width="120"
/>
<el-table-column
prop="amount"
label="金额(元)"
min-width="120"
sortable
align="right"
/>
<el-table-column
prop="mainOrderStatus"
label="状态"
min-width="120"
:filters="statusFilters"
:filter-method="filterStatus"
>
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<el-tag :type="getStatusTagType(row.mainOrderStatus)"> {{ row.totalAmount.toFixed(2) }}
{{ getStatusText(row.mainOrderStatus) }} </template>
</el-table-column>
<el-table-column prop="orderInitiator" label="订单发起人" min-width="120" />
<el-table-column prop="orderType" label="订单类型" min-width="100" />
<el-table-column prop="orderCreateTime" label="下单时间" min-width="180" sortable />
<el-table-column prop="status" label="订单状态" align="center" width="120">
<template #default="{ row }">
<el-tag
:type="getStatusTagType(row.mainOrderStatus)"
size="small"
effect="light"
>
{{ getOrderStatusText(row.mainOrderStatus) }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
prop="orderCreateTime" <el-table-column prop="settlementStatus" label="结算状态" align="center" width="120">
label="下单时间" <template #default="{ row }">
min-width="180" <el-tag
sortable :type="getSettlementTagType(row.settlementStatus)"
/>
<el-table-column
prop="orderFinishTime"
label="完成时间"
min-width="180"
/>
<!-- <el-table-column
label="操作"
min-width="120"
fixed="right"
>
<template slot-scope="{ row }">
<el-button
size="small" size="small"
@click="handleViewDetail(row)" effect="plain"
> >
详情 {{ getSettlementStatusText(row.settlementStatus) }}
</el-button> </el-tag>
</template> </template>
</el-table-column> --> </el-table-column>
</el-table> </el-table>
<!-- 分页 -->
<div class="pagination-wrapper"> <div class="pagination-wrapper">
<div class="pagination-info"> <div class="pagination-info">
显示第 {{ (pagination.currentPage - 1) * pagination.pageSize + 1 }} 显示第 {{ (pagination.currentPage - 1) * pagination.pageSize + 1 }}
@ -255,11 +236,26 @@ import {
getMonthlyOrderAnalysis, getMonthlyOrderAnalysis,
getYearlyOrderAnalysis getYearlyOrderAnalysis
} from '@/api/analysis/orderAnalysis'; } from '@/api/analysis/orderAnalysis';
import { allScenic } from "@/api/system/scenic";
import { allCustomer } from "@/api/system/customer";
import { getList } from "@/api/system/pilot";
import { getAllRoutes } from "@/api/system/route";
import { getOrderStatusText, getSettlementStatusText, getOrderStatusClass, getSettlementStatusClass } from "@/utils/orderStatus";
export default { export default {
name: 'orderAnalysis', name: 'orderAnalysis',
data() { data() {
return { return {
customerMap: {},
pilotMap: {},
scenicMap: {},
routeMap: {},
orderTypeMap: {
1: '载物飞行',
2: '载人飞行'
},
jumpPage: 1, jumpPage: 1,
loading: false, loading: false,
tableLoading: false, tableLoading: false,
@ -296,12 +292,6 @@ export default {
completionRate: 0 completionRate: 0
}, },
orderList: [], orderList: [],
statusFilters: [
{ text: '未开始', value: 0 },
{ text: '进行中', value: 1 },
{ text: '已完成', value: 2 },
{ text: '已取消', value: 3 }
],
pagination: { pagination: {
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
@ -313,6 +303,41 @@ export default {
}; };
}, },
computed: { computed: {
processedOrderList() {
return this.orderList.map(order => {
// 线routeIds
const routeNames = order.routeIds
? order.routeIds.split(',').map(id => this.routeMap[id] || id).join('、')
: '无路线';
return {
...order,
//
customerName: this.customerMap[order.customerId] || `客户${order.customerId}`,
//
pilotName: this.pilotMap[order.pilotId] || `飞行员${order.pilotId}`,
//
scenicName: this.scenicMap[order.scenicId] || `景区${order.scenicId}`,
//
orderInitiator: this.pilotMap[order.orderInitiatorId] || `发起人${order.orderInitiatorId}`,
// 线
routeNames: routeNames,
//
totalAmount: parseFloat(order.totalAmount || 0),
//
orderType: this.orderTypeMap[order.orderType] || '未知类型',
// - 使
statusText: this.getOrderStatusText(order.mainOrderStatus),
statusClass: this.getOrderStatusClass(order.mainOrderStatus),
// - 使
settlementStatusText: this.getSettlementStatusText(order.settlementStatus),
settlementClass: this.getSettlementStatusClass(order.settlementStatus),
//
mainOrderStatus: order.mainOrderStatus,
settlementStatus: order.settlementStatus
}
})
},
datePickerType() { datePickerType() {
return this.filter.timeRange === 'year' ? 'year' : return this.filter.timeRange === 'year' ? 'year' :
this.filter.timeRange === 'month' ? 'month' : 'date'; this.filter.timeRange === 'month' ? 'month' : 'date';
@ -336,6 +361,7 @@ export default {
}, },
mounted() { mounted() {
this.initCharts(); this.initCharts();
this.initMaps(); //
this.initDefaultDateRange(); this.initDefaultDateRange();
this.fetchData(); this.fetchData();
window.addEventListener('resize', this.handleResize); window.addEventListener('resize', this.handleResize);
@ -346,7 +372,89 @@ export default {
if (this.modelChart) this.modelChart.dispose(); if (this.modelChart) this.modelChart.dispose();
if (this.routeChart) this.routeChart.dispose(); if (this.routeChart) this.routeChart.dispose();
}, },
methods: { methods: {
getOrderStatusText,
getSettlementStatusText,
getOrderStatusClass,
getSettlementStatusClass,
getSettlementTagType(status) {
const map = {
0: 'info', //
1: 'warning', //
2: 'success' //
};
return map[status] || 'info';
},
getStatusTagType(status) {
const map = {
0: 'info', //
1: 'primary', //
2: 'success', // 绿
3: 'danger', //
4: 'warning' //
};
return map[status] || 'info';
},
//
getOrderStatusClass(status) {
const classObj = getOrderStatusClass(status);
return Object.keys(classObj).find(key => classObj[key]) || '';
},
getSettlementStatusClass(status) {
const classObj = getSettlementStatusClass(status);
return Object.keys(classObj).find(key => classObj[key]) || '';
},
//
filterStatus(value, row) {
return row.mainOrderStatus === value;
},
//
filterSettlementStatus(value, row) {
return row.settlementStatus === value;
},
//
async initMaps() {
try {
//
const customers = await allCustomer();
this.customerMap = customers.reduce((map, customer) => {
map[customer.id] = customer.name;
return map;
}, {});
//
const pilotsResponse = await getList();
this.pilotMap = (pilotsResponse.content || pilotsResponse.data || []).reduce((map, pilot) => {
map[pilot.id] = pilot.name;
return map;
}, {});
//
const scenicsResponse = await allScenic();
this.scenicMap = (scenicsResponse.data || scenicsResponse || []).reduce((map, scenic) => {
map[scenic.id] = scenic.name;
return map;
}, {});
// 线 - 使 getAllRoutes
const routesResponse = await getAllRoutes(); //
const routes = routesResponse.data || routesResponse; // API
this.routeMap = routes.reduce((map, route) => {
map[route.id] = route.name;
return map;
}, {});
} catch (error) {
console.error('初始化映射数据失败:', error);
this.$message.error('初始化数据失败,请刷新重试');
}
},
initCharts() { initCharts() {
this.$nextTick(() => { this.$nextTick(() => {
if (this.$refs.trendChartContainer) { if (this.$refs.trendChartContainer) {
@ -475,8 +583,11 @@ export default {
endDate: this.filter.endDate, endDate: this.filter.endDate,
pageNum: this.pagination.currentPage, pageNum: this.pagination.currentPage,
pageSize: this.pagination.pageSize, pageSize: this.pagination.pageSize,
// sortField
...(this.filter.sortField && {
sortField: this.filter.sortField, sortField: this.filter.sortField,
sortOrder: this.filter.sortOrder sortOrder: this.filter.sortOrder
})
}; };
console.log('请求参数:', params); console.log('请求参数:', params);
@ -510,16 +621,14 @@ export default {
}, },
processResponseData(data) { processResponseData(data) {
this.jumpPage = this.pagination.currentPage;
// 1. data // 1. data
if (!data) { if (!data) {
console.error('响应数据为空,将设置为空状态'); console.error('响应数据为空,将设置为空状态');
this.setEmptyDataState(); // this.setEmptyDataState();
return; // return;
} }
// 2. summaryData使 || || 0 undefined // 2. summaryData
this.summaryData = { this.summaryData = {
totalOrderCount: data.totalOrderCount || 0, totalOrderCount: data.totalOrderCount || 0,
totalOrderAmount: data.totalOrderAmount || 0, totalOrderAmount: data.totalOrderAmount || 0,
@ -528,17 +637,30 @@ export default {
cancelOrderCount: data.cancelOrderCount || 0, cancelOrderCount: data.cancelOrderCount || 0,
noStartOrderCount: data.noStartOrderCount || 0, noStartOrderCount: data.noStartOrderCount || 0,
completionRate: data.completionRate || 0, completionRate: data.completionRate || 0,
droneModelDistribution: data.droneModelDistribution || 0 droneModelDistribution: data.droneModelDistribution || {}
}; };
// 3. orderList -
// 2. orderList - this.orderList = (data.orderList || []).map(item => {
this.orderList = (data.orderList || []).map(item => ({ return {
...item, ...item,
amount: item.amount ? Number(item.amount).toFixed(2) : '0.00' customerName: this.customerMap[item.customerId] || `客户${item.customerId}`,
})); pilotName: this.pilotMap[item.pilotId] || `飞行员${item.pilotId}`,
scenicName: this.scenicMap[item.scenicId] || `景区${item.scenicId}`,
orderInitiator: this.pilotMap[item.orderInitiatorId] || `发起人${item.orderInitiatorId}`,
orderType: this.orderTypeMap[item.orderType] || '未知类型',
routeNames: item.routeIds ? item.routeIds.split(',').map(id => this.routeMap[id] || id).join('、') : '无路线',
totalAmount: parseFloat(item.totalAmount || 0),
statusText: this.getOrderStatusText(item.mainOrderStatus),
statusClass: this.getOrderStatusClass(item.mainOrderStatus),
settlementStatusText: this.getSettlementStatusText(item.settlementStatus),
settlementClass: this.getSettlementStatusClass(item.settlementStatus),
mainOrderStatus: item.mainOrderStatus,
settlementStatus: item.settlementStatus
}
});
// 3. // 4.
if (data.pageInfo) { if (data.pageInfo) {
this.pagination.total = data.pageInfo.total || 0; this.pagination.total = data.pageInfo.total || 0;
this.pagination.currentPage = data.pageInfo.pageNum || 1; this.pagination.currentPage = data.pageInfo.pageNum || 1;
@ -548,11 +670,10 @@ export default {
this.pagination.currentPage = 1; this.pagination.currentPage = 1;
} }
// 5. data // 5.
this.updateCharts({ this.updateCharts({
//
timeSeriesData: data.timeSeriesData || [], timeSeriesData: data.timeSeriesData || [],
droneModelDistribution: data.droneModelDistribution || data.dromeModelDistribution || {}, droneModelDistribution: data.droneModelDistribution || {},
routeDistribution: data.routeDistribution || [] routeDistribution: data.routeDistribution || []
}); });
}, },
@ -627,7 +748,7 @@ export default {
data: xAxisData, data: xAxisData,
axisTick: { axisTick: {
show: true, show: true,
inside: true, // inside: true,
}, },
axisLabel: { axisLabel: {
rotate: xAxisData.length > 10 ? 45 : 0, rotate: xAxisData.length > 10 ? 45 : 0,
@ -849,30 +970,6 @@ export default {
this.refreshData(); this.refreshData();
}, },
filterStatus(value, row) {
return row.mainOrderStatus === value;
},
getStatusTagType(status) {
switch (status) {
case 0: return 'info'; //
case 1: return 'warning'; //
case 2: return 'success'; //
case 3: return 'danger'; //
default: return '';
}
},
getStatusText(status) {
switch (status) {
case 0: return '未开始';
case 1: return '进行中';
case 2: return '已完成';
case 3: return '已取消';
default: return '未知状态';
}
},
handleViewDetail(row) { handleViewDetail(row) {
this.$router.push({ this.$router.push({
path: '/order/detail', path: '/order/detail',
@ -989,7 +1086,6 @@ export default {
} }
.filter-label { .filter-label {
font-size: 14px; font-size: 14px;
color: #666;
margin-right: 12px; margin-right: 12px;
} }
@ -1106,4 +1202,5 @@ export default {
.content-box { padding: 16px } .content-box { padding: 16px }
.chart-wrapper { height: 280px } .chart-wrapper { height: 280px }
} }
</style> </style>