This commit is contained in:
2025-10-05 03:09:15 +08:00
parent 57f1a7f121
commit f36dc4f3d3
15 changed files with 1479 additions and 612 deletions

View File

@@ -1,109 +1,185 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="京粉账号" prop="unionId">
<el-select v-model="queryParams.unionId" placeholder="请选择京粉账号" clearable style="width: 240px">
<el-option
v-for="admin in adminList"
:key="admin.value || admin.id"
:label="admin.label || (admin.name + ' (' + admin.wxid + ')')"
:value="admin.value || admin.id"
/>
</el-select>
</el-form-item>
<el-form-item label="订单号" prop="orderId">
<el-input v-model="queryParams.orderId" placeholder="请输入订单号" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="商品名称" prop="skuName">
<el-input v-model="queryParams.skuName" placeholder="请输入商品名称" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="订单状态" prop="statusGroup">
<el-select v-model="queryParams.statusGroup" placeholder="订单状态" clearable style="width: 240px">
<el-option v-for="status in mergedStatusList" :key="status.value" :label="status.label" :value="status.value" />
</el-select>
</el-form-item>
<el-form-item label="订单时间">
<el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 顶部搜索区域 -->
<div class="search-section">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="京粉账号" prop="unionId">
<el-select v-model="queryParams.unionId" placeholder="请选择京粉账号" clearable style="width: 240px">
<el-option
v-for="admin in adminList"
:key="admin.value || admin.id"
:label="admin.label || (admin.name + ' (' + admin.wxid + ')')"
:value="admin.value || admin.id"
/>
</el-select>
</el-form-item>
<el-form-item label="订单号" prop="orderId">
<el-input v-model="queryParams.orderId" placeholder="请输入订单号" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="商品名称" prop="skuName">
<el-input v-model="queryParams.skuName" placeholder="请输入商品名称" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="订单状态" prop="statusGroup">
<el-select v-model="queryParams.statusGroup" placeholder="订单状态" clearable style="width: 240px">
<el-option v-for="status in mergedStatusList" :key="status.value" :label="status.label" :value="status.value" />
</el-select>
</el-form-item>
<el-form-item label="订单时间">
<el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:orderrows:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['system:orderrows:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['system:orderrows:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:orderrows:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 统计悬浮模块 -->
<el-card class="statistics-card" shadow="hover" v-if="orderrowsList.length > 0">
<div slot="header" class="clearfix">
<span><i class="el-icon-data-analysis"></i> 佣金统计</span>
<el-button style="float: right; padding: 3px 0" type="text" @click="toggleStatistics">
{{ showStatistics ? '收起' : '展开' }}
</el-button>
</div>
<div v-show="showStatistics" class="statistics-content">
<el-row :gutter="20">
<el-col :span="6">
<div class="stat-item">
<div class="stat-label">总订单数</div>
<div class="stat-value">{{ statistics.totalOrders }}</div>
</div>
</el-col>
<el-col :span="6">
<div class="stat-item">
<div class="stat-label">总计佣金额</div>
<div class="stat-value">¥{{ statistics.totalCosPrice.toFixed(2) }}</div>
</div>
</el-col>
<el-col :span="6">
<div class="stat-item">
<div class="stat-label">预估佣金</div>
<div class="stat-value">¥{{ statistics.totalEstimateFee.toFixed(2) }}</div>
</div>
</el-col>
<el-col :span="6">
<div class="stat-item">
<div class="stat-label">实际佣金</div>
<div class="stat-value">¥{{ statistics.totalActualFee.toFixed(2) }}</div>
</div>
</el-col>
</el-row>
<el-divider></el-divider>
<el-row :gutter="20">
<el-col :span="12">
<div class="status-stats">
<h4>按状态统计</h4>
<div class="status-list">
<div v-for="(stat, key) in statistics.statusStats" :key="key" class="status-item">
<el-tag :type="getStatusTypeByKey(key)" size="small">{{ stat.label }}</el-tag>
<span class="status-count">{{ stat.count }}</span>
<span class="status-amount">¥{{ stat.amount.toFixed(2) }}</span>
</div>
</div>
</div>
</el-col>
<el-col :span="12">
<div class="account-stats">
<h4>按账号统计</h4>
<div class="account-list">
<div v-for="(stat, unionId) in statistics.accountStats" :key="unionId" class="account-item">
<span class="account-name">{{ getAdminName(unionId) }}</span>
<span class="account-count">{{ stat.count }}</span>
<span class="account-amount">¥{{ stat.amount.toFixed(2) }}</span>
</div>
</div>
</div>
</el-col>
</el-row>
</div>
</el-card>
<el-table v-loading="loading" :data="orderrowsList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="账号" align="center" prop="unionId" width="50">
<template slot-scope="scope">
<span>{{ getAdminName(scope.row.unionId) }}</span>
</template>
</el-table-column>
<el-table-column label="订单号" align="center" prop="orderId" width="120" />
<el-table-column label="商品名称" align="center" prop="skuName" :show-overflow-tooltip="true" min-width="200" />
<el-table-column label="计佣金额" align="center" prop="estimateCosPrice" width="100">
<template slot-scope="scope">
<span>¥{{ scope.row.estimateCosPrice }}</span>
</template>
</el-table-column>
<el-table-column label="商品数量" align="center" prop="skuNum" width="80" />
<el-table-column label="订单状态" align="center" prop="validCode" width="240">
<template slot-scope="scope">
<el-tag :type="getStatusType(scope.row.validCode)">
{{ getStatusText(scope.row.validCode) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="佣金比例" align="center" prop="commissionRate" width="100">
<template slot-scope="scope">
<span>{{ scope.row.commissionRate }}%</span>
</template>
</el-table-column>
<el-table-column label="预估佣金" align="center" prop="estimateFee" width="100">
<template slot-scope="scope">
<span>¥{{ scope.row.estimateFee }}</span>
</template>
</el-table-column>
<el-table-column label="实际佣金" align="center" prop="actualFee" width="100">
<template slot-scope="scope">
<span>¥{{ scope.row.actualFee }}</span>
</template>
</el-table-column>
<el-table-column label="订单时间" align="center" prop="orderTime" width="160">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.orderTime) }}</span>
</template>
</el-table-column>
<el-table-column label="完成时间" align="center" prop="finishTime" width="160">
<template slot-scope="scope">
<span>{{ scope.row.finishTime ? parseTime(scope.row.finishTime) : '-' }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">查看</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:orderrows:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:orderrows:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:orderrows:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['system:orderrows:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['system:orderrows:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:orderrows:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</div>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 表格区域 - 可滚动 -->
<div class="table-section">
<el-table v-loading="loading" :data="orderrowsList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="账号" align="center" prop="unionId" width="50">
<template slot-scope="scope">
<span>{{ getAdminName(scope.row.unionId) }}</span>
</template>
</el-table-column>
<el-table-column label="订单号" align="center" prop="orderId" width="120" />
<el-table-column label="商品名称" align="center" prop="skuName" :show-overflow-tooltip="true" min-width="200" />
<el-table-column label="计佣金额" align="center" prop="estimateCosPrice" width="100">
<template slot-scope="scope">
<span>¥{{ scope.row.estimateCosPrice }}</span>
</template>
</el-table-column>
<el-table-column label="商品数量" align="center" prop="skuNum" width="80" />
<el-table-column label="订单状态" align="center" prop="validCode" width="240">
<template slot-scope="scope">
<el-tag :type="getStatusType(scope.row.validCode)">
{{ getStatusText(scope.row.validCode) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="佣金比例" align="center" prop="commissionRate" width="100">
<template slot-scope="scope">
<span>{{ scope.row.commissionRate }}%</span>
</template>
</el-table-column>
<el-table-column label="预估佣金" align="center" prop="estimateFee" width="100">
<template slot-scope="scope">
<span>¥{{ scope.row.estimateFee }}</span>
</template>
</el-table-column>
<el-table-column label="实际佣金" align="center" prop="actualFee" width="100">
<template slot-scope="scope">
<span>¥{{ scope.row.actualFee }}</span>
</template>
</el-table-column>
<el-table-column label="订单时间" align="center" prop="orderTime" width="160">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.orderTime) }}</span>
</template>
</el-table-column>
<el-table-column label="完成时间" align="center" prop="finishTime" width="160">
<template slot-scope="scope">
<span>{{ scope.row.finishTime ? parseTime(scope.row.finishTime) : '-' }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">查看</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:orderrows:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:orderrows:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<!-- 固定分页区域 -->
<div class="pagination-section">
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
</div>
<!-- 查看订单详情对话框 -->
<el-dialog :title="'订单详情 - ' + currentOrder.orderId" :visible.sync="viewDialogVisible" width="900px" append-to-body>
@@ -263,7 +339,17 @@ export default {
// 查看详情对话框
viewDialogVisible: false,
// 当前查看的订单
currentOrder: {}
currentOrder: {},
// 统计相关
showStatistics: true,
statistics: {
totalOrders: 0,
totalCosPrice: 0,
totalEstimateFee: 0,
totalActualFee: 0,
statusStats: {},
accountStats: {}
}
};
},
created() {
@@ -271,6 +357,23 @@ export default {
this.getAdminList();
this.getStatusList();
},
watch: {
// 监听日期范围变化,自动调整分页条数
dateRange: {
handler(newVal) {
if (newVal && newVal.length === 2) {
// 选择了日期范围设置分页条数为1000
this.queryParams.pageSize = 1000;
this.queryParams.pageNum = 1;
} else {
// 清空日期范围,恢复默认分页条数
this.queryParams.pageSize = 10;
this.queryParams.pageNum = 1;
}
},
deep: true
}
},
methods: {
/** 查询京粉订单列表 */
getList() {
@@ -279,6 +382,8 @@ export default {
this.orderrowsList = response.rows;
this.total = response.total;
this.loading = false;
// 计算统计数据
this.calculateStatistics();
}).catch(error => {
console.error('获取订单列表失败:', error);
this.loading = false;
@@ -446,6 +551,7 @@ export default {
handleQuery() {
this.queryParams.pageNum = 1;
console.log(this.queryParams.validCode);
// 合并项转为原始code数组
if (this.queryParams.statusGroup) {
this.queryParams.validCodes = this.statusValueMap[this.queryParams.statusGroup].map(code => Number(code));
@@ -467,7 +573,10 @@ export default {
this.dateRange = [];
this.resetForm("queryForm");
this.queryParams.validCodes = [];
this.handleQuery();
// 重置时恢复默认分页条数
this.queryParams.pageSize = 10;
this.queryParams.pageNum = 1;
this.getList();
},
// 多选框选中数据
handleSelectionChange(selection) {
@@ -531,7 +640,336 @@ export default {
this.download('/jarvis/orderrows/export', {
...this.queryParams
}, `京粉订单数据_${new Date().getTime()}.xlsx`)
},
/** 切换统计显示 */
toggleStatistics() {
this.showStatistics = !this.showStatistics;
},
/** 计算统计数据 */
calculateStatistics() {
const stats = {
totalOrders: this.orderrowsList.length,
totalCosPrice: 0,
totalEstimateFee: 0,
totalActualFee: 0,
statusStats: {},
accountStats: {}
};
// 状态分组映射
const statusGroups = {
'cancel': { label: '取消', codes: ['3'] },
'invalid': { label: '无效', codes: ['2','4','5','6','7','8','9','10','11','14','19','20','21','22','23','29','30','31','32','33','34'] },
'pending': { label: '待付款', codes: ['15'] },
'paid': { label: '已付款', codes: ['16'] },
'finished': { label: '已完成', codes: ['17'] },
'deposit': { label: '已付定金', codes: ['24'] },
'illegal': { label: '违规', codes: ['25','26','27','28'] }
};
// 初始化状态统计
Object.keys(statusGroups).forEach(key => {
stats.statusStats[key] = {
label: statusGroups[key].label,
count: 0,
amount: 0
};
});
// 遍历订单数据计算统计
this.orderrowsList.forEach(order => {
// 总计佣金额
if (order.estimateCosPrice) {
stats.totalCosPrice += parseFloat(order.estimateCosPrice) || 0;
}
// 预估佣金
if (order.estimateFee) {
stats.totalEstimateFee += parseFloat(order.estimateFee) || 0;
}
// 实际佣金
if (order.actualFee) {
stats.totalActualFee += parseFloat(order.actualFee) || 0;
}
// 按状态统计
const validCode = String(order.validCode);
let statusKey = 'invalid'; // 默认无效
for (const [key, group] of Object.entries(statusGroups)) {
if (group.codes.includes(validCode)) {
statusKey = key;
break;
}
}
stats.statusStats[statusKey].count++;
stats.statusStats[statusKey].amount += parseFloat(order.actualFee) || 0;
// 按账号统计
const unionId = order.unionId;
if (!stats.accountStats[unionId]) {
stats.accountStats[unionId] = {
count: 0,
amount: 0
};
}
stats.accountStats[unionId].count++;
stats.accountStats[unionId].amount += parseFloat(order.actualFee) || 0;
});
this.statistics = stats;
},
/** 根据状态键获取标签类型 */
getStatusTypeByKey(key) {
const typeMap = {
'cancel': 'danger',
'invalid': 'info',
'pending': 'warning',
'paid': 'primary',
'finished': 'success',
'deposit': 'warning',
'illegal': 'danger'
};
return typeMap[key] || 'info';
}
}
};
</script>
</script>
<style scoped>
/* 主容器布局 */
.app-container {
display: flex;
flex-direction: column;
height: calc(100vh - 84px); /* 减去头部导航高度 */
overflow: hidden;
}
/* 搜索区域 - 固定在顶部 */
.search-section {
flex-shrink: 0;
background: #fff;
padding: 20px;
border-bottom: 1px solid #e4e7ed;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
/* 表格区域 - 可滚动 */
.table-section {
flex: 1;
overflow: auto;
padding: 0 20px;
background: #fff;
}
/* 固定分页区域 */
.pagination-section {
flex-shrink: 0;
background: #fff;
padding: 15px 20px;
border-top: 1px solid #e4e7ed;
box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
position: sticky;
bottom: 0;
z-index: 10;
}
/* 统计卡片样式 */
.statistics-card {
margin-bottom: 20px;
border-radius: 8px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
.statistics-card .el-card__header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border-radius: 8px 8px 0 0;
padding: 15px 20px;
}
.statistics-card .el-card__header span {
font-weight: 600;
font-size: 16px;
}
.statistics-card .el-card__header .el-button {
color: white;
font-weight: 500;
}
.statistics-card .el-card__header .el-button:hover {
color: #f0f0f0;
}
.statistics-content {
padding: 20px 0;
}
.stat-item {
text-align: center;
padding: 15px;
background: #f8f9fa;
border-radius: 6px;
margin-bottom: 10px;
transition: all 0.3s ease;
}
.stat-item:hover {
background: #e9ecef;
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.stat-label {
font-size: 14px;
color: #666;
margin-bottom: 8px;
font-weight: 500;
}
.stat-value {
font-size: 24px;
font-weight: bold;
color: #2c3e50;
}
.status-stats, .account-stats {
background: #f8f9fa;
padding: 15px;
border-radius: 6px;
height: 100%;
}
.status-stats h4, .account-stats h4 {
margin: 0 0 15px 0;
color: #2c3e50;
font-size: 16px;
font-weight: 600;
border-bottom: 2px solid #e9ecef;
padding-bottom: 8px;
}
.status-list, .account-list {
max-height: 200px;
overflow-y: auto;
}
.status-item, .account-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 8px 0;
border-bottom: 1px solid #e9ecef;
}
.status-item:last-child, .account-item:last-child {
border-bottom: none;
}
.status-count, .account-count {
font-size: 12px;
color: #666;
background: #e9ecef;
padding: 2px 8px;
border-radius: 12px;
min-width: 40px;
text-align: center;
}
.status-amount, .account-amount {
font-weight: 600;
color: #27ae60;
font-size: 14px;
}
.account-name {
font-weight: 500;
color: #2c3e50;
flex: 1;
margin-right: 10px;
}
/* 滚动条样式 */
.status-list::-webkit-scrollbar, .account-list::-webkit-scrollbar {
width: 4px;
}
.status-list::-webkit-scrollbar-track, .account-list::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 2px;
}
.status-list::-webkit-scrollbar-thumb, .account-list::-webkit-scrollbar-thumb {
background: #c1c1c1;
border-radius: 2px;
}
.status-list::-webkit-scrollbar-thumb:hover, .account-list::-webkit-scrollbar-thumb:hover {
background: #a8a8a8;
}
/* 表格区域滚动条样式 */
.table-section::-webkit-scrollbar {
width: 6px;
height: 6px;
}
.table-section::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 3px;
}
.table-section::-webkit-scrollbar-thumb {
background: #c0c0c0;
border-radius: 3px;
}
.table-section::-webkit-scrollbar-thumb:hover {
background: #a8a8a8;
}
/* 响应式设计 */
@media (max-width: 768px) {
.app-container {
height: calc(100vh - 50px); /* 移动端调整高度 */
}
.search-section {
padding: 15px;
}
.table-section {
padding: 0 15px;
}
.pagination-section {
padding: 10px 15px;
}
.statistics-content .el-col {
margin-bottom: 15px;
}
.stat-item {
padding: 10px;
}
.stat-value {
font-size: 20px;
}
}
/* 确保表格在容器内正确显示 */
.table-section .el-table {
width: 100%;
}
/* 分页组件样式优化 */
.pagination-section .pagination-container {
display: flex;
justify-content: center;
align-items: center;
background: #fff;
border-radius: 4px;
padding: 10px 0;
}
</style>