Browse Source

角色管理新增角色bug修复

main
pixel 4 years ago
parent
commit
7b0a012ae5
  1. 113
      web/src/view/superAdmin/authority/authority.vue

113
web/src/view/superAdmin/authority/authority.vue

@ -16,29 +16,48 @@
<el-table-column fixed="right" label="操作" width="460">
<template slot-scope="scope">
<el-button @click="opdendrawer(scope.row)" size="small" type="primary">设置权限</el-button>
<el-button @click="addAuthority(scope.row.authorityId)" size="small" type="primary" icon="el-icon-plus">新增子角色</el-button>
<el-button @click="copyAuthority(scope.row)" size="small" type="primary" icon="el-icon-copy-document" >拷贝</el-button>
<el-button @click="editAuthority(scope.row)" size="small" type="primary" icon="el-icon-edit">编辑</el-button>
<el-button @click="deleteAuth(scope.row)" size="small" type="danger" icon="el-icon-delete">删除</el-button>
<el-button
@click="addAuthority(scope.row.authorityId)"
icon="el-icon-plus"
size="small"
type="primary"
>新增子角色</el-button>
<el-button
@click="copyAuthority(scope.row)"
icon="el-icon-copy-document"
size="small"
type="primary"
>拷贝</el-button>
<el-button
@click="editAuthority(scope.row)"
icon="el-icon-edit"
size="small"
type="primary"
>编辑</el-button>
<el-button
@click="deleteAuth(scope.row)"
icon="el-icon-delete"
size="small"
type="danger"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 新增角色弹窗 -->
<el-dialog :visible.sync="dialogFormVisible" :title="dialogTitle">
<el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible">
<el-form :model="form" :rules="rules" ref="authorityForm">
<el-form-item label="父级角色" prop="parentId">
<el-cascader
:disabled="dialogType=='add'"
v-model="form.parentId"
:options="AuthorityOption"
:show-all-levels="false"
:props="{ checkStrictly: true,label:'authorityName',value:'authorityId',disabled:'disabled',emitPath:false}"
filterable>
</el-cascader>
:show-all-levels="false"
filterable
v-model="form.parentId"
></el-cascader>
</el-form-item>
<el-form-item label="角色ID" prop="authorityId">
<el-input autocomplete="off" :disabled="dialogType=='edit'" v-model="form.authorityId"></el-input>
<el-input :disabled="dialogType=='edit'" autocomplete="off" v-model="form.authorityId"></el-input>
</el-form-item>
<el-form-item label="角色姓名" prop="authorityName">
<el-input autocomplete="off" v-model="form.authorityName"></el-input>
@ -51,7 +70,7 @@
</el-dialog>
<el-drawer :visible.sync="drawer" :with-header="false" size="40%" title="角色配置" v-if="drawer">
<el-tabs class="role-box" type="border-card" :before-leave="autoEnter">
<el-tabs :before-leave="autoEnter" class="role-box" type="border-card">
<el-tab-pane label="角色菜单">
<Menus :row="activeRow" ref="menus" />
</el-tab-pane>
@ -87,16 +106,18 @@ export default {
mixins: [infoList],
data() {
return {
AuthorityOption:[{
authorityId:"0",
authorityName:"根角色"
}],
AuthorityOption: [
{
authorityId: '0',
authorityName: '根角色'
}
],
listApi: getAuthorityList,
drawer: false,
dialogType:"add",
dialogType: 'add',
activeRow: {},
activeUserId: 0,
dialogTitle:"新增角色",
dialogTitle: '新增角色',
dialogFormVisible: false,
apiDialogFlag: false,
copyForm: {},
@ -125,7 +146,7 @@ export default {
},
methods: {
autoEnter(activeName, oldActiveName) {
const paneArr = ["menus","apis","datas"]
const paneArr = ['menus', 'apis', 'datas']
if (oldActiveName) {
if (this.$refs[paneArr[oldActiveName]].needConfirm) {
this.$refs[paneArr[oldActiveName]].enterAndNext()
@ -136,13 +157,13 @@ export default {
//
copyAuthority(row) {
this.setOptions()
this.dialogTitle = "拷贝角色"
this.dialogType = "copy"
this.dialogTitle = '拷贝角色'
this.dialogType = 'copy'
for (let k in this.form) {
this.form[k] = row[k]
}
this.copyForm = row
this.dialogFormVisible = true;
this.dialogFormVisible = true
},
opdendrawer(row) {
this.drawer = true
@ -174,7 +195,9 @@ export default {
},
//
initForm() {
if (this.$refs.authorityForm) {
this.$refs.authorityForm.resetFields()
}
this.form = {
authorityId: '',
authorityName: '',
@ -212,7 +235,7 @@ export default {
this.closeDialog()
}
}
break;
break
case 'edit':
{
const res = await updateAuthority(this.form)
@ -225,16 +248,16 @@ export default {
this.closeDialog()
}
}
break;
break
case 'copy': {
const data = {
"authority": {
"authorityId": "string",
"authorityName": "string",
"datauthorityId": [],
"parentId": "string",
authority: {
authorityId: 'string',
authorityName: 'string',
datauthorityId: [],
parentId: 'string'
},
"oldAuthorityId": 0
oldAuthorityId: 0
}
data.authority.authorityId = this.form.authorityId
data.authority.authorityName = this.form.authorityName
@ -258,14 +281,17 @@ export default {
})
},
setOptions() {
this.AuthorityOption = [{
authorityId:"0",
authorityName:"根角色"
}]
this.AuthorityOption = [
{
authorityId: '0',
authorityName: '根角色'
}
]
this.setAuthorityOptions(this.tableData, this.AuthorityOption, false)
},
setAuthorityOptions(AuthorityData, optionsData, disabled) {
AuthorityData&&AuthorityData.map(item=>{
AuthorityData &&
AuthorityData.map(item => {
if (item.children && item.children.length) {
const option = {
authorityId: item.authorityId,
@ -273,13 +299,17 @@ export default {
disabled: disabled || item.authorityId == this.form.authorityId,
children: []
}
this.setAuthorityOptions(item.children,option.children,disabled||item.authorityId == this.form.authorityId)
this.setAuthorityOptions(
item.children,
option.children,
disabled || item.authorityId == this.form.authorityId
)
optionsData.push(option)
} else {
const option = {
authorityId: item.authorityId,
authorityName: item.authorityName,
disabled:disabled||item.authorityId == this.form.authorityId,
disabled: disabled || item.authorityId == this.form.authorityId
}
optionsData.push(option)
}
@ -288,18 +318,17 @@ export default {
//
addAuthority(parentId) {
this.initForm()
this.dialogTitle = "新增角色"
this.dialogType = "add"
this.dialogTitle = '新增角色'
this.dialogType = 'add'
this.form.parentId = parentId
this.setOptions()
this.dialogFormVisible = true
},
//
editAuthority(row) {
this.setOptions()
this.dialogTitle = "编辑角色"
this.dialogType = "edit"
this.dialogTitle = '编辑角色'
this.dialogType = 'edit'
for (let key in this.form) {
this.form[key] = row[key]
}

Loading…
Cancel
Save