add role page

木子李·De 3 years ago
parent 392b64f25f
commit 4f131daea5

@ -0,0 +1,58 @@
import request from '@/utils/request'
export function accessRoleList (params) {
return request({
url: 'accessRole/pageList',
method: 'GET',
params,
})
}
export function accessRoleAdd (data) {
return request({
url: 'accessRole',
method: 'post',
data
})
}
export function accessRoleDeleteBatch (data) {
return request({
url: 'accessRole/delete/batch',
method: 'post',
data
})
}
export function accessRoleUpdate (data) {
return request({
url: 'accessRole',
method: 'put', data,
})
}
export function accessRoleDetail (data) {
return request({
url: 'accessRole/' + data.id,
method: 'get',
params: { accessKey: data.accessKey }
})
}
export function accessRoleAuthorityTree (roleCode) {
return request({
url: 'accessRole/authorityTree/' + roleCode,
method: 'get',
})
}
export function saveAuthorityTree (data) {
return request({
url: 'accessRole/saveAuthorityTree',
method: 'post',
data
})
}
export default { accessRoleList, accessRoleAdd, accessRoleDeleteBatch, accessRoleUpdate, accessRoleDetail, accessRoleAuthorityTree, saveAuthorityTree }

@ -0,0 +1,192 @@
<template>
<anji-crud ref="listPage"
:option="crudOption">
<template v-slot:buttonLeftOnTable>
</template>
<template slot="rowButton"
slot-scope="props">
<el-button type="text"
@click="handleOpenDialogSetAuthorityForRole(props)">设定权限</el-button>
</template>
<!--自定义的卡片插槽将在编辑详情页面出现在底部新卡片-->
<template v-slot:pageSection>
<RoleAuthority :role-code="roleCode"
:visib="dialogVisibleSetAuthorityForRole"
@handleClose="dialogVisibleSetAuthorityForRole = false" />
</template>
</anji-crud>
</template>
<script>
import { accessRoleList, accessRoleAdd, accessRoleDeleteBatch, accessRoleUpdate, accessRoleDetail } from '@/api/accessRole'
import RoleAuthority from '@/views/accessRole/components/RoleAuthority'
export default {
name: 'AccessRole',
components: {
RoleAuthority: RoleAuthority,
},
data () {
return {
//
dialogVisibleSetAuthorityForRole: false,
roleCode: '',
// 使
crudOption: {
// 使
title: '角色管理',
//
labelWidth: '120px',
//
queryFormFields: [
{
inputType: 'input',
label: '角色编码',
field: 'roleCode'
},
{
inputType: 'input',
label: '角色名称',
field: 'roleName'
},
{
inputType: 'anji-select', //form input|input-number|anji-select(urldictCode)|anji-tree()|date|datetime|datetimerange
anjiSelectOption: {
dictCode: 'ENABLE_FLAG',
},
label: '启用状态',
field: 'enableFlag',
},
],
//
buttons: {
query: {
api: accessRoleList,
permission: 'AccessRole:PAGE'
},
queryByPrimarykey: {
api: accessRoleDetail,
permission: 'AccessRole:detail'
},
add: {
api: accessRoleAdd,
permission: 'AccessRole:insert'
},
delete: {
api: accessRoleDeleteBatch,
permission: 'AccessRole:delete'
},
edit: {
api: accessRoleUpdate,
permission: 'AccessRole:update'
},
},
//
columns: [
{
label: '',
field: 'id',
primaryKey: true, // ,
tableHide: true, //
editHide: true, //
},
{
label: '角色编码',
placeholder: '',
field: 'roleCode',
editField: 'roleCode',
tableHide: true, //
inputType: 'input',
rules: [
{ required: true, message: '角色编码必填', trigger: 'blur' },
{ min: 1, max: 32, message: '不超过32个字符', trigger: 'blur' }
],
disabled: false,
},
{
label: '角色名称',
placeholder: '',
field: 'roleName',
fieldTableRowRenderer: (row) => {
return `${row['roleName']}[${row['roleCode']}]`
},
editField: 'roleName',
inputType: 'input',
rules: [
{ required: true, message: '角色名称必填', trigger: 'blur' },
{ min: 1, max: 64, message: '不超过64个字符', trigger: 'blur' }
],
disabled: false,
},
{
label: '启用状态',//0-- 1-- DIC_NAME=ENABLE_FLAG
placeholder: '',
field: 'enableFlag',
fieldTableRowRenderer: (row) => {
return this.getDictLabelByCode('ENABLE_FLAG', row['enableFlag'])
},
editField: 'enableFlag',
inputType: 'anji-select',
anjiSelectOption: {
dictCode: 'ENABLE_FLAG', //
},
colorStyle: {
0: 'table-danger', //keyeditField'': 'danger','': 'primary','绿': 'success','': 'warning','': 'info',''''
1: 'table-success'
},
rules: [
{ required: true, message: '启用状态必填', trigger: 'blur' },
],
disabled: false,
},
{
label: '创建人',
placeholder: '',
field: 'createBy',
editField: 'createBy',
inputType: 'input',
editHide: 'hideOnAdd', // true/false/'hideOnAdd hideOnView hideOnEdit'
disabled: true,
},
{
label: '创建时间',
placeholder: '',
field: 'createTime',
editField: 'createTime',
inputType: 'input',
editHide: 'hideOnAdd', // true/false/'hideOnAdd hideOnView hideOnEdit'
disabled: true,
},
{
label: '修改人',
placeholder: '',
field: 'updateBy',
editField: 'updateBy',
inputType: 'input',
editHide: 'hideOnAdd', // true/false/'hideOnAdd hideOnView hideOnEdit'
disabled: true,
},
{
label: '修改时间',
placeholder: '',
field: 'updateTime',
editField: 'updateTime',
inputType: 'input',
editHide: 'hideOnAdd', // true/false/'hideOnAdd hideOnView hideOnEdit'
disabled: true,
},
],
},
}
},
created () { },
methods: {
handleOpenDialogSetAuthorityForRole (props) {
this.roleCode = props.msg.roleCode
this.dialogVisibleSetAuthorityForRole = true
},
}
}
</script>

@ -0,0 +1,86 @@
<template>
<el-dialog class="tree_dialog"
title="授权角色"
width="60%"
:close-on-click-modal="false"
center
:visible.sync="visib"
:before-close="closeDialog">
<el-tree ref="roleTree"
:data="treeData"
show-checkbox
node-key="id"
default-expand-all
:default-checked-keys="checkedKeys" />
<div slot="footer"
style="text-align: center">
<el-button type="primary"
plain
@click="saveTreeData">保存</el-button>
<el-button type="danger"
plain
@click="closeDialog">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import { getRoleTree, saveRoleTree } from '@/api/accessUser'
export default {
props: {
visib: {
required: true,
type: Boolean,
default: false,
},
loginName: {
required: true,
type: String,
default: () => {
return ''
},
},
},
data () {
return {
checkedKeys: [], // keys
treeData: [], //
}
},
watch: {
visib (val) {
if (val) {
//
console.log(1)
this.getTreeData()
}
},
},
created () { },
methods: {
//
async getTreeData () {
const { code, data } = await getRoleTree(this.loginName)
if (code != '200') return
this.treeData = data.treeData
this.checkedKeys = data.checkedKeys
},
async saveTreeData () {
var params = {
loginName: this.loginName,
roleCodeList: this.$refs.roleTree.getCheckedKeys(true),
}
const { code } = await saveRoleTree(params)
if (code != '200') return
this.closeDialog()
},
//
closeDialog () {
this.treeData = []
this.checkedKeys = []
this.$emit('handleClose')
},
},
}
</script>
Loading…
Cancel
Save