Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
scrm-micro-discover
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 68c0ca16
authored
Jul 10, 2023
by
zhangquan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改弹窗逻辑
1 parent
740d0e37
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
116 additions
and
74 deletions
src/views/store/components/selectCarDialog.vue
src/views/store/components/selectCarDialog.vue
View file @
68c0ca1
...
@@ -8,24 +8,25 @@
...
@@ -8,24 +8,25 @@
@
onCancel=
"handleClose"
>
@
onCancel=
"handleClose"
>
<div
class=
"car-container"
>
<div
class=
"car-container"
>
<div
class=
"wrap"
>
<div
class=
"wrap"
>
<div
:class=
"['item', 'flex-center',
{'curItem' : curBrandId==item.id}]" v-for="item in carSeriesData" :key="item.id" @click="selectBrand(item)">
<div
class=
"item son-brand-wrap"
v-for=
"(item, index) in carSeriesData"
:key=
"item.id"
>
<span>
{{
item
.
name
}}
</span>
<el-checkbox
:disabled=
"!(item.childs && item.childs.length)"
:indeterminate=
"isIndeterminate(item, 1)"
:value=
"isChecked(item, 1)"
@
change=
"changeBrandStatus($event, item, index)"
></el-checkbox>
<i
class=
"el-icon-arrow-right"
></i>
<span
:class=
"['son-brand-label',
{'curItem' : curBrandInfo.id==item.id}]" @click="showSonBrandList(item)">
{{
item
.
name
}}
<i
v-if=
"item.childs && item.childs.length"
class=
"el-icon-arrow-right"
></i>
</span>
</div>
</div>
</div>
</div>
<div
class=
"wrap"
>
<div
class=
"wrap"
>
<div
class=
"item son-brand-wrap"
v-for=
"(item, index) in sonBrandList"
:key=
"item.id"
>
<div
class=
"item son-brand-wrap"
v-for=
"(item, index) in sonBrandList"
:key=
"item.id"
>
<el-checkbox
:
indeterminate=
"isIndeterminate(item)"
:value=
"isChecked(item.id, 'son')"
@
change=
"selectSonBrand
($event, item, index)"
></el-checkbox>
<el-checkbox
:
disabled=
"!(item.childs && item.childs.length)"
:indeterminate=
"isIndeterminate(item, 2)"
:value=
"isChecked(item, 2)"
@
change=
"changeSonBrandStatus
($event, item, index)"
></el-checkbox>
<span
:class=
"['son-brand-label',
{'curItem' : curSonBrandI
d==item.id}]" @click="showCarSeries
(item)">
<span
:class=
"['son-brand-label',
{'curItem' : curSonBrandI
nfo.id==item.id}]" @click="showCarSeriesList
(item)">
{{
item
.
name
}}
{{
isIndeterminate
(
item
)
}}
{{
item
.
name
}}
<i
class=
"el-icon-arrow-right"
></i>
<i
v-if=
"item.childs && item.childs.length"
class=
"el-icon-arrow-right"
></i>
</span>
</span>
</div>
</div>
</div>
</div>
<div
class=
"wrap"
>
<div
class=
"wrap"
>
<el-checkbox-group
v-model=
"selectdData"
@
change=
"selectCarSeries()"
>
<el-checkbox
class=
"item"
v-for=
"item in carSeriesList"
:key=
"item.id"
:value=
"isChecked(item, '3')"
@
change=
"changeCarSeriesStatus($event, item, index)"
>
{{
item
.
name
}}
</el-checkbox>
<el-checkbox
class=
"item"
v-for=
"item in carSeriesList"
:label=
"item.id"
:key=
"item.id"
>
{{
item
.
name
}}
</el-checkbox>
</el-checkbox-group>
</div>
</div>
</div>
</div>
</GLDialog>
</GLDialog>
...
@@ -40,11 +41,15 @@
...
@@ -40,11 +41,15 @@
carSeriesData
:
[],
carSeriesData
:
[],
sonBrandList
:
[],
sonBrandList
:
[],
carSeriesList
:
[],
carSeriesList
:
[],
selectdData
:
[],
selectdData
:
{},
checkedList
:
[],
curBrandInfo
:
{
curBrandId
:
''
,
id
:
''
,
curSonBrandId
:
''
,
name
:
''
firstClick
:
false
},
curSonBrandInfo
:
{
id
:
''
,
name
:
''
}
}
}
},
},
computed
:{
computed
:{
...
@@ -61,80 +66,117 @@
...
@@ -61,80 +66,117 @@
},
},
methods
:{
methods
:{
isChecked
(
id
,
type
){
changeBrandStatus
(
e
,
row
,
idx
){
const
_target
=
this
.
checkedList
.
find
(
ele
=>
ele
==
id
)
const
{
id
:
rootId
,
name
:
rootName
}
=
row
if
(
t
ype
==
'son'
){
if
(
t
his
.
selectdData
[
rootId
]
){
return
!!
_target
this
.
$delete
(
this
.
selectdData
,
rootId
)
}
else
{
}
else
{
return
!!
_target
?.
child
?.
includes
(
id
)
let
targetObj
=
{}
row
?.
childs
.
forEach
(
item
=>
{
const
{
id
:
parentId
,
name
:
parentName
}
=
item
targetObj
[
parentId
]
=
[]
item
?.
childs
?.
forEach
(
ele
=>
{
targetObj
[
item
.
id
].
push
({
rootId
,
rootName
,
parentId
,
parentName
,
id
:
ele
.
id
,
name
:
ele
.
name
})
})
})
this
.
$set
(
this
.
selectdData
,
rootId
,
targetObj
)
}
}
console
.
log
(
this
.
selectdData
)
},
},
isIndeterminate
(
item
){
changeSonBrandStatus
(
e
,
row
,
idx
){
const
_existItem
=
item
?.
childs
?.
find
(
row
=>
!
this
.
selectdData
.
includes
(
row
.
id
))
const
{
id
:
rootId
,
name
:
rootName
}
=
this
.
curBrandInfo
const
_notExistItem
=
item
?.
childs
?.
find
(
row
=>
this
.
selectdData
.
includes
(
row
.
id
))
if
(
this
.
selectdData
[
rootId
]){
return
!!
_existItem
&&
!!
_notExistItem
if
(
this
.
selectdData
[
rootId
][
row
.
id
]){
},
this
.
$delete
(
this
.
selectdData
[
rootId
],
row
.
id
)
// 获取数据源
}
else
{
getCarSeriesData
()
{
let
carList
=
[]
this
.
$apis
.
case
.
getCarSeriesApi
({
needCarSeries
:
true
}).
then
(
res
=>
{
row
?.
childs
?.
forEach
(
ele
=>
{
console
.
log
(
res
)
carList
.
push
({
rootId
,
rootName
,
parentId
:
row
.
id
,
parentName
:
row
.
name
,
id
:
ele
.
id
,
name
:
ele
.
name
})
if
(
res
?.
length
){
})
this
.
carSeriesData
=
res
this
.
$set
(
this
.
selectdData
[
rootId
],
row
.
id
,
carList
)
}
}
})
}
else
{
},
let
targetObj
=
{
// 切换品牌
[
row
.
id
]
:
[]
selectBrand
(
item
)
{
}
if
(
this
.
curBrandId
==
item
.
id
)
return
;
row
?.
childs
?.
forEach
(
ele
=>
{
this
.
curBrandId
=
item
.
id
targetObj
[
row
.
id
].
push
({
rootId
,
rootName
,
parentId
:
row
.
id
,
parentName
:
row
.
name
,
id
:
ele
.
id
,
name
:
ele
.
name
})
this
.
sonBrandList
=
item
?.
childs
||
[]
this
.
curSonBrandId
=
''
this
.
carSeriesList
=
[]
},
// 选中子品牌
selectSonBrand
(
e
,
item
,
index
){
const
{
id
}
=
item
const
_targetIdx
=
this
.
checkedList
.
findIndex
(
ele
=>
ele
==
id
)
if
(
_targetIdx
>-
1
){
this
.
checkedList
.
splice
(
_targetIdx
,
1
)
item
.
childs
.
forEach
(
row
=>
{
const
spliceIdx
=
this
.
selectdData
.
findIndex
(
ele
=>
ele
==
row
.
id
)
this
.
selectdData
.
splice
(
spliceIdx
,
1
)
})
})
this
.
$set
(
this
.
selectdData
,
rootId
,
targetObj
)
}
},
changeCarSeriesStatus
(
e
,
row
,
idx
){
const
{
id
:
rootId
,
name
:
rootName
}
=
this
.
curBrandInfo
const
{
id
:
parentId
,
name
:
parentName
}
=
this
.
curSonBrandInfo
if
(
this
.
selectdData
[
rootId
]){
if
(
this
.
selectdData
[
rootId
][
parentId
]){
const
targetIdx
=
this
.
selectdData
[
rootId
][
parentId
]?.
findIndex
(
item
=>
item
.
id
==
row
.
id
)
if
(
targetIdx
>-
1
){
this
.
selectdData
[
rootId
][
parentId
].
splice
(
targetIdx
,
1
)
}
else
{
this
.
selectdData
[
rootId
][
parentId
].
push
({
rootId
,
rootName
,
parentId
,
parentName
,
id
:
row
.
id
,
name
:
row
.
name
})
}
}
else
{
this
.
$set
(
this
.
selectdData
[
rootId
],
parentId
,
[{
rootId
,
rootName
,
parentId
,
parentName
,
id
:
row
.
id
,
name
:
row
.
name
}])
}
}
else
{
}
else
{
this
.
checkedList
.
push
(
id
)
this
.
$set
(
this
.
selectdData
,
rootId
,
{[
parentId
]:
[{
rootId
,
rootName
,
parentId
,
parentName
,
id
:
row
.
id
,
name
:
row
.
name
}]})
let
ids
=
item
.
childs
.
map
(
item
=>
item
.
id
)
this
.
selectdData
=
[...
new
Set
([...
this
.
selectdData
,
...
ids
])]
}
}
console
.
log
(
this
.
selectdData
)
},
},
// 选中车系
showSonBrandList
(
row
){
selectCarSeries
(){
this
.
curBrandInfo
=
{
if
(
!
this
.
firstClick
){
id
:
row
.
id
,
this
.
selectdData
=
[]
name
:
row
.
name
this
.
firstClick
=
true
}
}
const
unChecked
=
this
.
carSeriesList
.
find
(
item
=>
!
this
.
selectdData
.
includes
(
item
.
id
))
this
.
sonBrandList
=
row
?.
childs
||
[]
const
checked
=
this
.
carSeriesList
.
find
(
item
=>
this
.
selectdData
.
includes
(
item
.
id
))
this
.
carSeriesList
=
[]
const
_targetIdx
=
this
.
checkedList
.
findIndex
(
ele
=>
ele
==
this
.
curSonBrandId
)
},
if
(
!
unChecked
&&
_targetIdx
==-
1
)
{
// 切换子品牌
this
.
checkedList
.
push
(
this
.
curSonBrandId
)
showCarSeriesList
(
row
){
this
.
curSonBrandInfo
=
{
id
:
row
.
id
,
name
:
row
.
name
}
}
if
(
!
checked
&&
_targetIdx
>-
1
){
this
.
carSeriesList
=
row
?.
childs
this
.
checkedList
.
splice
(
_targetIdx
,
1
)
},
isChecked
(
item
,
type
){
const
{
id
}
=
item
const
{
id
:
rootId
}
=
this
.
curBrandInfo
const
{
id
:
parentId
}
=
this
.
curSonBrandInfo
if
(
type
==
1
){
let
keyList
=
Object
.
keys
(
this
.
selectdData
[
id
]
||
[])
return
keyList
.
length
>
0
}
else
if
(
type
==
2
&&
rootId
&&
this
.
selectdData
[
rootId
]){
return
this
.
selectdData
[
rootId
][
id
]?.
length
>
0
}
else
if
(
type
==
3
&&
rootId
&&
parentId
&&
this
.
selectdData
[
rootId
]
&&
this
.
selectdData
[
rootId
][
parentId
]){
return
!!
this
.
selectdData
[
rootId
][
parentId
]?.
find
(
item
=>
item
.
id
==
id
)
}
else
{
return
false
}
}
},
},
// 切换子品牌
isIndeterminate
(
item
,
type
){
showCarSeries
(
item
){
const
{
id
}
=
item
if
(
!
this
.
firstClick
){
const
len
=
item
?.
childs
?.
length
this
.
selectdData
=
[]
if
(
type
==
1
&&
this
.
selectdData
[
id
]){
this
.
firstClick
=
true
return
Object
.
keys
(
this
.
selectdData
[
id
])?.
length
!=
len
&&
Object
.
keys
(
this
.
selectdData
[
id
])?.
length
!=
0
}
else
if
(
type
==
2
&&
this
.
curBrandInfo
.
id
&&
this
.
selectdData
[
this
.
curBrandInfo
.
id
]
&&
this
.
selectdData
[
this
.
curBrandInfo
.
id
][
id
]){
return
Object
.
keys
(
this
.
selectdData
[
this
.
curBrandInfo
.
id
][
id
])?.
length
!=
len
&&
Object
.
keys
(
this
.
selectdData
[
this
.
curBrandInfo
.
id
][
id
])?.
length
!=
0
}
else
{
return
false
}
}
if
(
this
.
curSonBrandId
==
item
.
id
)
return
;
},
this
.
curSonBrandId
=
item
.
id
// 获取数据源
this
.
carSeriesList
=
item
?.
childs
getCarSeriesData
()
{
this
.
$apis
.
case
.
getCarSeriesApi
({
needCarSeries
:
true
}).
then
(
res
=>
{
console
.
log
(
res
)
if
(
res
?.
length
){
this
.
carSeriesData
=
res
}
})
},
},
handleConfirm
(){
handleConfirm
(){
console
.
log
(
this
.
checkedList
,
155
)
console
.
log
(
this
.
selectdData
,
155
)
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment