mirror of
https://gitee.com/hhyykk/ipms-sjy-ui.git
synced 2025-02-02 03:34:59 +08:00
fix: 添加商品属性值时增加校验,如果是已存在的属性发出警告且不提交
This commit is contained in:
parent
bcb4fc3034
commit
0e9fde1f8a
@ -85,19 +85,9 @@ defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|||||||
/** 提交表单 */
|
/** 提交表单 */
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
// 情况一:如果是已存在的属性,直接结束,不提交表单新增
|
// 情况一:如果是已存在的属性,直接结束,不提交表单新增
|
||||||
for (const option of attributeOptions.value) {
|
for (const attrItem of attributeList.value) {
|
||||||
if (option.name === formData.value.name) {
|
if (attrItem.name === formData.value.name) {
|
||||||
// 添加到属性列表
|
return message.error('该属性已存在,请勿重复添加')
|
||||||
attributeList.value.push({
|
|
||||||
id: option.id,
|
|
||||||
...formData.value,
|
|
||||||
values: []
|
|
||||||
})
|
|
||||||
// 触发属性列表的加载
|
|
||||||
emit('success', option.id, option.id)
|
|
||||||
// 关闭弹窗
|
|
||||||
dialogVisible.value = false
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +107,15 @@ const submitForm = async () => {
|
|||||||
...formData.value,
|
...formData.value,
|
||||||
values: []
|
values: []
|
||||||
})
|
})
|
||||||
|
// 判断最终提交的属性名称是否是用户下拉选择的 自己手动输入的属性名称就不执行emit获取该属性名下属性值列表
|
||||||
|
for (const element of attributeOptions.value) {
|
||||||
|
if (element.name === formData.value.name) {
|
||||||
|
emit('success', propertyId, element.id)
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
dialogVisible.value = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
// 关闭弹窗
|
// 关闭弹窗
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
|
Loading…
Reference in New Issue
Block a user