Browse Source

【市北代码迁移至安宁】【权限管理-角色管理】-王公峰-2020-09-17

redesign
wanggongfeng 5 years ago
parent
commit
388d2bb939
  1. 86
      src/views/modules/sys/role-add-or-update.vue

86
src/views/modules/sys/role-add-or-update.vue

@ -6,12 +6,11 @@
<el-form :model="dataForm" <el-form :model="dataForm"
:rules="dataRule" :rules="dataRule"
ref="dataForm" ref="dataForm"
@keyup.enter.native="dataFormSubmitHandle()"
label-width="120px"> label-width="120px">
<el-form-item prop="name" <el-form-item prop="name"
:label="$t('role.name')"> :label="$t('role.name')">
<el-input v-model="dataForm.name" <el-input v-model="dataForm.name"
maxlength="30"
show-word-limit
:placeholder="$t('role.name')"></el-input> :placeholder="$t('role.name')"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="角色类型"> <el-form-item label="角色类型">
@ -27,12 +26,10 @@
<el-form-item prop="remark" <el-form-item prop="remark"
:label="$t('role.remark')"> :label="$t('role.remark')">
<el-input v-model="dataForm.remark" <el-input v-model="dataForm.remark"
maxlength="100"
show-word-limit
:placeholder="$t('role.remark')"></el-input> :placeholder="$t('role.remark')"></el-input>
</el-form-item> </el-form-item>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="5">
<el-form-item size="mini" <el-form-item size="mini"
:label="$t('role.menuList')"> :label="$t('role.menuList')">
<el-tree :data="menuList" <el-tree :data="menuList"
@ -44,7 +41,7 @@
</el-tree> </el-tree>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="5">
<el-form-item size="mini" <el-form-item size="mini"
:label="$t('role.deptList')"> :label="$t('role.deptList')">
<el-tree :data="deptList" <el-tree :data="deptList"
@ -56,7 +53,7 @@
</el-tree> </el-tree>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="4">
<el-form-item size="mini" <el-form-item size="mini"
:label="$t('role.appMenuList')"> :label="$t('role.appMenuList')">
<el-tree :data="appMenuList" <el-tree :data="appMenuList"
@ -68,7 +65,32 @@
</el-tree> </el-tree>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="10"> <el-col :span="4">
<el-form-item size="mini"
:label="$t('role.categoryList')">
<el-tree :data="categoryList"
:props="{ label: 'name', children: 'children' }"
node-key="id"
ref="categoryListTree"
accordion
show-checkbox>
</el-tree>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item size="mini"
:label="$t('role.whistleDeptList')">
<el-tree :data="whistleDeptList"
:props="{ label: 'name', children: 'children' }"
node-key="id"
ref="whistleDeptListTree"
accordion
show-checkbox
check-strictly=true>
</el-tree>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item size="mini" <el-form-item size="mini"
:label="$t('role.analysisMenuList')"> :label="$t('role.analysisMenuList')">
<el-tree :data="analysisMenuList" <el-tree :data="analysisMenuList"
@ -98,15 +120,19 @@ export default {
visible: false, visible: false,
menuList: [], menuList: [],
deptList: [], deptList: [],
whistleDeptList: [],
appMenuList: [], appMenuList: [],
analysisMenuList:[], categoryList: [],
roleTypeList: [], roleTypeList: [],
analysisMenuList: [],
dataForm: { dataForm: {
id: '', id: '',
name: '', name: '',
menuIdList: [], menuIdList: [],
deptIdList: [], deptIdList: [],
appMenuIdList: [], appMenuIdList: [],
categoryIdList: [],
whistleDeptIdList: [],
analysisMenuIdList: [], analysisMenuIdList: [],
remark: '', remark: '',
typeKey: '' typeKey: ''
@ -133,11 +159,15 @@ export default {
this.$refs.menuListTree.setCheckedKeys([]) this.$refs.menuListTree.setCheckedKeys([])
this.$refs.deptListTree.setCheckedKeys([]) this.$refs.deptListTree.setCheckedKeys([])
this.$refs.appMenuListTree.setCheckedKeys([]) this.$refs.appMenuListTree.setCheckedKeys([])
this.$refs.categoryListTree.setCheckedKeys([])
this.$refs.whistleDeptListTree.setCheckedKeys([])
this.$refs.analysisMenuListTree.setCheckedKeys([]) this.$refs.analysisMenuListTree.setCheckedKeys([])
Promise.all([ Promise.all([
this.getMenuList(), this.getMenuList(),
this.getDeptList(), this.getDeptList(),
this.getAppMenuList(), this.getAppMenuList(),
this.getCategoryList(),
this.getWhistleDeptList(),
this.getAnalysisMenuList() this.getAnalysisMenuList()
]).then(() => { ]).then(() => {
if (this.dataForm.id) { if (this.dataForm.id) {
@ -164,6 +194,15 @@ export default {
this.deptList = res.data this.deptList = res.data
}).catch(() => { }) }).catch(() => { })
}, },
//
getWhistleDeptList () {
return this.$http.get('/sys/dept/list').then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.whistleDeptList = res.data
}).catch(() => { })
},
// App // App
getAppMenuList () { getAppMenuList () {
return this.$http.get('/sys/appmenu/select').then(({ data: res }) => { return this.$http.get('/sys/appmenu/select').then(({ data: res }) => {
@ -173,6 +212,15 @@ export default {
this.appMenuList = res.data this.appMenuList = res.data
}).catch(() => { }) }).catch(() => { })
}, },
//
getCategoryList () {
return this.$http.get('/events/handlecategory/getCategoryList').then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.categoryList = res.data
}).catch(() => { })
},
getAnalysisMenuList () { getAnalysisMenuList () {
return this.$http.get('/sys/analysismenu/select').then(({ data: res }) => { return this.$http.get('/sys/analysismenu/select').then(({ data: res }) => {
if (res.code !== 0) { if (res.code !== 0) {
@ -194,7 +242,9 @@ export default {
this.dataForm.menuIdList.forEach(item => this.$refs.menuListTree.setChecked(item, true)) this.dataForm.menuIdList.forEach(item => this.$refs.menuListTree.setChecked(item, true))
this.$refs.deptListTree.setCheckedKeys(this.dataForm.deptIdList) this.$refs.deptListTree.setCheckedKeys(this.dataForm.deptIdList)
this.dataForm.appMenuIdList.forEach(item => this.$refs.appMenuListTree.setChecked(item, true)) this.dataForm.appMenuIdList.forEach(item => this.$refs.appMenuListTree.setChecked(item, true))
this.dataForm.categoryIdList.forEach(item => this.$refs.categoryListTree.setChecked(item, true))
this.dataForm.analysisMenuIdList.forEach(item => this.$refs.analysisMenuListTree.setChecked(item, true)) this.dataForm.analysisMenuIdList.forEach(item => this.$refs.analysisMenuListTree.setChecked(item, true))
this.$refs.whistleDeptListTree.setCheckedKeys(this.dataForm.whistleDeptIdList)
}).catch(() => { }) }).catch(() => { })
}, },
// //
@ -212,10 +262,15 @@ export default {
...this.$refs.appMenuListTree.getCheckedKeys(), ...this.$refs.appMenuListTree.getCheckedKeys(),
...this.$refs.appMenuListTree.getHalfCheckedKeys() ...this.$refs.appMenuListTree.getHalfCheckedKeys()
] ]
this.dataForm.categoryIdList = [
...this.$refs.categoryListTree.getCheckedKeys(),
...this.$refs.categoryListTree.getHalfCheckedKeys()
]
this.dataForm.analysisMenuIdList = [ this.dataForm.analysisMenuIdList = [
...this.$refs.analysisMenuListTree.getCheckedKeys(), ...this.$refs.analysisMenuListTree.getCheckedKeys(),
...this.$refs.analysisMenuListTree.getHalfCheckedKeys() ...this.$refs.analysisMenuListTree.getHalfCheckedKeys()
] ]
this.dataForm.whistleDeptIdList = this.$refs.whistleDeptListTree.getCheckedKeys()
this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/role', this.dataForm).then(({ data: res }) => { this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/role', this.dataForm).then(({ data: res }) => {
if (res.code !== 0) { if (res.code !== 0) {
return this.$message.error(res.msg) return this.$message.error(res.msg)
@ -243,8 +298,15 @@ export default {
} }
} }
</script> </script>
<style scoped> //
.el-dialog__wrapper /deep/ .el-dialog__footer { <style lang="scss">
text-align: center!important; .el-tree {
width: 100%;
overflow-x: auto;
overflow-y: hidden;
}
.el-tree>.el-tree-node {
display: inline-block;
min-width: 100%;
} }
</style> </style>

Loading…
Cancel
Save