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
35c3545e
authored
Apr 30, 2023
by
puhui999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商品管理: 保存属性值到数据库
parent
538d1e0b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
src/views/mall/product/management/components/ProductAttributes.vue
+15
-5
No files found.
src/views/mall/product/management/components/ProductAttributes.vue
View file @
35c3545e
...
...
@@ -8,7 +8,7 @@
<el-text
class=
"mx-1"
>
属性值:
</el-text>
<el-tag
v-for=
"(value, valueIndex) in item.values"
:key=
"value.
name
"
:key=
"value.
id
"
:disable-transitions=
"false"
class=
"mx-1"
closable
...
...
@@ -22,8 +22,8 @@
v-model=
"inputValue"
class=
"!w-20"
size=
"small"
@
blur=
"handleInputConfirm(index)"
@
keyup
.
enter=
"handleInputConfirm(index)"
@
blur=
"handleInputConfirm(index
, item.id
)"
@
keyup
.
enter=
"handleInputConfirm(index
, item.id
)"
/>
<el-button
v-show=
"!inputVisible(index)"
...
...
@@ -40,7 +40,10 @@
<
script
lang=
"ts"
name=
"ProductAttributes"
setup
>
import
{
ElInput
}
from
'element-plus'
import
*
as
PropertyApi
from
'@/api/mall/product/property'
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
const
inputValue
=
ref
(
''
)
// 输入框值
const
attributeIndex
=
ref
<
number
|
null
>
(
null
)
// 获取焦点时记录当前属性项的index
// 输入框显隐控制
...
...
@@ -79,9 +82,16 @@ const showInput = async (index) => {
InputRef
.
value
[
index
]
!
.
input
!
.
focus
()
}
/** 输入框失去焦点或点击回车时触发 */
const
handleInputConfirm
=
(
index
)
=>
{
const
handleInputConfirm
=
async
(
index
,
propertyId
)
=>
{
if
(
inputValue
.
value
)
{
attributeList
.
value
[
index
].
values
.
push
({
name
:
inputValue
.
value
})
// 保存属性值
try
{
const
id
=
await
PropertyApi
.
createPropertyValue
({
propertyId
,
name
:
inputValue
.
value
})
attributeList
.
value
[
index
].
values
.
push
({
id
,
name
:
inputValue
.
value
})
message
.
success
(
t
(
'common.createSuccess'
))
}
catch
{
message
.
error
(
'添加失败,请重试'
)
// TODO 缺少国际化
}
}
attributeIndex
.
value
=
null
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