|
@@ -1,5 +1,23 @@
|
|
|
<template>
|
|
|
<div class="main-content__div">
|
|
|
+ <div class="table-box__div" v-cloak v-loading="loadingFlag">
|
|
|
+ <el-form class="demo-form-inline">
|
|
|
+ <el-form-item label="角色名称">
|
|
|
+ <el-input
|
|
|
+ placeholder="角色名称"
|
|
|
+ v-model="keyword"
|
|
|
+ style="width:150px;"
|
|
|
+ size="small"
|
|
|
+ >
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <!-- 搜索按钮 -->
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" size="small" @click="searchFrom()">搜索</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
<!-- 列表 -->
|
|
|
<div class="table-box__div" v-cloak v-loading="loadingFlag">
|
|
|
<!-- 查询表单 -->
|
|
@@ -16,37 +34,15 @@
|
|
|
style="width: 100%;font-size: 15px;"
|
|
|
:header-cell-style="{background:'#FAFAFA'}"
|
|
|
>
|
|
|
- <el-table-column label="编号" width="150" prop="id"></el-table-column>
|
|
|
- <el-table-column label="菜单名称" prop="label" width="250"></el-table-column>
|
|
|
- <el-table-column label="路由地址" prop="url" width="200"></el-table-column>
|
|
|
- <el-table-column label="图标" prop="icon" width="200"></el-table-column>
|
|
|
- <el-table-column label="排序" prop="sort" width="200"></el-table-column>
|
|
|
- <el-table-column label="是否外链" width="200" prop="is_links">
|
|
|
- <template v-slot="{row}">
|
|
|
- <el-switch
|
|
|
- v-model="row.is_links"
|
|
|
- :active-value="1"
|
|
|
- :inactive-value="0"
|
|
|
- disabled
|
|
|
- ></el-switch>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
-
|
|
|
- <el-table-column label="是否隐藏" width="200">
|
|
|
- <template v-slot="{row}">
|
|
|
-
|
|
|
- <el-switch
|
|
|
- v-model="row.hidden"
|
|
|
- :active-value="1"
|
|
|
- :inactive-value="0"
|
|
|
- disabled
|
|
|
- ></el-switch>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column prop="" label="操作" align="center" >
|
|
|
+ <el-table-column label="编号" width="250" prop="id"></el-table-column>
|
|
|
+ <el-table-column label="角色名称" prop="role_name" width="350"></el-table-column>
|
|
|
+ <el-table-column label="角色备注" prop="remark" width="300"></el-table-column>
|
|
|
+ <el-table-column label="操作时间" prop="updated_at" width="300"></el-table-column>
|
|
|
+ <el-table-column label="排序" prop="sort" width="300"></el-table-column>
|
|
|
+ <el-table-column prop="" label="操作" align="center">
|
|
|
<template v-slot="scope">
|
|
|
- <div style="display: flex;flex-direction: column;justify-content: center;align-items: center;">
|
|
|
- <span class="btn " @click="nextClick(scope.row.id)">查看下级</span>
|
|
|
+ <div style="display: flex;flex-direction: column;justify-content: center;align-items: center;" v-if="scope.row.rule[0]!='0'">
|
|
|
+ <span class="btn" @click="assignPermissions(scope.row, scope.$index)">分配权限</span>
|
|
|
<span class="btn" @click="updateClick(scope.row, scope.$index)">编辑</span>
|
|
|
<span class="btn" @click="deleteAuthority(scope.row,scope.$index)">删除</span>
|
|
|
</div>
|
|
@@ -66,7 +62,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <Dialog title="温馨提示" content="您确认要删除该菜单吗?"
|
|
|
+ <Dialog title="温馨提示" content="您确认要删除该角色吗?"
|
|
|
@close="DialogShow = false"
|
|
|
@submitSureClick="submitSureClickDel"
|
|
|
@DialogFalse="DialogShow = false"
|
|
@@ -74,30 +70,50 @@
|
|
|
</Dialog>
|
|
|
<DialogSlot
|
|
|
title="添加/编辑"
|
|
|
- @close="menuDialogShow = false"
|
|
|
- @DialogClose="menuDialogShow = false"
|
|
|
- :innerVisible="menuDialogShow"
|
|
|
- @colesClick="menuDialogShow = false"
|
|
|
+ @close="roleDialogShow = false"
|
|
|
+ @DialogClose="roleDialogShow = false"
|
|
|
+ :innerVisible="roleDialogShow"
|
|
|
+ @colesClick="roleDialogShow = false"
|
|
|
>
|
|
|
<editFrom
|
|
|
- @colesClick="menuDialogShow = false"
|
|
|
- :menuDataForm="menuDataForm"
|
|
|
+ @colesClick="roleDialogShow = false"
|
|
|
+ :roleDataForm="roleDataForm"
|
|
|
:isloading="isloading"
|
|
|
- @menuSubmitClick="menuSubmitClick"
|
|
|
+ @roleSubmitClick="roleSubmitClick"
|
|
|
@closeDlg="closeDlg"
|
|
|
>
|
|
|
</editFrom>
|
|
|
</DialogSlot>
|
|
|
+
|
|
|
+ <DialogSlot
|
|
|
+ title="添加权限/编辑权限"
|
|
|
+ @close="authorityDialogShow = false"
|
|
|
+ @DialogClose="authorityDialogShow = false"
|
|
|
+ :innerVisible="authorityDialogShow"
|
|
|
+ @colesClick="authorityDialogShow = false"
|
|
|
+ >
|
|
|
+ <authorityFrom
|
|
|
+ @colesClick="authorityDialogShow = false"
|
|
|
+ :authorityDataForm="authorityDataForm"
|
|
|
+ :isloading="isloading"
|
|
|
+ @authoritySubmitClick="authoritySubmitClick"
|
|
|
+ @closeDlg="closeDlg"
|
|
|
+ >
|
|
|
+ </authorityFrom>
|
|
|
+ </DialogSlot>
|
|
|
</template>
|
|
|
<script>
|
|
|
import Dialog from "../../components/dialog";
|
|
|
import editFrom from "./components/edit";
|
|
|
+ import authorityFrom from "./components/authority";
|
|
|
import DialogSlot from "../../components/DialogSlot";
|
|
|
+import router from "../../router";
|
|
|
export default {
|
|
|
components: {
|
|
|
Dialog,
|
|
|
editFrom,
|
|
|
- DialogSlot
|
|
|
+ DialogSlot,
|
|
|
+ authorityFrom
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
@@ -119,12 +135,17 @@
|
|
|
isShowSource: false, // 是否显示来源列
|
|
|
id:0,
|
|
|
DialogShow: false, //控制删除弹窗
|
|
|
- MenuId:'',
|
|
|
- MenuRowIndex:'',
|
|
|
- menuDataForm: {},
|
|
|
- menuTableData: [],
|
|
|
+ roleId:'',
|
|
|
+ roleRowIndex:'',
|
|
|
+ roleDataForm: {},
|
|
|
+ roleTableData: [],
|
|
|
isloading:false, //提交按钮状态
|
|
|
- menuDialogShow: false, // 控制保存弹窗
|
|
|
+ roleDialogShow: false, // 控制保存弹窗
|
|
|
+
|
|
|
+
|
|
|
+ authorityDialogShow:false,
|
|
|
+ authorityDataForm: {},
|
|
|
+ keyword:'',
|
|
|
}
|
|
|
},
|
|
|
mounted() {},
|
|
@@ -136,13 +157,14 @@
|
|
|
let parames = {
|
|
|
'page':this.currentPage,
|
|
|
'pageSize':this.pageSize,
|
|
|
- 'id':this.id
|
|
|
+ 'keyword':this.keyword
|
|
|
}
|
|
|
- this.$api.authority.getMenuList(parames).then(res=>{
|
|
|
+ console.log("**************")
|
|
|
+ this.$api.user.roleList(parames).then(res=>{
|
|
|
_t.loadingFlag = false;
|
|
|
if(res.code==200){
|
|
|
if(res.data.rows.length==0){
|
|
|
- this.$message.error("没有下级了,休息一下吧!!!")
|
|
|
+ this.$message.error("没找到该角色!!!")
|
|
|
return
|
|
|
}
|
|
|
_t.tableData = res.data.rows;
|
|
@@ -173,76 +195,110 @@
|
|
|
this.getList()
|
|
|
},
|
|
|
addClick(){
|
|
|
- this.menuDataForm = {}
|
|
|
- this.menuDialogShow = true
|
|
|
+ this.roleDataForm = {}
|
|
|
+ this.roleDialogShow = true
|
|
|
},
|
|
|
- //更新菜单
|
|
|
+ //更新角色
|
|
|
updateClick(row,index){
|
|
|
console.log(row)
|
|
|
- this.menuDataForm = row
|
|
|
+ this.roleDataForm = row
|
|
|
this.rowIndex = index
|
|
|
- this.menuDialogShow = true
|
|
|
+ this.roleDialogShow = true
|
|
|
},
|
|
|
- // menuDialogShow(){
|
|
|
- // this.isloading = false
|
|
|
- // },
|
|
|
closeDlg(val){
|
|
|
console.log("aaaaaa",val)
|
|
|
- this.menuDialogShow = false
|
|
|
+ this.roleDialogShow = false
|
|
|
this.isloading = false
|
|
|
+ this.authorityDialogShow = false
|
|
|
},
|
|
|
- menuSubmitClick(data){
|
|
|
+ roleSubmitClick(data){
|
|
|
let _t = this
|
|
|
console.log("提交数据",data)
|
|
|
let parames = data
|
|
|
_t.isloading = true
|
|
|
//有id更新,没有新增
|
|
|
if(parames.id){
|
|
|
- this.$api.authority.updateMenu(parames).then(res=>{
|
|
|
+ this.$api.user.updateRole(parames).then(res=>{
|
|
|
_t.loadingFlag = false;
|
|
|
if(res.code==200){
|
|
|
_t.tableData[_t.rowIndex] = parames
|
|
|
console.log("修改成功")
|
|
|
- location.reload();
|
|
|
+ this.getList()
|
|
|
}else{
|
|
|
this.$message.error("修改失败")
|
|
|
}
|
|
|
- this.menuDialogShow = false
|
|
|
+ this.roleDialogShow = false
|
|
|
this.isloading = false
|
|
|
})
|
|
|
}else{
|
|
|
- this.$api.authority.addMenu(parames).then(res=>{
|
|
|
+ this.$api.user.addRole(parames).then(res=>{
|
|
|
_t.loadingFlag = false;
|
|
|
if(res.code==200){
|
|
|
console.log("创建成功")
|
|
|
- location.reload();
|
|
|
+ this.getList()
|
|
|
}else{
|
|
|
this.$message.error(res.message)
|
|
|
}
|
|
|
- this.menuDialogShow = false
|
|
|
+ this.roleDialogShow = false
|
|
|
this.isloading = false
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ },
|
|
|
+ //
|
|
|
+ authoritySubmitClick(data){
|
|
|
+ let _t = this
|
|
|
+ console.log("提交数据",data)
|
|
|
+ let parames = {
|
|
|
+ rule:data,
|
|
|
+ id: this.authorityDataForm.id,
|
|
|
+ role_name:this.authorityDataForm.role_name,
|
|
|
+ }
|
|
|
+ _t.isloading = true
|
|
|
+ //有id更新,没有新增
|
|
|
+ this.$api.user.updateRole(parames).then(res=>{
|
|
|
+ _t.loadingFlag = false;
|
|
|
+ if(res.code==200){
|
|
|
+ _t.tableData[_t.rowIndex] = parames
|
|
|
+ this.$message.success("分配成功")
|
|
|
+ _t.authorityDialogShow = false
|
|
|
+ this.getList()
|
|
|
+ }else{
|
|
|
+ this.$message.error("分配失败")
|
|
|
+ }
|
|
|
+ this.authorityDialogShow = false
|
|
|
+ this.isloading = false
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
//删除菜单
|
|
|
deleteAuthority(row, index) {
|
|
|
- this.MenuId = row.id
|
|
|
- this.MenuRowIndex = index
|
|
|
+ this.roleId = row.id
|
|
|
+ this.roleRowIndex = index
|
|
|
this.DialogShow = true
|
|
|
},
|
|
|
submitSureClickDel(row,index){
|
|
|
let parames = {
|
|
|
- 'id':this.MenuId
|
|
|
+ 'id':this.roleId
|
|
|
}
|
|
|
- this.$api.authority.delMenu(parames).then(res=>{
|
|
|
+ this.$api.user.delRole(parames).then(res=>{
|
|
|
if(res.code==200){
|
|
|
this.DialogShow = false
|
|
|
this.getList()
|
|
|
}else{
|
|
|
- this.$message.error("查询失败")
|
|
|
+ this.$message.error("删除失败")
|
|
|
}
|
|
|
})
|
|
|
+ },
|
|
|
+ searchFrom(){
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ assignPermissions(row,index){
|
|
|
+ console.log(row)
|
|
|
+ this.authorityDataForm = row
|
|
|
+ this.rowIndex = index
|
|
|
+ this.authorityDialogShow = true
|
|
|
}
|
|
|
|
|
|
},
|
|
@@ -251,5 +307,13 @@
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
+ <style >
|
|
|
+ .demo-form-inline{
|
|
|
+ display: flex;
|
|
|
+ }
|
|
|
+ .demo-form-inline .el-form-item{
|
|
|
+ margin: 0 20px;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
|
|
|
|