From 8df728f2d702493436d555ecd939160f8bb9561b Mon Sep 17 00:00:00 2001 From: wuweihua <88888888> Date: Wed, 18 Nov 2026 13:22:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=A1=E8=B4=B9=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=B1=95=E7=A4=BA=E9=80=BB=E8=BE=91=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=20prc=5Fincome=5Fbill=20=E8=BF=87=E6=BB=A4=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/price/BillingController.java | 19 +- .../price/LabelPackageController.java | 2 +- .../com/bms/price/domain/PrcOrderBill.java | 2 + .../com/bms/price/domain/PrcPriceSet.java | 2 + .../bms/price/mapper/LblProductMapper.java | 9 + .../service/impl/LblProductServiceImpl.java | 208 +++++++++++++++++- .../mapper/price/LblProductMapper.xml | 22 +- .../mapper/price/PrcOrderBillMapper.xml | 5 + .../mapper/price/PrcPriceSetMapper.xml | 8 +- .../src/views/price/exclusive/detail.vue | 4 +- .../views/price/exclusive/exclusiveQuote.vue | 8 +- .../label/components/LabelVersionTable.vue | 8 +- bms-front/src/views/price/label/detail.vue | 6 +- .../src/views/price/label/labelPackage.vue | 9 +- .../set/components/create/PriceEditDrawer.vue | 12 +- .../set/components/create/StepDetails.vue | 46 +--- .../create/SurchargePickerDialog.vue | 90 ++++++-- bms-front/src/views/price/set/detail.vue | 4 +- bms-front/src/views/price/set/priceSet.vue | 8 +- .../src/views/price/set/styles/dialog.scss | 12 + 20 files changed, 385 insertions(+), 99 deletions(-) diff --git a/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/BillingController.java b/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/BillingController.java index b1253159..d98a4625 100644 --- a/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/BillingController.java +++ b/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/BillingController.java @@ -2,7 +2,6 @@ package com.bms.web.controller.price; import java.io.ByteArrayInputStream; import java.util.ArrayList; -import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -168,8 +167,9 @@ public class BillingController extends BaseController { query = new PrcOrderBill(); } - // 计费列表只展示计费成功的订单。 - query.setBillingFailStatuses(limitBillingListFailStatus()); + // 计费列表:仅展示 prc_income_bill 存在的订单 + query.setRequireIncomeBill(Boolean.TRUE); + query.setBillingFailStatuses(null); query.setBillingFailStatus(null); startPage(); List list = prcOrderBillService.selectBillList(query); @@ -177,7 +177,7 @@ public class BillingController extends BaseController } /** - * 按当前筛选条件异步导出计费列表(状态限定为成功 success=0)。 + * 按当前筛选条件异步导出计费列表(仅 prc_income_bill 存在)。 * 需至少一个有效筛选条件。轮询任务完成后再下载。 */ @PreAuthorize("@ss.hasPermi('price:billing:export')") @@ -194,7 +194,8 @@ public class BillingController extends BaseController { return error(MessageUtils.message("price.bill.export.filterRequired")); } - query.setBillingFailStatuses(limitBillingListFailStatus()); + query.setRequireIncomeBill(Boolean.TRUE); + query.setBillingFailStatuses(null); query.setBillingFailStatus(null); return successTask(prcOrderBillService.submitOrderBillExport( PrcOrderBillExportTask.TYPE_BILLING, query)); @@ -220,13 +221,7 @@ public class BillingController extends BaseController prcOrderBillService.downloadOrderBillExport(taskId, response); } - private static List limitBillingListFailStatus() - { - // 计费列表仅包含成功数据(billing_fail_status = 0)。 - return new ArrayList(Arrays.asList(Integer.valueOf(0))); - } - - /** 全部 prc_order_bill 记录。计费列表仍限定为状态 0。 */ + /** 全部 prc_order_bill 记录。计费列表按 prc_income_bill 存在过滤。 */ @PreAuthorize("@ss.hasPermi('price:orderBill:list')") @GetMapping("/orderBill/list") public TableDataInfo orderBillList(PrcOrderBill query) diff --git a/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/LabelPackageController.java b/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/LabelPackageController.java index a56c953f..67e6fd05 100644 --- a/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/LabelPackageController.java +++ b/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/LabelPackageController.java @@ -186,7 +186,7 @@ public class LabelPackageController extends BaseController return success(payload); } - @PreAuthorize("@ss.hasPermi('price:label:remove')") + @PreAuthorize("@ss.hasPermi('price:label:edit')") @Log(title = "打单套餐删除版本", businessType = BusinessType.DELETE) @DeleteMapping("/{priceSetId}/versions/{versionNo}") public AjaxResult deleteVersion(@PathVariable Long priceSetId, @PathVariable Integer versionNo) diff --git a/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcOrderBill.java b/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcOrderBill.java index 6fbf94e3..8550a109 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcOrderBill.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcOrderBill.java @@ -129,6 +129,8 @@ public class PrcOrderBill extends BaseEntity private String errorMessage; /** 批量查询:多个计费失败状态(仅查询用,非表字段) */ private List billingFailStatuses; + /** 计费列表:仅返回 prc_income_bill 存在的订单(仅查询用,非表字段) */ + private Boolean requireIncomeBill; private String roundMode; private List incomeFees; diff --git a/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcPriceSet.java b/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcPriceSet.java index 9bd6ed5f..fcfa7f16 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcPriceSet.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcPriceSet.java @@ -39,6 +39,8 @@ public class PrcPriceSet extends BaseEntity private Date expireDate; /** D/A/E/R/S */ private String status; + /** 仅查询用:状态多选(如 D、E) */ + private List statuses; private Long tmsId; private Integer productCount; diff --git a/bms-back/bms-system/src/main/java/com/bms/price/mapper/LblProductMapper.java b/bms-back/bms-system/src/main/java/com/bms/price/mapper/LblProductMapper.java index 0a03db3b..b002e8ad 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/mapper/LblProductMapper.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/mapper/LblProductMapper.java @@ -88,4 +88,13 @@ public interface LblProductMapper int expireOtherActive(@Param("priceSetId") Long priceSetId, @Param("versionNo") Integer versionNo, @Param("endDate") java.util.Date endDate, @Param("operator") String operator); + + /** 恢复指定版本为生效:清空失效时间并将 status 置为 1 */ + int reopenVersionRows(@Param("priceSetId") Long priceSetId, @Param("versionNo") Integer versionNo, + @Param("operator") String operator); + + /** 按生效窗口写回失效时间与状态(整版号) */ + int updateVersionWindowBySetAndNo(@Param("priceSetId") Long priceSetId, @Param("versionNo") Integer versionNo, + @Param("effectiveEnd") java.util.Date effectiveEnd, @Param("status") String status, + @Param("operator") String operator); } \ No newline at end of file diff --git a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/LblProductServiceImpl.java b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/LblProductServiceImpl.java index 3a47407f..d333beeb 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/LblProductServiceImpl.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/LblProductServiceImpl.java @@ -350,6 +350,21 @@ public class LblProductServiceImpl implements ILblProductService { return Collections.emptyList(); } + // 旧数据或历史错误串联时,查询时自动按生效时间重串 + if (labelVersionWindowsNeedRelink(groups)) + { + refreshLabelVersionWindows(priceSetId); + groups = lblProductMapper.selectLabelVersionGroups(priceSetId); + if (groups == null || groups.isEmpty()) + { + return Collections.emptyList(); + } + } + return decorateLabelVersions(priceSetId, groups); + } + + private List decorateLabelVersions(Long priceSetId, List groups) + { Date now = new Date(); for (LabelPackageVersion ver : groups) { @@ -376,9 +391,87 @@ public class LblProductServiceImpl implements ILblProductService ver.setStatus(TERM_EFFECT); } } + // 按生效时间倒序;未设生效时间的待启动版排前 + groups.sort((a, b) -> { + Date ta = a.getEffectiveTime(); + Date tb = b.getEffectiveTime(); + if (ta == null && tb == null) + { + return Integer.compare( + b.getVersionNo() == null ? 0 : b.getVersionNo(), + a.getVersionNo() == null ? 0 : a.getVersionNo()); + } + if (ta == null) + { + return -1; + } + if (tb == null) + { + return 1; + } + int c = tb.compareTo(ta); + if (c != 0) + { + return c; + } + return Integer.compare( + b.getVersionNo() == null ? 0 : b.getVersionNo(), + a.getVersionNo() == null ? 0 : a.getVersionNo()); + }); return groups; } + /** 检查各版失效时间是否已按生效时间升序串联 */ + private boolean labelVersionWindowsNeedRelink(List groups) + { + List timed = new ArrayList(); + for (LabelPackageVersion ver : groups) + { + if (ver != null && ver.getVersionNo() != null && ver.getEffectiveTime() != null) + { + timed.add(ver); + } + } + if (timed.size() <= 1) + { + // 单版若还挂着失效时间,也需清掉 + return timed.size() == 1 && timed.get(0).getExpireTime() != null; + } + timed.sort((a, b) -> { + int c = a.getEffectiveTime().compareTo(b.getEffectiveTime()); + if (c != 0) + { + return c; + } + return Integer.compare( + a.getVersionNo() == null ? 0 : a.getVersionNo(), + b.getVersionNo() == null ? 0 : b.getVersionNo()); + }); + for (int i = 0; i < timed.size(); i++) + { + Date nextStart = (i + 1 < timed.size()) ? timed.get(i + 1).getEffectiveTime() : null; + Date end = timed.get(i).getExpireTime(); + if (!sameLabelTime(end, nextStart)) + { + return true; + } + } + return false; + } + + private static boolean sameLabelTime(Date a, Date b) + { + if (a == null && b == null) + { + return true; + } + if (a == null || b == null) + { + return false; + } + return a.getTime() == b.getTime(); + } + @Override @Transactional(rollbackFor = Exception.class) public String activateVersion(Long priceSetId, Integer versionNo, Date effectiveTime) @@ -389,8 +482,9 @@ public class LblProductServiceImpl implements ILblProductService throw new ServiceException("请指定版本号"); } Date start = effectiveTime == null ? new Date() : effectiveTime; - lblProductMapper.expireOtherActive(priceSetId, versionNo, yesterday(), SecurityUtils.getUsername()); + // 先写入本版生效时间,再按生效时间串联各版失效窗/状态 lblProductMapper.activateVersionRows(priceSetId, versionNo, start, SecurityUtils.getUsername()); + refreshLabelVersionWindows(priceSetId); PrcPriceSet set = priceSetMapper.selectPrcPriceSetById(priceSetId); if (set != null && !"E".equalsIgnoreCase(String.valueOf(set.getStatus()))) { @@ -406,16 +500,116 @@ public class LblProductServiceImpl implements ILblProductService public int deleteVersion(Long priceSetId, Integer versionNo) { assertLabelSet(priceSetId); - List ids = lblProductMapper.selectVersionIdsBySetAndNo(priceSetId, versionNo); - if (ids != null) + if (versionNo == null) { - for (Long versionId : ids) + throw new ServiceException("请指定版本号"); + } + LabelPackageVersion target = null; + for (LabelPackageVersion ver : selectVersions(priceSetId)) + { + if (versionNo.equals(ver.getVersionNo())) { - lblProductMapper.deleteWeightBandsByVersion(versionId); - lblProductMapper.deleteSurchargesByVersion(versionId); + target = ver; + break; } } - return lblProductMapper.deletePendingVersionsBySetAndNo(priceSetId, versionNo); + if (target == null) + { + throw new ServiceException("版本不存在"); + } + String status = target.getStatus(); + // 待生效/已生效可删;已失效仅可查看 + if (!TERM_PENDING.equals(status) && !TERM_EFFECT.equals(status)) + { + throw new ServiceException("已失效版本不可删除"); + } + List ids = lblProductMapper.selectVersionIdsBySetAndNo(priceSetId, versionNo); + if (ids == null || ids.isEmpty()) + { + throw new ServiceException("版本不存在"); + } + for (Long versionId : ids) + { + lblProductMapper.deleteWeightBandsByVersion(versionId); + lblProductMapper.deleteSurchargesByVersion(versionId); + } + int rows = lblProductMapper.deleteAllVersionsBySetAndNo(priceSetId, versionNo); + if (rows <= 0) + { + throw new ServiceException("删除失败,版本不存在或已删除"); + } + // 删除后按生效时间重新串联失效窗,最新窗口自动恢复为生效 + refreshLabelVersionWindows(priceSetId); + return rows; + } + + /** + * 按生效时间升序串联各版:本版失效时间 = 下一版生效时间;最后一版无失效时间。 + * 状态按当前时间落在哪个窗口判定(待生效/已生效/已失效)。 + */ + private void refreshLabelVersionWindows(Long priceSetId) + { + if (priceSetId == null) + { + return; + } + List groups = lblProductMapper.selectLabelVersionGroups(priceSetId); + if (groups == null || groups.isEmpty()) + { + return; + } + List timed = new ArrayList(); + for (LabelPackageVersion ver : groups) + { + if (ver != null && ver.getVersionNo() != null && ver.getEffectiveTime() != null) + { + timed.add(ver); + } + } + timed.sort((a, b) -> { + int c = a.getEffectiveTime().compareTo(b.getEffectiveTime()); + if (c != 0) + { + return c; + } + return Integer.compare( + a.getVersionNo() == null ? 0 : a.getVersionNo(), + b.getVersionNo() == null ? 0 : b.getVersionNo()); + }); + Date now = new Date(); + String operator = safeLabelOperator(); + for (int i = 0; i < timed.size(); i++) + { + LabelPackageVersion ver = timed.get(i); + Date nextStart = (i + 1 < timed.size()) ? timed.get(i + 1).getEffectiveTime() : null; + String status; + Date start = ver.getEffectiveTime(); + if (start.after(now)) + { + status = TERM_PENDING; + } + else if (nextStart != null && !nextStart.after(now)) + { + status = TERM_EXPIRED; + } + else + { + status = TERM_EFFECT; + } + lblProductMapper.updateVersionWindowBySetAndNo(priceSetId, ver.getVersionNo(), nextStart, status, operator); + } + } + + private static String safeLabelOperator() + { + try + { + return SecurityUtils.getUsername(); + } + catch (Exception ex) + { + return "system"; + } } @Override diff --git a/bms-back/bms-system/src/main/resources/mapper/price/LblProductMapper.xml b/bms-back/bms-system/src/main/resources/mapper/price/LblProductMapper.xml index f631e51c..26584130 100644 --- a/bms-back/bms-system/src/main/resources/mapper/price/LblProductMapper.xml +++ b/bms-back/bms-system/src/main/resources/mapper/price/LblProductMapper.xml @@ -165,7 +165,7 @@ from prc_label_product_version where price_set_id = #{priceSetId} group by price_set_id, version_no - order by version_no desc + order by (min(effective_start) is null) desc, min(effective_start) desc, version_no desc @@ -329,4 +329,24 @@ and version_no <> #{versionNo} and status = '1' + + + update prc_label_product_version + set status = '1', + effective_end = null, + updated_by = #{operator}, + update_time = sysdate() + where price_set_id = #{priceSetId} + and version_no = #{versionNo} + + + + update prc_label_product_version + set effective_end = #{effectiveEnd}, + status = #{status}, + updated_by = #{operator}, + update_time = sysdate() + where price_set_id = #{priceSetId} + and version_no = #{versionNo} + \ No newline at end of file diff --git a/bms-back/bms-system/src/main/resources/mapper/price/PrcOrderBillMapper.xml b/bms-back/bms-system/src/main/resources/mapper/price/PrcOrderBillMapper.xml index 2d168b22..ba94f7a3 100644 --- a/bms-back/bms-system/src/main/resources/mapper/price/PrcOrderBillMapper.xml +++ b/bms-back/bms-system/src/main/resources/mapper/price/PrcOrderBillMapper.xml @@ -516,6 +516,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{bfs} + + AND EXISTS ( + SELECT 1 FROM prc_income_bill i WHERE i.bill_id = p.bill_id + ) + AND p.refund_status = #{refundStatus} diff --git a/bms-back/bms-system/src/main/resources/mapper/price/PrcPriceSetMapper.xml b/bms-back/bms-system/src/main/resources/mapper/price/PrcPriceSetMapper.xml index 0a598966..9bf8d4b1 100644 --- a/bms-back/bms-system/src/main/resources/mapper/price/PrcPriceSetMapper.xml +++ b/bms-back/bms-system/src/main/resources/mapper/price/PrcPriceSetMapper.xml @@ -80,7 +80,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND ifnull(s.set_category, 'PACKAGE') = #{setCategory} - + + AND s.status in + + #{st} + + + AND s.status = #{status} diff --git a/bms-front/src/views/price/exclusive/detail.vue b/bms-front/src/views/price/exclusive/detail.vue index 0c6f0ff7..10eaa709 100644 --- a/bms-front/src/views/price/exclusive/detail.vue +++ b/bms-front/src/views/price/exclusive/detail.vue @@ -504,8 +504,10 @@ onActivated(() => { syncFromRoute(pendingRefresh.value) }) -// 组件已处于激活状态时路由 query 变化的兜底 +// 仅当前路由就是本详情页时才响应 query; +// 避免 keep-alive 缓存的另一个详情页(普通/专属)误用对方 API 导致「套餐不存在」 watch(() => route.query.priceSetId, () => { + if (route.path !== mod.routes.detail) return syncFromRoute(false) }) diff --git a/bms-front/src/views/price/exclusive/exclusiveQuote.vue b/bms-front/src/views/price/exclusive/exclusiveQuote.vue index f5b978d9..ba2c1b70 100644 --- a/bms-front/src/views/price/exclusive/exclusiveQuote.vue +++ b/bms-front/src/views/price/exclusive/exclusiveQuote.vue @@ -5,6 +5,7 @@ :columns="columns" :search-columns="searchColumns" :query="queryList" + :default-params="defaultParams" row-key="priceSetId" > @@ -154,9 +154,11 @@ function canReschedule(row) { return row && String(row.status) === '0' && hasEffectiveTime(row) } -/** 仅待生效可删除整版 */ +/** 待生效/已生效可删;已失效不展示删除 */ function canDelete(row) { - return row && String(row.status) === '0' + if (!row) return false + const s = String(row.status ?? '') + return s === '0' || s === '1' } diff --git a/bms-front/src/views/price/label/detail.vue b/bms-front/src/views/price/label/detail.vue index 8fc5eab6..2f627349 100644 --- a/bms-front/src/views/price/label/detail.vue +++ b/bms-front/src/views/price/label/detail.vue @@ -285,7 +285,11 @@ function openEditVersion(row) { function removeVersion(row) { if (!priceSetId.value || !row?.versionNo) return const label = row.versionLabel || ('V' + row.versionNo) - proxy.$modal.confirm('确认删除待生效版本 ' + label + '?该版产品价卡将一起清除。').then(() => { + const isEffect = String(row.status) === '1' + const tip = isEffect + ? ('确认删除版本 ' + label + '?该版产品价卡将一起清除,且上一周期将自动恢复为生效。') + : ('确认删除版本 ' + label + '?该版产品价卡将一起清除。') + proxy.$modal.confirm(tip).then(() => { return deleteLabelVersion(priceSetId.value, row.versionNo) }).then(() => { proxy.$modal.msgSuccess('版本已删除') diff --git a/bms-front/src/views/price/label/labelPackage.vue b/bms-front/src/views/price/label/labelPackage.vue index 0a6ecbdc..77ccad57 100644 --- a/bms-front/src/views/price/label/labelPackage.vue +++ b/bms-front/src/views/price/label/labelPackage.vue @@ -5,6 +5,7 @@ :columns="columns" :search-columns="searchColumns" :query="queryList" + :default-params="defaultParams" row-key="priceSetId" > - - - @@ -95,7 +90,7 @@ const props = defineProps({ productName: { type: String, default: '' }, rows: { type: Array, default: () => [] } }) -const emit = defineEmits(['update:modelValue', 'pick-surcharge', 'row-change', 'surcharge-change']) +const emit = defineEmits(['update:modelValue', 'row-change', 'surcharge-change']) const keyword = ref('') const editingKey = ref('') @@ -115,7 +110,6 @@ const colWeight = '重量段' const colSetFv = '套餐运费' const colSetReg = '套餐挂号费' const colSurcharge = '附加费' -const colAction = '操作' function cellKey(row, field) { if (!row) return 'none:' + field @@ -171,10 +165,6 @@ async function commitEdit(row, field) { } } -function pickSurcharge(row) { - emit('pick-surcharge', row || null) -} - function removeSurcharge(row, sc) { if (!row || !sc || sc.scId == null) return const scId = String(sc.scId) diff --git a/bms-front/src/views/price/set/components/create/StepDetails.vue b/bms-front/src/views/price/set/components/create/StepDetails.vue index 3e7c4098..a4b9a598 100644 --- a/bms-front/src/views/price/set/components/create/StepDetails.vue +++ b/bms-front/src/views/price/set/components/create/StepDetails.vue @@ -146,7 +146,6 @@ :rows="editRows" @row-change="onRowPriceChange" @surcharge-change="onRowSurchargeChange" - @pick-surcharge="openSurchargeFromDrawer" /> rowScopeKey(r) === scScopeKey.value) - : scRows.value - scScopeName.value = scopeName || (scScopeKey.value - ? ((targets[0] && rowScopeLabel(targets[0])) || '') - : '') + scScopeKey.value = null + scScopeName.value = '' + const targets = scRows.value scList.value = props.refData.allSurchargeConfigs() const picked = new Set() targets.forEach(r => { @@ -1017,25 +1001,17 @@ async function openSurcharge(row, scopeKey, scopeName) { }) }) scPickedIds.value = [...picked] - scTitle.value = row.productCode - + (scScopeName.value ? ' · ' + scScopeName.value : '') - + ' · 附加费' + scTitle.value = row.productCode + ' · 附加费' scVisible.value = true } /** - * 勾选结果写回:行级只改该行(国家+重量段),产品级覆盖该产品全部明细行;同一附加费只留一条。 - * - * 校验口径:附加费的 country_code 是它自身的计费适用国家(如「燃油附加费 RO」仅对罗马 - * 尼亚计费),勾选挂载时【按目标明细行的国家做适用性校验】——国家码不匹配的附加费 - * 不落到该行(该行计费时也不会命中它,见 TmsPriceQuoteServiceImpl.surchargeApplies), - * 并统计不匹配数提示用户。country_code 为空 = 全部国家,直接适用。 + * 勾选结果写回该产品全部明细行;同一附加费只留一条。 + * 按明细行国家做适用性校验:country_code 不匹配则该行不落;为空=全部国家。 */ function onSurchargeConfirm(picked) { const ids = new Set((picked || []).map(s => String(s.scId))) - const targets = scScopeKey.value - ? scRows.value.filter(r => rowScopeKey(r) === scScopeKey.value) - : scRows.value + const targets = scRows.value let applied = 0 let skipped = 0 targets.forEach(r => { diff --git a/bms-front/src/views/price/set/components/create/SurchargePickerDialog.vue b/bms-front/src/views/price/set/components/create/SurchargePickerDialog.vue index 6b838c75..84b37a2c 100644 --- a/bms-front/src/views/price/set/components/create/SurchargePickerDialog.vue +++ b/bms-front/src/views/price/set/components/create/SurchargePickerDialog.vue @@ -7,13 +7,21 @@ class="ps-dialog" >
- 共 {{ rows.length }} 项附加费配置,勾选后写入所选范围的明细行 +
+ + 共 {{ filteredRows.length }} 项附加费配置(全部 {{ rows.length }} 项),勾选后写入所选范围的明细行 +
已选 {{ picked.length }} 项
/** - * 套餐 · 附加费勾选弹窗(新建流程第 3 步) + * 套餐 · 附加费勾选弹窗(新建流程第 3 步 / 专属报价详情) * - * 数据来源:产品已关联的附加费配置(prc_surcharge_rel ∩ prc_surcharge), - * 与明细表格里「附加费」列展示的口径一致;勾选结果由父级写回该产品的明细行。 + * 数据来源:附加费配置主表全量;勾选结果由父级写回明细行。 + * 搜索仅过滤列表展示,已勾选项在筛选后仍保留。 */ import { formatChargeValue, surchargeScopeLabel } from '../../utils/priceSet' @@ -63,7 +71,9 @@ const props = defineProps({ const emit = defineEmits(['update:modelValue', 'confirm']) const tableRef = ref() -const picked = ref([]) +const keyword = ref('') +const pickedIds = ref(new Set()) +const syncing = ref(false) const visible = computed({ get: () => props.modelValue, @@ -107,19 +117,59 @@ function chargeTypeLabel(val) { return chargeTypeLabelMap[val] || chargeTypeLabelMap[String(val).toUpperCase()] || val } +const filteredRows = computed(() => { + const text = String(keyword.value || '').trim().toLowerCase() + const list = rows.value || [] + if (!text) return list + return list.filter(row => { + const bag = [ + row.scName, + chargeTypeLabel(row.chargeType), + row.chargeType, + row.scopeText, + row.chargeValue, + row.currency + ].map(v => String(v ?? '').toLowerCase()) + return bag.some(item => item.includes(text)) + }) +}) + +const picked = computed(() => { + const ids = pickedIds.value + return (rows.value || []).filter(row => row?.scId != null && ids.has(String(row.scId))) +}) + function onSelectionChange(selection) { - picked.value = selection + if (syncing.value) return + const visibleIds = new Set((filteredRows.value || []).map(row => String(row.scId))) + const next = new Set(pickedIds.value) + for (const id of visibleIds) { + next.delete(id) + } + for (const row of selection || []) { + if (row?.scId != null) next.add(String(row.scId)) + } + pickedIds.value = next } -/** 确定:以表格当前选中为准(回显/重渲染可能清掉 selection,不能只信 selection-change 的快照) */ -function submit() { +function restoreSelection() { const table = tableRef.value - let list = picked.value - if (table && typeof table.getSelection === 'function') { - const cur = table.getSelection() || [] - if (cur.length || !list.length) list = cur + if (!table) return + syncing.value = true + table.clearSelection() + for (const row of filteredRows.value || []) { + if (row?.scId != null && pickedIds.value.has(String(row.scId))) { + table.toggleRowSelection(row, true) + } } - emit('confirm', list) + nextTick(() => { + syncing.value = false + }) +} + +/** 确定:以当前已选 scId 为准(筛选隐藏行仍保留) */ +function submit() { + emit('confirm', picked.value) visible.value = false } @@ -130,15 +180,17 @@ function applySelection(ids, tries) { if ((tries || 0) < 5) nextTick(() => applySelection(ids, (tries || 0) + 1)) return } - table.clearSelection() - rows.value.forEach(row => { - table.toggleRowSelection(row, ids.includes(String(row.scId))) - }) - picked.value = rows.value.filter(row => ids.includes(String(row.scId))) + pickedIds.value = new Set(ids) + restoreSelection() } +watch(keyword, () => { + nextTick(() => restoreSelection()) +}) + watch(() => props.modelValue, v => { if (!v) return + keyword.value = '' const ids = (props.selectedIds || []).map(id => String(id)) nextTick(() => applySelection(ids, 0)) }) diff --git a/bms-front/src/views/price/set/detail.vue b/bms-front/src/views/price/set/detail.vue index 46a9ba09..7eba1e55 100644 --- a/bms-front/src/views/price/set/detail.vue +++ b/bms-front/src/views/price/set/detail.vue @@ -521,8 +521,10 @@ onActivated(() => { syncFromRoute(pendingRefresh.value) }) -// 组件已处于激活状态时路由 query 变化的兜底 +// 仅当前路由就是本详情页时才响应 query; +// 避免 keep-alive 缓存的另一个详情页(普通/专属)误用对方 API 导致「套餐不存在」 watch(() => route.query.priceSetId, () => { + if (route.path !== mod.routes.detail) return syncFromRoute(false) }) diff --git a/bms-front/src/views/price/set/priceSet.vue b/bms-front/src/views/price/set/priceSet.vue index 9b358daa..6b29e903 100644 --- a/bms-front/src/views/price/set/priceSet.vue +++ b/bms-front/src/views/price/set/priceSet.vue @@ -5,6 +5,7 @@ :columns="columns" :search-columns="searchColumns" :query="queryList" + :default-params="defaultParams" row-key="priceSetId" >