Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-4
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
office
haoban-4
Commits
e97c7475
Commit
e97c7475
authored
Sep 09, 2020
by
caoyanzhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: 权限设置
parent
0e98ba68
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
43 deletions
+84
-43
edit-role.vue
src/views/enterprise/edit-role.vue
+16
-31
edit-store-role.vue
src/views/enterprise/edit-store-role.vue
+68
-12
No files found.
src/views/enterprise/edit-role.vue
View file @
e97c7475
...
@@ -88,8 +88,7 @@ export default {
...
@@ -88,8 +88,7 @@ export default {
const
{
roleId
}
=
this
.
$route
.
query
;
const
{
roleId
}
=
this
.
$route
.
query
;
this
.
$emit
(
'showAsideMenu'
,
false
);
this
.
$emit
(
'showAsideMenu'
,
false
);
this
.
wxEnterpriseId
=
haoBanUser
.
wxEnterpriseId
;
this
.
wxEnterpriseId
=
haoBanUser
.
wxEnterpriseId
;
await
this
.
getMenuList
();
await
this
.
getMenuList
(
roleId
);
this
.
findAppSetting
(
roleId
);
if
(
roleId
)
{
if
(
roleId
)
{
this
.
bread
[
1
]
=
{
name
:
'编辑管理角色'
};
this
.
bread
[
1
]
=
{
name
:
'编辑管理角色'
};
this
.
getRoleDetail
(
roleId
);
this
.
getRoleDetail
(
roleId
);
...
@@ -97,18 +96,26 @@ export default {
...
@@ -97,18 +96,26 @@ export default {
},
},
methods
:
{
methods
:
{
// 获取权限菜单列表
// 获取权限菜单列表
getMenuList
()
{
getMenuList
(
roleId
)
{
const
params
=
{
wxEnterpriseId
:
this
.
wxEnterpriseId
};
// roleType 1管理员,0门店
const
params
=
{
wxEnterpriseId
:
this
.
wxEnterpriseId
,
roleType
:
1
};
const
prom
=
[];
const
prom
=
[];
this
.
tabList
.
forEach
(
el
=>
{
this
.
tabList
.
forEach
(
el
=>
{
// appType 1好办后台2应用后台3好办小程序4小程序应用
// appType 1好办后台2应用后台3好办小程序4小程序应用
// roleType 1管理员角色 2门店角色
// roleType 1管理员角色 2门店角色
prom
.
push
(
menuList
(
Object
.
assign
({},
params
,
{
appType
:
el
.
appType
,
roleType
:
1
})).
then
(
res
=>
{
prom
.
push
(
menuList
(
Object
.
assign
({},
params
,
{
appType
:
el
.
appType
})).
then
(
res
=>
{
el
.
flatMenu
=
res
.
result
||
[];
el
.
flatMenu
=
res
.
result
||
[];
el
.
menuList
=
this
.
flatDataToTree
(
el
.
flatMenu
);
el
.
menuList
=
this
.
flatDataToTree
(
el
.
flatMenu
);
el
.
menuList
.
forEach
(
item
=>
{
el
.
menuList
.
forEach
(
item
=>
{
this
.
$set
(
el
.
checkedId
,
item
.
menuId
,
[]);
this
.
$set
(
el
.
checkedId
,
item
.
menuId
,
[]);
});
});
if
(
el
.
appType
==
2
||
el
.
appType
==
4
)
{
// 应用开关-查看
findAppSetting
(
Object
.
assign
({},
params
,
{
roleId
,
appType
:
el
.
appType
})).
then
(
res
=>
{
el
.
appIds
=
res
.
result
||
[];
this
.
setChildrenDisable
(
el
.
menuList
,
el
.
appIds
);
});
}
}));
}));
});
});
return
Promise
.
all
(
prom
);
return
Promise
.
all
(
prom
);
...
@@ -174,23 +181,6 @@ export default {
...
@@ -174,23 +181,6 @@ export default {
return
result
;
return
result
;
}
}
},
},
// 应用开关-查看
findAppSetting
(
roleId
)
{
const
params
=
{
wxEnterpriseId
:
this
.
wxEnterpriseId
,
roleId
,
appType
:
''
,
roleType
:
1
,
// 1管理员,0门店
};
this
.
tabList
.
forEach
(
el
=>
{
if
(
el
.
appType
==
2
||
el
.
appType
==
4
)
{
findAppSetting
(
Object
.
assign
({},
params
,
{
appType
:
el
.
appType
})).
then
(
res
=>
{
el
.
appIds
=
res
.
result
||
[];
this
.
setChildrenDisable
(
el
.
menuList
,
el
.
appIds
);
});
}
});
},
// 将平铺的数据转为树形结构
// 将平铺的数据转为树形结构
flatDataToTree
(
data
)
{
flatDataToTree
(
data
)
{
return
data
.
filter
(
el
=>
{
return
data
.
filter
(
el
=>
{
...
@@ -302,25 +292,20 @@ export default {
...
@@ -302,25 +292,20 @@ export default {
if
(
roleId
)
{
if
(
roleId
)
{
params
.
roleId
=
roleId
;
params
.
roleId
=
roleId
;
editRole
(
params
).
then
(
succ
.
bind
(
this
,
roleId
,
'保存成功!'
));
editRole
(
params
).
then
(
succ
.
bind
(
this
,
roleId
,
'保存成功!'
))
.
catch
(()
=>
this
.
roleData
.
loading
=
false
)
;
}
else
{
}
else
{
addRole
(
params
).
then
(
res
=>
{
addRole
(
params
).
then
(
res
=>
{
succ
.
call
(
this
,
res
.
result
.
roleId
,
'新建成功!'
);
succ
.
call
(
this
,
res
.
result
.
roleId
,
'新建成功!'
);
});
})
.
catch
(()
=>
this
.
roleData
.
loading
=
false
)
;
}
}
function
succ
(
roleId
,
msg
)
{
function
succ
(
roleId
,
msg
)
{
const
pro
=
[];
const
pro
=
[];
const
params
=
{
roleId
,
wxEnterpriseId
:
this
.
wxEnterpriseId
};
this
.
tabList
.
forEach
(
el
=>
{
this
.
tabList
.
forEach
(
el
=>
{
if
(
el
.
appType
==
2
||
el
.
appType
==
4
)
{
if
(
el
.
appType
==
2
||
el
.
appType
==
4
)
{
pro
.
push
(
new
Promise
(
resolve
=>
{
pro
.
push
(
new
Promise
(
resolve
=>
{
const
saveApp
=
{
saveAppSetting
(
Object
.
assign
({},
params
,
{
appType
:
el
.
appType
,
json
:
JSON
.
stringify
(
el
.
appIds
)
})).
finally
(
resolve
);
roleId
,
appType
:
el
.
appType
,
wxEnterpriseId
:
this
.
wxEnterpriseId
,
json
:
JSON
.
stringify
(
el
.
appIds
),
// [{appId:1,openFlag:1},{appId:2,openFlag:0}]
};
saveAppSetting
(
saveApp
).
finally
(
resolve
);
}));
}));
}
}
});
});
...
...
src/views/enterprise/edit-store-role.vue
View file @
e97c7475
...
@@ -20,7 +20,10 @@
...
@@ -20,7 +20,10 @@
style=
"margin-top: 12px"
style=
"margin-top: 12px"
:menu-list=
"getActiveMenuList()"
:menu-list=
"getActiveMenuList()"
:checked-id=
"getActiveCheckId()"
:checked-id=
"getActiveCheckId()"
@
change=
"onCheckedChange"
></menu-tree>
:app-ids=
"getAppIds()"
:is-app=
"activeType == 4"
@
change=
"onCheckedChange"
@
app-open-change=
"onAppOpenChange"
></menu-tree>
</el-form-item>
</el-form-item>
<el-form-item
label=
"资源范围"
prop=
"resourceCode"
>
<el-form-item
label=
"资源范围"
prop=
"resourceCode"
>
<div
class=
"resource-list"
>
<div
class=
"resource-list"
>
...
@@ -45,7 +48,7 @@ import navCrumb from '@/components/nav/nav.vue';
...
@@ -45,7 +48,7 @@ import navCrumb from '@/components/nav/nav.vue';
import
MenuTree
from
'./edit-role/menu-tree.vue'
;
import
MenuTree
from
'./edit-role/menu-tree.vue'
;
import
api
from
'@/api/admin-list'
;
import
api
from
'@/api/admin-list'
;
const
{
resourceList
,
menuList
,
editRole
,
roleDetail
}
=
api
;
const
{
resourceList
,
menuList
,
editRole
,
roleDetail
,
findAppSetting
,
saveAppSetting
}
=
api
;
export
default
{
export
default
{
name
:
'EditStoreRole'
,
name
:
'EditStoreRole'
,
...
@@ -79,8 +82,8 @@ export default {
...
@@ -79,8 +82,8 @@ export default {
// 权限菜单列表
// 权限菜单列表
tabList
:
[
tabList
:
[
// 1好办后台2应用后台3好办小程序4小程序应用
// 1好办后台2应用后台3好办小程序4小程序应用
{
label
:
'好办小程序'
,
appType
:
3
,
menuList
:
[],
checkedId
:
{}
},
{
label
:
'好办小程序'
,
appType
:
3
,
menuList
:
[],
checkedId
:
{}
,
appIds
:
[]
},
{
label
:
'小程序应用'
,
appType
:
4
,
menuList
:
[],
checkedId
:
{}
},
{
label
:
'小程序应用'
,
appType
:
4
,
menuList
:
[],
checkedId
:
{}
,
appIds
:
[]
},
],
],
// 资源范围
// 资源范围
resourceList
:
[],
resourceList
:
[],
...
@@ -94,21 +97,27 @@ export default {
...
@@ -94,21 +97,27 @@ export default {
const
haoBanUser
=
JSON
.
parse
(
localStorage
.
getItem
(
'haoBanUser'
)
||
'{}'
);
const
haoBanUser
=
JSON
.
parse
(
localStorage
.
getItem
(
'haoBanUser'
)
||
'{}'
);
this
.
wxEnterpriseId
=
haoBanUser
.
wxEnterpriseId
;
this
.
wxEnterpriseId
=
haoBanUser
.
wxEnterpriseId
;
this
.
$emit
(
'showAsideMenu'
,
false
);
this
.
$emit
(
'showAsideMenu'
,
false
);
await
this
.
initData
();
await
this
.
initData
(
roleId
);
this
.
getRoleDetail
(
roleId
);
this
.
getRoleDetail
(
roleId
);
},
},
methods
:
{
methods
:
{
initData
()
{
initData
(
roleId
)
{
const
params
=
{
wxEnterpriseId
:
this
.
wxEnterpriseId
};
const
params
=
{
wxEnterpriseId
:
this
.
wxEnterpriseId
,
roleType
:
2
};
const
prom
=
[];
const
prom
=
[];
this
.
tabList
.
forEach
(
el
=>
{
this
.
tabList
.
forEach
(
el
=>
{
// appType 1好办后台2应用后台3好办小程序4小程序应用
// appType 1好办后台2应用后台3好办小程序4小程序应用
// roleType 1管理员角色 2门店角色
// roleType 1管理员角色 2门店角色
prom
.
push
(
menuList
(
Object
.
assign
({},
params
,
{
appType
:
el
.
appType
,
roleType
:
2
})).
then
(
res
=>
{
prom
.
push
(
menuList
(
Object
.
assign
({},
params
,
{
appType
:
el
.
appType
})).
then
(
res
=>
{
el
.
menuList
=
this
.
flatDataToTree
(
res
.
result
||
[]);
el
.
menuList
=
this
.
flatDataToTree
(
res
.
result
||
[]);
el
.
menuList
.
forEach
(
item
=>
{
el
.
menuList
.
forEach
(
item
=>
{
this
.
$set
(
el
.
checkedId
,
item
.
menuId
,
[]);
this
.
$set
(
el
.
checkedId
,
item
.
menuId
,
[]);
});
});
if
(
el
.
appType
==
4
)
{
findAppSetting
(
Object
.
assign
({},
params
,
{
roleId
,
appType
:
el
.
appType
})).
then
(
res
=>
{
el
.
appIds
=
res
.
result
||
[];
this
.
setChildrenDisable
(
el
.
menuList
,
el
.
appIds
);
});
}
}));
}));
});
});
prom
.
push
(
resourceList
().
then
(
res
=>
{
prom
.
push
(
resourceList
().
then
(
res
=>
{
...
@@ -168,6 +177,10 @@ export default {
...
@@ -168,6 +177,10 @@ export default {
const
result
=
this
.
tabList
.
filter
(
el
=>
el
.
appType
==
this
.
activeType
);
const
result
=
this
.
tabList
.
filter
(
el
=>
el
.
appType
==
this
.
activeType
);
return
result
[
0
].
checkedId
;
return
result
[
0
].
checkedId
;
},
},
getAppIds
()
{
const
result
=
this
.
tabList
.
filter
(
el
=>
el
.
appType
==
this
.
activeType
);
return
result
[
0
].
appIds
;
},
// 将平铺的数据转为树形结构
// 将平铺的数据转为树形结构
flatDataToTree
(
data
)
{
flatDataToTree
(
data
)
{
return
data
.
filter
(
el
=>
{
return
data
.
filter
(
el
=>
{
...
@@ -204,6 +217,39 @@ export default {
...
@@ -204,6 +217,39 @@ export default {
this
.
roleData
.
menuIds
.
push
({
appType
:
this
.
activeType
,
menuIds
});
this
.
roleData
.
menuIds
.
push
({
appType
:
this
.
activeType
,
menuIds
});
}
}
},
},
onAppOpenChange
(
appIds
)
{
this
.
tabList
.
some
(
el
=>
{
if
(
el
.
appType
==
this
.
activeType
)
{
el
.
appIds
=
appIds
;
this
.
setChildrenDisable
(
el
.
menuList
,
appIds
);
}
return
el
.
appType
==
this
.
activeType
;
});
},
setChildrenDisable
(
menuList
,
appIds
)
{
menuList
.
forEach
(
el
=>
{
let
openFlag
=
false
;
appIds
.
some
(
item
=>
{
if
(
item
.
appId
==
el
.
project
)
{
openFlag
=
item
.
openFlag
;
}
return
item
.
appId
==
el
.
project
;
});
this
.
$set
(
el
,
'disabled'
,
openFlag
==
0
);
if
(
Array
.
isArray
(
el
.
children
))
{
el
.
children
=
setDisable
.
call
(
this
,
el
.
children
,
openFlag
==
0
);
}
});
function
setDisable
(
menuList
,
openFlag
)
{
return
menuList
.
map
(
el
=>
{
this
.
$set
(
el
,
'disabled'
,
openFlag
);
if
(
Array
.
isArray
(
el
.
children
))
{
el
.
children
=
setDisable
.
call
(
this
,
el
.
children
,
openFlag
);
}
return
el
;
});
}
},
onSave
()
{
onSave
()
{
this
.
$refs
.
roleData
.
validate
(
vali
=>
{
this
.
$refs
.
roleData
.
validate
(
vali
=>
{
if
(
!
vali
)
return
;
if
(
!
vali
)
return
;
...
@@ -220,12 +266,22 @@ export default {
...
@@ -220,12 +266,22 @@ export default {
}
}
params
.
resourceCode
=
params
.
resourceCode
.
join
(
','
);
params
.
resourceCode
=
params
.
resourceCode
.
join
(
','
);
this
.
loading
=
true
;
this
.
loading
=
true
;
editRole
(
params
).
then
(
res
=>
{
editRole
(
params
).
then
(
succ
.
bind
(
this
,
roleId
,
'保存成功'
)).
catch
(()
=>
this
.
loading
=
false
);
if
(
res
.
code
==
'0000'
)
{
function
succ
(
roleId
,
msg
)
{
this
.
$message
.
success
(
'保存成功!'
);
const
prom
=
[];
this
.
$router
.
go
(
-
1
);
const
params
=
{
roleId
,
wxEnterpriseId
:
this
.
wxEnterpriseId
};
this
.
tabList
.
forEach
(
el
=>
{
if
(
el
.
appType
==
4
)
{
prom
.
push
(
new
Promise
(
resolve
=>
{
saveAppSetting
(
Object
.
assign
({},
params
,
{
appType
:
el
.
appType
,
json
:
JSON
.
stringify
(
el
.
appIds
)
})).
finally
(
resolve
);
}));
}
}
});
Promise
.
all
(
prom
).
then
(()
=>
{
this
.
$message
.
success
(
msg
);
this
.
$router
.
go
(
-
1
);
}).
finally
(()
=>
this
.
loading
=
false
);
}).
finally
(()
=>
this
.
loading
=
false
);
}
});
});
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment