Skip to content

Commit

Permalink
fix: 修复带.多层级在使用editDefaultValue时赋值无效,修复使用过see之后,再使用edit表单仍处于禁用状态
Browse files Browse the repository at this point in the history
  • Loading branch information
kanyxmo committed Aug 2, 2024
1 parent d8183c1 commit de2c0c5
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions src/components/ma-crud/components/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,30 +225,35 @@ const columnItemHandle = async (item) => {
layoutColumns.value.set(item.dataIndex, item)
formColumns.value.push(item)

if (options.formOption.viewType !== 'tag') {
// 针对带点的数据处理
if (item.dataIndex && item.dataIndex.indexOf('.') > -1) {
form.value[item.dataIndex] = get(form.value, item.dataIndex)
}
await Promise.all(async () => {
if (options.formOption.viewType !== 'tag') {
// 针对带点的数据处理
if (item.dataIndex && item.dataIndex.indexOf('.') > -1) {
form.value[item.dataIndex] = get(form.value, item.dataIndex)
}

// add 默认值处理
if (currentAction.value === 'add') {
if (item.addDefaultValue && isFunction(item.addDefaultValue)) {
form.value[item.dataIndex] = await item.addDefaultValue(form.value)
} else if (typeof item.addDefaultValue != 'undefined') {
form.value[item.dataIndex] = item.addDefaultValue
// add 默认值处理
if (currentAction.value === 'add') {
if (item.addDefaultValue && isFunction(item.addDefaultValue)) {
form.value[item.dataIndex] = await item.addDefaultValue(form.value)
} else if (typeof item.addDefaultValue != 'undefined') {
form.value[item.dataIndex] = item.addDefaultValue
}
}
}
// editsee 默认值处理
if (currentAction.value === 'edit' || currentAction.value === 'see') {
if (item.editDefaultValue && isFunction(item.editDefaultValue)) {
form.value[item.dataIndex] = await item.editDefaultValue(form.value)
} else if (typeof item.editDefaultValue != 'undefined') {
form.value[item.dataIndex] = item.editDefaultValue
// edit 和 see 默认值处理
if (currentAction.value === 'edit' || currentAction.value === 'see') {
if (item.editDefaultValue && isFunction(item.editDefaultValue)) {
form.value[item.dataIndex] = await item.editDefaultValue(form.value)
} else if (typeof item.editDefaultValue != 'undefined') {
form.value[item.dataIndex] = item.editDefaultValue
}
}
}
}
})

item.disabled = undefined
item.readonly = undefined
await nextTick()
// 其他处理
item.display = formItemShow(item)
item.disabled = formItemDisabled(item)
Expand Down Expand Up @@ -355,6 +360,9 @@ const formItemReadonly = (item) => {
if (currentAction.value === 'edit' && ! isUndefined(item.editReadonly)) {
return isFunction(item.editReadonly) ? item.editReadonly(form.value) : item.editReadonly
}
if (currentAction.value === 'see') {
return true
}
if (! isUndefined(item.readonly)) {
return item.readonly
}
Expand Down

0 comments on commit de2c0c5

Please sign in to comment.