fix(plugin-dataSource): 修复数据源面板新增时未校验名称的重复性 (#434)

This commit is contained in:
tianxin 2024-04-23 08:55:31 +08:00 committed by GitHub
parent 4864fb66c5
commit 7d965fceee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -23,6 +23,7 @@
<data-source-field-type @cancel="closeFieldType" @select="selectFieldType"></data-source-field-type>
<data-source-field-form
ref="fieldForm"
:modelValue="modelValue"
:field="state.field"
:editable="true"
:is-open="false"

View File

@ -66,6 +66,10 @@ export default {
isOpen: {
type: Boolean,
default: true
},
modelValue: {
type: Array,
default: () => []
}
},
emits: ['save', 'cancel'],
@ -98,7 +102,9 @@ export default {
const handleCancel = () => {
emit('cancel')
}
const uniqueName = () => {
return props.modelValue.some((item) => item.name === state.field.name)
}
const saveField = () => {
form.value.validate((valid) => {
if (valid) {
@ -116,6 +122,10 @@ export default {
return
}
if (uniqueName() && rule.field === 'name') {
callback(new Error('该字段已存在,请重新输入'))
return
}
callback()
}