fix(接口场景): 场景参数默认行

This commit is contained in:
baiqi 2024-06-26 18:20:20 +08:00 committed by 刘瑞斌
parent 157758ea45
commit 2243142491
3 changed files with 10 additions and 8 deletions

View File

@ -926,12 +926,14 @@
} }
return item; return item;
}); });
const { lastDataIsDefault } = filterKeyValParams(arr, defaultLineData.value, false);
if ( if (
(arr.length === 1 && !lastDataIsDefault) ||
(hasNoIdItem &&
!props.disabledExceptParam && !props.disabledExceptParam &&
!props.disabledParamValue && !props.disabledParamValue &&
hasNoIdItem && !lastDataIsDefault &&
!filterKeyValParams(arr, defaultLineData.value, !props.selectable).lastDataIsDefault && !props.isTreeTable)
!props.isTreeTable
) { ) {
addTableLine(arr.length - 1, false, true); addTableLine(arr.length - 1, false, true);
} }

View File

@ -173,7 +173,7 @@ export function filterKeyValParams<T>(
const defaultParam = cloneDeep(defaultParamItem); const defaultParam = cloneDeep(defaultParamItem);
if (!lastData || !defaultParam) { if (!lastData || !defaultParam) {
return { return {
lastDataIsDefault: false, lastDataIsDefault: true,
validParams: params, validParams: params,
}; };
} }

View File

@ -234,7 +234,7 @@ export function initFormCreate(customFields: CustomAttributes[], permission: str
currentDefaultValue = item.defaultValue; currentDefaultValue = item.defaultValue;
// 处理多选情况 // 处理多选情况
} else if (multipleType.includes(item.type)) { } else if (multipleType.includes(item.type)) {
const tempValue = JSON.parse(item.defaultValue); const tempValue = typeof item.defaultValue === 'string' ? JSON.parse(item.defaultValue) : item.defaultValue;
const optionsIds = optionsValue.map((e: any) => e.value); const optionsIds = optionsValue.map((e: any) => e.value);
currentDefaultValue = (optionsIds || []).filter((e: any) => tempValue.includes(e)); currentDefaultValue = (optionsIds || []).filter((e: any) => tempValue.includes(e));
} else if (memberType.includes(item.type)) { } else if (memberType.includes(item.type)) {
@ -248,7 +248,7 @@ export function initFormCreate(customFields: CustomAttributes[], permission: str
// @desc 如果默认原本的成员被系统移除则过滤掉该用户不展示 // @desc 如果默认原本的成员被系统移除则过滤掉该用户不展示
const optionsIds = optionsValue.map((e: any) => e.value); const optionsIds = optionsValue.map((e: any) => e.value);
if (item.type === 'MULTIPLE_MEMBER') { if (item.type === 'MULTIPLE_MEMBER') {
const tempValue = JSON.parse(item.defaultValue); const tempValue = typeof item.defaultValue === 'string' ? JSON.parse(item.defaultValue) : item.defaultValue;
currentDefaultValue = (optionsIds || []).filter((e: any) => tempValue.includes(e)); currentDefaultValue = (optionsIds || []).filter((e: any) => tempValue.includes(e));
} else { } else {
currentDefaultValue = (optionsIds || []).find((e: any) => item.defaultValue === e) || ''; currentDefaultValue = (optionsIds || []).find((e: any) => item.defaultValue === e) || '';