|
@@ -0,0 +1,382 @@
|
|
|
+<template>
|
|
|
+ <div class="box">
|
|
|
+ <h2
|
|
|
+ style="margin-bottom: 20px;padding-bottom:7px;border-bottom:2px solid #ddd"
|
|
|
+ >
|
|
|
+ 权限管理
|
|
|
+ </h2>
|
|
|
+ <div class="box-content">
|
|
|
+ <div style="margin-bottom: 10px">
|
|
|
+ <el-form :inline="true" label-width="80px">
|
|
|
+ <el-form-item>
|
|
|
+ <el-input v-model="keyword" placeholder="请输入用户姓名或手机号"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button @click="search" type="success">搜索</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="dialogVisible = true">新增权限组</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <el-table
|
|
|
+ :data="tableData"
|
|
|
+ border
|
|
|
+ :height="590 + 'px'">
|
|
|
+ <el-table-column
|
|
|
+ prop="id"
|
|
|
+ label="权限组id">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="groupName"
|
|
|
+ label="权限组名称">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="remark"
|
|
|
+ label="备注">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="primary"
|
|
|
+ @click="handleEdit(scope.row)">编辑</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="warning"
|
|
|
+ @click="handleLimits(scope.row)">权限分配</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="danger"
|
|
|
+ @click="handleUser(scope.row)">用户分配</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="danger"
|
|
|
+ @click="del(scope.row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <table-footer
|
|
|
+ :totals="total"
|
|
|
+ :size="size"
|
|
|
+ @sizeChange="sizeChange"
|
|
|
+ @pageChange="pageChange"></table-footer>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- // 新增-->
|
|
|
+ <el-dialog
|
|
|
+ :title="showType ? '编辑权限组' : '新增权限组'"
|
|
|
+ :visible.sync="dialogVisible"
|
|
|
+ width="30%">
|
|
|
+ <div>
|
|
|
+ <el-form ref="form" :model="form" label-width="100px">
|
|
|
+ <el-form-item label="权限组名称">
|
|
|
+ <el-input v-model="form.groupName"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="备注">
|
|
|
+ <el-input v-model="form.remark" disabled></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogVisible = false">取 消</el-button>
|
|
|
+ <el-button v-if="showType" type="primary" @click="setUpdate">更 新</el-button>
|
|
|
+ <el-button v-else type="primary" @click="onSubmit">新 增</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ <!-- 权限分配 -->
|
|
|
+ <el-dialog
|
|
|
+ title="权限分配"
|
|
|
+ :visible.sync="dialogLimits"
|
|
|
+ width="50%">
|
|
|
+ <div>
|
|
|
+ <el-tree
|
|
|
+ v-if="dialogLimits"
|
|
|
+ :data="limitList"
|
|
|
+ show-checkbox
|
|
|
+ node-key="id"
|
|
|
+ default-expand-all
|
|
|
+ :default-checked-keys="selectList"
|
|
|
+ :props="defaultProps"
|
|
|
+ @check="selectTable"
|
|
|
+ ref="tree">
|
|
|
+ </el-tree>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogLimits = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="limitSave">保存</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ <el-dialog
|
|
|
+ title="用户分配"
|
|
|
+ :visible.sync="dialogUsers"
|
|
|
+ width="50%">
|
|
|
+ <div>
|
|
|
+ <el-table
|
|
|
+ :data="userList"
|
|
|
+ ref="multipleTable"
|
|
|
+ tooltip-effect="dark"
|
|
|
+ @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column
|
|
|
+ type="selection"
|
|
|
+ width="55">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="id"
|
|
|
+ label="用户ID">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="userName"
|
|
|
+ label="用户姓名">
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogUsers = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="userSave">保存</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import TableFooter from "../../components/TableFooter";
|
|
|
+ import { mapState } from 'vuex';
|
|
|
+ export default {
|
|
|
+ name: "authAdmin",
|
|
|
+ components: {
|
|
|
+ TableFooter
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ tableData: [
|
|
|
+ ],
|
|
|
+ showType: false,
|
|
|
+ dialogVisible: false,
|
|
|
+ form: {
|
|
|
+ id: '',
|
|
|
+ groupName: '',
|
|
|
+ remark: '养殖管理菜单',
|
|
|
+ },
|
|
|
+ dialogLimits: false,
|
|
|
+ // 权限分配list
|
|
|
+ limitList: [
|
|
|
+ ],
|
|
|
+ defaultProps: {
|
|
|
+ children: 'children',
|
|
|
+ label: 'menuName'
|
|
|
+ },
|
|
|
+ // 选择得参数
|
|
|
+ selectList: [],
|
|
|
+ keyword: '',
|
|
|
+ total: 0,
|
|
|
+ size: 20,
|
|
|
+ pageNum: 1,
|
|
|
+ selectId: '',
|
|
|
+ // 用户列表
|
|
|
+ userList: [],
|
|
|
+ dialogUsers: false,
|
|
|
+ userSelect: [],
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState(['typeCode'])
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 搜索
|
|
|
+ search() {
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ // 修改size
|
|
|
+ sizeChange(val) {
|
|
|
+ this.size = val;
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ // 修改页数
|
|
|
+ pageChange(val) {
|
|
|
+ this.pageNum= val;
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ handleEdit(data) {
|
|
|
+ this.showType = true;
|
|
|
+ this.dialogVisible = true;
|
|
|
+ this.form.remark = data.remark;
|
|
|
+ this.form.groupName = data.groupName;
|
|
|
+ this.form.id = data.id;
|
|
|
+ },
|
|
|
+ handleLimits(data) {
|
|
|
+ this.dialogLimits = true;
|
|
|
+ this.selectId = data.id;
|
|
|
+ this.selectList = [];
|
|
|
+ this.$axios.post(`http://121.37.169.186:8081/auth/getMenuByGroup?groupId=${data.id}`)
|
|
|
+ .then(res => {
|
|
|
+ if(res.data.code === 10005) {
|
|
|
+ this.selectList = [];
|
|
|
+ } else {
|
|
|
+ this.selectList = res.data.data.split(',');
|
|
|
+ this.$forceUpdate();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 用户分配
|
|
|
+ handleUser(data) {
|
|
|
+ this.dialogUsers = true;
|
|
|
+ this.selectId = data.id;
|
|
|
+ this.$axios.post(`http://121.37.169.186:8081/auth/getAcountByGroup?groupId=${data.id}`)
|
|
|
+ .then(res => {
|
|
|
+ if(res.data.code === 10006) {
|
|
|
+ this.userSelect = [];
|
|
|
+ } else {
|
|
|
+ let arr = res.data.data.split(',');
|
|
|
+ this.$nextTick(() => {
|
|
|
+ for (let key in this.userList) {
|
|
|
+ for(let i in arr) {
|
|
|
+ if(this.userList[key]['id'] == arr[i]) {
|
|
|
+ this.$refs.multipleTable.toggleRowSelection(this.userList[key], true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 用户分配选择
|
|
|
+ handleSelectionChange(val) {
|
|
|
+ this.userSelect = val;
|
|
|
+ },
|
|
|
+ // 用户分配保存
|
|
|
+ userSave() {
|
|
|
+ let users = [];
|
|
|
+ this.userSelect.forEach(item => {
|
|
|
+ users.push(item.id);
|
|
|
+ });
|
|
|
+ let str = users.join(',');
|
|
|
+ this.$axios.post(`http://121.37.169.186:8081/auth/saveAccountGroup?accountId=${str}&groupIds=${this.selectId}`)
|
|
|
+ .then(res => {
|
|
|
+ if(res.data.code === 10001) {
|
|
|
+ }
|
|
|
+ this.userSelect = [];
|
|
|
+ this.selectId = '';
|
|
|
+ this.$message(res.data.message);
|
|
|
+ });
|
|
|
+ this.dialogUsers = false;
|
|
|
+ },
|
|
|
+ selectTable(data, checked, ) {
|
|
|
+ this.selectList = checked.checkedKeys.concat(checked.halfCheckedKeys);
|
|
|
+ },
|
|
|
+ // 新增角色
|
|
|
+ onSubmit() {
|
|
|
+ this.$axios.post(`http://121.37.169.186:8081/group/add?groupName=${this.form.groupName}&remark=${this.form.remark}`)
|
|
|
+ .then(res => {
|
|
|
+ if(res.data.code === 10000) {
|
|
|
+ this.init();
|
|
|
+ }
|
|
|
+ this.$message(res.data.message);
|
|
|
+ this.dialogVisible = false;
|
|
|
+ this.reset();
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 权限分配
|
|
|
+ limitSave() {
|
|
|
+ let menuIds = this.selectList.join(',');
|
|
|
+ menuIds += ',82';
|
|
|
+ this.$axios.post(`http://121.37.169.186:8081/auth/saveGroupMenu?groupId=${this.selectId}&menuIds=${menuIds}`)
|
|
|
+ .then(res => {
|
|
|
+ if(res.data.code === 10001) {
|
|
|
+ }
|
|
|
+ this.$message(res.data.message);
|
|
|
+ this.selectId = '';
|
|
|
+ });
|
|
|
+ this.dialogLimits = false;
|
|
|
+ this.selectList = [];
|
|
|
+ },
|
|
|
+ init() {
|
|
|
+ this.$axios.post(`http://121.37.169.186:8081/group/list?pageNum=${this.pageNum}&pageSize=${this.size}&searchStr=${this.keyword}`)
|
|
|
+ .then(res => {
|
|
|
+ this.tableData = res.data.content;
|
|
|
+ this.total = res.data.totalElements;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 重置
|
|
|
+ reset(){
|
|
|
+ this.form.id = '';
|
|
|
+ this.form.groupName = '';
|
|
|
+ this.form.remark = '养殖管理菜单';
|
|
|
+ this.pageNum = 1;
|
|
|
+ this.keyword = '';
|
|
|
+ this.showType = false;
|
|
|
+ },
|
|
|
+ // 更新
|
|
|
+ setUpdate() {
|
|
|
+ this.$axios.post(`http://121.37.169.186:8081/group/edit?groupName=${this.form.groupName}&remark=${this.form.remark}&groupId=${this.form.id}`)
|
|
|
+ .then(res => {
|
|
|
+ if(res.data.code === 10000) {
|
|
|
+ this.init();
|
|
|
+ }
|
|
|
+ this.$message(res.data.message);
|
|
|
+ this.dialogVisible = false;
|
|
|
+ this.reset();
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 删除
|
|
|
+ del(data) {
|
|
|
+ this.$confirm('此操作将永久删除批量删除, 是否继续?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ this.$axios.post(`http://121.37.169.186:8081/group/remove?groupId=${data.id}`)
|
|
|
+ .then(res => {
|
|
|
+ if(res.data.code === 10000) {
|
|
|
+ this.init();
|
|
|
+ }
|
|
|
+ this.$message(res.data.message);
|
|
|
+ })
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: 'info',
|
|
|
+ message: '已取消删除'
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 菜单列表
|
|
|
+ authInit() {
|
|
|
+ this.$axios.post('http://121.37.169.186:8081/menu/list')
|
|
|
+ .then(res => {
|
|
|
+ res.data.forEach(item => {
|
|
|
+ if(item.menuName === this.typeCode) {
|
|
|
+ this.limitList = item.children;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // this.limitList = res.data;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 用户列表
|
|
|
+ userInit() {
|
|
|
+ this.$axios.post(`http://121.37.169.186:8081/user/list?pageNum=1&pageSize=100&searchStr=`)
|
|
|
+ .then(res => {
|
|
|
+ if(res.data.code === 10001) {
|
|
|
+ this.userList = res.data.data;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.init();
|
|
|
+ this.authInit();
|
|
|
+ this.userInit();
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+ .box {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 20px;
|
|
|
+ border: 1px solid #Ddd;
|
|
|
+ }
|
|
|
+</style>
|