Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
杨明
/
scrm-micro-config
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 8c86e214
authored
Nov 24, 2021
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改树组件
1 parent
86058006
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
184 additions
and
258 deletions
src/views/account/components/selectProduct.vue
src/views/role/components/selectProduct.vue
src/views/account/components/selectProduct.vue
View file @
8c86e21
<
template
>
<
template
>
<div
class=
"account-body scrm-box-f"
v-loading=
"loading"
>
<div
class=
"account-body scrm-box-f"
v-loading=
"loading"
>
<div
class=
"account-title"
>
{{
title
}}
</div>
<div
class=
"account-title"
>
{{
title
}}
</div>
<el-tabs
<el-tabs
v-if=
"tabMenu.length != 0"
v-model=
"tabName"
type=
"card"
@
tab-click=
"handleClik"
>
v-if=
"tabMenu.length != 0"
<el-tab-pane
:label=
"item.accounttypeName"
:name=
"item.accounttypeId"
v-for=
"(item, index) in tabMenu"
:key=
"index"
></el-tab-pane>
v-model=
"tabName"
type=
"card"
@
tab-click=
"handleClik"
>
<el-tab-pane
:label=
"item.accounttypeName"
:name=
"item.accounttypeId"
v-for=
"(item, index) in tabMenu"
:key=
"index"
></el-tab-pane>
</el-tabs>
</el-tabs>
<div
<div
class=
"account-select-pro"
v-for=
"(item, index) in tabMenu"
:key=
"index"
v-show=
"tabName == item.accounttypeId"
>
class=
"account-select-pro"
v-for=
"(item, index) in tabMenu"
:key=
"index"
v-show=
"tabName == item.accounttypeId"
>
<label>
选择产品
</label>
<label>
选择产品
</label>
<el-checkbox-group
v-model=
"item.productsArr"
@
change=
"selectPro"
>
<el-checkbox-group
v-model=
"item.productsArr"
@
change=
"selectPro"
>
<el-checkbox
v-for=
"(itm, idx) in item.products"
:label=
"itm"
:key=
"idx"
>
{{
<el-checkbox
v-for=
"(itm, idx) in item.products"
:label=
"itm"
:key=
"idx"
>
{{
itm
.
productName
}}
</el-checkbox>
itm
.
productName
}}
</el-checkbox>
</el-checkbox-group>
</el-checkbox-group>
</div>
</div>
<div
class=
"account-select-menu"
>
请选择产品权限
</div>
<div
class=
"account-select-menu"
>
请选择产品权限
</div>
...
@@ -32,52 +15,20 @@
...
@@ -32,52 +15,20 @@
<div
class=
"menu-box-panel"
>
<div
class=
"menu-box-panel"
>
<div
:key=
"index"
v-for=
"(item, index) in tabMenu"
>
<div
:key=
"index"
v-for=
"(item, index) in tabMenu"
>
<div
class=
"menu-box-tab"
v-show=
"tabName == item.accounttypeId"
>
<div
class=
"menu-box-tab"
v-show=
"tabName == item.accounttypeId"
>
<div
<div
v-show=
"item.productsArr.indexOf(itm) != -1"
class=
"tab-item text-hide"
:class=
"
{ 'select-checked': productTab == itm.productId }" @click="productClick(itm.productId)" v-for="(itm, idx) in item.products" :key="idx">
v-show=
"item.productsArr.indexOf(itm) != -1"
class=
"tab-item text-hide"
:class=
"
{ 'select-checked': productTab == itm.productId }"
@click="productClick(itm.productId)"
v-for="(itm, idx) in item.products"
:key="idx"
>
{{
itm
.
productName
}}
{{
itm
.
productName
}}
</div>
</div>
</div>
</div>
<div
<div
v-show=
"tabName == item.accounttypeId"
class=
"menu-box-tree"
v-if=
"item.products"
:style=
"
{ 'min-height': treeHeight + 'px' }">
v-show=
"tabName == item.accounttypeId"
class=
"menu-box-tree"
v-if=
"item.products"
:style=
"
{ 'min-height': treeHeight + 'px' }"
>
<div
v-for=
"(itm, idx) in item.products"
:key=
"idx"
>
<div
v-for=
"(itm, idx) in item.products"
:key=
"idx"
>
<div
<div
class=
"nodata"
v-if=
"item.productsArr.length == 0 || itm.merchantProTreeResponses.length == 0"
>
class=
"nodata"
v-if=
"
item.productsArr.length == 0 || itm.merchantProTreeResponses.length == 0
"
>
<img
src=
"../../../assets/img/empty.png"
alt=
""
/>
<img
src=
"../../../assets/img/empty.png"
alt=
""
/>
<div>
<div>
{{
item
.
productsArr
.
length
==
0
?
"请先选择产品"
:
"暂无菜单权限"
}}
{{
item
.
productsArr
.
length
==
0
?
'请先选择产品'
:
'暂无菜单权限'
}}
</div>
</div>
</div>
</div>
<div
v-else
>
<div
v-else
>
<el-tree
<el-tree
v-show=
"productTab == itm.productId"
:data=
"itm.merchantProTreeResponses"
show-checkbox
check-strictly
check-on-click-node
:expand-on-click-node=
"false"
default-expand-all
node-key=
"id"
:class=
"'tree_' + item.accounttypeId + '_' + itm.productId"
:ref=
"`tree_$
{item.accounttypeId}_${itm.productId}`" highlight-current :render-content="renderContent" :props="defaultProps" @check="clickDeal">
</el-tree>
v-show=
"productTab == itm.productId"
:data=
"itm.merchantProTreeResponses"
show-checkbox
check-strictly
check-on-click-node
:expand-on-click-node=
"false"
default-expand-all
node-key=
"id"
:class=
"'tree_' + item.accounttypeId + '_' + itm.productId"
:ref=
"`tree_$
{item.accounttypeId}_${itm.productId}`"
highlight-current
:render-content="renderContent"
:props="defaultProps"
@check="clickDeal"
>
</el-tree>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -87,16 +38,16 @@
...
@@ -87,16 +38,16 @@
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
util
from
"@/utils/util"
;
import
util
from
'@/utils/util'
export
default
{
export
default
{
name
:
"product"
,
name
:
'product'
,
props
:
{
props
:
{
title
:
{
title
:
{
type
:
String
,
type
:
String
},
},
roleType
:
{
roleType
:
{
type
:
Boolean
,
type
:
Boolean
}
,
}
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -110,202 +61,192 @@ export default {
...
@@ -110,202 +61,192 @@ export default {
productId
:
0
,
productId
:
0
,
products
:
[],
products
:
[],
productsArr
:
[],
productsArr
:
[],
tabName
:
""
,
tabName
:
''
,
productTab
:
""
,
productTab
:
''
,
defaultProps
:
{
defaultProps
:
{
children
:
"children"
,
children
:
'children'
,
label
:
"label"
,
label
:
'label'
},
},
accountTypes
:
[]
,
accountTypes
:
[]
}
;
}
},
},
methods
:
{
methods
:
{
handleClik
(
tab
,
event
)
{
handleClik
(
tab
,
event
)
{
console
.
log
(
tab
,
event
);
console
.
log
(
tab
,
event
)
const
tabId
=
tab
.
name
;
const
tabId
=
tab
.
name
const
productTab
=
this
.
tabMenu
.
find
((
i
)
=>
i
.
accounttypeId
==
tabId
);
const
productTab
=
this
.
tabMenu
.
find
(
i
=>
i
.
accounttypeId
==
tabId
)
this
.
productTab
=
productTab
.
productsArr
[
0
]
this
.
productTab
=
productTab
.
productsArr
[
0
]
?
productTab
.
productsArr
[
0
].
productId
:
''
?
productTab
.
productsArr
[
0
].
productId
:
""
;
},
},
selectPro
(
data
)
{
selectPro
(
data
)
{
this
.
$parent
.
editStatus
=
true
;
this
.
$parent
.
editStatus
=
true
this
.
productTab
=
data
.
length
!=
0
?
data
[
data
.
length
-
1
].
productId
:
""
;
this
.
productTab
=
data
.
length
!=
0
?
data
[
data
.
length
-
1
].
productId
:
''
const
{
tabName
,
tabMenu
,
productTab
}
=
this
;
const
{
tabName
,
tabMenu
,
productTab
}
=
this
console
.
log
(
tabName
,
data
)
;
console
.
log
(
tabName
,
data
)
// 设置全选
// 设置全选
var
arr
=
tabMenu
var
arr
=
tabMenu
.
find
(
i
=>
i
.
accounttypeId
==
tabName
).
products
.
find
(
j
=>
j
.
productId
==
productTab
).
merchantProTreeResponses
.
find
((
i
)
=>
i
.
accounttypeId
==
tabName
)
this
.
$refs
[
`tree_
${
tabName
}
_
${
productTab
}
`
][
0
].
setCheckedKeys
(
this
.
getAllId
(
arr
))
.
products
.
find
((
j
)
=>
j
.
productId
==
productTab
).
merchantProTreeResponses
;
console
.
log
(
tabMenu
)
this
.
$refs
[
`tree_
${
tabName
}
_
${
productTab
}
`
][
0
].
setCheckedKeys
(
this
.
getAllId
(
arr
));
console
.
log
(
tabMenu
);
},
},
productClick
(
productId
)
{
productClick
(
productId
)
{
this
.
productTab
=
productId
;
this
.
productTab
=
productId
},
},
// 获取当前的所有权限
// 获取当前的所有权限
async
findMenuFunTreeByMerId
(
params
,
arr
)
{
async
findMenuFunTreeByMerId
(
params
,
arr
)
{
let
tabMenu
=
await
this
.
$apis
.
store
.
findMenuFunTreeByMerId
(
params
)
;
let
tabMenu
=
await
this
.
$apis
.
store
.
findMenuFunTreeByMerId
(
params
)
this
.
tabMenu
=
tabMenu
this
.
tabMenu
=
tabMenu
.
map
(
(
item
)
=>
{
.
map
(
item
=>
{
return
{
return
{
productsArr
:
[],
productsArr
:
[],
products
:
item
.
products
,
products
:
item
.
products
,
accounttypeName
:
item
.
accounttypeName
,
accounttypeName
:
item
.
accounttypeName
,
accounttypeId
:
item
.
accounttypeId
,
accounttypeId
:
item
.
accounttypeId
}
;
}
})
})
.
filter
(
(
i
)
=>
arr
.
includes
(
i
.
accounttypeId
));
.
filter
(
i
=>
arr
.
includes
(
i
.
accounttypeId
))
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
addStyle
()
;
this
.
addStyle
()
})
;
})
console
.
log
(
this
.
tabMenu
)
;
console
.
log
(
this
.
tabMenu
)
this
.
accountTypes
=
tabMenu
.
map
(
(
item
)
=>
{
this
.
accountTypes
=
tabMenu
.
map
(
item
=>
{
return
{
return
{
products
:
null
,
products
:
null
,
accounttypeId
:
item
.
accounttypeId
,
accounttypeId
:
item
.
accounttypeId
}
;
}
})
;
})
this
.
tabName
=
this
.
tabMenu
[
0
].
accounttypeId
;
this
.
tabName
=
this
.
tabMenu
[
0
].
accounttypeId
return
this
.
tabMenu
;
return
this
.
tabMenu
},
},
// 获取当前的所有权限
// 获取当前的所有权限
async
accountTypeSearchRequest
(
params
,
status
)
{
async
accountTypeSearchRequest
(
params
,
status
)
{
this
.
loading
=
true
;
this
.
loading
=
true
let
account
=
""
;
let
account
=
''
if
(
status
)
{
if
(
status
)
{
account
=
"findMenuFunTreeByMerId"
;
account
=
'findMenuFunTreeByMerId'
}
else
{
}
else
{
account
=
"accountTypeSearchRequest"
;
account
=
'accountTypeSearchRequest'
}
}
this
.
$apis
.
store
[
account
](
params
).
then
(
(
res
)
=>
{
this
.
$apis
.
store
[
account
](
params
).
then
(
res
=>
{
console
.
log
(
res
)
;
console
.
log
(
res
)
let
tabMenu
=
res
;
let
tabMenu
=
res
this
.
accountList
=
tabMenu
.
map
(
(
item
)
=>
{
this
.
accountList
=
tabMenu
.
map
(
item
=>
{
return
{
return
{
productsArr
:
[],
productsArr
:
[],
products
:
item
.
products
,
products
:
item
.
products
,
accounttypeName
:
item
.
accounttypeName
,
accounttypeName
:
item
.
accounttypeName
,
accounttypeId
:
item
.
accounttypeId
,
accounttypeId
:
item
.
accounttypeId
// merchantProTreeResponses: item.merchantProTreeResponses,
// merchantProTreeResponses: item.merchantProTreeResponses,
// productId: ''
// productId: ''
}
;
}
})
;
})
console
.
log
(
this
.
accountList
)
;
console
.
log
(
this
.
accountList
)
this
.
accountTypes
=
tabMenu
.
map
(
(
item
)
=>
{
this
.
accountTypes
=
tabMenu
.
map
(
item
=>
{
return
{
return
{
products
:
null
,
products
:
null
,
accounttypeId
:
item
.
accounttypeId
,
accounttypeId
:
item
.
accounttypeId
}
;
}
})
;
})
this
.
tabMenu_s
=
util
.
deepClone
(
this
.
accountList
)
;
this
.
tabMenu_s
=
util
.
deepClone
(
this
.
accountList
)
this
.
findPermissionsByMerId
(
params
.
merchantId
?
params
.
merchantId
:
params
.
id
)
;
this
.
findPermissionsByMerId
(
params
.
merchantId
?
params
.
merchantId
:
params
.
id
)
})
;
})
},
},
// 获取已选择的权限
// 获取已选择的权限
findPermissionsByMerId
(
id
)
{
findPermissionsByMerId
(
id
)
{
const
params
=
{
const
params
=
{
id
,
id
}
;
}
this
.
$apis
.
store
.
findPermissionsByMerId
(
params
).
then
(
(
res
)
=>
{
this
.
$apis
.
store
.
findPermissionsByMerId
(
params
).
then
(
res
=>
{
this
.
loading
=
false
;
this
.
loading
=
false
this
.
tabMenu_x
=
util
.
deepClone
(
res
)
;
this
.
tabMenu_x
=
util
.
deepClone
(
res
)
res
.
forEach
(
(
item
)
=>
{
res
.
forEach
(
item
=>
{
console
.
log
(
item
)
;
console
.
log
(
item
)
this
.
accountList
.
forEach
(
(
itm
)
=>
{
this
.
accountList
.
forEach
(
itm
=>
{
console
.
log
(
itm
)
;
console
.
log
(
itm
)
if
(
item
.
accounttypeId
==
itm
.
accounttypeId
)
{
if
(
item
.
accounttypeId
==
itm
.
accounttypeId
)
{
this
.
tabMenu
.
push
(
itm
)
;
this
.
tabMenu
.
push
(
itm
)
item
.
products
.
forEach
(
(
i
)
=>
{
item
.
products
.
forEach
(
i
=>
{
itm
.
products
.
forEach
(
(
j
)
=>
{
itm
.
products
.
forEach
(
j
=>
{
if
(
i
.
productId
==
j
.
productId
)
{
if
(
i
.
productId
==
j
.
productId
)
{
itm
.
productsArr
.
push
(
j
)
;
itm
.
productsArr
.
push
(
j
)
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
$refs
[
this
.
$refs
[
`tree_
${
itm
.
accounttypeId
}
_
${
j
.
productId
}
`
][
0
].
setCheckedKeys
(
i
.
menuIds
)
`tree_
${
itm
.
accounttypeId
}
_
${
j
.
productId
}
`
this
.
addStyle
()
][
0
].
setCheckedKeys
(
i
.
menuIds
);
})
this
.
addStyle
();
}
});
})
}
})
});
}
});
})
}
})
});
this
.
tabName
=
this
.
tabMenu
[
0
].
accounttypeId
});
this
.
productTab
=
this
.
tabMenu
[
0
].
productsArr
[
0
].
productId
this
.
tabName
=
this
.
tabMenu
[
0
].
accounttypeId
;
this
.
productTab
=
this
.
tabMenu
[
0
].
productsArr
[
0
].
productId
;
// const arr = res.map(i => i.accounttypeId)
// const arr = res.map(i => i.accounttypeId)
// this.tabMenu.map(i => arr.includes(i.accounttypeId))
// this.tabMenu.map(i => arr.includes(i.accounttypeId))
// console.log(this.tabMenu, arr)
// console.log(this.tabMenu, arr)
})
;
})
},
},
resetView
()
{
resetView
()
{
this
.
tabMenu
=
[]
;
this
.
tabMenu
=
[]
this
.
accountList
=
util
.
deepClone
(
this
.
tabMenu_s
)
;
this
.
accountList
=
util
.
deepClone
(
this
.
tabMenu_s
)
this
.
tabMenu_x
.
forEach
(
(
item
)
=>
{
this
.
tabMenu_x
.
forEach
(
item
=>
{
this
.
accountList
.
forEach
(
(
itm
)
=>
{
this
.
accountList
.
forEach
(
itm
=>
{
console
.
log
(
itm
)
;
console
.
log
(
itm
)
if
(
item
.
accounttypeId
==
itm
.
accounttypeId
)
{
if
(
item
.
accounttypeId
==
itm
.
accounttypeId
)
{
this
.
tabMenu
.
push
(
itm
)
;
this
.
tabMenu
.
push
(
itm
)
item
.
products
.
forEach
(
(
i
)
=>
{
item
.
products
.
forEach
(
i
=>
{
itm
.
products
.
forEach
(
(
j
)
=>
{
itm
.
products
.
forEach
(
j
=>
{
if
(
i
.
productId
==
j
.
productId
)
{
if
(
i
.
productId
==
j
.
productId
)
{
itm
.
productsArr
.
push
(
j
)
;
itm
.
productsArr
.
push
(
j
)
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
$refs
[
`tree_
${
itm
.
accounttypeId
}
_
${
j
.
productId
}
`
]
this
.
$refs
[
`tree_
${
itm
.
accounttypeId
}
_
${
j
.
productId
}
`
]
?
this
.
$refs
[
`tree_
${
itm
.
accounttypeId
}
_
${
j
.
productId
}
`
][
0
].
setCheckedKeys
(
i
.
menuIds
)
:
''
?
this
.
$refs
[
})
`tree_
${
itm
.
accounttypeId
}
_
${
j
.
productId
}
`
}
][
0
].
setCheckedKeys
(
i
.
menuIds
)
})
:
""
;
})
});
}
}
})
});
})
});
}
});
});
},
},
// 渲染树结构
// 渲染树结构
renderContent
(
h
,
v
)
{
renderContent
(
h
,
v
)
{
if
(
v
.
data
.
logo
==
"functionValue"
)
{
if
(
v
.
data
.
logo
==
'functionValue'
)
{
return
(
return
(
<
div
class
=
"custom-tree-node fun-tree-node"
>
<
div
class
=
"custom-tree-node fun-tree-node"
>
<
span
>
{
v
.
node
.
label
}
<
/span
>
<
span
>
{
v
.
node
.
label
}
<
/span
>
<
/div
>
<
/div
>
)
;
)
}
else
{
}
else
{
return
(
return
(
<
div
class
=
"custom-tree-node"
>
<
div
class
=
"custom-tree-node"
>
<
span
>
{
v
.
node
.
label
}
<
/span
>
<
span
>
{
v
.
node
.
label
}
<
/span
>
<
/div
>
<
/div
>
)
;
)
}
}
},
},
addStyle
()
{
addStyle
()
{
const
nodes
=
document
.
getElementsByClassName
(
"fun-tree-node"
);
const
nodes
=
document
.
getElementsByClassName
(
'fun-tree-node'
)
for
(
let
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
const
parentNode
=
nodes
[
i
].
parentNode
.
parentNode
;
const
parentNode
=
nodes
[
i
].
parentNode
.
parentNode
console
.
log
(
parentNode
)
;
console
.
log
(
parentNode
)
parentNode
.
style
.
float
=
"left"
;
parentNode
.
style
.
float
=
'left'
}
}
},
},
clickDeal
(
currentObj
,
treeStatus
)
{
clickDeal
(
currentObj
,
treeStatus
)
{
this
.
$parent
.
editStatus
=
true
;
this
.
$parent
.
editStatus
=
true
// 用于:父子节点严格互不关联时,父节点勾选变化时通知子节点同步变化,实现单向关联。
// 用于:父子节点严格互不关联时,父节点勾选变化时通知子节点同步变化,实现单向关联。
let
selected
=
treeStatus
.
checkedKeys
.
indexOf
(
currentObj
.
id
)
;
// -1未选中
let
selected
=
treeStatus
.
checkedKeys
.
indexOf
(
currentObj
.
id
)
// -1未选中
// 选中
// 选中
if
(
selected
!==
-
1
)
{
if
(
selected
!==
-
1
)
{
// 子节点只要被选中父节点就被选中
// 子节点只要被选中父节点就被选中
this
.
selectedParent
(
currentObj
)
;
this
.
selectedParent
(
currentObj
)
// 统一处理子节点为相同的勾选状态
// 统一处理子节点为相同的勾选状态
this
.
uniteChildSame
(
currentObj
,
true
)
;
this
.
uniteChildSame
(
currentObj
,
true
)
}
else
{
}
else
{
// 未选中 处理子节点全部未选中
// 未选中 处理子节点全部未选中
console
.
log
(
currentObj
)
;
console
.
log
(
currentObj
)
if
(
currentObj
.
children
!==
null
)
{
if
(
currentObj
.
children
!==
null
)
{
if
(
currentObj
.
children
.
length
!==
0
)
{
if
(
currentObj
.
children
.
length
!==
0
)
{
this
.
uniteChildSame
(
currentObj
,
false
)
;
this
.
uniteChildSame
(
currentObj
,
false
)
}
}
//放开时为当子节点全为未选中时父节点也变为未选中状态 注释后就是父节点不和子节点强制绑定
//放开时为当子节点全为未选中时父节点也变为未选中状态 注释后就是父节点不和子节点强制绑定
// this.uniteParentSame(currentObj.id,treeStatus)//当子节点全为未选中时父节点也变为未选中状态
// this.uniteParentSame(currentObj.id,treeStatus)//当子节点全为未选中时父节点也变为未选中状态
...
@@ -317,146 +258,135 @@ export default {
...
@@ -317,146 +258,135 @@ export default {
},
},
uniteParentSame
(
id
,
treeStatus
)
{
uniteParentSame
(
id
,
treeStatus
)
{
//当子节点全为未选中时父节点也变为未选中状态
//当子节点全为未选中时父节点也变为未选中状态
const
tree_ref
=
`tree_
${
this
.
tabName
}
_
${
this
.
productTab
}
`
;
const
tree_ref
=
`tree_
${
this
.
tabName
}
_
${
this
.
productTab
}
`
let
node
=
this
.
$refs
[
tree_ref
][
0
].
getNode
(
id
)
;
//获取当前节点的节点树
let
node
=
this
.
$refs
[
tree_ref
][
0
].
getNode
(
id
)
//获取当前节点的节点树
if
(
node
.
parent
!==
null
&&
node
.
parent
!==
undefined
)
{
if
(
node
.
parent
!==
null
&&
node
.
parent
!==
undefined
)
{
let
parentNode
=
node
.
parent
.
data
;
//获取当前节点的父节点树
let
parentNode
=
node
.
parent
.
data
//获取当前节点的父节点树
if
(
parentNode
!=
undefined
)
{
if
(
parentNode
!=
undefined
)
{
//判断父节点是否存在
//判断父节点是否存在
for
(
let
i
=
0
;
i
<
parentNode
.
children
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
parentNode
.
children
.
length
;
i
++
)
{
let
checkedKeys
=
this
.
$refs
[
tree_ref
][
0
].
getCheckedKeys
()
;
let
checkedKeys
=
this
.
$refs
[
tree_ref
][
0
].
getCheckedKeys
()
let
hafCheckedKeys
=
this
.
$refs
[
tree_ref
][
0
].
getHalfCheckedKeys
()
;
let
hafCheckedKeys
=
this
.
$refs
[
tree_ref
][
0
].
getHalfCheckedKeys
()
let
selectNodes
=
checkedKeys
.
concat
(
hafCheckedKeys
)
;
//获取已选择树节点
let
selectNodes
=
checkedKeys
.
concat
(
hafCheckedKeys
)
//获取已选择树节点
let
selected
=
selectNodes
.
indexOf
(
parentNode
.
children
[
i
].
id
)
;
// -1当前节点的同级节点是否全部未选中
let
selected
=
selectNodes
.
indexOf
(
parentNode
.
children
[
i
].
id
)
// -1当前节点的同级节点是否全部未选中
if
(
selected
!==
-
1
)
{
if
(
selected
!==
-
1
)
{
return
;
return
}
}
}
}
}
else
{
}
else
{
return
;
return
}
}
this
.
$refs
[
tree_ref
][
0
].
setChecked
(
parentNode
.
id
,
false
)
;
//修改节点为未选择
this
.
$refs
[
tree_ref
][
0
].
setChecked
(
parentNode
.
id
,
false
)
//修改节点为未选择
if
(
node
.
level
>
2
)
{
if
(
node
.
level
>
2
)
{
//判断是否是最上级节点
//判断是否是最上级节点
this
.
uniteParentSame
(
parentNode
.
id
,
treeStatus
)
;
this
.
uniteParentSame
(
parentNode
.
id
,
treeStatus
)
}
}
}
else
{
}
else
{
return
;
return
}
}
},
},
// 统一处理子节点为相同的勾选状态
// 统一处理子节点为相同的勾选状态
uniteChildSame
(
treeList
,
isSelected
)
{
uniteChildSame
(
treeList
,
isSelected
)
{
const
tree_ref
=
`tree_
${
this
.
tabName
}
_
${
this
.
productTab
}
`
;
const
tree_ref
=
`tree_
${
this
.
tabName
}
_
${
this
.
productTab
}
`
this
.
$refs
[
tree_ref
][
0
].
setChecked
(
treeList
.
id
,
isSelected
)
;
this
.
$refs
[
tree_ref
][
0
].
setChecked
(
treeList
.
id
,
isSelected
)
console
.
log
(
treeList
)
;
console
.
log
(
treeList
)
if
(
treeList
.
children
!==
null
)
{
if
(
treeList
.
children
!==
null
)
{
for
(
let
i
=
0
;
i
<
treeList
.
children
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
treeList
.
children
.
length
;
i
++
)
{
this
.
uniteChildSame
(
treeList
.
children
[
i
],
isSelected
)
;
this
.
uniteChildSame
(
treeList
.
children
[
i
],
isSelected
)
}
}
}
}
},
},
// 统一处理父节点为选中
// 统一处理父节点为选中
selectedParent
(
currentObj
)
{
selectedParent
(
currentObj
)
{
const
tree_ref
=
`tree_
${
this
.
tabName
}
_
${
this
.
productTab
}
`
;
const
tree_ref
=
`tree_
${
this
.
tabName
}
_
${
this
.
productTab
}
`
let
currentNode
=
this
.
$refs
[
tree_ref
][
0
].
getNode
(
currentObj
)
;
let
currentNode
=
this
.
$refs
[
tree_ref
][
0
].
getNode
(
currentObj
)
if
(
currentNode
.
parent
.
key
!==
undefined
)
{
if
(
currentNode
.
parent
.
key
!==
undefined
)
{
this
.
$refs
[
tree_ref
][
0
].
setChecked
(
currentNode
.
parent
,
true
)
;
this
.
$refs
[
tree_ref
][
0
].
setChecked
(
currentNode
.
parent
,
true
)
this
.
selectedParent
(
currentNode
.
parent
)
;
this
.
selectedParent
(
currentNode
.
parent
)
}
}
},
},
// 获取所有节点的id
// 获取所有节点的id
getAllId
(
data
,
arr
=
[])
{
getAllId
(
data
,
arr
=
[])
{
if
(
data
)
{
if
(
data
)
{
data
.
forEach
(
(
item
)
=>
{
data
.
forEach
(
item
=>
{
arr
.
push
(
item
.
id
)
;
arr
.
push
(
item
.
id
)
if
(
item
.
children
&&
item
.
children
.
length
!=
0
)
{
if
(
item
.
children
&&
item
.
children
.
length
!=
0
)
{
item
.
children
.
forEach
(
(
i
)
=>
{
item
.
children
.
forEach
(
i
=>
{
arr
.
push
(
i
.
id
)
;
arr
.
push
(
i
.
id
)
this
.
getAllId
(
i
.
children
,
arr
)
;
this
.
getAllId
(
i
.
children
,
arr
)
})
;
})
}
}
})
;
})
}
}
return
arr
;
return
arr
},
},
getSelectInfo
()
{
getSelectInfo
()
{
this
.
accountTypes
=
this
.
tabMenu
.
map
((
item
)
=>
{
this
.
accountTypes
=
this
.
tabMenu
.
map
(
item
=>
{
let
products
=
[];
let
products
=
[]
let
productList
=
[];
let
productList
=
[]
item
.
productsArr
.
forEach
((
itm
)
=>
{
item
.
productsArr
.
forEach
(
itm
=>
{
const
checkedNodes
=
this
.
$refs
[
`tree_
${
item
.
accounttypeId
}
_
${
itm
.
productId
}
`
]
const
checkedNodes
=
this
.
$refs
[
`tree_
${
item
.
accounttypeId
}
_
${
itm
.
productId
}
`
]
?
this
.
$refs
[
`tree_
${
item
.
accounttypeId
}
_
${
itm
.
productId
}
`
][
0
].
getCheckedNodes
()
:
[]
?
this
.
$refs
[
console
.
log
(
checkedNodes
)
`tree_
${
item
.
accounttypeId
}
_
${
itm
.
productId
}
`
][
0
].
getCheckedNodes
()
:
[];
console
.
log
(
checkedNodes
);
const
menuIdList
=
checkedNodes
const
menuIdList
=
checkedNodes
// .filter((item) => item.logo === "menu")
// .filter((item) => item.logo === "menu")
.
filter
(
.
filter
(
item
=>
item
.
logo
!==
'function'
&&
item
.
logo
!==
'functionValue'
&&
item
.
logo
!==
'neglect'
)
(
item
)
=>
.
map
(
i
=>
i
.
id
)
// 全选菜单idlist
item
.
logo
!==
"function"
&&
item
.
logo
!==
"functionValue"
&&
item
.
logo
!==
"neglect"
)
.
map
((
i
)
=>
i
.
id
);
// 全选菜单idlist
// const partSelectList = halfCheckedNodes.filter(item => item.logo === 'menu').map(i => i.id) // 半选菜单idlist
// const partSelectList = halfCheckedNodes.filter(item => item.logo === 'menu').map(i => i.id) // 半选菜单idlist
const
functionIdList
=
checkedNodes
.
filter
((
item
)
=>
item
.
logo
===
"function"
);
const
functionIdList
=
checkedNodes
.
filter
(
item
=>
item
.
logo
===
'function'
)
const
functionValueIdLists
=
checkedNodes
.
filter
(
const
functionValueIdLists
=
checkedNodes
.
filter
(
item
=>
item
.
logo
===
'functionValue'
)
(
item
)
=>
item
.
logo
===
"functionValue"
var
list
=
[]
);
var
list
=
[];
/** { menuId, id, functionValue} */
/** { menuId, id, functionValue} */
if
(
functionValueIdLists
.
length
!==
0
)
{
if
(
functionValueIdLists
.
length
!==
0
)
{
functionValueIdLists
.
forEach
((
j
,
index
)
=>
{
functionValueIdLists
.
forEach
((
j
,
index
)
=>
{
if
(
list
.
map
(
(
item
)
=>
item
.
id
).
includes
(
j
.
parentId
))
{
if
(
list
.
map
(
item
=>
item
.
id
).
includes
(
j
.
parentId
))
{
const
obj
=
list
.
find
(
(
k
)
=>
k
.
id
===
j
.
parentId
);
const
obj
=
list
.
find
(
k
=>
k
.
id
===
j
.
parentId
)
obj
.
functionValue
+=
";"
+
j
.
id
+
":"
+
j
.
label
;
obj
.
functionValue
+=
';'
+
j
.
id
+
':'
+
j
.
label
}
else
{
}
else
{
list
.
push
({
list
.
push
({
i
d
:
j
.
parentId
,
functionI
d
:
j
.
parentId
,
menuId
:
j
.
superParentId
,
menuId
:
j
.
superParentId
,
functionValue
:
j
.
id
+
":"
+
j
.
label
,
functionValue
:
j
.
id
+
':'
+
j
.
label
})
;
})
}
}
})
;
})
}
}
console
.
log
(
menuIdList
,
functionIdList
,
functionValueIdLists
,
list
)
;
console
.
log
(
menuIdList
,
functionIdList
,
functionValueIdLists
,
list
)
if
(
this
.
roleType
)
{
if
(
this
.
roleType
)
{
productList
.
push
({
productList
.
push
({
productId
:
itm
.
productId
,
productId
:
itm
.
productId
,
functionIdList
:
functionIdList
,
functionIdList
:
functionIdList
,
// functionValue: list,
// functionValue: list,
menuIdList
:
menuIdList
,
menuIdList
:
menuIdList
})
;
})
}
else
{
}
else
{
products
.
push
({
products
.
push
({
productId
:
itm
.
productId
,
productId
:
itm
.
productId
,
functionIds
:
functionIdL
ist
,
functionIds
:
l
ist
,
functionValue
:
list
,
//
functionValue: list,
menuIds
:
menuIdList
,
menuIds
:
menuIdList
})
;
})
}
}
})
;
})
if
(
this
.
roleType
)
{
if
(
this
.
roleType
)
{
return
{
return
{
accounttypeId
:
item
.
accounttypeId
,
accounttypeId
:
item
.
accounttypeId
,
productList
,
productList
}
;
}
}
else
{
}
else
{
return
{
return
{
accounttypeId
:
item
.
accounttypeId
,
accounttypeId
:
item
.
accounttypeId
,
products
,
products
};
}
}
})
return
this
.
accountTypes
}
}
});
return
this
.
accountTypes
;
},
},
},
mounted
()
{
mounted
()
{
// this.accountTypeSearchRequest();
// this.accountTypeSearchRequest();
// this.findPermissionsByMerId()
// this.findPermissionsByMerId()
}
,
}
}
;
}
</
script
>
</
script
>
<
style
scoped
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
...
...
src/views/role/components/selectProduct.vue
View file @
8c86e21
...
@@ -98,13 +98,11 @@ export default {
...
@@ -98,13 +98,11 @@ export default {
// 设置全选
// 设置全选
var
arr
=
tabMenu
.
find
(
i
=>
i
.
accounttypeId
==
tabName
).
products
.
find
(
j
=>
j
.
productId
==
productTab
).
merchantProTreeResponses
var
arr
=
tabMenu
.
find
(
i
=>
i
.
accounttypeId
==
tabName
).
products
.
find
(
j
=>
j
.
productId
==
productTab
).
merchantProTreeResponses
this
.
$refs
[
`tree_
${
tabName
}
_
${
productTab
}
`
]
?
this
.
$refs
[
`tree_
${
tabName
}
_
${
productTab
}
`
][
0
].
setCheckedKeys
(
this
.
getAllId
(
arr
))
:
''
this
.
$refs
[
`tree_
${
tabName
}
_
${
productTab
}
`
]
?
this
.
$refs
[
`tree_
${
tabName
}
_
${
productTab
}
`
][
0
].
setCheckedKeys
(
this
.
getAllId
(
arr
))
:
''
console
.
log
(
tabMenu
)
},
},
productClick
(
productId
)
{
productClick
(
productId
)
{
this
.
productTab
=
productId
this
.
productTab
=
productId
},
},
findMenuFunTree
(
id
,
status
)
{
findMenuFunTree
(
id
,
status
)
{
console
.
log
(
id
,
status
)
let
tabMenu
=
util
.
deepClone
(
this
.
tabMenu_r
)
let
tabMenu
=
util
.
deepClone
(
this
.
tabMenu_r
)
let
menu
=
tabMenu
.
filter
(
item
=>
item
.
accounttypeId
==
id
)
let
menu
=
tabMenu
.
filter
(
item
=>
item
.
accounttypeId
==
id
)
let
index
=
tabMenu
.
findIndex
(
item
=>
item
.
accounttypeId
==
id
)
let
index
=
tabMenu
.
findIndex
(
item
=>
item
.
accounttypeId
==
id
)
...
@@ -160,7 +158,6 @@ export default {
...
@@ -160,7 +158,6 @@ export default {
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
addStyle
()
this
.
addStyle
()
})
})
console
.
log
(
this
.
accountList
)
this
.
accountTypes
=
tabMenu
.
map
(
item
=>
{
this
.
accountTypes
=
tabMenu
.
map
(
item
=>
{
return
{
return
{
products
:
null
,
products
:
null
,
...
@@ -203,7 +200,6 @@ export default {
...
@@ -203,7 +200,6 @@ export default {
this
.
accountList
=
util
.
deepClone
(
this
.
tabMenu_s
)
this
.
accountList
=
util
.
deepClone
(
this
.
tabMenu_s
)
this
.
tabMenu_x
.
forEach
(
item
=>
{
this
.
tabMenu_x
.
forEach
(
item
=>
{
this
.
accountList
.
forEach
(
itm
=>
{
this
.
accountList
.
forEach
(
itm
=>
{
console
.
log
(
itm
)
if
(
item
.
accounttypeId
==
itm
.
accounttypeId
)
{
if
(
item
.
accounttypeId
==
itm
.
accounttypeId
)
{
this
.
tabMenu
.
push
(
itm
)
this
.
tabMenu
.
push
(
itm
)
item
.
products
.
forEach
(
i
=>
{
item
.
products
.
forEach
(
i
=>
{
...
@@ -367,7 +363,7 @@ export default {
...
@@ -367,7 +363,7 @@ export default {
if
(
this
.
roleType
)
{
if
(
this
.
roleType
)
{
productList
.
push
({
productList
.
push
({
productId
:
itm
.
productId
,
productId
:
itm
.
productId
,
functionIdList
:
functionIdL
ist
,
functionIdList
:
l
ist
,
// functionValue: list,
// functionValue: list,
menuIdList
:
menuIdList
menuIdList
:
menuIdList
})
})
...
...
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