fix: #579 (codex)

This commit is contained in:
2026-05-24 15:07:56 +08:00
parent 926c1f68e3
commit 232577caaa
2 changed files with 268 additions and 195 deletions

View File

@@ -551,7 +551,7 @@ function handleTotalAmount() {
// 表格合并行方法(纯函数,不修改数据)
const arraySpanMethod = ({ row, column, rowIndex, columnIndex }) => {
// 仅处理科室columnIndex === 1的门诊号合并
// 合并门诊号columnIndex === 1
if (columnIndex === 1) {
const spanInfo = rowSpanMap.value[rowIndex];
if (spanInfo) {
@@ -694,8 +694,8 @@ function getList(type) {
: '0.0000' + (k.quantityUnit_dictText ? k.quantityUnit_dictText : '');
});
// 处理搜索关键词时的合计
if (queryParams.value.searchKey) {
// 处理搜索关键词或单页数据
if (queryParams.value.searchKey || (total.value && total.value <= queryParams.value.pageSize)) {
// 先处理小计行和合并信息
purchaseinventoryList.value = processListWithSubtotals(purchaseinventoryList.value);
@@ -706,42 +706,24 @@ function getList(type) {
});
totalPrice2 = totalPrice2 ? totalPrice2.toFixed(4) : totalPrice2;
purchaseinventoryList.value.push({ departmentName: '合计', totalPrice: totalPrice2 });
loading.value = false;
return;
}
// 处理分页数据
purchaseinventoryList.value.forEach((k) => {
if (total.value && total.value <= queryParams.value.pageSize) {
totalPrice2 += Number(k.totalPrice);
}
});
if (total.value <= res.data.size) {
loading.value = false;
}
// 单页数据合计
if (total.value && total.value <= queryParams.value.pageSize) {
// 先处理小计行和合并信息
purchaseinventoryList.value = processListWithSubtotals(purchaseinventoryList.value);
totalPrice2 = totalPrice2 ? totalPrice2.toFixed(4) : totalPrice2;
let pageNoAll = total.value / queryParams.value.pageSize;
if (Math.ceil(pageNoAll) == queryParams.value.pageNo) {
purchaseinventoryList.value.push({ departmentName: '合计', totalPrice: totalPrice2 });
rowSpanMap.value[purchaseinventoryList.value.length - 1] = { rowspan: 1, colspan: 1 };
}
}
// 多页数据处理
if (total.value && total.value > queryParams.value.pageSize && !queryParams.value.searchKey) {
loading.value = false;
} else if (total.value && total.value > queryParams.value.pageSize && !queryParams.value.searchKey) {
// 多页数据先处理当前页数据确保rowSpanMap正确初始化避免表格格式错乱
purchaseinventoryList.value = processListWithSubtotals(purchaseinventoryList.value);
loading.value = false;
// 然后获取全部数据进行完整处理
let queryParamsValue = { ...queryParams.value };
queryParamsValue.pageSize = total.value;
queryParamsValue.pageNo = 1;
// 移除空值参数
Object.keys(queryParamsValue).forEach(key => {
if (queryParamsValue[key] === undefined || queryParamsValue[key] === null || queryParamsValue[key] === '') {
delete queryParamsValue[key];
@@ -762,15 +744,14 @@ function getList(type) {
totalPrice2 += Number(k.totalPrice);
});
// 用 processListWithSubtotals 统一处理小计和合并行
purchaseinventoryList.value = processListWithSubtotals(purchaseinventoryListAll.value);
totalPrice2 = totalPrice2 ? totalPrice2.toFixed(4) : totalPrice2;
loading.value = false;
let pageNoAll = total.value / queryParams.value.pageSize;
if (Math.ceil(pageNoAll) == queryParams.value.pageNo) {
purchaseinventoryList.value.push({ departmentName: '合计', totalPrice: totalPrice2 });
rowSpanMap.value[purchaseinventoryList.value.length - 1] = { rowspan: 1, colspan: 1 };
}
}
});