File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed
src/views/mall/product/spu/form Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -85,19 +85,9 @@ defineExpose({ open }) // 提供 open 方法,用于打开弹窗
85
85
/** 提交表单 */
86
86
const submitForm = async () => {
87
87
// 情况一:如果是已存在的属性,直接结束,不提交表单新增
88
- for (const option of attributeOptions .value ) {
89
- if (option .name === formData .value .name ) {
90
- // 添加到属性列表
91
- attributeList .value .push ({
92
- id: option .id ,
93
- ... formData .value ,
94
- values: []
95
- })
96
- // 触发属性列表的加载
97
- emit (' success' , option .id , option .id )
98
- // 关闭弹窗
99
- dialogVisible .value = false
100
- return
88
+ for (const attrItem of attributeList .value ) {
89
+ if (attrItem .name === formData .value .name ) {
90
+ return message .error (' 该属性已存在,请勿重复添加' )
101
91
}
102
92
}
103
93
@@ -117,6 +107,15 @@ const submitForm = async () => {
117
107
... formData .value ,
118
108
values: []
119
109
})
110
+ // 判断最终提交的属性名称是否是用户下拉选择的 自己手动输入的属性名称就不执行emit获取该属性名下属性值列表
111
+ for (const element of attributeOptions .value ) {
112
+ if (element .name === formData .value .name ) {
113
+ emit (' success' , propertyId , element .id )
114
+ message .success (t (' common.createSuccess' ))
115
+ dialogVisible .value = false
116
+ return
117
+ }
118
+ }
120
119
// 关闭弹窗
121
120
message .success (t (' common.createSuccess' ))
122
121
dialogVisible .value = false
You can’t perform that action at this time.
0 commit comments