|
@@ -80,73 +80,102 @@
|
|
|
<pagination />
|
|
|
</el-card>
|
|
|
</el-col>
|
|
|
+ </el-row>
|
|
|
+ <div style="display: flex;" >
|
|
|
<!-- 菜单授权 -->
|
|
|
- <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="7">
|
|
|
- <el-card class="box-card" shadow="never">
|
|
|
- <div slot="header" class="clearfix">
|
|
|
- <el-tooltip class="item" effect="dark" content="选择指定角色分配菜单" placement="top">
|
|
|
- <span class="role-span">菜单分配</span>
|
|
|
- </el-tooltip>
|
|
|
- <el-button
|
|
|
- v-permission="['admin','roles:edit']"
|
|
|
- :disabled="!showButton"
|
|
|
- :loading="menuLoading"
|
|
|
- icon="el-icon-check"
|
|
|
- size="mini"
|
|
|
- style="float: right; padding: 6px 9px"
|
|
|
- type="primary"
|
|
|
- @click="saveMenu"
|
|
|
- >保存</el-button>
|
|
|
- </div>
|
|
|
- <el-tree
|
|
|
- ref="menu"
|
|
|
- lazy
|
|
|
- :data="menus"
|
|
|
- :default-checked-keys="menuIds"
|
|
|
- :load="getMenuDatas"
|
|
|
- :props="defaultProps"
|
|
|
- check-strictly
|
|
|
- accordion
|
|
|
- show-checkbox
|
|
|
- node-key="id"
|
|
|
- @check="menuChange"
|
|
|
- />
|
|
|
- </el-card>
|
|
|
- </el-col>
|
|
|
+ <el-card class="box-card mar_20" shadow="never" >
|
|
|
+ <div slot="header" class="clearfix">
|
|
|
+ <el-tooltip class="item" effect="dark" content="选择指定角色分配菜单" placement="top">
|
|
|
+ <span class="role-span">菜单分配</span>
|
|
|
+ </el-tooltip>
|
|
|
+ <el-button
|
|
|
+ v-permission="['admin','roles:edit']"
|
|
|
+ :disabled="!showButton"
|
|
|
+ :loading="menuLoading"
|
|
|
+ icon="el-icon-check"
|
|
|
+ size="mini"
|
|
|
+ style="float: right; padding: 6px 9px"
|
|
|
+ type="primary"
|
|
|
+ @click="saveMenu"
|
|
|
+ >保存</el-button>
|
|
|
+ </div>
|
|
|
+ <el-tree
|
|
|
+ ref="menu"
|
|
|
+ lazy
|
|
|
+ :data="menus"
|
|
|
+ :default-checked-keys="menuIds"
|
|
|
+ :load="getMenuDatas"
|
|
|
+ :props="defaultProps"
|
|
|
+ check-strictly
|
|
|
+ accordion
|
|
|
+ show-checkbox
|
|
|
+ node-key="id"
|
|
|
+ @check="menuChange"
|
|
|
+ />
|
|
|
+ </el-card>
|
|
|
<!-- 子系统授权 -->
|
|
|
- <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="7">
|
|
|
- <el-card class="box-card" shadow="never">
|
|
|
- <div slot="header" class="clearfix">
|
|
|
- <el-tooltip class="item" effect="dark" content="选择指定角色分配子系统" placement="top">
|
|
|
- <span class="role-span">子系统分配</span>
|
|
|
- </el-tooltip>
|
|
|
- <el-button
|
|
|
- v-permission="['admin','roles:edit']"
|
|
|
- :disabled="!showButton2"
|
|
|
- :loading="menuLoading2"
|
|
|
- icon="el-icon-check"
|
|
|
- size="mini"
|
|
|
- style="float: right; padding: 6px 9px"
|
|
|
- type="primary"
|
|
|
- @click="saveSystem"
|
|
|
- >保存</el-button>
|
|
|
- </div>
|
|
|
- <el-tree
|
|
|
- ref="system"
|
|
|
- lazy
|
|
|
- :data="systems"
|
|
|
- :default-checked-keys="systemIds"
|
|
|
- :load="getSystemDatas"
|
|
|
- :props="defaultProps2"
|
|
|
- check-strictly
|
|
|
- accordion
|
|
|
- show-checkbox
|
|
|
- node-key="id"
|
|
|
- @check="systemChange"
|
|
|
- />
|
|
|
- </el-card>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
+ <el-card class="box-card mar_20" shadow="never" >
|
|
|
+ <div slot="header" class="clearfix">
|
|
|
+ <el-tooltip class="item" effect="dark" content="选择指定角色分配子系统" placement="top">
|
|
|
+ <span class="role-span">子系统分配</span>
|
|
|
+ </el-tooltip>
|
|
|
+ <el-button
|
|
|
+ v-permission="['admin','roles:edit']"
|
|
|
+ :disabled="!showButton2"
|
|
|
+ :loading="menuLoading2"
|
|
|
+ icon="el-icon-check"
|
|
|
+ size="mini"
|
|
|
+ style="float: right; padding: 6px 9px"
|
|
|
+ type="primary"
|
|
|
+ @click="saveSystem"
|
|
|
+ >保存</el-button>
|
|
|
+ </div>
|
|
|
+ <el-tree
|
|
|
+ ref="system"
|
|
|
+ lazy
|
|
|
+ :data="systems"
|
|
|
+ :default-checked-keys="systemIds"
|
|
|
+ :load="getSystemDatas"
|
|
|
+ :props="defaultProps2"
|
|
|
+ check-strictly
|
|
|
+ accordion
|
|
|
+ show-checkbox
|
|
|
+ node-key="id"
|
|
|
+ @check="systemChange"
|
|
|
+ />
|
|
|
+ </el-card>
|
|
|
+ <!-- APP菜单授权 -->
|
|
|
+ <el-card class="box-card mar_20" shadow="never" >
|
|
|
+ <div slot="header" class="clearfix">
|
|
|
+ <el-tooltip class="item" effect="dark" content="选择指定角色分配子系统" placement="top">
|
|
|
+ <span class="role-span">子系统分配</span>
|
|
|
+ </el-tooltip>
|
|
|
+ <el-button
|
|
|
+ v-permission="['admin','roles:edit']"
|
|
|
+ :disabled="!showButton2"
|
|
|
+ :loading="menuLoading2"
|
|
|
+ icon="el-icon-check"
|
|
|
+ size="mini"
|
|
|
+ style="float: right; padding: 6px 9px"
|
|
|
+ type="primary"
|
|
|
+ @click="saveAppMenu"
|
|
|
+ >保存</el-button>
|
|
|
+ </div>
|
|
|
+ <el-tree
|
|
|
+ ref="appMenu"
|
|
|
+ lazy
|
|
|
+ :data="appMenus"
|
|
|
+ :default-checked-keys="appMenuIds"
|
|
|
+ :load="getAppMenuDatas"
|
|
|
+ :props="defaultProps3"
|
|
|
+ check-strictly
|
|
|
+ accordion
|
|
|
+ show-checkbox
|
|
|
+ node-key="id"
|
|
|
+ @check="appMenuChange"
|
|
|
+ />
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -155,6 +184,7 @@ import crudRoles from '@/api/system/role'
|
|
|
import { getDepts, getRoleDeptSuperior } from '@/api/system/dept'
|
|
|
import { getMenusTree, getChild } from '@/api/system/menu'
|
|
|
import { getSystemsTree } from '@/api/dm/system/dmSystem'
|
|
|
+import { getAppMenusTree } from '@/api/dm/appMenu/dmAppMenu'
|
|
|
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
|
|
import rrOperation from '@crud/RR.operation'
|
|
|
import crudOperation from '@crud/CRUD.operation'
|
|
@@ -177,11 +207,13 @@ export default {
|
|
|
return {
|
|
|
defaultProps: { children: 'children', label: 'label', isLeaf: 'leaf' },
|
|
|
defaultProps2: { children: 'children', label: 'systemName', isLeaf: 'leaf' },
|
|
|
+ defaultProps3: { children: 'children', label: 'name', isLeaf: 'leaf' },
|
|
|
dateScopes: ['全部', '本级', '自定义'], level: 3,
|
|
|
currentId: 0, menuLoading: false, showButton: false,
|
|
|
menuLoading2: false, showButton2: false,
|
|
|
menus: [], menuIds: [], depts: [], deptDatas: [], // 多选时使用
|
|
|
systems: [], systemIds: [],
|
|
|
+ appMenus: [], appMenuIds: [],
|
|
|
permission: {
|
|
|
add: ['admin', 'roles:add'],
|
|
|
edit: ['admin', 'roles:edit'],
|
|
@@ -220,6 +252,13 @@ export default {
|
|
|
})
|
|
|
}, 100)
|
|
|
},
|
|
|
+ getAppMenuDatas(node, resolve) {
|
|
|
+ setTimeout(() => {
|
|
|
+ getAppMenusTree().then(res => {
|
|
|
+ resolve(res)
|
|
|
+ })
|
|
|
+ }, 100)
|
|
|
+ },
|
|
|
[CRUD.HOOK.afterRefresh]() {
|
|
|
this.$refs.menu.setCheckedKeys([])
|
|
|
},
|
|
@@ -265,17 +304,22 @@ export default {
|
|
|
// 清空菜单的选中
|
|
|
this.$refs.menu.setCheckedKeys([])
|
|
|
this.$refs.system.setCheckedKeys([])
|
|
|
+ this.$refs.appMenu.setCheckedKeys([])
|
|
|
// 保存当前的角色id
|
|
|
this.currentId = val.id
|
|
|
// 初始化默认选中的key
|
|
|
this.menuIds = []
|
|
|
this.systemIds = []
|
|
|
+ this.appMenuIds = []
|
|
|
val.menus.forEach(function(data) {
|
|
|
_this.menuIds.push(data.id)
|
|
|
})
|
|
|
val.systems.forEach(function(data) {
|
|
|
_this.systemIds.push(data.id)
|
|
|
})
|
|
|
+ val.appMenus.forEach(function(data) {
|
|
|
+ _this.appMenuIds.push(data.id)
|
|
|
+ })
|
|
|
this.showButton = true
|
|
|
this.showButton2 = true
|
|
|
}
|
|
@@ -323,6 +367,27 @@ export default {
|
|
|
}
|
|
|
this.$refs.system.setCheckedKeys(this.systemIds)
|
|
|
},
|
|
|
+ appMenuChange(appMenu) {
|
|
|
+ // 获取该节点的所有子节点,id 包含自身
|
|
|
+ const childIds = [appMenu.id]
|
|
|
+ // 判断是否在 appMenuIds 中,如果存在则删除,否则添加
|
|
|
+ if (this.appMenuIds.indexOf(appMenu.id) !== -1) {
|
|
|
+ for (let i = 0; i < childIds.length; i++) {
|
|
|
+ const index = this.appMenuIds.indexOf(childIds[i])
|
|
|
+ if (index !== -1) {
|
|
|
+ this.appMenuIds.splice(index, 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (let i = 0; i < childIds.length; i++) {
|
|
|
+ const index = this.appMenuIds.indexOf(childIds[i])
|
|
|
+ if (index === -1) {
|
|
|
+ this.appMenuIds.push(childIds[i])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$refs.appMenu.setCheckedKeys(this.appMenuIds)
|
|
|
+ },
|
|
|
// 保存菜单
|
|
|
saveMenu() {
|
|
|
this.menuLoading = true
|
|
@@ -359,6 +424,24 @@ export default {
|
|
|
console.log(err.response.data.message)
|
|
|
})
|
|
|
},
|
|
|
+ // 保存子系统
|
|
|
+ saveAppMenu() {
|
|
|
+ this.menuLoading2 = true
|
|
|
+ const role = { id: this.currentId, appMenus: [] }
|
|
|
+ // 得到已选中的 key 值
|
|
|
+ this.appMenuIds.forEach(function(id) {
|
|
|
+ const appMenu = { id: id }
|
|
|
+ role.appMenus.push(appMenu)
|
|
|
+ })
|
|
|
+ crudRoles.editAppMenu(role).then(() => {
|
|
|
+ this.crud.notify('保存成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
|
|
+ this.menuLoading2 = false
|
|
|
+ this.update()
|
|
|
+ }).catch(err => {
|
|
|
+ this.menuLoading2 = false
|
|
|
+ console.log(err.response.data.message)
|
|
|
+ })
|
|
|
+ },
|
|
|
// 改变数据
|
|
|
update() {
|
|
|
// 无刷新更新 表格数据
|
|
@@ -450,4 +533,7 @@ export default {
|
|
|
border: 0;
|
|
|
padding: 0;
|
|
|
}
|
|
|
+ .mar_20{
|
|
|
+ flex: 1;margin: 0 20px;
|
|
|
+ }
|
|
|
</style>
|