fix(schema): 自动新增默认行修复
This commit is contained in:
parent
a445c6e83e
commit
89fef39731
|
@ -535,6 +535,10 @@
|
||||||
emit('selectAll', checked);
|
emit('selectAll', checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
validateAndUpdateErrorMessageList,
|
||||||
|
});
|
||||||
|
|
||||||
await initColumns();
|
await initColumns();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<MsFormTable
|
<MsFormTable
|
||||||
|
ref="formTableRef"
|
||||||
v-model:originalSelectedKeys="selectedKeys"
|
v-model:originalSelectedKeys="selectedKeys"
|
||||||
v-model:expanded-keys="expandKeys"
|
v-model:expanded-keys="expandKeys"
|
||||||
:data="data"
|
:data="data"
|
||||||
|
@ -617,7 +618,6 @@
|
||||||
const selectedKeys = defineModel<string[]>('selectedKeys', {
|
const selectedKeys = defineModel<string[]>('selectedKeys', {
|
||||||
default: () => ['root'],
|
default: () => ['root'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const rowSelection = computed<TableRowSelection | undefined>(() => {
|
const rowSelection = computed<TableRowSelection | undefined>(() => {
|
||||||
if (props.disabled) {
|
if (props.disabled) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -629,6 +629,7 @@
|
||||||
width: 32,
|
width: 32,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
const formTableRef = ref<InstanceType<typeof MsFormTable>>();
|
||||||
|
|
||||||
// 初始化根节点
|
// 初始化根节点
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
|
@ -963,7 +964,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function addLineIfLast(record: TableData, rowIndex: number) {
|
function addLineIfLast(record: TableData, rowIndex: number) {
|
||||||
if (rowIndex === (record.parent || data.value[0]).children.length - 1) {
|
formTableRef.value?.validateAndUpdateErrorMessageList(); // 输入名称,校验重复名
|
||||||
|
const firstLevelLastChild = data.value[0].children?.[data.value[0].children.length - 1]; // root 的最后一个子节点
|
||||||
|
// 当前输入的是最后一行,且 root 的最后一个子节点不是默认行数据,则自动新增一行默认数据
|
||||||
|
if (
|
||||||
|
rowIndex === (record.parent || data.value[0]).children.length - 1 &&
|
||||||
|
(firstLevelLastChild?.title !== '' || firstLevelLastChild?.type !== 'string')
|
||||||
|
) {
|
||||||
addChild(data.value[0]);
|
addChild(data.value[0]);
|
||||||
}
|
}
|
||||||
emitChange('titleInput');
|
emitChange('titleInput');
|
||||||
|
|
Loading…
Reference in New Issue