|
@@ -0,0 +1,170 @@
|
|
|
+<template>
|
|
|
+ <div class='m-container'>
|
|
|
+ <h2>{{ pageType == "create" ? '添加' : '修改' }}角色</h2>
|
|
|
+ <div class="m-core">
|
|
|
+ <el-form ref="form" label-width="120px" width="500px">
|
|
|
+ <el-form-item label="角色名称" prop="roleName">
|
|
|
+ <el-input v-model="result.roleName"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="角色描述">
|
|
|
+ <el-input type="textarea" v-model="result.roleDesc"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="基本权限">
|
|
|
+ <el-checkbox :indeterminate="isIndeterminate" @change="onCheckAll" v-model="checkAll">全选</el-checkbox>
|
|
|
+ <el-tree
|
|
|
+ :data="data"
|
|
|
+ show-checkbox
|
|
|
+ node-key="id"
|
|
|
+ ref="tree"
|
|
|
+ highlight-current
|
|
|
+ :props="defaultProps">
|
|
|
+ </el-tree>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button @click="onSubmit" type="primary">立即{{ pageType == "create" ? '创建' : '修改' }}</el-button>
|
|
|
+ <el-button @click="onCancel">取消</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import { getUserRole } from '@/api/systemManage'
|
|
|
+import store from '@/store'
|
|
|
+import { getSilder } from '@/api/silder'
|
|
|
+import { roleGetMenus, getRoleInfo, roleUpdate, roleAdd } from '@/api/systemManage'
|
|
|
+export default {
|
|
|
+ name: 'adminManager',
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ organId: store.getters.organ,
|
|
|
+ pageType: this.$route.query.type,
|
|
|
+ id: this.$route.query.id,
|
|
|
+ isIndeterminate: true,
|
|
|
+ data: [],
|
|
|
+ defaultProps: {
|
|
|
+ children: 'children',
|
|
|
+ label: 'label'
|
|
|
+ },
|
|
|
+ result: {
|
|
|
+ roleName: null,
|
|
|
+ roleDesc: null,
|
|
|
+ },
|
|
|
+ checkAll: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.lookSilder()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onSubmit() {
|
|
|
+ if(this.pageType == 'update') {
|
|
|
+ roleUpdate({
|
|
|
+ id: this.id,
|
|
|
+ organId: this.organId,
|
|
|
+ roleDesc: this.result.roleDesc,
|
|
|
+ roleName: this.result.roleName,
|
|
|
+ menuIds: this.$refs.tree.getCheckedKeys()
|
|
|
+ }).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ })
|
|
|
+ } else if(this.pageType == 'create') {
|
|
|
+ roleAdd({
|
|
|
+ organId: this.organId,
|
|
|
+ roleDesc: this.result.roleDesc,
|
|
|
+ roleName: this.result.roleName,
|
|
|
+ menuIds: this.$refs.tree.getCheckedKeys()
|
|
|
+ }).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ lookSilder () {
|
|
|
+ getSilder().then(res => {
|
|
|
+ if(res.code != 200) return
|
|
|
+ this.data = this.setTableData(res.data)
|
|
|
+ })
|
|
|
+ if(this.pageType == 'update') {
|
|
|
+ getRoleInfo({ id: this.id }).then(res => {
|
|
|
+ if(res.code == 200) {
|
|
|
+ this.result = res.data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onCheckAll(val) {
|
|
|
+ if(val) {
|
|
|
+ this.$refs.tree.setCheckedNodes(this.data)
|
|
|
+ } else {
|
|
|
+ this.$refs.tree.setCheckedNodes([])
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setTableData(result) {
|
|
|
+ let list = []
|
|
|
+ list = result.map( res => {
|
|
|
+ let tempList = {}
|
|
|
+ tempList = {
|
|
|
+ id: res.id,
|
|
|
+ name: res.name,
|
|
|
+ label: res.name,
|
|
|
+ type: res.type,
|
|
|
+ path: res.path,
|
|
|
+ permission: res.permission,
|
|
|
+ icon: res.icon,
|
|
|
+ parentId: res.parentId
|
|
|
+ }
|
|
|
+ if(res.sysMenus && res.sysMenus.length > 0) {
|
|
|
+ tempList.children = this.setTableData(res.sysMenus)
|
|
|
+ }
|
|
|
+ return tempList
|
|
|
+ })
|
|
|
+ return list
|
|
|
+ },
|
|
|
+ submitForm(formName) {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ alert('submit!');
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ resetForm(formName) {
|
|
|
+ this.$refs[formName].resetFields()
|
|
|
+ },
|
|
|
+ onCancel() {
|
|
|
+ this.$router.push('/system/insideSetting/adminManager')
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.el-button--primary {
|
|
|
+ background: #14928a;
|
|
|
+ border-color: #14928a;
|
|
|
+ color: #fff;
|
|
|
+ &:hover, &:active, &:focus {
|
|
|
+ background: #14928a;
|
|
|
+ border-color: #14928a;
|
|
|
+ color: #FFF;
|
|
|
+ }
|
|
|
+}
|
|
|
+.el-row {
|
|
|
+ margin-top: 40px;
|
|
|
+}
|
|
|
+.el-col {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ margin-bottom: 20px;
|
|
|
+ justify-content: flex-end;
|
|
|
+ margin-right: 50%;
|
|
|
+}
|
|
|
+.el-input-group {
|
|
|
+ width: 200px;
|
|
|
+ margin: 0 20px;
|
|
|
+}
|
|
|
+/deep/.el-tree-node__content {
|
|
|
+ height: 40px !important;
|
|
|
+}
|
|
|
+</style>
|