Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
879870ee
authored
Aug 14, 2024
by
芋道源码
Committed by
GitHub
Aug 14, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #75 from GoldenZqqq/GoldenZqqq/Bug-Fix
添加商品属性项重复选择校验
parents
bcb4fc30
9475ded9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
22 deletions
+18
-22
src/views/mall/product/spu/form/ProductAttributes.vue
+6
-9
src/views/mall/product/spu/form/ProductPropertyAddForm.vue
+12
-13
No files found.
src/views/mall/product/spu/form/ProductAttributes.vue
View file @
879870ee
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
v-for=
"item2 in item.propertyOpts"
v-for=
"item2 in item.propertyOpts"
:key=
"item2.id"
:key=
"item2.id"
:label=
"item2.name"
:label=
"item2.name"
:value=
"item2.
id
"
:value=
"item2.
name
"
/>
/>
</el-select>
</el-select>
<el-button
<el-button
...
@@ -57,7 +57,6 @@
...
@@ -57,7 +57,6 @@
import
*
as
PropertyApi
from
'@/api/mall/product/property'
import
*
as
PropertyApi
from
'@/api/mall/product/property'
import
{
PropertyAndValues
}
from
'@/views/mall/product/spu/components'
import
{
PropertyAndValues
}
from
'@/views/mall/product/spu/components'
import
{
propTypes
}
from
'@/utils/propTypes'
import
{
propTypes
}
from
'@/utils/propTypes'
import
{
isNumber
}
from
'@/utils/is'
defineOptions
({
name
:
'ProductAttributes'
})
defineOptions
({
name
:
'ProductAttributes'
})
...
@@ -123,13 +122,11 @@ const handleInputConfirm = async (index: number, propertyId: number) => {
...
@@ -123,13 +122,11 @@ const handleInputConfirm = async (index: number, propertyId: number) => {
if
(
inputValue
.
value
)
{
if
(
inputValue
.
value
)
{
// 重复添加校验
// 重复添加校验
// TODO @芋艿:需要测试下
// TODO @芋艿:需要测试下
if
(
isNumber
(
inputValue
.
value
))
{
if
(
attributeList
.
value
[
index
].
values
.
find
((
item
)
=>
item
.
name
===
inputValue
.
value
))
{
if
(
attributeList
.
value
[
index
].
values
?.
some
((
item
)
=>
item
.
id
===
inputValue
.
value
))
{
message
.
warning
(
'已存在相同属性值,请重试'
)
message
.
warning
(
'已存在相同属性值,请重试'
)
attributeIndex
.
value
=
null
attributeIndex
.
value
=
null
inputValue
.
value
=
''
inputValue
.
value
=
''
return
return
}
}
}
// 保存属性值
// 保存属性值
try
{
try
{
...
...
src/views/mall/product/spu/form/ProductPropertyAddForm.vue
View file @
879870ee
...
@@ -85,19 +85,9 @@ defineExpose({ open }) // 提供 open 方法,用于打开弹窗
...
@@ -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 () => {
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment