feat(crm): 新增配卷相关API并重构合同、销售员页面的配卷管理

1.  新增crm/coil.js封装配卷相关接口,包括列表查询和统计汇总
2.  重构合同页面:移除冗余的coilList状态,改用分页API加载生产成果和发货配卷数据,新增分页和统计展示
3.  重构销售员页面:改用独立分页API获取生产成果和计划发货数据,新增分页、加载状态和全局统计
4.  升级CoilTable组件:支持分页功能和双维度统计(本页/全部)
This commit is contained in:
2026-06-30 14:38:58 +08:00
parent 81dec034b3
commit 524f8f3333
5 changed files with 362 additions and 108 deletions

View File

@@ -76,10 +76,18 @@
<DeliveryTable :data="waybillList" table-height="calc(100vh - 240px)" />
</el-tab-pane>
<el-tab-pane label="生产成果" name="production">
<CoilTable :data="productList || []" table-height="calc(100vh - 240px)" />
<div v-loading="productCoilLoading">
<CoilTable :data="productList || []" table-height="calc(100vh - 240px)"
:pagination="productPagination" :total-statistics="productTotalStatistics"
@page-change="handleProductPageChange" />
</div>
</el-tab-pane>
<el-tab-pane label="计划发货" name="planDelivery">
<CoilTable :data="deliveryList || []" table-height="calc(100vh - 240px)" />
<div v-loading="deliveryCoilLoading">
<CoilTable :data="deliveryList || []" table-height="calc(100vh - 240px)"
:pagination="deliveryPagination" :total-statistics="deliveryTotalStatistics"
@page-change="handleDeliveryPageChange" />
</div>
</el-tab-pane>
</el-tabs>
</div>
@@ -123,7 +131,7 @@ import DeliveryTable from "../components/DeliveryTable.vue";
import { listDeliveryWaybill } from "@/api/wms/deliveryWaybill";
import { listCustomer } from "@/api/crm/customer";
import { listOrder } from "@/api/crm/order";
import { listDeliveryWaybillDetailBySaleman } from "@/api/wms/deliveryWaybillDetail";
import { listProductCoilsBySalesman, getProductCoilsStatisticsBySalesman, listDeliveryCoilsByPrincipal, getDeliveryCoilsStatisticsByPrincipal } from "@/api/crm/coil";
export default {
name: "Data",
@@ -169,8 +177,20 @@ export default {
activeTab: 'customer',
// 生产成果列表
productList: [],
// 生产成果分页
productPagination: { total: 0, currentPage: 1, pageSize: 20 },
// 生产成果统计
productCoilStatistics: {},
// 生产成果加载
productCoilLoading: false,
// 计划发货列表
deliveryList: [],
// 计划发货分页
deliveryPagination: { total: 0, currentPage: 1, pageSize: 20 },
// 计划发货统计
deliveryCoilStatistics: {},
// 计划发货加载
deliveryCoilLoading: false,
// 发货单据列表
waybillList: [],
// 跟进客户列表
@@ -196,6 +216,24 @@ export default {
rightLoading: false
};
},
computed: {
productTotalStatistics() {
const stats = this.productCoilStatistics;
if (!stats || Object.keys(stats).length === 0) return null;
return {
totalCoils: stats.total_count || 0,
totalNetWeight: stats.total_net_weight || 0
};
},
deliveryTotalStatistics() {
const stats = this.deliveryCoilStatistics;
if (!stats || Object.keys(stats).length === 0) return null;
return {
totalCoils: stats.total_count || 0,
totalNetWeight: stats.total_net_weight || 0
};
}
},
created() {
// const dictId = this.$route.params && this.$route.params.dictId;
const dictId = '2036334758127824897'
@@ -237,6 +275,11 @@ export default {
this.rightLoading = true;
this.selectedItem = row;
this.loadedTabs = {};
// 重置分页
this.productPagination.currentPage = 1;
this.deliveryPagination.currentPage = 1;
this.productCoilStatistics = {};
this.deliveryCoilStatistics = {};
// 只加载当前激活tab的数据
this.loadTabData(this.activeTab, row.dictValue)
},
@@ -289,64 +332,73 @@ export default {
this.rightLoading = false;
});
case 'production':
// 生产成果和contract使用同一个api获取数据
if (this.loadedTabs.contract) {
// 合同数据已加载,直接处理
this.processProductionData();
return Promise.resolve();
} else {
// 合同数据未加载,先请求合同数据
return listOrder({
salesman: dictValue,
pageNum: 1,
pageSize: 10000
}).then(response => {
this.rawOrderList = response.rows;
this.orderList = response.rows;
this.loadedTabs.contract = true;
this.processProductionData();
}).catch(() => {
this.rightLoading = false;
});
}
// 使用独立的分页接口
return this.fetchProductCoils(dictValue).then(() => {
this.fetchProductCoilStatistics(dictValue);
});
case 'planDelivery':
return listDeliveryWaybillDetailBySaleman({ principal: dictValue, pageNum: 1, pageSize: 10000 }).then(response => {
this.deliveryList = response.rows || [];
this.loadedTabs.planDelivery = true;
this.rightLoading = false;
}).catch(() => {
this.rightLoading = false;
// 使用独立的分页接口
return this.fetchDeliveryCoils(dictValue).then(() => {
this.fetchDeliveryCoilStatistics(dictValue);
});
default:
this.rightLoading = false;
return Promise.resolve();
}
},
processProductionData() {
// 扁平化处理所有合同下的生产成果(coilList)
const allCoils = [];
this.rawOrderList.forEach(order => {
if (order.coilList && Array.isArray(order.coilList)) {
allCoils.push(...order.coilList);
}
fetchProductCoils(salesman) {
this.productCoilLoading = true;
return listProductCoilsBySalesman({
salesman: salesman,
pageNum: this.productPagination.currentPage,
pageSize: this.productPagination.pageSize
}).then(res => {
this.productList = res.rows || [];
this.productPagination.total = res.total || 0;
this.loadedTabs.production = true;
this.rightLoading = false;
}).catch(() => {
this.rightLoading = false;
}).finally(() => {
this.productCoilLoading = false;
});
this.productList = allCoils;
this.loadedTabs.production = true;
this.rightLoading = false;
},
processPlanDeliveryData() {
// 扁平化处理所有合同下的计划发货数据
const allDeliveryCoils = [];
this.rawOrderList.forEach(order => {
if (order.coilList && Array.isArray(order.coilList)) {
// 可以根据需要过滤未发货的钢卷
const deliveryCoils = order.coilList.filter(coil => coil.status !== 1);
allDeliveryCoils.push(...deliveryCoils);
}
fetchProductCoilStatistics(salesman) {
getProductCoilsStatisticsBySalesman(salesman).then(res => {
this.productCoilStatistics = res.data || {};
});
this.deliveryList = allDeliveryCoils;
this.loadedTabs.planDelivery = true;
this.rightLoading = false;
},
fetchDeliveryCoils(principal) {
this.deliveryCoilLoading = true;
return listDeliveryCoilsByPrincipal({
principal: principal,
pageNum: this.deliveryPagination.currentPage,
pageSize: this.deliveryPagination.pageSize
}).then(res => {
this.deliveryList = res.rows || [];
this.deliveryPagination.total = res.total || 0;
this.loadedTabs.planDelivery = true;
this.rightLoading = false;
}).catch(() => {
this.rightLoading = false;
}).finally(() => {
this.deliveryCoilLoading = false;
});
},
fetchDeliveryCoilStatistics(principal) {
getDeliveryCoilsStatisticsByPrincipal(principal).then(res => {
this.deliveryCoilStatistics = res.data || {};
});
},
handleProductPageChange({ currentPage, pageSize }) {
this.productPagination.currentPage = currentPage;
this.productPagination.pageSize = pageSize;
this.fetchProductCoils(this.selectedItem.dictValue);
},
handleDeliveryPageChange({ currentPage, pageSize }) {
this.deliveryPagination.currentPage = currentPage;
this.deliveryPagination.pageSize = pageSize;
this.fetchDeliveryCoils(this.selectedItem.dictValue);
},
// 取消按钮
cancel() {