fix(schema): 自动新增默认行修复

This commit is contained in:
baiqi 2024-07-16 11:14:42 +08:00 committed by 刘瑞斌
parent a445c6e83e
commit 89fef39731
2 changed files with 13 additions and 2 deletions

View File

@ -535,6 +535,10 @@
emit('selectAll', checked);
}
defineExpose({
validateAndUpdateErrorMessageList,
});
await initColumns();
</script>

View File

@ -1,5 +1,6 @@
<template>
<MsFormTable
ref="formTableRef"
v-model:originalSelectedKeys="selectedKeys"
v-model:expanded-keys="expandKeys"
:data="data"
@ -617,7 +618,6 @@
const selectedKeys = defineModel<string[]>('selectedKeys', {
default: () => ['root'],
});
const rowSelection = computed<TableRowSelection | undefined>(() => {
if (props.disabled) {
return undefined;
@ -629,6 +629,7 @@
width: 32,
};
});
const formTableRef = ref<InstanceType<typeof MsFormTable>>();
//
watchEffect(() => {
@ -963,7 +964,13 @@
}
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]);
}
emitChange('titleInput');