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 e2e6348d
authored
Nov 02, 2021
by
杨北旺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
角色管理模块
1 parent
8515a437
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
258 additions
and
164 deletions
src/setup/single.js
src/views/account/components/selectProduct.vue
src/views/role/create.vue
src/views/role/index.vue
src/setup/single.js
View file @
e2e6348
...
@@ -17,7 +17,7 @@ import { routes } from '@/router'
...
@@ -17,7 +17,7 @@ import { routes } from '@/router'
export
async
function
start
()
{
export
async
function
start
()
{
if
(
window
.
__POWERED_BY_QIANKUN__
)
return
if
(
window
.
__POWERED_BY_QIANKUN__
)
return
const
{
response
,
request
,
sign
,
secret
}
=
await
fetchConfig
()
const
{
response
,
request
,
sign
,
secret
}
=
await
fetchConfig
()
Vue
.
prototype
.
$http
=
new
Http
({
response
,
request
,
sign
,
secret
,
alert
:
message
.
error
,
headers
:
{
TGT
:
'scrm-base-
57a2c9a4-42bd-4821-8af0-02e98a473594
-rop'
}
})
Vue
.
prototype
.
$http
=
new
Http
({
response
,
request
,
sign
,
secret
,
alert
:
message
.
error
,
headers
:
{
TGT
:
'scrm-base-
61a28f77-294f-4510-aa1c-6a35cff86f25
-rop'
}
})
Vue
.
use
(
GLButton
,
{
permissions
:
[
'1-1-1-1'
,
'2-1-1-1'
,
'3-1-1-1'
]
})
Vue
.
use
(
GLButton
,
{
permissions
:
[
'1-1-1-1'
,
'2-1-1-1'
,
'3-1-1-1'
]
})
render
(
'/'
,
routes
)
render
(
'/'
,
routes
)
}
}
\ No newline at end of file
\ No newline at end of file
src/views/account/components/selectProduct.vue
View file @
e2e6348
<
template
>
<
template
>
<div
class=
"account-body scrm-box-f"
>
<div
class=
"account-body scrm-box-f"
>
<div
class=
"account-title"
>
功能权限
</div>
<div
class=
"account-title"
>
{{
title
}}
</div>
<el-tabs
v-model=
"tabName"
type=
"card"
>
<el-tabs
v-model=
"tabName"
type=
"card"
>
<el-tab-pane
:label=
"item.accounttypeName"
:name=
"item.accounttypeId"
v-for=
"(item, index) in tabMenu"
:key=
"index"
></el-tab-pane>
<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
class=
"account-select-pro"
v-for=
"(item, index) in tabMenu"
:key=
"index"
v-show=
"tabName == item.accounttypeId"
>
<div
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"
>
{{
itm
.
productName
}}
</el-checkbox>
<el-checkbox
v-for=
"(itm, idx) in item.products"
:label=
"itm"
:key=
"idx"
>
{{
itm
.
productName
}}
</el-checkbox>
</el-checkbox-group>
</el-checkbox-group>
</div>
</div>
<div
class=
"account-select-menu"
>
请选择产品权限
</div>
<div
class=
"account-select-menu"
>
请选择产品权限
</div>
...
@@ -15,38 +27,58 @@
...
@@ -15,38 +27,58 @@
<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
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">
<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"
>
{{
itm
.
productName
}}
{{
itm
.
productName
}}
</div>
</div>
</div>
</div>
<div
v-show=
"tabName == item.accounttypeId"
class=
"menu-box-tree"
v-if=
"item.products"
:style=
"
{ 'min-height': treeHeight + 'px' }">
<div
<div
v-for=
"(itm, idx) in item.products"
:key=
"idx"
>
v-show=
"tabName == item.accounttypeId"
<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>
class=
"menu-box-tree"
v-if=
"item.products"
:style=
"
{ 'min-height': treeHeight + 'px' }"
>
<div
v-for=
"(itm, idx) in item.products"
:key=
"idx"
>
<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>
</div>
</div>
</div>
</div>
<button
@
click=
"getSelectInfo"
>
tijiao
</button>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
export
default
{
export
default
{
name
:
'product'
,
name
:
"product"
,
props
:
{
props
:
{
parentId
:
{
title
:
{
type
:
Number
type
:
String
,
},
},
pId
:
{
roleType
:
{
type
:
Number
type
:
Boolean
,
},
accountlevel
:
{
type
:
Number
},
roleType
:{
type
:
Boolean
}
}
},
},
...
@@ -58,40 +90,35 @@ export default {
...
@@ -58,40 +90,35 @@ 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
:
{
selectPro
(
data
)
{
selectPro
(
data
)
{
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
.
find
(
i
=>
i
.
accounttypeId
==
tabName
).
products
.
find
(
j
=>
j
.
productId
==
productTab
).
merchantProTreeResponses
var
arr
=
tabMenu
this
.
$refs
[
`tree_
${
tabName
}
_
${
productTab
}
`
][
0
].
setCheckedKeys
(
this
.
getAllId
(
arr
))
.
find
((
i
)
=>
i
.
accounttypeId
==
tabName
)
console
.
log
(
tabMenu
)
.
products
.
find
((
j
)
=>
j
.
productId
==
productTab
).
merchantProTreeResponses
;
this
.
$refs
[
`tree_
${
tabName
}
_
${
productTab
}
`
][
0
].
setCheckedKeys
(
this
.
getAllId
(
arr
));
console
.
log
(
tabMenu
);
},
},
productClick
(
productId
)
{
productClick
(
productId
)
{
this
.
productTab
=
productId
this
.
productTab
=
productId
;
},
},
// 获取当前的所有权限
// 获取当前的所有权限
findMenuFunTreeByMerId
()
{
async
findMenuFunTreeByMerId
(
params
)
{
let
params
=
{
let
tabMenu
=
await
this
.
$apis
.
store
.
findMenuFunTreeByMerId
(
params
);
accountlevel
:
this
.
accountlevel
,
this
.
tabMenu
=
tabMenu
.
map
((
item
)
=>
{
parentId
:
this
.
parentId
,
id
:
this
.
pId
}
console
.
log
(
params
);
this
.
$apis
.
store
.
findMenuFunTreeByMerId
(
params
).
then
(
res
=>
{
this
.
tabMenu
=
res
.
map
(
item
=>
{
console
.
log
(
item
)
return
{
return
{
productsArr
:
[],
productsArr
:
[],
products
:
item
.
products
,
products
:
item
.
products
,
...
@@ -99,72 +126,127 @@ export default {
...
@@ -99,72 +126,127 @@ export default {
accounttypeId
:
item
.
accounttypeId
,
accounttypeId
:
item
.
accounttypeId
,
// merchantProTreeResponses: item.merchantProTreeResponses,
// merchantProTreeResponses: item.merchantProTreeResponses,
// productId: ''
// productId: ''
}
};
})
});
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
addStyle
()
this
.
addStyle
();
})
});
console
.
log
(
this
.
tabMenu
)
this
.
accountTypes
=
tabMenu
.
map
((
item
)
=>
{
this
.
accountTypes
=
res
.
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
},
// 获取当前的所有权限
async
accountTypeSearchRequest
(
params
,
status
)
{
let
account
=
''
if
(
status
)
{
account
=
'findMenuFunTreeByMerId'
}
else
{
account
=
'accountTypeSearchRequest'
}
let
tabMenu
=
await
this
.
$apis
.
store
[
account
](
params
);
this
.
tabMenu
=
tabMenu
.
map
((
item
)
=>
{
return
{
productsArr
:
[],
products
:
item
.
products
,
accounttypeName
:
item
.
accounttypeName
,
accounttypeId
:
item
.
accounttypeId
,
// merchantProTreeResponses: item.merchantProTreeResponses,
// productId: ''
};
});
this
.
$nextTick
(()
=>
{
this
.
addStyle
();
});
this
.
accountTypes
=
tabMenu
.
map
((
item
)
=>
{
return
{
products
:
null
,
accounttypeId
:
item
.
accounttypeId
,
};
});
this
.
tabName
=
this
.
tabMenu
[
0
].
accounttypeId
;
this
.
findPermissionsByMerId
(
params
.
merchantId
?
params
.
merchantId
:
params
.
id
);
return
this
.
tabMenu
},
},
// 获取已选择的权限
// 获取已选择的权限
findPermissionsByMerId
()
{
findPermissionsByMerId
(
id
)
{
const
params
=
{
const
params
=
{
id
:
41588
id
,
}
};
this
.
$apis
.
store
.
findPermissionsByMerId
(
params
).
then
(
res
=>
{
this
.
$apis
.
store
.
findPermissionsByMerId
(
params
).
then
((
res
)
=>
{
console
.
log
(
res
)
// this.accountTypes = res.map(item=>{
res
.
map
(
i
=>
{
// let products = item.products.map(i=>{
console
.
log
(
i
,
this
.
tabMenu
.
find
(
j
=>
j
.
accounttypeId
==
i
.
accounttypeId
))
// return {
// i.productsArr = this.tabMenu.find(j => j.accounttypeId == i.accounttypeId).products
// menuIds: i.menuIds,
})
// productId: i.productId,
})
// functionIds: i.functionIds
// }
// })
// return {
// accounttypeId: item.accounttypeId,
// products
// }
// })
res
.
forEach
((
item
)
=>
{
this
.
tabMenu
.
forEach
((
itm
)
=>
{
if
(
item
.
accounttypeId
==
itm
.
accounttypeId
)
{
item
.
products
.
forEach
((
i
)
=>
{
itm
.
products
.
forEach
((
j
)
=>
{
if
(
i
.
productId
==
j
.
productId
)
{
itm
.
productsArr
.
push
(
j
);
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
const
parentNode
=
nodes
[
i
].
parentNode
;
parentNode
.
style
.
float
=
'left'
parentNode
.
style
.
float
=
"left"
;
}
}
},
},
clickDeal
(
currentObj
,
treeStatus
)
{
clickDeal
(
currentObj
,
treeStatus
)
{
// 用于:父子节点严格互不关联时,父节点勾选变化时通知子节点同步变化,实现单向关联。
// 用于:父子节点严格互不关联时,父节点勾选变化时通知子节点同步变化,实现单向关联。
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)//当子节点全为未选中时父节点也变为未选中状态
...
@@ -176,140 +258,153 @@ export default {
...
@@ -176,140 +258,153 @@ 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
}
`
]
?
this
.
$refs
[
`tree_
${
item
.
accounttypeId
}
_
${
itm
.
productId
}
`
][
0
].
getCheckedNodes
()
:
[]
const
checkedNodes
=
this
.
$refs
[
`tree_
${
item
.
accounttypeId
}
_
${
itm
.
productId
}
`
]
console
.
log
(
checkedNodes
)
?
this
.
$refs
[
const
menuIdList
=
checkedNodes
.
filter
(
item
=>
item
.
logo
===
'menu'
).
map
(
i
=>
i
.
id
)
// 全选菜单idlist
`tree_
${
item
.
accounttypeId
}
_
${
itm
.
productId
}
`
][
0
].
getCheckedNodes
()
:
[];
console
.
log
(
checkedNodes
);
const
menuIdList
=
checkedNodes
// .filter((item) => item.logo === "menu")
.
filter
((
item
)
=>
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
(
item
=>
item
.
logo
===
'functionValue'
)
const
functionValueIdLists
=
checkedNodes
.
filter
(
var
list
=
[]
(
item
)
=>
item
.
logo
===
"functionValue"
);
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
({
id
:
j
.
parentId
,
id
:
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
:
functionIdList
,
functionIds
:
functionIdList
,
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
.
findMenuFunTreeByMerId
()
// this.accountTypeSearchRequest();
// this.findPermissionsByMerId()
// this.findPermissionsByMerId()
}
}
,
}
}
;
</
script
>
</
script
>
<
style
scoped
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
.account-body
{
.account-body
{
padding
:
20px
;
padding
:
20px
;
margin-bottom
:
50px
;
margin-bottom
:
50px
;
/deep/
{
.
el-checkbox
:
last-of-type
{
margin-right
:
8px
;
}
}
.account-title
{
.account-title
{
font-size
:
20px
;
font-size
:
20px
;
font-weight
:
600
;
font-weight
:
600
;
...
...
src/views/role/create.vue
View file @
e2e6348
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
</div>
</div>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
<SelectProduct
ref=
"productFrom"
:roleType=
"true"
:parentId=
"41712"
:accountlevel=
"accountLevel"
:pId=
"41713
"
></SelectProduct>
<SelectProduct
ref=
"productFrom"
:roleType=
"true"
title=
"
"
></SelectProduct>
</div>
</div>
<div
style=
"height: 84px"
></div>
<div
style=
"height: 84px"
></div>
<div
class=
"fixed_bottom"
>
<div
class=
"fixed_bottom"
>
...
@@ -73,18 +73,18 @@ export default {
...
@@ -73,18 +73,18 @@ export default {
list
:
[],
list
:
[],
// tree数据
// tree数据
treeDataList
:
[],
treeDataList
:
[],
accountLevel
:
1
accountLevel
:
1
}
}
},
},
created
()
{
created
()
{
let
id
=
Number
(
this
.
$route
.
params
.
id
)
;
let
id
=
Number
(
this
.
$route
.
params
.
id
)
if
(
!
id
)
{
if
(
!
id
)
{
this
.
pageName
=
'新增角色'
this
.
pageName
=
'新增角色'
this
.
pageType
=
'create'
this
.
pageType
=
'create'
this
.
getMerchantName
()
this
.
getMerchantName
()
}
else
{
}
else
{
this
.
pageName
=
'修改角色'
this
.
pageName
=
'修改角色'
this
.
pageType
=
'edit'
this
.
pageType
=
'edit'
this
.
getRoleData
(
id
)
this
.
getRoleData
(
id
)
this
.
editId
=
id
this
.
editId
=
id
}
}
...
@@ -100,9 +100,10 @@ export default {
...
@@ -100,9 +100,10 @@ export default {
merchantName
:
res
.
merchantName
,
merchantName
:
res
.
merchantName
,
roleName
:
res
.
roleName
,
roleName
:
res
.
roleName
,
roleDesc
:
res
.
roleDescription
,
roleDesc
:
res
.
roleDescription
,
merchantId
:
res
.
merchantId
merchantId
:
res
.
merchantId
}
}
this
.
getMerchantTree
(
id
,
res
.
responseList
)
this
.
getMerchantTree
(
id
,
res
.
responseList
)
this
.
$refs
.
productFrom
.
accountTypeSearchRequest
({
id
:
res
.
merchantId
},
'edit'
)
})
})
},
},
// 获取商户树
// 获取商户树
...
@@ -136,13 +137,12 @@ export default {
...
@@ -136,13 +137,12 @@ export default {
}
}
},
},
// 选择商户----获取权限
// 选择商户----获取权限
selectMerchant
(
id
)
{
async
selectMerchant
(
id
)
{
this
.
$apis
.
role
.
merchantRootById
({
id
}).
then
(
res
=>
{
let
res
=
await
this
.
$refs
.
productFrom
.
accountTypeSearchRequest
({
id
},
'create'
)
this
.
accountList
=
res
.
map
(
item
=>
{
this
.
accountList
=
res
.
map
(
item
=>
{
item
.
select
=
fals
e
item
.
select
=
tru
e
return
item
return
item
})
})
})
},
},
// 选择商户权限
// 选择商户权限
selectCurAccount
(
item
,
index
)
{
selectCurAccount
(
item
,
index
)
{
...
@@ -158,21 +158,20 @@ export default {
...
@@ -158,21 +158,20 @@ export default {
}
}
},
},
// 确定按钮---处理参数---提交数据---创建为0---草稿为1
// 确定按钮---处理参数---提交数据---创建为0---草稿为1
toCreateRole
(
delFlag
)
{
toCreateRole
(
delFlag
)
{
let
{
merchantId
,
roleDesc
,
roleName
}
=
this
.
ruleForm
let
{
merchantId
,
roleDesc
,
roleName
}
=
this
.
ruleForm
if
(
!
merchantId
)
{
if
(
!
merchantId
)
{
this
.
$message
.
error
(
"请选择所属商户"
);
this
.
$message
.
error
(
'请选择所属商户'
)
return
return
}
}
if
(
!
roleName
)
{
if
(
!
roleName
)
{
this
.
$message
.
error
(
"请输入角色名称"
);
this
.
$message
.
error
(
'请输入角色名称'
)
return
return
}
}
if
(
this
.
$refs
.
productFrom
.
getSelectInfo
().
length
==
0
)
{
if
(
this
.
$refs
.
productFrom
.
getSelectInfo
().
length
==
0
)
{
this
.
$message
.
error
(
"请选择产品"
);
this
.
$message
.
error
(
'请选择产品'
)
return
;
return
}
}
let
accountTypes
=
JSON
.
stringify
(
this
.
$refs
.
productFrom
.
getSelectInfo
())
let
accountTypes
=
JSON
.
stringify
(
this
.
$refs
.
productFrom
.
getSelectInfo
())
let
para
=
{
let
para
=
{
...
@@ -180,12 +179,12 @@ export default {
...
@@ -180,12 +179,12 @@ export default {
roleName
:
roleName
,
roleName
:
roleName
,
roleDescription
:
roleDesc
,
roleDescription
:
roleDesc
,
delFlag
,
delFlag
,
requestList
:
accountTypes
,
requestList
:
accountTypes
}
}
if
(
this
.
pageType
==
'edit'
)
{
if
(
this
.
pageType
==
'edit'
)
{
para
.
id
=
this
.
editId
para
.
id
=
this
.
editId
this
.
updateRole
(
para
)
this
.
updateRole
(
para
)
}
else
{
}
else
{
this
.
insertRole
(
para
)
this
.
insertRole
(
para
)
}
}
},
},
...
@@ -204,7 +203,7 @@ export default {
...
@@ -204,7 +203,7 @@ export default {
})
})
},
},
toBack
()
{
toBack
()
{
this
.
$router
.
push
(
"/role/index"
);
this
.
$router
.
push
(
'/role/index'
)
}
}
}
}
}
}
...
@@ -246,6 +245,7 @@ export default {
...
@@ -246,6 +245,7 @@ export default {
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
center
;
justify-content
:
center
;
z-index
:
20
;
.wrap_driver
{
.wrap_driver
{
margin
:
0
40px
;
margin
:
0
40px
;
}
}
...
@@ -258,5 +258,4 @@ export default {
...
@@ -258,5 +258,4 @@ export default {
margin-right
:
15px
;
margin-right
:
15px
;
}
}
}
}
</
style
>
</
style
>
src/views/role/index.vue
View file @
e2e6348
...
@@ -137,7 +137,7 @@ export default {
...
@@ -137,7 +137,7 @@ export default {
this
.
$apis
.
role
.
roleDataList
(
para
).
then
(
res
=>
{
this
.
$apis
.
role
.
roleDataList
(
para
).
then
(
res
=>
{
this
.
tableData
=
res
.
data
this
.
tableData
=
res
.
data
this
.
tableTotal
=
res
.
count
this
.
tableTotal
=
res
.
count
if
(
!
res
.
data
.
length
)
{
if
(
!
res
.
data
.
length
||
!
res
)
{
this
.
$refs
.
table
.
setTableHeightFun
()
this
.
$refs
.
table
.
setTableHeightFun
()
}
}
// this.$nextTick(() => {
// this.$nextTick(() => {
...
...
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