Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yongxinda-admin
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
刘旭
yongxinda-admin
Commits
1927fdf2
提交
1927fdf2
authored
12月 13, 2022
作者:
刘旭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复添加规格属性顺序错误问题
上级
1b4a0bcb
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
63 行增加
和
1 行删除
+63
-1
selectSpec.vue
src/views/commodityManage/components/selectSpec.vue
+63
-1
没有找到文件。
src/views/commodityManage/components/selectSpec.vue
浏览文件 @
1927fdf2
...
...
@@ -178,7 +178,6 @@ let partsChange = (type: string, data: any, index: any) => {
// 每组只可以取一个
let
radioChange
=
(
e
:
any
,
item
:
any
)
=>
{
// console.log(e, item);
item
.
values
.
forEach
((
res
:
any
)
=>
{
if
(
specList
.
value
.
indexOf
(
res
.
value
)
!=
-
1
)
{
let
s
=
specList
.
value
.
indexOf
(
res
.
value
)
...
...
@@ -190,9 +189,72 @@ let radioChange = (e: any, item: any) => {
if
(
specList
.
value
.
indexOf
(
e
)
==
-
1
)
specList
.
value
.
push
(
e
)
}
// 把配件数据整合,让数据选择规格时顺序从上到下
let
handleSpecData
=
()
=>
{
let
data
=
[]
as
any
// specification, value
// 深拷贝,避免影响原数组
let
newarr
=
JSON
.
parse
((
JSON
.
stringify
(
props
.
specData
)))
newarr
.
map
((
item
:
any
)
=>
{
let
flag
=
true
// 如果已经存储了相同的specification,则下面就不在循环
data
.
map
((
res
:
any
)
=>
{
if
(
item
.
specification
===
res
.
specification
)
flag
=
false
})
newarr
.
map
((
item1
:
any
)
=>
{
if
(
flag
)
{
if
(
item
.
specification
===
item1
.
specification
)
{
let
flag1
=
true
// 如果已经存储了相同的specification,就只添加value
data
.
map
((
res
:
any
)
=>
{
if
(
item
.
specification
===
res
.
specification
)
flag1
=
false
})
if
(
flag1
)
{
data
.
push
({
specification
:
item
.
specification
,
value
:
[
item1
.
value
]
})
}
else
{
data
.
forEach
((
res
:
any
)
=>
{
if
(
item1
.
specification
===
res
.
specification
)
{
res
.
value
.
push
(
item1
.
value
)
}
})
}
}
}
})
})
return
data
}
// 判断规格属性的顺序是否正确,错误需要排序
let
handleSequence
=
(
data
:
any
)
=>
{
let
specListCopy
=
[...
specList
.
value
]
// 浅拷贝
// 双重循环判断对应索引值是否对应
specList
.
value
.
map
((
arrVal
:
any
,
arr
:
number
)
=>
{
data
.
map
((
item
:
any
,
i
:
number
)
=>
{
if
(
arr
===
i
)
{
let
index
=
item
.
value
.
indexOf
(
arrVal
)
// 如果对应索引中没有对应关系,则取当前索引在拷贝数组找到对应值,直接赋值
if
(
index
===
-
1
)
{
data
[
arr
].
value
.
map
((
element
:
any
)
=>
{
let
index1
=
specListCopy
.
indexOf
(
element
)
if
(
index1
!==
-
1
)
{
specList
.
value
[
arr
]
=
specListCopy
[
index1
]
}
})
}
}
})
})
}
// 打开添加规格属性框
let
showAddSpec
=
()
=>
{
if
(
specList
.
value
.
length
===
0
)
return
ElMessage
({
type
:
'warning'
,
message
:
'请先选择规格属性'
})
let
resultSpecData
=
handleSpecData
()
if
(
specList
.
value
.
length
!==
resultSpecData
.
length
)
return
ElMessage
({
type
:
'warning'
,
message
:
'请选择所有规格属性'
})
handleSequence
(
resultSpecData
)
specificationsRef
.
value
.
formData
=
{
bomCode
:
''
,
model
:
''
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论