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
Commit
2937f3c1
authored
Aug 13, 2024
by
黄兆琦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 使用id来对商品属性值重复添加操作进行校验
parent
24e69ecf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
src/views/mall/product/spu/form/ProductAttributes.vue
+5
-2
No files found.
src/views/mall/product/spu/form/ProductAttributes.vue
View file @
2937f3c1
...
@@ -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.
name
"
:value=
"item2.
id
"
/>
/>
</el-select>
</el-select>
<el-button
<el-button
...
@@ -57,6 +57,7 @@
...
@@ -57,6 +57,7 @@
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'
})
...
@@ -121,12 +122,14 @@ const emit = defineEmits(['success']) // 定义 success 事件,用于操作成
...
@@ -121,12 +122,14 @@ const emit = defineEmits(['success']) // 定义 success 事件,用于操作成
const
handleInputConfirm
=
async
(
index
:
number
,
propertyId
:
number
)
=>
{
const
handleInputConfirm
=
async
(
index
:
number
,
propertyId
:
number
)
=>
{
if
(
inputValue
.
value
)
{
if
(
inputValue
.
value
)
{
// 重复添加校验
// 重复添加校验
if
(
attributeList
.
value
[
index
].
values
.
find
((
item
)
=>
item
.
name
===
inputValue
.
value
))
{
if
(
isNumber
(
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
{
const
id
=
await
PropertyApi
.
createPropertyValue
({
propertyId
,
name
:
inputValue
.
value
})
const
id
=
await
PropertyApi
.
createPropertyValue
({
propertyId
,
name
:
inputValue
.
value
})
...
...
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