Commit 83f779ac by Sendya

fix: update RoleList2

parent d860f308
...@@ -100,6 +100,12 @@ export const asyncRouterMap = [ ...@@ -100,6 +100,12 @@ export const asyncRouterMap = [
meta: { title: '角色列表', permission: [ 'table' ] } meta: { title: '角色列表', permission: [ 'table' ] }
}, },
{ {
path: '/list/system-role',
name: 'SystemRole',
component: () => import('@/views/role/RoleList'),
meta: { title: '角色列表2', permission: [ 'table' ]}
},
{
path: '/list/permission-list', path: '/list/permission-list',
name: 'PermissionList', name: 'PermissionList',
component: () => import('@/views/list/PermissionList'), component: () => import('@/views/list/PermissionList'),
...@@ -169,21 +175,6 @@ export const asyncRouterMap = [ ...@@ -169,21 +175,6 @@ export const asyncRouterMap = [
} }
] ]
}, },
{
path: '/system',
name: 'system',
component: RouteView,
redirect: '/system/role',
meta: { title: '系统管理', icon: 'setting', permission: [ 'table' ] },
children: [
{
path: '/system/role',
name: 'SystemRole',
component: () => import('@/views/role/RoleList'),
meta: { title: '角色列表', permission: [ 'table' ]}
}
]
},
// result // result
{ {
......
...@@ -8,46 +8,46 @@ const PERMISSION_ENUM = { ...@@ -8,46 +8,46 @@ const PERMISSION_ENUM = {
'disable': { key: 'disable', label: '禁用' }, 'disable': { key: 'disable', label: '禁用' },
'import': { key: 'import', label: '导入' }, 'import': { key: 'import', label: '导入' },
'export': { key: 'import', label: '导入' }, 'export': { key: 'import', label: '导入' },
}; }
function plugin(Vue) { function plugin(Vue) {
if (plugin.installed) { if (plugin.installed) {
return; return
} }
!Vue.prototype.$auth && Object.defineProperties(Vue.prototype, { !Vue.prototype.$auth && Object.defineProperties(Vue.prototype, {
$auth: { $auth: {
get() { get() {
const _this = this; const _this = this
return (permissions) => { return (permissions) => {
let [permission, action] = permissions.split('.'); const [permission, action] = permissions.split('.')
const permissionList = _this.$store.getters.roles.permissions; const permissionList = _this.$store.getters.roles.permissions
permissionList.find((val) => { permissionList.find((val) => {
return val.permissionId === permission return val.permissionId === permission
}).actionList.findIndex((val) => { }).actionList.findIndex((val) => {
return val === action return val === action
}); })
return false return false
} }
} }
} }
}); })
!Vue.prototype.$enum && Object.defineProperties(Vue.prototype, { !Vue.prototype.$enum && Object.defineProperties(Vue.prototype, {
$enum: { $enum: {
get() { get() {
// const _this = this; // const _this = this;
return (val) => { return (val) => {
let result = PERMISSION_ENUM; let result = PERMISSION_ENUM
val && val.split('.').forEach(v => { val && val.split('.').forEach(v => {
result = result && result[v] || null result = result && result[v] || null
}); })
return result return result
} }
} }
} }
}); })
} }
export default plugin export default plugin
\ No newline at end of file
<template> <template>
<page-layout title="角色管理">
<a-card :bordered="false" :style="{ height: '100%' }"> <a-card :bordered="false" :style="{ height: '100%' }">
<!--<a-tabs defaultActiveKey="1" tabPosition="left" size="large" :style="{ height: '400px'}" :tabBarStyle="{ textAlign: 'left' }" @prevClick="callback" @nextClick="callback">
<a-tab-pane tab="管理员" key="1">Content of tab 1</a-tab-pane>
<a-tab-pane tab="销售组长" key="2">Content of tab 2</a-tab-pane>
<a-tab-pane tab="销售总负责人" key="3">Content of tab 3</a-tab-pane>
<a-tab-pane tab="总经理" key="4">Content of tab 4</a-tab-pane>
<a-tab-pane tab="普通销售" key="5">Content of tab 5</a-tab-pane>
<a-tab-pane tab="客服" key="6">Content of tab 6</a-tab-pane>
<a-tab-pane tab="会员" key="7">Content of tab 7</a-tab-pane>
<a-tab-pane tab="增加角色" key="-1">Content of tab 7</a-tab-pane>
</a-tabs>-->
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :md="4"> <a-col :md="4">
<a-list itemLayout="vertical" :dataSource="roles"> <a-list itemLayout="vertical" :dataSource="roles">
...@@ -24,56 +12,37 @@ ...@@ -24,56 +12,37 @@
</a-list> </a-list>
</a-col> </a-col>
<a-col :md="20"> <a-col :md="20">
<a-row v-if="mdl.id"> <div style="max-width: 800px">
<a-col :span="5"><h3 style="text-align: right">角色:</h3></a-col> <a-divider v-if="isMobile()" />
<a-col :span="19"><h3>{{ mdl.name }}</h3></a-col> <div v-if="mdl.id">
</a-row> <h3>角色:{{ mdl.name }}</h3>
<a-form :form="form"> </div>
<a-form-item <a-form :form="form" :layout="isMobile() ? 'vertical' : 'horizontal'">
label="唯一键" <a-form-item label="唯一键">
:labelCol="{ span: 5 }"
:wrapperCol="{ span: 18 }"
>
<a-input v-decorator="[ 'id', {rules: [{ required: true, message: 'Please input unique key!' }]} ]" placeholder="请填写唯一键" /> <a-input v-decorator="[ 'id', {rules: [{ required: true, message: 'Please input unique key!' }]} ]" placeholder="请填写唯一键" />
</a-form-item> </a-form-item>
<a-form-item <a-form-item label="角色名称">
label="角色名称"
:labelCol="{ span: 5 }"
:wrapperCol="{ span: 18 }"
>
<a-input v-decorator="[ 'name', {rules: [{ required: true, message: 'Please input role name!' }]} ]" placeholder="请填写角色名称" /> <a-input v-decorator="[ 'name', {rules: [{ required: true, message: 'Please input role name!' }]} ]" placeholder="请填写角色名称" />
</a-form-item> </a-form-item>
<a-form-item <a-form-item label="状态">
label="状态"
:labelCol="{ span: 5 }"
:wrapperCol="{ span: 18 }"
>
<a-select v-decorator="[ 'status', {rules: []} ]"> <a-select v-decorator="[ 'status', {rules: []} ]">
<a-select-option :value="1">正常</a-select-option> <a-select-option :value="1">正常</a-select-option>
<a-select-option :value="2">禁用</a-select-option> <a-select-option :value="2">禁用</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item <a-form-item label="备注说明">
label="备注说明"
:labelCol="{ span: 5 }"
:wrapperCol="{ span: 18 }"
>
<a-textarea :row="3" v-decorator="[ 'describe', {rules: [{ required: true, message: 'Please input role name!' }]} ]" placeholder="请填写角色名称" /> <a-textarea :row="3" v-decorator="[ 'describe', {rules: [{ required: true, message: 'Please input role name!' }]} ]" placeholder="请填写角色名称" />
</a-form-item> </a-form-item>
<a-form-item <a-form-item label="拥有权限">
label="拥有权限"
:labelCol="{ span: 5 }"
:wrapperCol="{ span: 18 }"
>
<a-row :gutter="16" v-for="(permission, index) in permissions" :key="index"> <a-row :gutter="16" v-for="(permission, index) in permissions" :key="index">
<a-col :span="4"> <a-col :xl="4" :lg="24">
{{ permission.name }} {{ permission.name }}
</a-col> </a-col>
<a-col :span="20"> <a-col :xl="20" :lg="24">
<a-checkbox <a-checkbox
v-if="permission.actionsOptions.length > 0" v-if="permission.actionsOptions.length > 0"
:indeterminate="permission.indeterminate" :indeterminate="permission.indeterminate"
...@@ -87,23 +56,22 @@ ...@@ -87,23 +56,22 @@
</a-form-item> </a-form-item>
</a-form> </a-form>
</div>
</a-col> </a-col>
</a-row> </a-row>
</a-card> </a-card>
</page-layout>
</template> </template>
<script> <script>
import PageLayout from '@/components/page/PageLayout' import { getRoleList, getPermissions } from '@/api/manage'
import { getRoleList, getPermissions } from "@/api/manage" import { mixinDevice } from '@/utils/mixin'
import { actionToObject } from '@/utils/permissions' import { actionToObject } from '@/utils/permissions'
import pick from 'lodash.pick' import pick from 'lodash.pick'
export default { export default {
name: "RoleList", name: 'RoleList',
components: { mixins: [mixinDevice],
PageLayout components: {},
},
data () { data () {
return { return {
form: this.$form.createForm(this), form: this.$form.createForm(this),
...@@ -168,7 +136,7 @@ ...@@ -168,7 +136,7 @@
}, },
loadPermissions () { loadPermissions () {
getPermissions().then(res => { getPermissions().then(res => {
let result = res.result const result = res.result
this.permissions = result.map(permission => { this.permissions = result.map(permission => {
const options = actionToObject(permission.actionData) const options = actionToObject(permission.actionData)
permission.checkedAll = false permission.checkedAll = false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment