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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
115 additions
and
73 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
]
:
[]
}
}
row
?.
childs
?.
forEach
(
ele
=>
{
targetObj
[
row
.
id
].
push
({
rootId
,
rootName
,
parentId
:
row
.
id
,
parentName
:
row
.
name
,
id
:
ele
.
id
,
name
:
ele
.
name
})
})
})
this
.
$set
(
this
.
selectdData
,
rootId
,
targetObj
)
}
},
},
// 切换品牌
changeCarSeriesStatus
(
e
,
row
,
idx
){
selectBrand
(
item
)
{
const
{
id
:
rootId
,
name
:
rootName
}
=
this
.
curBrandInfo
if
(
this
.
curBrandId
==
item
.
id
)
return
;
const
{
id
:
parentId
,
name
:
parentName
}
=
this
.
curSonBrandInfo
this
.
curBrandId
=
item
.
id
if
(
this
.
selectdData
[
rootId
]){
this
.
sonBrandList
=
item
?.
childs
||
[]
if
(
this
.
selectdData
[
rootId
][
parentId
]){
this
.
curSonBrandId
=
''
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
{
this
.
$set
(
this
.
selectdData
,
rootId
,
{[
parentId
]:
[{
rootId
,
rootName
,
parentId
,
parentName
,
id
:
row
.
id
,
name
:
row
.
name
}]})
}
console
.
log
(
this
.
selectdData
)
},
showSonBrandList
(
row
){
this
.
curBrandInfo
=
{
id
:
row
.
id
,
name
:
row
.
name
}
this
.
sonBrandList
=
row
?.
childs
||
[]
this
.
carSeriesList
=
[]
this
.
carSeriesList
=
[]
},
},
// 选中子品牌
// 切换子品牌
selectSonBrand
(
e
,
item
,
index
){
showCarSeriesList
(
row
){
this
.
curSonBrandInfo
=
{
id
:
row
.
id
,
name
:
row
.
name
}
this
.
carSeriesList
=
row
?.
childs
},
isChecked
(
item
,
type
){
const
{
id
}
=
item
const
{
id
}
=
item
const
_targetIdx
=
this
.
checkedList
.
findIndex
(
ele
=>
ele
==
id
)
const
{
id
:
rootId
}
=
this
.
curBrandInfo
if
(
_targetIdx
>-
1
){
const
{
id
:
parentId
}
=
this
.
curSonBrandInfo
this
.
checkedList
.
splice
(
_targetIdx
,
1
)
if
(
type
==
1
){
item
.
childs
.
forEach
(
row
=>
{
let
keyList
=
Object
.
keys
(
this
.
selectdData
[
id
]
||
[])
const
spliceIdx
=
this
.
selectdData
.
findIndex
(
ele
=>
ele
==
row
.
id
)
return
keyList
.
length
>
0
this
.
selectdData
.
splice
(
spliceIdx
,
1
)
}
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
{
}
else
{
this
.
checkedList
.
push
(
id
)
return
false
let
ids
=
item
.
childs
.
map
(
item
=>
item
.
id
)
this
.
selectdData
=
[...
new
Set
([...
this
.
selectdData
,
...
ids
])]
}
}
},
},
// 选中车系
isIndeterminate
(
item
,
type
){
selectCarSeries
(){
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
]){
const
unChecked
=
this
.
carSeriesList
.
find
(
item
=>
!
this
.
selectdData
.
includes
(
item
.
id
))
return
Object
.
keys
(
this
.
selectdData
[
this
.
curBrandInfo
.
id
][
id
])?.
length
!=
len
&&
Object
.
keys
(
this
.
selectdData
[
this
.
curBrandInfo
.
id
][
id
])?.
length
!=
0
const
checked
=
this
.
carSeriesList
.
find
(
item
=>
this
.
selectdData
.
includes
(
item
.
id
))
}
else
{
const
_targetIdx
=
this
.
checkedList
.
findIndex
(
ele
=>
ele
==
this
.
curSonBrandId
)
return
false
if
(
!
unChecked
&&
_targetIdx
==-
1
)
{
this
.
checkedList
.
push
(
this
.
curSonBrandId
)
}
if
(
!
checked
&&
_targetIdx
>-
1
){
this
.
checkedList
.
splice
(
_targetIdx
,
1
)
}
}
},
},
// 切换子品牌
// 获取数据源
showCarSeries
(
item
){
getCarSeriesData
()
{
if
(
!
this
.
firstClick
){
this
.
$apis
.
case
.
getCarSeriesApi
({
needCarSeries
:
true
}).
then
(
res
=>
{
this
.
selectdData
=
[]
console
.
log
(
res
)
this
.
firstClick
=
true
if
(
res
?.
length
){
}
this
.
carSeriesData
=
res
if
(
this
.
curSonBrandId
==
item
.
id
)
return
;
}
this
.
curSonBrandId
=
item
.
id
})
this
.
carSeriesList
=
item
?.
childs
},
},
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