Fix Bug #426: handleMethodSelect/onDetailMethodChange 补充 packageName 套餐解析支持
根因:check_method 表只有 package_name 字段无 package_id,handleMethodSelect 等路径只检查 packageId 导致套餐的 hasChildren、右侧卡片展开、套餐明细加载 全部不生效。补充 6 处 packageId→packageName 兜底检查,使所有选择路径 一致支持 packageName→packageId 解析。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -639,9 +639,9 @@ function getPackageDetailsList(item) {
|
|||||||
return Array.isArray(carrier?.packageDetails) ? carrier.packageDetails : [];
|
return Array.isArray(carrier?.packageDetails) ? carrier.packageDetails : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 有套餐 ID 的已选行才展示右侧套餐区(加载中 / 空 / 明细列表) */
|
/** 有套餐 ID 或 packageName 的已选行才展示右侧套餐区(加载中 / 空 / 明细列表) */
|
||||||
function shouldShowPackageBody(item) {
|
function shouldShowPackageBody(item) {
|
||||||
return !!getPackageCarrier(item)?.packageId;
|
return !!(getPackageCarrier(item)?.packageId || item.packageName || item.packageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 金额展示:统一两位小数 */
|
/** 金额展示:统一两位小数 */
|
||||||
@@ -1381,10 +1381,10 @@ async function handleMethodSelect(checked, method, cat) {
|
|||||||
const existingItem = selectedItems.value.find(s => s.id === targetItem.id);
|
const existingItem = selectedItems.value.find(s => s.id === targetItem.id);
|
||||||
if (existingItem) {
|
if (existingItem) {
|
||||||
existingItem.selectedMethod = method;
|
existingItem.selectedMethod = method;
|
||||||
// 从方法中获取套餐信息
|
// 从方法中获取套餐信息(支持 packageId 或 packageName 解析)
|
||||||
if (method.packageId) {
|
if (method.packageId || method.packageName) {
|
||||||
existingItem.isPackage = true;
|
existingItem.isPackage = true;
|
||||||
existingItem.packageId = method.packageId;
|
existingItem.packageId = method.packageId || existingItem.packageId;
|
||||||
existingItem.hasChildren = true; // #426修复
|
existingItem.hasChildren = true; // #426修复
|
||||||
existingItem.packageName = method.packageName || existingItem.packageName; // #428修复: 确保 packageName 同步
|
existingItem.packageName = method.packageName || existingItem.packageName; // #428修复: 确保 packageName 同步
|
||||||
// 预加载套餐明细
|
// 预加载套餐明细
|
||||||
@@ -1421,12 +1421,12 @@ async function handleMethodSelect(checked, method, cat) {
|
|||||||
isPackage: !!method.packageId || !!targetItem.packageName,
|
isPackage: !!method.packageId || !!targetItem.packageName,
|
||||||
packageId: method.packageId || targetItem.packageId || null,
|
packageId: method.packageId || targetItem.packageId || null,
|
||||||
packageName: method.packageName || targetItem.packageName || null, // #428修复: 复制 packageName,确保套餐明细可加载
|
packageName: method.packageName || targetItem.packageName || null, // #428修复: 复制 packageName,确保套餐明细可加载
|
||||||
hasChildren: !!(method.packageId || targetItem.packageId) // #426修复: 树形表格懒加载展开标记
|
hasChildren: !!(method.packageId || method.packageName || targetItem.packageId || targetItem.packageName) // #426修复: 树形表格懒加载展开标记,支持 packageName 解析
|
||||||
};
|
};
|
||||||
selectedItems.value.push(newItem);
|
selectedItems.value.push(newItem);
|
||||||
|
|
||||||
// 如果是套餐,预加载套餐明细
|
// 如果是套餐,预加载套餐明细
|
||||||
if (newItem.isPackage && newItem.packageId) {
|
if (newItem.isPackage && (newItem.packageId || newItem.packageName)) {
|
||||||
loadPackageDetailsForItem(newItem);
|
loadPackageDetailsForItem(newItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1564,7 +1564,7 @@ async function toggleItemExpand(item) {
|
|||||||
async function selectMethodCheckbox(checked, item, method) {
|
async function selectMethodCheckbox(checked, item, method) {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
item.selectedMethod = method;
|
item.selectedMethod = method;
|
||||||
if (item.expanded && method.packageId) {
|
if (item.expanded && (method.packageId || method.packageName)) {
|
||||||
loadPackageDetailsForItem(item);
|
loadPackageDetailsForItem(item);
|
||||||
}
|
}
|
||||||
// 动态加载该方法对应的套餐明细
|
// 动态加载该方法对应的套餐明细
|
||||||
@@ -1629,8 +1629,9 @@ async function loadMethodPackageDetails(item, method) {
|
|||||||
/** 检查明细表格中切换检查方法 */
|
/** 检查明细表格中切换检查方法 */
|
||||||
async function onDetailMethodChange(row, val) {
|
async function onDetailMethodChange(row, val) {
|
||||||
row.selectedMethod = val || null;
|
row.selectedMethod = val || null;
|
||||||
if (val?.packageId) {
|
if (val?.packageId || val?.packageName) {
|
||||||
row.packageId = val.packageId;
|
row.packageId = val.packageId || row.packageId;
|
||||||
|
row.packageName = val.packageName || row.packageName;
|
||||||
row.isPackage = true;
|
row.isPackage = true;
|
||||||
row.hasChildren = true; // #426修复
|
row.hasChildren = true; // #426修复
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user