| | |
| | | <template> |
| | | <div> |
| | | <div class="body" :style="{height:mainHeight+'px'}"> |
| | | <div class="bodyTopButtonGroup" style="justify-content: space-between"> |
| | | <el-button v-waves type="primary" icon="el-icon-circle-plus-outline">新增</el-button> |
| | | <el-button v-waves icon="el-icon-download">导入</el-button> |
| | | </div> |
| | | |
| | | <div class="bodyTopFormGroup"> |
| | | <el-form |
| | | ref="form" |
| | | :model="form" |
| | | label-width="100px" |
| | | inline |
| | | style="display: flex;" |
| | | > |
| | | <div class="elForm"> |
| | | <el-form-item label="母件编码" style=" display: flex;"> |
| | | <el-input v-model="form.OrgCode" placeholder="请输入" style="width: 200px" /> |
| | | </el-form-item> |
| | | <el-form-item label="母件名称" style=" display: flex;"> |
| | | <el-input v-model="form.OrgName" placeholder="请输入" style="width: 200px" /> |
| | | </el-form-item> |
| | | <el-form-item label="母件规格" style=" display: flex;"> |
| | | <el-input v-model="form.OrgName" placeholder="请输入" style="width: 200px" /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="版本编号" style=" display: flex;"> |
| | | <el-input v-model="form.OrgName" placeholder="请输入" style="width: 200px" /> |
| | | </el-form-item> |
| | | <el-form-item v-show="isExpandForm" label="创建人员" style=" display: flex;"> |
| | | <el-input v-model="form.UserName" style="width: 200px" placeholder="请输入" /> |
| | | </el-form-item> |
| | | <el-form-item v-show="isExpandForm" label="创建日期" style=" display: flex;"> |
| | | <el-date-picker |
| | | v-model="form.createdate" |
| | | style="width: 200px" |
| | | type="date" |
| | | placeholder="选择日期" |
| | | /> |
| | | </el-form-item> |
| | | </div> |
| | | <div |
| | | class="bodySearchReset" |
| | | :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}" |
| | | > |
| | | <el-button v-waves type="primary" icon="el-icon-search">查询</el-button> |
| | | <el-button v-waves type="info" icon="el-icon-refresh">重置</el-button> |
| | | </div> |
| | | </el-form> |
| | | <div |
| | | class="bodyTopFormExpand" |
| | | > |
| | | <svg-icon |
| | | v-show="mouseHoverType==='mouseout'" |
| | | style="cursor: pointer" |
| | | :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'" |
| | | @mouseenter="mouseHoverType=$event.type" |
| | | /> |
| | | <svg-icon |
| | | v-show="mouseHoverType==='mouseenter'" |
| | | style="cursor: pointer" |
| | | :icon-class="!isExpandForm?'doubleDown':'doubleUp'" |
| | | @click="isExpandForm=!isExpandForm" |
| | | @mouseout="mouseHoverType=$event.type" |
| | | /> |
| | | </div> |
| | | </div> |
| | | |
| | | <div |
| | | class="elTableDiv" |
| | | > |
| | | |
| | | <div style="width: 300px;"> |
| | | <div style="width: 300px;background:#fff"> |
| | | |
| | | <div style="margin: 20px 10px 0 10px;display: flex;justify-content: space-between;"> |
| | | <div style="display: flex;"> |
| | | <div |
| | | style="width: 5px;height: 100%;border-radius: 5px;" |
| | | :style="{background:$store.state.settings.theme}" |
| | | /> |
| | | <div style="margin-left: 8px;">角色名称</div> |
| | | </div> |
| | | |
| | | <div style="margin-right:10px"> |
| | | <i class="el-icon-plus" style="cursor: pointer;color: #999" @click="rolePlusClick" /> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <el-tree |
| | | ref="treeLeftRef" |
| | | style="padding: 10px;" |
| | | :style="{height:isExpandForm?tableHeight:(tableHeight+105)+'px'}" |
| | | style="padding: 10px;overflow: auto" |
| | | :style="{height:(tableHeight-20)+'px'}" |
| | | :data="treeLeft" |
| | | node-key="code" |
| | | highlight-current |
| | | :props="defaultPropsLeft" |
| | | :default-expand-all="true" |
| | | :expand-on-click-node="false" |
| | | draggable |
| | | :allow-drop="treeLeftAllowDrop" |
| | | @node-click="treeLeftNodeClick" |
| | | /> |
| | | > |
| | | <span slot-scope="{ node, data }" class="custom-tree-node"> |
| | | <span v-if="!data.isEdit">{{ node.label }}</span> |
| | | <input |
| | | v-if="data.isEdit" |
| | | :ref="data.code" |
| | | v-model="data.name" |
| | | type="text" |
| | | @click.stop |
| | | @blur="roleSave(data)" |
| | | @keyup.enter="roleSave(data)" |
| | | > |
| | | |
| | | <span v-if="!data.isEdit&&data.identifying!=='0'&&data.identifying!=='1'"> |
| | | <i |
| | | v-if="data.code!=='000'" |
| | | class="el-icon-edit" |
| | | style="margin-right:10px;color: #999" |
| | | @click.stop="val=>roleEditClick(val,node,data)" |
| | | /> |
| | | <i |
| | | v-if="data.code!=='000'" |
| | | class="el-icon-delete" |
| | | style="margin-right: 4px;color: #999" |
| | | @click.stop="val=>roleDeleteClick(val,node,data)" |
| | | /> |
| | | </span> |
| | | </span> |
| | | </el-tree> |
| | | </div> |
| | | |
| | | <div |
| | | style="margin-left: 15px;width:100%;" |
| | | style="margin-left: 10px;width:100%;position: relative" |
| | | > |
| | | |
| | | <el-button |
| | | style="position: absolute;right: 15px;z-index:1;top:3px" |
| | | type="primary" |
| | | @click="saveClick" |
| | | >保 存 |
| | | </el-button> |
| | | |
| | | <el-tabs v-model="activeName" type="border-card"> |
| | | <el-tab-pane label="PC端" name="PC端"> |
| | | <el-tab-pane label="PC端" name="PC"> |
| | | <div style="display: flex;"> |
| | | |
| | | <div |
| | | ref="scrollLeft" |
| | | style="border-right: 1px solid rgba(0,0,0,0.2);width: 200px; |
| | | overflow-y: auto;overflow-x:hidden;" |
| | | :style="{height:isExpandForm?tableHeight:(tableHeight+35)+'px',}" |
| | | :style="{height:(tableHeight-40)+'px'}" |
| | | @scroll="scrollLeftScroll()" |
| | | @mouseover="changeScrollLeftFlag('left')" |
| | | @mouseover="isScroll='left'" |
| | | > |
| | | <div style=" "> |
| | | <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 菜单权限 |
| | | </div> |
| | | <!-- :style="{height:isExpandForm?tableHeight:(tableHeight+15)+'px',}"--> |
| | | |
| | | <el-tree |
| | | ref="treeCenterRef" |
| | | style="padding-top: 10px;width: 199px;" |
| | |
| | | highlight-current |
| | | :props="defaultPropsCenter" |
| | | show-checkbox |
| | | node-key="code" |
| | | node-key="menucode" |
| | | :default-expand-all="true" |
| | | @check-change="handleTreeCenterCheckChange" |
| | | @check="handleTreeCenterCheck" |
| | |
| | | |
| | | <div |
| | | ref="scrollCenter" |
| | | style="border-right: 1px solid rgba(0,0,0,0.2);width: 600px;padding-left: 10px;overflow-y: auto" |
| | | :style="{height:isExpandForm?tableHeight:(tableHeight+35)+'px',}" |
| | | style="border-right: 1px solid rgba(0,0,0,0.2);width: 660px;padding-left: 10px;overflow-y: auto" |
| | | :style="{height:(tableHeight-40)+'px'}" |
| | | @scroll="scrollCenterScroll()" |
| | | @mouseover="changeScrollLeftFlag('center')" |
| | | @mouseover="isScroll='center'" |
| | | > |
| | | <div style=" "> |
| | | <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 按钮权限 |
| | |
| | | </el-checkbox> |
| | | |
| | | <div v-if="treeCenter.length>0"> |
| | | <div v-for="item in treeCenter[0].children" :key="item.code"> |
| | | <div v-for="(item,index) in treeCenter[0].children" :key="item.menucode"> |
| | | |
| | | <div |
| | | v-if="item.display" |
| | | v-if="!item.buttoncodelist" |
| | | style="margin-left: 40px;height:26px;display: flex;" |
| | | /> |
| | | |
| | | <el-checkbox-group |
| | | v-for="it in item.children" |
| | | v-if="item.expanded" |
| | | :key="it.code" |
| | | v-model="it.checkedButton" |
| | | style="margin-left: 40px;height:26px;display: flex" |
| | | @change="val=>handleCheckedButtonChange(val,it.code)" |
| | | :key="it.menucode" |
| | | v-model="it.buttonChecked" |
| | | style="margin-left: 40px;height:26px;display: flex;" |
| | | @change="val=>handleCheckedButtonChange(val,index,it.menucode,it.buttonChecked)" |
| | | > |
| | | |
| | | <el-checkbox |
| | | v-for="i in it.itemButton" |
| | | v-for="i in it.buttoncodelist" |
| | | :key="i" |
| | | :label="i" |
| | | style="display:flex;align-items: center" |
| | | style="display:flex;align-items: center;" |
| | | /> |
| | | </el-checkbox-group> |
| | | |
| | | </div> |
| | | |
| | | </div> |
| | |
| | | <div |
| | | ref="scrollRight" |
| | | style="width: 360px;padding-left: 10px;overflow-y: auto" |
| | | :style="{height:isExpandForm?tableHeight:(tableHeight+35)+'px',}" |
| | | :style="{height:(tableHeight-40)+'px',}" |
| | | @scroll="scrollRightScroll()" |
| | | @mouseover="changeScrollLeftFlag('right')" |
| | | @mouseover="isScroll='right'" |
| | | > |
| | | <div style=" "> |
| | | <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 数据权限 |
| | |
| | | </el-checkbox> |
| | | |
| | | <div v-if="treeCenter.length>0"> |
| | | <div v-for="item in treeCenter[0].children" :key="item.code"> |
| | | <div v-for="item in treeCenter[0].children" :key="item.menucode"> |
| | | <div |
| | | v-if="item.display" |
| | | v-if="!item.datacodelist" |
| | | style="margin-left: 40px;height:26px;display: flex;" |
| | | /> |
| | | |
| | | <el-radio-group |
| | | v-for="it in item.children" |
| | | v-if="item.expanded" |
| | | :key="it.code" |
| | | v-model="it.checkedData" |
| | | :key="it.menucode" |
| | | v-model="it.dataChecked" |
| | | style="margin-left: 40px;height:26px;display: flex" |
| | | @change="val=>handleCheckedDataChange(val,it.code)" |
| | | @change="val=>handleCheckedDataChange(val,it.menucode)" |
| | | > |
| | | <el-radio |
| | | v-for="i in it.itemData" |
| | | v-for="i in it.datacodelist" |
| | | :key="i" |
| | | style="display:flex;align-items: center" |
| | | :label="i" |
| | |
| | | |
| | | </div> |
| | | </el-tab-pane> |
| | | <el-tab-pane label="APP端" name="APP端">大大</el-tab-pane> |
| | | <el-tab-pane label="APP端" name="APP">大大</el-tab-pane> |
| | | <el-tab-pane label="工控端" name="工控端">工控端</el-tab-pane> |
| | | </el-tabs> |
| | | |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import Pagination from '@/components/Pagination' |
| | | import ImportPicker from '@/components/ImportPicker' |
| | | import elDragDialog from '@/directive/el-drag-dialog' |
| | | import waves from '@/directive/waves' |
| | | import { |
| | | RoleAddUpdateSava, RoleDeleteSava, |
| | | RolePermissionSava, |
| | | RolePermissionSearchRole, |
| | | RolePermissionSearchRoleMenu, |
| | | RolePermissionSearchRoleMenuButton |
| | | } from '@/api/basicSettings' |
| | | import arrayToTree from 'array-to-tree' |
| | | import { throttle } from '@/utils/debounceAndThrottle' |
| | | import { DataPermissions } from '@/api/GeneralBasicData' |
| | | |
| | | export default { |
| | | name: 'Zzjg', |
| | | components: { |
| | | Pagination, ImportPicker |
| | | }, |
| | | directives: { elDragDialog, waves }, |
| | | name: 'RoleList', |
| | | directives: { waves }, |
| | | data() { |
| | | return { |
| | | mouseHoverType: 'mouseout', |
| | | isExpandForm: false, |
| | | mainHeight: 0, |
| | | tableHeight: 0, |
| | | form: { |
| | | OrgCode: '', // 组织架构代码 |
| | | OrgName: '', // 组织架构名称 |
| | | OrgType: '', // 组织类型 |
| | | UserName: '', // 创建人员 |
| | | createdate: '', |
| | | prop: 'lm_date', // 排序字段 |
| | | order: 'desc', // 排序字段 |
| | | page: 1, // 第几页 |
| | | rows: 20 // 每页多少条 |
| | | }, |
| | | treeLeft: [], |
| | | treeCenter: [], |
| | | |
| | | treeLeft: [], // 左侧树 |
| | | treeCenter: [], // 中间树 |
| | | defaultPropsLeft: { |
| | | children: 'roles', |
| | | label: 'name' |
| | | }, |
| | | defaultPropsCenter: { |
| | | children: 'children', |
| | | label: 'name' |
| | | label: 'menuname' |
| | | }, |
| | | activeName: 'PC端', |
| | | activeName: 'PC', |
| | | |
| | | buttonIsChecked: false, |
| | | dataIsChecked: false, |
| | | |
| | | menuCheckedCodeArr: [], // 菜单权限数组选中的 |
| | | |
| | | allButtonData: [], // 所有的按钮加权限 |
| | | allButtonData: [], // 所有菜单对应的按钮权限加数据权限 |
| | | |
| | | isScroll: 'left' |
| | | isScroll: 'left', |
| | | |
| | | dataKeyValue: []// 数据权限键值对 |
| | | |
| | | } |
| | | }, |
| | | watch: { |
| | | treeLeft: { |
| | | handler(newValue, oldValue) { |
| | | newValue[0].roles.forEach(i => { |
| | | if (i.isEdit) { |
| | | this.$nextTick(() => { |
| | | this.$refs[i.code].focus() |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | deep: true |
| | | } |
| | | }, |
| | | |
| | | created() { |
| | | this.getRolePermissionSearchRole() |
| | | }, |
| | | mounted() { |
| | | window.addEventListener('resize', this.getHeight) |
| | | this.getHeight() |
| | | |
| | | this.getRolePermissionSearchRole() |
| | | }, |
| | | methods: { |
| | | |
| | | // 获取角色权限查询角色 |
| | | async getRolePermissionSearchRole() { |
| | | const { data: res } = await RolePermissionSearchRole() |
| | | res[0].roles.forEach(i => { |
| | | i.isEdit = false |
| | | }) |
| | | |
| | | this.treeLeft = res |
| | | if (res.length > 0) { |
| | | |
| | | if (res && res.length > 0) { |
| | | this.$nextTick(() => { // 默认选中第一个 |
| | | this.$refs.treeLeftRef.setCurrentKey(res[0].roles[0].code) // 默认选中节点第一个 |
| | | }) |
| | | await this.getRolePermissionSearchRoleMenuButton(res[0].roles[0].code) |
| | | await this.getRolePermissionSearchRoleMenu(res[0].roles[0].code) |
| | | |
| | | await this.getDataPermissions()// 获取数据权限键值对 |
| | | await this.getRolePermissionSearchRoleMenuButton(res[0].roles[0].code)// 用于数据回显 |
| | | |
| | | await this.getRolePermissionSearchRoleMenu(res[0].roles[0].code)// 用于渲染页面 |
| | | } else { |
| | | this.$notify.error('请先建相对应的角色!') |
| | | } |
| | | }, |
| | | async getDataPermissions() { |
| | | const { data: res } = await DataPermissions() |
| | | this.dataKeyValue = res |
| | | }, |
| | | |
| | | // 获取菜单权限对应的按钮 |
| | | async getRolePermissionSearchRoleMenuButton(rolecode) { |
| | | const { data: res } = await RolePermissionSearchRoleMenuButton({ rolecode }) |
| | | this.allButtonData = res |
| | | const { data: res } = await RolePermissionSearchRoleMenuButton({ rolecode, type: this.activeName }) |
| | | this.allButtonData = res.length > 0 ? JSON.parse(res[0].jsondate) : [] |
| | | }, |
| | | // 获取菜单权限 |
| | | async getRolePermissionSearchRoleMenu(rolecode) { |
| | | const { data: res } = await RolePermissionSearchRoleMenu({ rolecode, type: 'PC' }) |
| | | const { data: res } = await RolePermissionSearchRoleMenu({ rolecode, type: this.activeName }) |
| | | |
| | | // 拿到数组list转换成树形tree |
| | | const result = arrayToTree(res, { |
| | | parentProperty: 'parentid', |
| | | customID: 'code', |
| | | parentProperty: 'parent_id', |
| | | customID: 'menucode', |
| | | childrenProperty: 'children' |
| | | }) |
| | | |
| | | this.menuCheckedCodeArr = [] |
| | | this.treeCenter = [ |
| | | { menucode: '-1', menuname: '全部', children: result } |
| | | ] |
| | | |
| | | // console.log(this.allButtonData, 213) |
| | | result.forEach(item => { |
| | | this.treeCenter[0].children.forEach(item => { |
| | | if (item.children && item.children.length) { |
| | | item.children.forEach(it => { |
| | | // 按钮权限回显 |
| | | const buttonAll = this.allButtonData.tButton.filter(j => j.menucode === it.code).map(j => j.name) |
| | | const buttonChecked = this.allButtonData.tButton.filter(j => |
| | | j.menucode === it.code && j.flag === 'Y' |
| | | ).map(j => j.name) |
| | | it.itemButton = buttonAll |
| | | it.checkedButton = buttonChecked |
| | | it.buttoncodelist = it.buttoncodelist !== '' && it.buttoncodelist !== null ? it.buttoncodelist.split(',') : [] |
| | | if (it.buttoncodelist && it.buttoncodelist.length > 0) { |
| | | it.buttoncodelist = this.$ButtonData.filter(j => |
| | | it.buttoncodelist.includes(j.buttoncode) |
| | | ) |
| | | |
| | | // 数据权限回显 |
| | | const dataAll = this.allButtonData.tData.filter(j => j.menucode === it.code).map(j => j.name) |
| | | const dataChecked = this.allButtonData.tData.filter(j => j.menucode === it.code && j.flag === 'Y').name |
| | | // console.log(dataAll, dataChecked, 2) |
| | | it.itemData = dataAll |
| | | it.checkedData = dataChecked |
| | | it.buttoncodelist = it.buttoncodelist.map(j => j.buttonname) |
| | | } |
| | | |
| | | // 用作菜单勾选回显 |
| | | if (it.flag === 'Y') { |
| | | this.menuCheckedCodeArr.push(it.code) |
| | | it.datacodelist = it.datacodelist ? it.datacodelist.split(',') : [] |
| | | if (it.datacodelist && it.datacodelist.length > 0) { |
| | | it.datacodelist = this.dataKeyValue.filter(j => |
| | | it.datacodelist.includes(j.datacode) |
| | | ).map(j => j.dataname) |
| | | } |
| | | }) |
| | | item.display = true |
| | | |
| | | item.expanded = true |
| | | } |
| | | }) |
| | | |
| | | console.log(JSON.parse(JSON.stringify(result)), 8) |
| | | |
| | | this.treeCenter = [ |
| | | { code: '-1', name: '全部', flag: result.every(i => i.flag === 'Y') ? 'Y' : 'N', children: result } |
| | | ] |
| | | |
| | | // this.buttonIsChecked = result.every(i => i.flag === 'Y') |
| | | this.handleCheckedButtonChange('', '', true) |
| | | this.handleCheckedDataChange('', '', true) |
| | | // console.log(this.menuCheckedCodeArr, 2) |
| | | this.handleData()// 处理数据回显 |
| | | }, |
| | | // 处理组合数据 |
| | | handleData() { |
| | | this.menuCheckedCodeArr = this.allButtonData.map(i => i.menucode) |
| | | this.$nextTick(() => { |
| | | this.$refs.treeCenterRef.setCheckedKeys(this.menuCheckedCodeArr) |
| | | }) |
| | | |
| | | this.$forceUpdate() |
| | | // console.log(this.treeCenter[0].children) |
| | | this.treeCenter[0].children.forEach(item => { |
| | | if (item.children && item.children.length) { |
| | | item.children.forEach(it => { |
| | | let temp = this.allButtonData.filter(j => j.menucode === it.menucode).length > 0 ? this.allButtonData.filter(j => j.menucode === it.menucode)[0].buttoncode : [] |
| | | temp = temp.length > 0 ? temp.split(',') : [] |
| | | it.buttonChecked = [] // 数据回显 |
| | | this.$ButtonData.forEach(j => { |
| | | if (temp.includes(j.buttoncode)) { |
| | | it.buttonChecked.push(j.buttonname) |
| | | } |
| | | }) |
| | | |
| | | const datacode = this.allButtonData.filter(j => j.menucode === it.menucode).length > 0 ? this.allButtonData.filter(j => j.menucode === it.menucode)[0].datacode : '' |
| | | it.dataChecked = datacode ? this.dataKeyValue.find(j => j.datacode === datacode).dataname : '' // 数据回显 |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | this.handleCheckedButtonChange('', '', '', '', true) |
| | | this.handleCheckedDataChange('', '', true) |
| | | // this.$forceUpdate() |
| | | }, |
| | | |
| | | // 左边滚动条滑动时 |
| | |
| | | this.$refs.scrollCenter.scrollTop = this.$refs.scrollRight.scrollTop |
| | | } |
| | | }, |
| | | |
| | | resize() { |
| | | |
| | | }, |
| | | |
| | | changeScrollLeftFlag(val) { |
| | | this.isScroll = val |
| | | }, |
| | | |
| | | // 全选改变 |
| | | handleCheckAllChange(val, belong) { |
| | | const checkedKeys = this.$refs.treeCenterRef.getCheckedKeys() |
| | |
| | | this.treeCenter[0].children.forEach(item => { |
| | | if (item.children && item.children.length) { |
| | | item.children.forEach(it => { |
| | | if (checkedKeys.includes(it.code)) { |
| | | if (checkedKeys.includes(it.menucode)) { |
| | | if (belong === 'button') { |
| | | it.checkedButton = it.itemButton |
| | | it.buttonChecked = it.buttoncodelist |
| | | } |
| | | if (belong === 'data') { |
| | | it.checkedData = '全部' |
| | | it.dataChecked = '全部' |
| | | } |
| | | } |
| | | }) |
| | |
| | | this.treeCenter[0].children.forEach(item => { |
| | | if (item.children && item.children.length) { |
| | | item.children.forEach(it => { |
| | | if (checkedKeys.includes(it.code)) { |
| | | if (checkedKeys.includes(it.menucode)) { |
| | | if (belong === 'button') { |
| | | it.checkedButton = [] |
| | | it.buttonChecked = [] |
| | | } |
| | | if (belong === 'data') { |
| | | it.checkedData = undefined |
| | | it.dataChecked = '' |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // console.log(this.treeCenter[0].children, 20) |
| | | }, |
| | | // 单个按钮改变 |
| | | handleCheckedButtonChange(value, code, flag) { |
| | | handleCheckedButtonChange(oldValue, index, code, newValue, flag) { |
| | | // console.log(oldValue, index, code, newValue, 2) |
| | | // 判断是否包含在内 |
| | | if (!flag) { |
| | | if (!this.menuCheckedCodeArr.includes(code) && value.length === 1) { // 否 |
| | | if (!this.menuCheckedCodeArr.includes(code) && oldValue.length === 0 && newValue.length === 1) { // 否 |
| | | this.menuCheckedCodeArr.push(code) |
| | | } else if (this.menuCheckedCodeArr.includes(code) && value.length === 0) { // 是 |
| | | this.menuCheckedCodeArr = this.menuCheckedCodeArr.filter(i => i !== code) |
| | | } else if (this.menuCheckedCodeArr.includes(code) && oldValue.length === 1 && newValue.length === 0) { // 是 |
| | | // 当数据权限未勾选时则过滤掉相对应的菜单 |
| | | if (this.treeCenter[0].children[index].children.find(i => i.menucode === code).dataChecked.toString().length < 1) { |
| | | this.menuCheckedCodeArr = this.menuCheckedCodeArr.filter(i => i !== code) |
| | | } |
| | | } |
| | | this.$refs.treeCenterRef.setCheckedKeys(this.menuCheckedCodeArr) |
| | | } |
| | |
| | | this.treeCenter[0].children.forEach(item => { |
| | | if (item.children && item.children.length) { |
| | | item.children.forEach(it => { |
| | | if (it.checkedButton.length === it.itemButton.length) { |
| | | if (it.buttonChecked && it.buttonChecked.length === it.buttoncodelist.length && it.buttoncodelist.length > 0) { |
| | | count++ |
| | | } |
| | | childrenLength++ |
| | | |
| | | if (it.buttoncodelist.length) { |
| | | childrenLength++ |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | this.buttonIsChecked = count === childrenLength |
| | | this.$forceUpdate() |
| | | }, |
| | | |
| | | // 获取树形节点node |
| | | getLeftTreeNode(data, Node, VueComponent) { |
| | | // console.log(data, Node, VueComponent, 2221) |
| | | // console.log(Node.expanded) |
| | | this.treeCenter[0].children.forEach(item => { |
| | | if (item.name === data.name) { |
| | | if (item.menucode === data.menucode) { |
| | | item.expanded = Node.expanded |
| | | } |
| | | }) |
| | | if (data.code === '-1') { |
| | | if (data.menucode === '-1') { |
| | | Node.expanded = true // 暂时先写成这个 |
| | | // this.treeCenter[0].children.forEach(item => { |
| | | // item.expanded = Node.expanded |
| | | // }) |
| | | } |
| | | this.$forceUpdate() |
| | | }, |
| | | // 处理树形勾选 |
| | | // 处理中间树形勾选 |
| | | handleTreeCenterCheck(obj, { checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys }) { |
| | | // console.log(obj, checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys, '加多宝') |
| | | |
| | |
| | | this.dataIsChecked = false |
| | | this.menuCheckedCodeArr = [] |
| | | } else { |
| | | if (checkedKeys.includes(obj.code)) { // 判断是否包含在内 //是 |
| | | this.menuCheckedCodeArr.push(obj.code) |
| | | if (checkedKeys.includes(obj.menucode)) { // 判断是否包含在内 //是 |
| | | this.menuCheckedCodeArr.push(obj.menucode) |
| | | } else { // 否 |
| | | this.menuCheckedCodeArr = this.menuCheckedCodeArr.filter(i => i !== obj.code) |
| | | this.menuCheckedCodeArr = this.menuCheckedCodeArr.filter(i => i !== obj.menucode) |
| | | } |
| | | } |
| | | }, |
| | | // 处理树形选中值改变 |
| | | // 处理中间树形选中值改变 |
| | | handleTreeCenterCheckChange(obj, selfChecked, selfChildrenTreeCheck) { |
| | | // console.log(obj, selfChecked, selfChildrenTreeCheck, '王老吉') |
| | | if (!selfChildrenTreeCheck) { |
| | | if (!selfChecked) { |
| | | if (!selfChecked) { // 从选中到不选中 |
| | | obj.buttonChecked = [] |
| | | obj.dataChecked = '' |
| | | this.menuCheckedCodeArr = this.menuCheckedCodeArr.filter(i => i !== obj.menucode) |
| | | } |
| | | if (selfChecked) { // 从不选中到选中 |
| | | obj.buttonCheckedCode = [] |
| | | this.treeCenter[0].children.forEach(item => { |
| | | if (item.children && item.children.length) { |
| | | item.children.forEach(it => { |
| | | if (it.code === obj.code) { |
| | | it.checkedButton = [] |
| | | it.checkedData = undefined |
| | | if (it.menucode === obj.menucode) { |
| | | this.menuCheckedCodeArr.push(obj.menucode) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | this.$forceUpdate() |
| | | } |
| | | |
| | | this.$forceUpdate() |
| | | } |
| | | }, |
| | | |
| | | // 单选框按钮改变 |
| | | handleCheckedDataChange(value, code, flag) { |
| | | // console.log(value, code) |
| | | if (flag) { |
| | | if (!flag) { |
| | | this.menuCheckedCodeArr.push(code) |
| | | this.menuCheckedCodeArr = [...new Set(this.menuCheckedCodeArr)] |
| | | |
| | | this.$refs.treeCenterRef.setCheckedKeys(this.menuCheckedCodeArr) |
| | | } |
| | | |
| | | // 这里是判断全选radio 是否选中 |
| | | let count = 0 |
| | | let childrenLength = 0 |
| | | this.treeCenter[0].children.forEach(item => { |
| | | if (item.children && item.children.length) { |
| | | item.children.forEach(it => { |
| | | if (it.checkedData) { |
| | | if (it.dataChecked.length > 0 && it.datacodelist.length > 0) { |
| | | count++ |
| | | } |
| | | if (it.itemData.length > 0) { |
| | | // console.log(it.dataChecked, 234) |
| | | if (it.datacodelist.length > 0) { |
| | | childrenLength++ |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | // console.log(count, childrenLength, 9) |
| | | // console.log(count, childrenLength, 123) |
| | | this.dataIsChecked = count === childrenLength |
| | | // console.log(JSON.parse(JSON.stringify(this.treeCenter[0].children))) |
| | | |
| | | this.$forceUpdate() |
| | | }, |
| | | |
| | | async treeLeftNodeClick(obj, Node, VueComponent) { |
| | | // this.menuCheckedCodeArr = [] |
| | | |
| | | await this.getRolePermissionSearchRoleMenuButton(obj.code) |
| | | await this.getRolePermissionSearchRoleMenu(obj.code) |
| | | // 角色切换 |
| | | async treeLeftNodeClick(obj, Node, VueComponent) { |
| | | if (obj.code !== '000') { |
| | | await this.getRolePermissionSearchRoleMenuButton(obj.code) |
| | | // await this.getRolePermissionSearchRoleMenu(obj.code) |
| | | this.handleData() |
| | | } |
| | | }, |
| | | // 角色名称新增 |
| | | rolePlusClick() { |
| | | this.treeLeft[0].roles.push({ code: '', name: '', isEdit: true }) |
| | | }, |
| | | // 角色名称修改 |
| | | roleEditClick(self, node, data) { |
| | | // console.log(self, node, data) |
| | | this.treeLeft[0].roles.forEach(i => { |
| | | i.isEdit = false |
| | | }) |
| | | data.isEdit = !data.isEdit |
| | | }, |
| | | // 角色名称删除 |
| | | roleDeleteClick(self, node, data) { |
| | | // console.log(self, node, data) |
| | | this.$confirm('是否确认删除?', '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | const D = { |
| | | rolecode: data.code, |
| | | rolename: data.name, |
| | | type: this.activeName |
| | | } |
| | | RoleDeleteSava(D).then(res => { |
| | | if (res.code === '200') { |
| | | this.$notify.success('角色删除成功!') |
| | | } |
| | | this.getRolePermissionSearchRole() |
| | | }) |
| | | }).catch(() => { |
| | | this.$notify.info('已取消删除') |
| | | }) |
| | | }, |
| | | // 角色名称保存 采用防抖形式 |
| | | roleSave: throttle(function(val) { |
| | | val.isEdit = false |
| | | |
| | | if (val.name.trim().length === 0) { |
| | | this.getRolePermissionSearchRole() |
| | | return this.$notify.info('无效保存!') |
| | | } |
| | | |
| | | const data = { |
| | | rolecode: val.code, |
| | | rolename: val.name, |
| | | type: val.code === '' ? 'Add' : 'Update' |
| | | } |
| | | console.log(data, '执行了!') |
| | | RoleAddUpdateSava(data).then(res => { |
| | | if (res.code === '200') { |
| | | this.$notify.success(val.code === '' ? '角色新增成功!' : '角色修改成功!') |
| | | } |
| | | }) |
| | | this.getRolePermissionSearchRole() |
| | | }, 1000, true), |
| | | |
| | | // 页面勾选好保存事件 |
| | | async saveClick() { |
| | | const menuKeyArr = this.$refs.treeCenterRef.getCheckedKeys() |
| | | const arr = [] |
| | | this.treeCenter[0].children.forEach(item => { |
| | | if (item.children && item.children.length) { |
| | | item.children.forEach(it => { |
| | | if (menuKeyArr.includes(it.menucode)) { |
| | | if (it.buttoncodelist.length > 0 && it.buttoncodelist && it.dataChecked && it.dataChecked.toString().length > 0) { // 数据权限已勾选 |
| | | it.dataCheckedCode = this.dataKeyValue.find(i => i.dataname === it.dataChecked).datacode |
| | | } |
| | | |
| | | if (it.buttonChecked && it.buttonChecked.length > 0) { // 已选菜单 |
| | | it.buttonCheckedCode = this.$ButtonData.filter(i => |
| | | it.buttonChecked.includes(i.buttonname) |
| | | ).map(i => i.buttoncode) |
| | | } |
| | | arr.push({ |
| | | menucode: it.menucode, |
| | | datacode: it.dataCheckedCode !== undefined ? it.dataCheckedCode : '', |
| | | buttoncode: it.buttonCheckedCode ? it.buttonCheckedCode.join(',') : '' |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | const rolecode = this.$refs.treeLeftRef.getCurrentKey() |
| | | const res = await RolePermissionSava(JSON.stringify(arr), rolecode, this.activeName) |
| | | if (res.code === '200') { |
| | | const rolename = this.treeLeft[0].roles.find(i => i.code === rolecode).name |
| | | this.$notify.success(rolename + '的角色权限提交成功!') |
| | | await this.getRolePermissionSearchRoleMenuButton(rolecode) |
| | | } |
| | | }, |
| | | // 获取页面高度 |
| | | getHeight() { |
| | | this.$nextTick(() => { |
| | | this.mainHeight = window.innerHeight - 85 |
| | | this.tableHeight = this.mainHeight - 255 |
| | | // this.$refs.tableDataRef.doLayout() |
| | | this.tableHeight = this.mainHeight - 50 |
| | | }) |
| | | }, |
| | | // 左侧树形拖动处理 |
| | | treeLeftAllowDrop(draggingNode, dropNode, type) { |
| | | // console.log(draggingNode, dropNode, type) |
| | | // 注掉的是同级拖拽 |
| | | if (draggingNode.level === dropNode.level) { |
| | | return type === 'prev' || type === 'next' |
| | | } else { |
| | | // 不同级进行处理 |
| | | return false |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <!--公共页面样式--> |
| | | <style lang="scss" scoped> |
| | | $main_color: #42b983; |
| | | ::v-deep .el-button--text { |
| | | font-size: 14px; |
| | | cursor: pointer; |
| | | } |
| | | |
| | | .el-icon-share, .el-icon-delete, .el-icon-edit-outline { |
| | | color: $main_color; |
| | | cursor: pointer; |
| | | } |
| | | |
| | | .el-icon-edit-outline { |
| | | margin-right: 15px; |
| | | } |
| | | |
| | | ::v-deep .el-button--primary, .el-button--default, .el-button--info { |
| | | height: 34px; |
| | | display: flex; |
| | | align-items: center; |
| | | padding: 0 15px; |
| | | } |
| | | |
| | | ::v-deep .el-button--primary { |
| | | //background-color: $main_color !important; |
| | | } |
| | | |
| | | ::v-deep .el-button--default { |
| | | background-color: #f8f8fa; |
| | | border: none; |
| | | } |
| | | |
| | | ::v-deep .el-input__inner { |
| | | height: 34px; |
| | | line-height: 34px; |
| | | //color: #a7a7a7; |
| | | } |
| | | |
| | | ::v-deep .el-dialog__body { |
| | | padding: 20px 100px !important; |
| | | } |
| | | |
| | | ::v-deep .dialogVisibleRoles .el-dialog__body { |
| | | padding: 20px 20px !important; |
| | | } |
| | | |
| | | ::v-deep .importPickerClass .el-dialog__body { |
| | | padding: 20px 20px !important; |
| | | } |
| | | |
| | | ::v-deep .el-dialog__footer { |
| | | display: flex; |
| | | justify-content: flex-end; |
| | | } |
| | | |
| | | ::v-deep .el-table .caret-wrapper { |
| | | transform: scale(0.8); |
| | | } |
| | | |
| | | ::v-deep .cell { |
| | | <style scoped lang="scss"> |
| | | .custom-tree-node { |
| | | flex: 1; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | font-size: 14px; |
| | | padding-right: 8px; |
| | | } |
| | | |
| | | ::v-deep .el-table::before { |
| | | height: 0; |
| | | ::v-deep .el-checkbox__label { |
| | | width: 55px; |
| | | } |
| | | |
| | | ::v-deep .el-table__body-wrapper { |
| | | background-color: #f8f8fa; |
| | | } |
| | | |
| | | ::v-deep .el-table__body .el-table__row.hover-row td { |
| | | background-color: #eaecef; |
| | | } |
| | | |
| | | ::v-deep .el-form--inline .el-form-item__label { |
| | | color: #a7a7a7; |
| | | } |
| | | |
| | | .body ::v-deep .el-divider { |
| | | border: 1px solid #eee; |
| | | width: 99%; |
| | | margin: 10px auto; |
| | | } |
| | | |
| | | .body ::v-deep .el-form-item { |
| | | margin-bottom: 0; |
| | | } |
| | | |
| | | .userDialogVisible ::v-deep .el-form-item { |
| | | margin-bottom: 0; |
| | | } |
| | | |
| | | ::v-deep .el-select__caret { |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | } |
| | | |
| | | .tableFixed { |
| | | ::v-deep .el-table__fixed-right { |
| | | height: 100% !important; |
| | | } |
| | | |
| | | ::v-deep .el-table__fixed { |
| | | height: 100% !important; |
| | | } |
| | | } |
| | | </style> |
| | | <style> |
| | | |
| | | .el-table .custom-row { |
| | | background: #f8f8fa; |
| | | .el-icon-plus:hover, .el-icon-edit:hover, .el-icon-delete:hover { |
| | | color: #000 !important; |
| | | } |
| | | </style> |