Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
liuminghui
2026-11-18 13:34:24 +08:00
20 changed files with 385 additions and 99 deletions
@@ -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<PrcOrderBill> 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<Integer> limitBillingListFailStatus()
{
// 计费列表仅包含成功数据(billing_fail_status = 0)。
return new ArrayList<Integer>(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)
@@ -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)
@@ -129,6 +129,8 @@ public class PrcOrderBill extends BaseEntity
private String errorMessage;
/** 批量查询:多个计费失败状态(仅查询用,非表字段) */
private List<Integer> billingFailStatuses;
/** 计费列表:仅返回 prc_income_bill 存在的订单(仅查询用,非表字段) */
private Boolean requireIncomeBill;
private String roundMode;
private List<PrcIncomeBillFee> incomeFees;
@@ -39,6 +39,8 @@ public class PrcPriceSet extends BaseEntity
private Date expireDate;
/** D/A/E/R/S */
private String status;
/** 仅查询用:状态多选(如 D、E) */
private List<String> statuses;
private Long tmsId;
private Integer productCount;
@@ -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);
}
@@ -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<LabelPackageVersion> decorateLabelVersions(Long priceSetId, List<LabelPackageVersion> 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<LabelPackageVersion> groups)
{
List<LabelPackageVersion> timed = new ArrayList<LabelPackageVersion>();
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<Long> 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<Long> 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<LabelPackageVersion> groups = lblProductMapper.selectLabelVersionGroups(priceSetId);
if (groups == null || groups.isEmpty())
{
return;
}
List<LabelPackageVersion> timed = new ArrayList<LabelPackageVersion>();
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
@@ -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
</select>
<insert id="insertWeightBand" useGeneratedKeys="true" keyProperty="bandId">
@@ -329,4 +329,24 @@
and version_no &lt;&gt; #{versionNo}
and status = '1'
</update>
<update id="reopenVersionRows">
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>
<update id="updateVersionWindowBySetAndNo">
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}
</update>
</mapper>
@@ -516,6 +516,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{bfs}
</foreach>
</if>
<if test="requireIncomeBill != null and requireIncomeBill">
AND EXISTS (
SELECT 1 FROM prc_income_bill i WHERE i.bill_id = p.bill_id
)
</if>
<if test="refundStatus != null and refundStatus != ''">
AND p.refund_status = #{refundStatus}
</if>
@@ -80,7 +80,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="setCategory != null and setCategory != ''">
AND ifnull(s.set_category, 'PACKAGE') = #{setCategory}
</if>
<if test="status != null and status != ''">
<if test="statuses != null and statuses.size() &gt; 0">
AND s.status in
<foreach collection="statuses" item="st" open="(" separator="," close=")">
#{st}
</foreach>
</if>
<if test="(statuses == null or statuses.size() == 0) and status != null and status != ''">
AND s.status = #{status}
</if>
<if test="tmsId != null">
@@ -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)
})
@@ -5,6 +5,7 @@
:columns="columns"
:search-columns="searchColumns"
:query="queryList"
:default-params="defaultParams"
row-key="priceSetId"
>
<template #toolbar>
@@ -120,19 +121,22 @@ const auditPerm = [`${mod.permPrefix}:audit`]
const { proxy } = getCurrentInstance()
const tableRef = ref()
const isFirstActivate = ref(true)
/** 默认只看待启用、生效(排除已停用) */
const defaultParams = { statuses: ['D', 'E'] }
const searchColumns = computed(() => [
{
label: '状态',
prop: 'status',
prop: 'statuses',
component: 'select',
options: [
{ label: '待启用', value: 'D' },
{ label: '生效', value: 'E' },
{ label: '已停用', value: 'S' }
],
props: { multiple: true, collapseTags: true, clearable: true },
placeholder: '全部状态',
width: '140px'
width: '200px'
},
{ label: '关键字', prop: 'keyword', component: 'input', placeholder: mod.labels.keywordPlaceholder, width: '200px' },
{ label: '客户', prop: 'customerId', placeholder: '客户名称 / 代码', width: '240px' }
@@ -78,7 +78,7 @@
link
type="danger"
@click="$emit('remove', row)"
v-hasPermi="['price:label:remove']"
v-hasPermi="['price:label:edit']"
>删除</el-button>
</template>
</el-table-column>
@@ -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'
}
</script>
+5 -1
View File
@@ -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('版本已删除')
@@ -5,6 +5,7 @@
:columns="columns"
:search-columns="searchColumns"
:query="queryList"
:default-params="defaultParams"
row-key="priceSetId"
>
<template #toolbar>
@@ -75,18 +76,22 @@ const { proxy } = getCurrentInstance()
const tableRef = ref()
const isFirstActivate = ref(true)
/** 默认只看待启用、生效(排除已停用) */
const defaultParams = { statuses: ['D', 'E'] }
const searchColumns = [
{
label: '状态',
prop: 'status',
prop: 'statuses',
component: 'select',
options: [
{ label: '待启用', value: 'D' },
{ label: '生效', value: 'E' },
{ label: '已停用', value: 'S' }
],
props: { multiple: true, collapseTags: true, clearable: true },
placeholder: '全部状态',
width: '140px'
width: '200px'
},
{ label: '关键字', prop: 'keyword', component: 'input', placeholder: '套餐编码 / 名称', width: '200px' }
]
@@ -75,11 +75,6 @@
<surcharge-count-cell :list="row.surcharges || []" @remove="s => removeSurcharge(row, s)" />
</template>
</el-table-column>
<el-table-column :label="colAction" width="90" align="center">
<template #default="{ row }">
<el-button link type="primary" @click="pickSurcharge(row)">附加费</el-button>
</template>
</el-table-column>
</el-table>
</div>
</div>
@@ -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)
@@ -146,7 +146,6 @@
:rows="editRows"
@row-change="onRowPriceChange"
@surcharge-change="onRowSurchargeChange"
@pick-surcharge="openSurchargeFromDrawer"
/>
<excel-import-dialog
@@ -893,16 +892,6 @@ async function openSurchargeForProduct(row) {
}
}
/** 抽屉里点附加费:带行 = 行级(只改该行,国家+重量段),不带 = 产品级(覆盖全部明细行) */
function openSurchargeFromDrawer(row) {
const group = editGroup.value || { productCode: editCode.value, rows: editRows.value }
if (row && (row.countryCode || row.countryName)) {
openSurcharge(group, rowScopeKey(row), rowScopeLabel(row))
} else {
openSurcharge(group)
}
}
/** persist one detail row to DB immediately (edit mode only) */
async function persistDetail(row, withSurcharge) {
@@ -994,21 +983,16 @@ function rowScopeLabel(r) {
}
/**
* 打开附加费勾选弹窗
* 列表 = 价格基础 → 附加费配置 主表全量(不要求产品已做关联);
* 勾选回显 = 作用范围内明细行当前附加费的并集;
* scopeKey 传行级键时只作用于该行(国家+重量段),不传则产品级全覆盖。
* 打开附加费勾选弹窗(仅产品级:覆盖该产品全部明细行)
* 列表 = 价格基础 → 附加费配置 主表全量;
* 勾选回显 = 该产品明细行当前附加费的并集。
*/
async function openSurcharge(row, scopeKey, scopeName) {
async function openSurcharge(row) {
await props.refData.ensureAllSurcharges()
scRows.value = row.rows || []
scScopeKey.value = scopeKey || null
const targets = scScopeKey.value
? scRows.value.filter(r => 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 => {
@@ -7,13 +7,21 @@
class="ps-dialog"
>
<div class="ps-picker-bar">
<span>共 {{ rows.length }} 项附加费配置,勾选后写入所选范围的明细行</span>
<div class="ps-picker-bar__left">
<el-input
v-model="keyword"
clearable
placeholder="搜索附加费名称、计费方式或作用范围"
class="ps-picker-search"
/>
<span>共 {{ filteredRows.length }} 项附加费配置(全部 {{ rows.length }} 项),勾选后写入所选范围的明细行</span>
</div>
<span class="ps-picker-bar__picked">已选 {{ picked.length }} 项</span>
</div>
<el-table
ref="tableRef"
:data="rows"
:data="filteredRows"
row-key="scId"
border
size="small"
@@ -45,10 +53,10 @@
<script setup name="SurchargePickerDialog">
/**
* 套餐 · 附加费勾选弹窗(新建流程第 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))
})
+3 -1
View File
@@ -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)
})
+6 -2
View File
@@ -5,6 +5,7 @@
:columns="columns"
:search-columns="searchColumns"
:query="queryList"
:default-params="defaultParams"
row-key="priceSetId"
>
<template #toolbar>
@@ -117,19 +118,22 @@ const editPerm = usePriceSetPerm('edit')
const auditPerm = usePriceSetPerm('audit')
const tableRef = ref()
const isFirstActivate = ref(true)
/** 默认只看待启用、生效(排除已停用) */
const defaultParams = { statuses: ['D', 'E'] }
const searchColumns = computed(() => [
{
label: '状态',
prop: 'status',
prop: 'statuses',
component: 'select',
options: [
{ label: '待启用', value: 'D' },
{ label: '生效', value: 'E' },
{ label: '已停用', value: 'S' }
],
props: { multiple: true, collapseTags: true, clearable: true },
placeholder: '全部状态',
width: '140px'
width: '200px'
},
{ label: '关键字', prop: 'keyword', component: 'input', placeholder: mod.labels.keywordPlaceholder, width: '200px' },
{ label: '客户', prop: 'customerId', placeholder: '客户名称 / 代码', width: '240px' }
@@ -223,6 +223,18 @@
font-size: 13px;
color: #606266;
&__left {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
min-width: 0;
}
.ps-picker-search {
width: 280px;
}
&__picked {
flex: none;
padding: 0 8px;