Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
scrm-micro-settings
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 f09a265e
authored
Jun 17, 2022
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新建员工创建角色交互修改
1 parent
f37e5094
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
773 additions
and
7 deletions
src/assets/css/demo.scss
src/views/employee/components/createRole.vue
src/views/employee/components/selectProduct.vue
src/views/employee/editEmployee.vue
src/assets/css/demo.scss
View file @
f09a265
...
...
@@ -34,4 +34,8 @@
img
{
width
:
64px
;
}
}
.message-z
{
z-index
:
9999
!
important
;
}
\ No newline at end of file
src/views/employee/components/createRole.vue
0 → 100644
View file @
f09a265
<!--
* @Description:
* @Author: huyue
* @Date: 2022-06-10 15:36:06
* @LastEditors: huyue
* @LastEditTime: 2022-06-17 16:39:38
-->
<
template
>
<div>
<GLDialog
:width=
"'1080px'"
:visible=
"roleVisible"
:close-on-click-modal=
"false"
@
close=
"handleClose"
title=
"创建角色"
:showClose=
"true"
>
<el-form
:model=
"ruleForm"
:rules=
"rules"
ref=
"ruleForm"
label-width=
"100px"
class=
"demo-ruleForm"
>
<el-form-item
class=
"aa"
v-if=
"$globalState.session.accountLevel != 4"
label=
"所属商户"
prop=
"merchantId"
>
<el-select
size=
"small"
style=
"width: 40%"
v-model=
"ruleForm.merchantId"
clearable
filterable
placeholder=
"请选择"
@
change=
"merchantChange"
>
<el-option
v-for=
"item in merchantList"
:key=
"item.id"
:label=
"item.merchantName"
:value=
"item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item
label=
"所属商户"
prop=
"merchantName"
v-else
>
<span>
{{
$globalState
.
session
.
merchantName
}}
</span>
</el-form-item>
<el-form-item
label=
"角色名称"
prop=
"roleName"
>
<el-input
size=
"small"
maxlength=
"20"
style=
"width: 40%; padding-right: 50px"
@
input=
"changeInput"
v-model=
"ruleForm.roleName"
placeholder=
"请输入角色名称"
></el-input>
</el-form-item>
<el-form-item
label=
"角色说明"
prop=
"roleDesc"
>
<el-input
size=
"small"
maxlength=
"50"
style=
"width: 40%; padding-right: 50px"
@
input=
"changeInput"
v-model=
"ruleForm.roleDesc"
placeholder=
"请输入角色说明"
></el-input>
</el-form-item>
<el-form-item
label=
"角色权限"
prop=
"roleAuth"
>
<el-checkbox-group
v-model=
"ruleForm.roleAuth"
>
<el-checkbox
v-for=
"(itm, idx) in accountListSelect"
:label=
"itm.accounttypeName"
@
change=
"selectCurAccount(itm, idx)"
:key=
"idx"
>
{{
itm
.
accounttypeName
}}
</el-checkbox>
</el-checkbox-group>
<SelectProduct
ref=
"productFrom"
:roleType=
"true"
title=
"角色权限"
></SelectProduct>
</el-form-item>
</el-form>
<div
slot=
"footer"
>
<el-button
:size=
"size"
@
click=
"handleClose"
>
取消
</el-button>
<el-button
:size=
"size"
type=
"primary"
@
click=
"toCreateRole"
>
提交
</el-button>
</div>
</GLDialog>
</div>
</
template
>
<
script
>
import
SelectProduct
from
'./selectProduct'
export
default
{
name
:
'CreateRole'
,
components
:
{
SelectProduct
},
data
()
{
return
{
roleVisible
:
false
,
ruleForm
:
{
merchantId
:
''
,
roleName
:
''
,
roleDesc
:
''
,
roleAuth
:
''
},
rules
:
{
roleName
:
[{
required
:
true
,
message
:
'请输入角色名称'
,
trigger
:
'blur'
}],
merchantId
:
[{
required
:
true
,
message
:
'请选择所属商户'
,
trigger
:
'change'
}],
roleAuth
:
[{
required
:
true
,
message
:
'请选择角色权限'
,
trigger
:
'change'
}]
},
//商户下拉框
merchantList
:
[],
accountListSelect
:
[],
rootList
:
[]
}
},
methods
:
{
init
()
{
this
.
roleVisible
=
true
this
.
getMerchantName
()
},
handleClose
()
{
this
.
roleVisible
=
false
},
getMerchantName
()
{
this
.
$apis
.
role
.
merchantDataList
({
source
:
'glsx'
}).
then
(
res
=>
{
this
.
merchantList
=
res
if
(
this
.
$globalState
.
session
.
accountLevel
==
4
)
{
this
.
ruleForm
.
merchantId
=
this
.
merchantList
[
0
].
id
this
.
selectMerchant
(
this
.
merchantList
[
0
].
id
)
}
// this.filterList()
})
},
// 选择商户----获取权限
async
selectMerchant
(
id
,
list
)
{
let
res
=
await
this
.
$refs
.
productFrom
.
findMenuFunTreeByMerId
({
id
})
console
.
log
(
res
)
this
.
accountListSelect
=
res
.
map
(
item
=>
{
item
.
select
=
false
return
item
})
},
// 选择商户权限
selectCurAccount
(
item
,
index
)
{
console
.
log
(
item
,
index
)
this
.
isChangeEdit
=
true
this
.
roleRootRules
=
false
this
.
accountListSelect
[
index
].
select
=
!
item
.
select
this
.
curRootIndex
=
0
if
(
this
.
accountListSelect
[
index
].
select
)
{
this
.
rootList
.
push
(
item
)
}
else
{
let
arr
=
this
.
rootList
.
filter
(
el
=>
{
return
item
.
accounttypeId
!=
el
.
accounttypeId
})
this
.
rootList
=
arr
}
let
accounttypeId
=
[]
this
.
rootList
.
forEach
(
item
=>
{
accounttypeId
.
push
(
item
.
accounttypeId
)
})
console
.
log
(
this
.
rootList
,
accounttypeId
,
'99999'
)
this
.
accounttypeIds
=
accounttypeId
this
.
$refs
.
productFrom
.
findMenuFunTree
(
item
.
accounttypeId
,
item
.
select
)
},
toCreateRole
()
{
console
.
log
(
this
.
ruleForm
,
this
.
$refs
.
productFrom
.
getSelectInfo
())
this
.
$refs
.
ruleForm
.
validate
(
valid
=>
{
if
(
valid
)
{
let
{
merchantId
,
roleDesc
,
roleName
}
=
this
.
ruleForm
let
product
=
this
.
$refs
.
productFrom
.
getSelectInfo
()
if
(
product
&&
product
.
every
(
item
=>
item
.
productList
.
length
==
0
))
{
this
.
$message
({
type
:
'error'
,
message
:
'请至少选择一个产品'
,
customClass
:
'message-z'
})
return
}
let
accountTypes
=
JSON
.
stringify
(
this
.
$refs
.
productFrom
.
getSelectInfo
())
let
para
=
{
merchantId
:
merchantId
,
roleName
:
roleName
,
roleDescription
:
roleDesc
,
delFlag
:
0
,
requestList
:
accountTypes
}
console
.
log
(
para
)
this
.
$apis
.
role
.
createRole
(
para
).
then
(
res
=>
{
res
?
this
.
$message
.
success
(
'操作成功'
)
:
this
.
$message
.
error
(
'操作失败'
)
this
.
$emit
(
'updataRole'
,
true
)
this
.
roleVisible
=
!
res
})
}
else
{
return
false
}
})
}
}
}
</
script
>
<
style
scoped
lang=
"scss"
>
/
deep
/
{
.el-dialog__body
{
padding
:
20px
;
}
.el-form-item
{
display
:
inline-block
;
width
:
50%
;
vertical-align
:
text-top
;
margin-bottom
:
0
!important
;
.el-input
{
width
:
360px
!important
;
}
&
:last-child
{
width
:
100%
;
}
}
}
</
style
>
src/views/employee/components/selectProduct.vue
0 → 100644
View file @
f09a265
<
template
>
<div
class=
"account-body"
v-loading=
"loading"
v-if=
"tabMenuStatus"
>
<!--
<div
class=
"account-title"
>
{{
title
}}
</div>
-->
<el-tabs
v-if=
"tabMenu.length != 0"
v-model=
"tabName"
type=
"card"
@
tab-click=
"handleClik"
>
<template
v-for=
"(item, index) in tabMenu"
>
<el-tab-pane
v-show=
"item && item.accounttypeId"
:label=
"item.accounttypeName"
:name=
"item.accounttypeId"
v-if=
"item"
:key=
"index"
></el-tab-pane>
</
template
>
</el-tabs>
<div
class=
"account-select-pro"
v-for=
"(item, index) in tabMenu"
:key=
"index"
v-show=
"tabName == item.accounttypeId"
>
<label>
选择产品:
</label>
<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-group>
</div>
<div
class=
"account-select-menu"
>
请选择产品权限:
</div>
<div
class=
"menu-box"
>
<div
class=
"menu-box-panel"
>
<div
:key=
"index"
v-for=
"(item, index) in tabMenu"
>
<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"
>
{{ itm.productName }}
</div>
</div>
<div
v-show=
"tabName == item.accounttypeId"
class=
"menu-box-tree"
v-if=
"item.products"
>
<div
v-for=
"(itm, idx) in item.products"
:key=
"idx"
>
<div
class=
"nodata"
v-if=
"item.productsArr.length == 0 || itm.merchantProTreeResponses.length == 0"
>
<img
src=
"../../../assets/img/empty.png"
alt=
""
/>
<div>
{{ item.productsArr.length == 0 ? '请先选择产品' : '暂无菜单权限' }}
</div>
</div>
<div
v-else
>
<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>
</template>
<
script
>
import
util
from
'@/utils/util'
export
default
{
name
:
'product'
,
props
:
{
title
:
{
type
:
String
},
roleType
:
{
type
:
Boolean
}
},
data
()
{
return
{
loading
:
false
,
tabMenuStatus
:
false
,
treeHeight
:
450
,
tabMenu
:
[],
tabMenu_r
:
[],
tabMenu_x
:
[],
tabMenu_s
:
[],
accountList
:
[],
selectIndex
:
0
,
productId
:
0
,
products
:
[],
productsArr
:
[],
tabName
:
''
,
productTab
:
''
,
defaultProps
:
{
children
:
'children'
,
label
:
'label'
},
accountTypes
:
[]
}
},
watch
:
{
tabMenu
:
{
handler
()
{
this
.
tabMenuStatus
=
this
.
tabMenu
.
some
(
item
=>
item
)
},
deep
:
true
}
},
methods
:
{
handleClik
(
tab
,
event
)
{
console
.
log
(
tab
,
event
)
const
tabId
=
tab
.
name
const
productTab
=
this
.
tabMenu
.
find
(
i
=>
i
.
accounttypeId
==
tabId
)
this
.
productTab
=
productTab
.
productsArr
[
0
]
?
productTab
.
productsArr
[
0
].
productId
:
''
},
selectPro
(
data
)
{
this
.
$parent
.
roleRootRules
=
false
this
.
$parent
.
editStatus
=
true
this
.
productTab
=
data
.
length
!=
0
?
data
[
data
.
length
-
1
].
productId
:
''
const
{
tabName
,
tabMenu
,
productTab
}
=
this
console
.
log
(
tabName
,
data
,
productTab
,
'选中'
)
// 设置全选
var
merchantProTreeResponses
=
tabMenu
.
find
(
i
=>
i
.
accounttypeId
==
tabName
).
products
.
find
(
j
=>
j
.
productId
==
productTab
)
var
arr
=
merchantProTreeResponses
?
merchantProTreeResponses
.
merchantProTreeResponses
:
''
this
.
$refs
[
`tree_
${
tabName
}
_
${
productTab
}
`
]
?
this
.
$refs
[
`tree_
${
tabName
}
_
${
productTab
}
`
][
0
].
setCheckedKeys
(
this
.
getAllId
(
arr
))
:
''
this
.
$nextTick
(()
=>
{
this
.
addStyle
()
})
},
productClick
(
productId
)
{
this
.
productTab
=
productId
},
findMenuFunTree
(
id
,
status
)
{
let
menu
=
util
.
deepClone
(
this
.
tabMenu
)
let
tabMenu
=
util
.
deepClone
(
this
.
tabMenu_r
)
let
menuSelect
=
tabMenu
.
filter
(
item
=>
item
.
accounttypeId
==
id
)
let
idx
=
tabMenu
.
findIndex
(
item
=>
item
.
accounttypeId
==
id
)
this
.
tabMenu_r
.
forEach
((
item
,
index
)
=>
{
if
(
menu
.
length
==
0
)
{
this
.
tabMenu
[
index
]
=
''
return
}
menu
.
forEach
(
itm
=>
{
if
(
itm
.
accounttypeId
!=
item
.
accounttypeId
)
{
if
(
!
this
.
tabMenu
[
index
])
{
this
.
tabMenu
[
index
]
=
''
}
}
if
(
itm
.
accounttypeId
==
item
.
accounttypeId
)
{
if
(
!
this
.
tabMenu
[
index
])
{
this
.
tabMenu
[
index
]
=
item
}
}
})
})
if
(
status
)
{
this
.
$set
(
this
.
tabMenu
,
idx
,
menuSelect
[
0
])
this
.
tabName
=
this
.
tabMenu
[
idx
]
?
this
.
tabMenu
[
idx
].
accounttypeId
:
''
}
else
{
this
.
$set
(
this
.
tabMenu
,
idx
,
''
)
let
accounttypeId
=
this
.
tabMenu
.
find
(
item
=>
item
)
this
.
tabName
=
accounttypeId
?
accounttypeId
.
accounttypeId
:
''
}
console
.
log
(
this
.
tabMenu
)
this
.
tabMenuStatus
=
this
.
tabMenu
.
some
(
item
=>
item
)
},
// 获取当前的所有权限
async
findMenuFunTreeByMerId
(
params
)
{
let
tabMenu
=
await
this
.
$apis
.
store
.
findMenuFunTreeByMerId
(
params
)
tabMenu
=
tabMenu
.
map
(
item
=>
{
return
{
productsArr
:
[],
products
:
item
.
products
,
accounttypeName
:
item
.
accounttypeName
,
accounttypeId
:
item
.
accounttypeId
}
})
this
.
tabMenu_r
=
util
.
deepClone
(
tabMenu
)
this
.
accountTypes
=
tabMenu
.
map
(
item
=>
{
return
{
products
:
null
,
accounttypeId
:
item
.
accounttypeId
}
})
this
.
tabName
=
this
.
tabMenu_r
[
0
].
accounttypeId
return
this
.
tabMenu_r
},
// 获取当前的所有权限
async
accountTypeSearchRequest
(
params
,
arr
)
{
let
account
=
''
let
tabMenu
=
await
this
.
$apis
.
store
.
findMenuFunTreeByMerId
(
params
)
this
.
accountList
=
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
.
tabMenu_s
=
util
.
deepClone
(
this
.
accountList
)
// this.tabName = this.tabMenu[0].accounttypeId
this
.
findPermissionsByMerId
(
arr
)
this
.
tabMenu_r
=
util
.
deepClone
(
this
.
accountList
)
return
this
.
accountList
},
// 获取已选择的权限
findPermissionsByMerId
(
arr
)
{
console
.
log
(
arr
)
let
accounttypeId
=
[]
arr
.
forEach
(
item
=>
{
accounttypeId
.
push
(
item
.
accounttypeId
)
this
.
accountList
.
forEach
((
itm
,
index
)
=>
{
console
.
log
(
accounttypeId
)
if
(
accounttypeId
.
includes
(
itm
.
accounttypeId
))
{
this
.
tabMenu
[
index
]
=
itm
if
(
!
item
.
productList
)
{
return
}
item
.
productList
.
forEach
(
i
=>
{
itm
.
products
.
forEach
(
j
=>
{
if
(
i
.
productId
==
j
.
productId
)
{
itm
.
productsArr
.
push
(
j
)
this
.
$nextTick
(()
=>
{
setTimeout
(()
=>
{
this
.
addStyle
()
this
.
$refs
[
`tree_
${
itm
.
accounttypeId
}
_
${
j
.
productId
}
`
]
?
this
.
$refs
[
`tree_
${
itm
.
accounttypeId
}
_
${
j
.
productId
}
`
][
0
].
setCheckedKeys
(
i
.
idList
)
:
''
},
300
)
})
}
})
})
}
else
{
this
.
tabMenu
[
index
]
=
''
}
})
})
this
.
tabMenuStatus
=
this
.
tabMenu
.
some
(
item
=>
item
)
let
tabMenu
=
this
.
tabMenu
.
filter
((
item
,
index
)
=>
{
return
item
&&
item
.
accounttypeId
&&
this
.
tabMenu
[
index
].
productsArr
.
length
>
0
})
setTimeout
(()
=>
{
this
.
tabName
=
tabMenu
[
0
].
accounttypeId
this
.
productTab
=
tabMenu
[
0
].
productsArr
[
0
].
productId
},
100
)
},
resetView
()
{
this
.
tabMenu
=
[]
this
.
accountList
=
util
.
deepClone
(
this
.
tabMenu_s
)
this
.
tabMenu_x
.
forEach
(
item
=>
{
this
.
accountList
.
forEach
(
itm
=>
{
if
(
item
.
accounttypeId
==
itm
.
accounttypeId
)
{
this
.
tabMenu
.
push
(
itm
)
item
.
products
.
forEach
(
i
=>
{
itm
.
products
.
forEach
(
j
=>
{
if
(
i
.
productId
==
j
.
productId
)
{
itm
.
productsArr
.
push
(
j
)
this
.
$nextTick
(()
=>
{
this
.
addStyle
()
this
.
$refs
[
`tree_
${
itm
.
accounttypeId
}
_
${
j
.
productId
}
`
]
?
this
.
$refs
[
`tree_
${
itm
.
accounttypeId
}
_
${
j
.
productId
}
`
][
0
].
setCheckedKeys
(
i
.
menuIds
)
:
''
})
}
})
})
}
})
})
},
// 渲染树结构
renderContent
(
h
,
v
)
{
if
(
v
.
data
.
logo
==
'functionValue'
)
{
return
(
<
div
class
=
"custom-tree-node fun-tree-node"
>
<
span
>
{
v
.
node
.
label
}
<
/span
>
<
/div
>
)
}
else
{
return
(
<
div
class
=
"custom-tree-node"
>
<
span
>
{
v
.
node
.
label
}
<
/span
>
<
/div
>
)
}
},
addStyle
()
{
const
nodes
=
document
.
getElementsByClassName
(
'fun-tree-node'
)
for
(
let
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
const
parentNode
=
nodes
[
i
].
parentNode
parentNode
.
style
.
float
=
'left'
}
},
clickDeal
(
currentObj
,
treeStatus
)
{
this
.
$parent
.
editStatus
=
true
// 用于:父子节点严格互不关联时,父节点勾选变化时通知子节点同步变化,实现单向关联。
let
selected
=
treeStatus
.
checkedKeys
.
indexOf
(
currentObj
.
id
)
// -1未选中
// 选中
if
(
selected
!==
-
1
)
{
// 子节点只要被选中父节点就被选中
this
.
selectedParent
(
currentObj
)
// 统一处理子节点为相同的勾选状态
this
.
uniteChildSame
(
currentObj
,
true
)
}
else
{
// 未选中 处理子节点全部未选中
console
.
log
(
currentObj
)
if
(
currentObj
.
children
!==
null
)
{
if
(
currentObj
.
children
.
length
!==
0
)
{
this
.
uniteChildSame
(
currentObj
,
false
)
}
//放开时为当子节点全为未选中时父节点也变为未选中状态 注释后就是父节点不和子节点强制绑定
// this.uniteParentSame(currentObj.id,treeStatus)//当子节点全为未选中时父节点也变为未选中状态
}
// else {
// this.uniteParentSame(currentObj.id,treeStatus)
// }
}
},
uniteParentSame
(
id
,
treeStatus
)
{
//当子节点全为未选中时父节点也变为未选中状态
const
tree_ref
=
`tree_
${
this
.
tabName
}
_
${
this
.
productTab
}
`
let
node
=
this
.
$refs
[
tree_ref
][
0
].
getNode
(
id
)
//获取当前节点的节点树
if
(
node
.
parent
!==
null
&&
node
.
parent
!==
undefined
)
{
let
parentNode
=
node
.
parent
.
data
//获取当前节点的父节点树
if
(
parentNode
!=
undefined
)
{
//判断父节点是否存在
for
(
let
i
=
0
;
i
<
parentNode
.
children
.
length
;
i
++
)
{
let
checkedKeys
=
this
.
$refs
[
tree_ref
][
0
].
getCheckedKeys
()
let
hafCheckedKeys
=
this
.
$refs
[
tree_ref
][
0
].
getHalfCheckedKeys
()
let
selectNodes
=
checkedKeys
.
concat
(
hafCheckedKeys
)
//获取已选择树节点
let
selected
=
selectNodes
.
indexOf
(
parentNode
.
children
[
i
].
id
)
// -1当前节点的同级节点是否全部未选中
if
(
selected
!==
-
1
)
{
return
}
}
}
else
{
return
}
this
.
$refs
[
tree_ref
][
0
].
setChecked
(
parentNode
.
id
,
false
)
//修改节点为未选择
if
(
node
.
level
>
2
)
{
//判断是否是最上级节点
this
.
uniteParentSame
(
parentNode
.
id
,
treeStatus
)
}
}
else
{
return
}
},
// 统一处理子节点为相同的勾选状态
uniteChildSame
(
treeList
,
isSelected
)
{
const
tree_ref
=
`tree_
${
this
.
tabName
}
_
${
this
.
productTab
}
`
this
.
$refs
[
tree_ref
][
0
].
setChecked
(
treeList
.
id
,
isSelected
)
console
.
log
(
treeList
)
if
(
treeList
.
children
!==
null
)
{
for
(
let
i
=
0
;
i
<
treeList
.
children
.
length
;
i
++
)
{
this
.
uniteChildSame
(
treeList
.
children
[
i
],
isSelected
)
}
}
},
// 统一处理父节点为选中
selectedParent
(
currentObj
)
{
const
tree_ref
=
`tree_
${
this
.
tabName
}
_
${
this
.
productTab
}
`
let
currentNode
=
this
.
$refs
[
tree_ref
][
0
].
getNode
(
currentObj
)
if
(
currentNode
.
parent
.
key
!==
undefined
)
{
this
.
$refs
[
tree_ref
][
0
].
setChecked
(
currentNode
.
parent
,
true
)
this
.
selectedParent
(
currentNode
.
parent
)
}
},
// 获取所有节点的id
getAllId
(
data
,
arr
=
[])
{
if
(
data
)
{
data
.
forEach
(
item
=>
{
arr
.
push
(
item
.
id
)
if
(
item
.
children
&&
item
.
children
.
length
!=
0
)
{
item
.
children
.
forEach
(
i
=>
{
arr
.
push
(
i
.
id
)
this
.
getAllId
(
i
.
children
,
arr
)
})
}
})
}
return
arr
},
getSelectInfo
()
{
this
.
tabMenu
=
this
.
tabMenu
.
filter
(
item
=>
item
)
this
.
accountTypes
=
this
.
tabMenu
.
map
(
item
=>
{
let
products
=
[]
let
productList
=
[]
item
.
productsArr
.
forEach
(
itm
=>
{
const
checkedNodes
=
this
.
$refs
[
`tree_
${
item
.
accounttypeId
}
_
${
itm
.
productId
}
`
]
?
this
.
$refs
[
`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
functionIdList
=
checkedNodes
.
filter
(
item
=>
item
.
logo
===
'function'
)
const
functionValueIdLists
=
checkedNodes
.
filter
(
item
=>
item
.
logo
===
'functionValue'
)
var
list
=
[]
/** { menuId, id, functionValue} */
if
(
functionValueIdLists
.
length
!==
0
)
{
functionValueIdLists
.
forEach
((
j
,
index
)
=>
{
if
(
list
.
map
(
item
=>
item
.
id
).
includes
(
j
.
parentId
))
{
const
obj
=
list
.
find
(
k
=>
k
.
id
===
j
.
parentId
)
obj
.
functionValue
+=
';'
+
j
.
id
+
':'
+
j
.
label
}
else
{
list
.
push
({
id
:
j
.
parentId
,
menuId
:
j
.
superParentId
,
functionValue
:
j
.
id
+
':'
+
j
.
label
})
}
})
}
if
(
functionIdList
.
length
!==
0
)
{
functionIdList
.
forEach
(
i
=>
{
list
.
push
({
id
:
i
.
parentId
,
menuId
:
i
.
superParentId
})
})
}
console
.
log
(
menuIdList
,
functionIdList
,
functionValueIdLists
,
list
)
if
(
this
.
roleType
)
{
productList
.
push
({
productId
:
itm
.
productId
,
functionIdList
:
list
,
// functionValue: list,
menuIdList
:
menuIdList
})
}
else
{
products
.
push
({
productId
:
itm
.
productId
,
functionIds
:
list
,
// functionValue: list,
menuIds
:
menuIdList
})
}
})
if
(
this
.
roleType
)
{
return
{
accounttypeId
:
item
.
accounttypeId
,
productList
}
}
else
{
return
{
accounttypeId
:
item
.
accounttypeId
,
products
}
}
})
console
.
log
(
this
.
accountTypes
,
' =-=-=-=-=='
)
return
this
.
accountTypes
}
},
mounted
()
{
// this.accountTypeSearchRequest();
// this.findPermissionsByMerId()
}
}
</
script
>
<
style
scoped
lang=
"scss"
>
.account-body
{
border
:
1px
solid
#e5e5e5
;
border-radius
:
4px
;
/deep/
{
.
el-checkbox
:
last-of-type
{
margin-right
:
8px
;
}
.el-tabs--card
>
.el-tabs__header
.el-tabs__nav
{
border
:
0
;
}
.el-tabs--card
>
.el-tabs__header
{
border
:
0
;
border-bottom
:
1px
solid
#e5e5e5
;
//
background-color
:
#f4f6fc
;
}
.el-tabs--card
>
.el-tabs__header
.el-tabs__item
{
position
:
relative
;
border
:
none
;
//
width
:
180px
;
margin
:
2px
;
text-align
:
center
;
&::after
{
content
:
''
;
display
:
inline-block
;
width
:
calc
(
100%
-
40px
);
height
:
2px
;
background-color
:
#5850ff
;
position
:
absolute
;
bottom
:
-2px
;
left
:
20px
;
}
}
.el-tabs__item.is-active
{
background-color
:
#fff
;
}
.el-form-item
{
margin-bottom
:
0
!important
;
}
}
.account-title
{
font-size
:
16px
;
font-weight
:
600
;
color
:
#333333
;
line-height
:
16px
;
letter-spacing
:
1px
;
margin-bottom
:
30px
;
}
.account-select-pro
{
padding-left
:
20px
;
font-size
:
14px
;
font-weight
:
500
;
color
:
#333333
;
line-height
:
20px
;
display
:
flex
;
flex-wrap
:
wrap
;
//
margin-top
:
12px
;
label
{
margin-right
:
20px
;
}
}
.account-select-menu
{
font-size
:
14px
;
font-weight
:
500
;
color
:
#333333
;
line-height
:
20px
;
margin-top
:
6px
;
padding-left
:
20px
;
}
.menu-box
{
position
:
relative
;
margin-top
:
8px
;
background
:
#fff
;
border-radius
:
4px
;
padding
:
8px
20px
16px
;
.tab-item
{
//
width
:
180px
;
background
:
#fafafa
;
border-radius
:
4px
4px
0px
0px
;
border
:
1px
solid
rgba
(
229
,
229
,
229
,
1
);
border-bottom
:
none
;
font-size
:
14px
;
line-height
:
14px
;
font-weight
:
400
;
color
:
#37383a
;
text-align
:
center
;
padding
:
12px
20px
;
margin-right
:
1px
;
cursor
:
pointer
;
&.select-checked
{
position
:
relative
;
color
:
#5850ff
;
background-color
:
#fff
;
transform
:
scaleY
(
1.05
);
}
}
.menu-box-tab
{
display
:
flex
;
}
.menu-box-tree
{
background
:
#ffffff
;
border
:
1px
solid
rgba
(
229
,
229
,
229
,
1
);
border-radius
:
0px
4px
4px
4px
;
height
:
305px
;
overflow
:
auto
;
}
}
}
.nodata
{
position
:
absolute
;
top
:
50%
;
left
:
50%
;
text-align
:
center
;
transform
:
translate
(
-50%
,
-50%
);
img
{
width
:
64px
;
height
:
41px
;
margin-bottom
:
12px
;
}
}
</
style
>
src/views/employee/editEmployee.vue
View file @
f09a265
...
...
@@ -18,7 +18,7 @@
</
template
>
<
template
v-if=
"userInfo.accountLevel == 4 && routeInfo.addOrEdit == 1"
slot=
"roleIdsSlot"
>
<el-button
class=
"m-l-10"
type=
"primary"
@
click=
"handleJumpRole"
>
创建角色
</el-button>
<
el-button
class=
"m-l-10 el-icon-refresh"
type=
"primary"
@
click=
"handleRefresh"
>
刷新
</el-button
>
<
!--
<el-button
class=
"m-l-10 el-icon-refresh"
type=
"primary"
@
click=
"handleRefresh"
>
刷新
</el-button>
--
>
</
template
>
<
template
slot=
"visibleInferiorMer"
slot-scope=
"item"
>
<el-input
:style=
"
{ width: item.width || '320px' }" placeholder="可见商户" v-model="filterText">
</el-input>
...
...
@@ -27,6 +27,8 @@
</
template
>
</glsx-combi-form>
</div>
<CreateRole
ref=
"createRole"
@
updataRole=
"updataRole"
></CreateRole>
<GLFooter>
<el-button
type=
"primary"
@
click=
"handleConfirm"
>
确定
</el-button>
<el-button
type=
"default"
@
click=
"handleCancel"
>
取消
</el-button>
...
...
@@ -35,6 +37,7 @@
</template>
<
script
>
import
CreateRole
from
'./components/createRole'
import
{
utils
}
from
'glsx-common'
// import selectPage from './components/selectPage'
import
glsxCombiForm
from
'./glsx-combi-form'
...
...
@@ -42,7 +45,8 @@ export default {
name
:
'editEmployee'
,
components
:
{
glsxCombiForm
glsxCombiForm
,
CreateRole
// selectPage
},
...
...
@@ -103,8 +107,22 @@ export default {
}
],
visibleInferiorMer
:
[{
required
:
true
,
message
:
'请选择可见商户'
,
trigger
:
'change'
}],
roleIds
:
[{
required
:
true
,
message
:
'请选择角色权限'
,
trigger
:
'change'
}]
// staffEmail: [{ required: false, validator: (rule, value, callback) => {}, trigger: 'change' }]
roleIds
:
[{
required
:
true
,
message
:
'请选择角色权限'
,
trigger
:
'change'
}],
staffEmail
:
[
{
required
:
false
,
validator
:
(
rule
,
value
,
callback
)
=>
{
var
reg
=
/^
[
a-zA-Z0-9_-
]
+@
[
a-zA-Z0-9_-
]
+
(\.[
a-zA-Z0-9_-
]
+
)
+$/
console
.
log
(
reg
.
test
(
value
))
if
(
!
reg
.
test
(
value
))
{
return
callback
(
new
Error
(
'请输入正确格式的邮箱'
))
}
else
{
return
callback
()
}
},
trigger
:
'change'
}
]
},
isBlock
:
true
,
editFormData
:
[
...
...
@@ -321,8 +339,10 @@ export default {
this
.
editForm
.
password
=
''
},
handleJumpRole
()
{
let
path
=
document
.
location
.
pathname
.
split
(
'/'
)[
1
]
this
.
$history
.
push
(
'/'
+
path
+
'/role/create'
)
console
.
log
(
'创建角色'
,
this
.
$refs
.
createRole
)
// let path = document.location.pathname.split('/')[1]
// this.$history.push('/' + path + '/role/create')
this
.
$refs
.
createRole
.
init
()
},
handleRefresh
()
{
this
.
editForm
.
merchantId
...
...
@@ -404,6 +424,9 @@ export default {
this
.
$refs
.
tree
.
setCheckedKeys
(
allId
)
}
this
.
isCheckAll
=
!
this
.
isCheckAll
},
updataRole
()
{
this
.
getRoleList
(
this
.
editForm
.
merchantId
)
}
},
...
...
@@ -418,7 +441,7 @@ export default {
this
.
routeInfo
.
addOrEdit
!=
1
?
this
.
getInfo
()
:
''
}
}
</
script
>
</
script
>
<
style
>
.config-employee
{
...
...
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