forked from opentiny/tiny-engine
fix(plugin-dataSource): 修复数据源面板新增时未校验名称的重复性 (#434)
This commit is contained in:
parent
4864fb66c5
commit
7d965fceee
|
@ -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"
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue