| | |
| | | <div class="app-container"> |
| | | <div class="filter-container"> |
| | | <el-input v-model="queryParams.roleName" :placeholder="$t('table.role.roleName')" class="filter-item search-item" /> |
| | | <el-button class="filter-item" type="primary" @click="search"> |
| | | <el-button class="hr-but-all" type="primary" @click="search"> |
| | | {{ $t('table.search') }} |
| | | </el-button> |
| | | <el-button class="filter-item" type="success" @click="reset"> |
| | | <el-button class="hr-but-all" type="success" @click="reset"> |
| | | {{ $t('table.reset') }} |
| | | </el-button> |
| | | <el-button v-has-permission="['role:add']" class="filter-item" type="success" @click.native="add"> |
| | | <el-button v-has-permission="['role:add']" class="hr-but-all" type="success" @click.native="add"> |
| | | {{ $t('table.add') }} |
| | | </el-button> |
| | | <el-button v-has-permission="['role:delete']" class="filter-item" type="success" @click.native="batchDelete"> |
| | | <el-button v-has-permission="['role:delete']" type="primary" @click.native="batchDelete"> |
| | | {{ $t('table.delete') }} |
| | | </el-button> |
| | | <el-button v-has-permission="['role:export']" class="filter-item" type="success" @click.native="exportExcel"> |
| | | <el-button v-has-permission="['role:export']" class="hr-but-all" type="success" @click.native="exportExcel"> |
| | | {{ $t('table.export') }} |
| | | </el-button> |
| | | </div> |
| | |
| | | <el-tree |
| | | ref="permsTree" |
| | | :data="permsTree" |
| | | :check-strictly="false" |
| | | show-checkbox |
| | | accordion |
| | | node-key="id" |
| | |
| | | queryParams: {}, |
| | | sort: {}, |
| | | pagination: { |
| | | size: 10, |
| | | size: 15, |
| | | num: 1 |
| | | }, |
| | | role: this.initRole(), |
| | |
| | | edit(row) { |
| | | this.$refs.form.clearValidate() |
| | | this.role = { ...row } |
| | | var this_ = this |
| | | if (this.role.menuIds) { |
| | | this.$refs.permsTree.setCheckedKeys(this.role.menuIds.split(',')) |
| | | var deptIdArrStr = [] |
| | | this.role.menuIds.split(',').forEach(element => { |
| | | const thisNode = this_.$refs.permsTree.getNode(element) // 获取当前节点 |
| | | if (thisNode.childNodes.length === 0) { |
| | | deptIdArrStr.push(thisNode.data.id) |
| | | return |
| | | } |
| | | }) |
| | | this.$refs.permsTree.setCheckedKeys(deptIdArrStr) |
| | | // this.$refs.permsTree.setCheckedKeys(this.role.menuIds.split(',')) |
| | | } else { |
| | | this.$refs.permsTree.setCheckedKeys([]) |
| | | } |
| | |
| | | if (valid) { |
| | | this.buttonLoading = true |
| | | if (this.role.roleId) { |
| | | this.role.menuIds = this.$refs.permsTree.getCheckedKeys().join(',') |
| | | this.role.menuIds = this.$refs.permsTree.getCheckedKeys().concat(this.$refs.permsTree.getHalfCheckedKeys()).join(',') |
| | | this.role.createTime = this.role.modifyTime = null |
| | | this.$put('system/role', { ...this.role }).then(() => { |
| | | this.buttonLoading = false |
| | |
| | | this.reset() |
| | | }) |
| | | } else { |
| | | this.role.menuIds = this.$refs.permsTree.getCheckedKeys().join(',') |
| | | this.role.menuIds = this.$refs.permsTree.getCheckedKeys().concat(this.$refs.permsTree.getHalfCheckedKeys()).join(',') |
| | | this.$post('system/role', { ...this.role }).then(() => { |
| | | this.buttonLoading = false |
| | | this.$message({ |
| | |
| | | } |
| | | } |
| | | </style> |
| | | |