数据来源及角色接口更换

ui1
yujialong 3 years ago
parent d77081cf16
commit 4ab8483486
  1. 15
      src/api/index.js
  2. 4
      src/layouts/navbar/index.vue
  3. 24
      src/libs/auth/generateBtnPermission.js
  4. 2
      src/libs/route/addRoutes.js
  5. 213
      src/pages/data/list/index.vue
  6. 47
      src/pages/role/list/index.vue
  7. 4
      src/pages/user/list/index.vue

@ -40,19 +40,18 @@ export default {
userTemplate: `http://39.108.250.202/template/%E6%95%B0%E6%8D%AE%E5%B9%B3%E5%8F%B0%E7%94%A8%E6%88%B7%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx`, userTemplate: `http://39.108.250.202/template/%E6%95%B0%E6%8D%AE%E5%B9%B3%E5%8F%B0%E7%94%A8%E6%88%B7%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx`,
// 角色管理 // 角色管理
batchRemove:`/data/data/role/batchRemove`, batchRemove:`/users/role/batchRemove`,
getRole:`/data/data/role/get`, getRole:`/users/role/obtainDetails`,
getName:`/data/data/role/getName`, getName:`/data/data/role/getName`,
listRole:`/data/data/role/list`, listRole:`/users/role/list`,
removeRole:`/data/data/role/remove`, removeRole:`/data/data/role/remove`,
saveOrUpdate:`/data/data/role/saveOrUpdate`, saveOrUpdate:`/users/role/saveOrUpdate`,
getRoles:`/data/data/role/getRole`, getPermissions:`/users/user-role/getUserRolesPermissionMenu`,
getPermissions:`/data/data/permission/getPermissions`,
// 权限菜单管理 // 权限菜单管理
doAssign:`/data/data/permission/doAssign`, doAssign:`/data/data/permission/doAssign`,
queryPermissionMenu:`/data/data/permission/queryPermissionMenu`, queryPermissionMenu:`/users/user-role/grantAllPermissions`,
savePer:`/data/data/permission/save`, savePer:`/users/user-role/rolePermissionService`,
toAssign:`/data/data/permission/toAssign`, toAssign:`/data/data/permission/toAssign`,
// 表展示 // 表展示

@ -96,8 +96,8 @@ export default {
}, },
// //
getPer(){ getPer(){
this.$post(this.api.getPermissions).then(res => { this.$get(`${this.api.getPermissions}?platformId=${Setting.platformId}`).then(res => {
let routes = res.permissions[0].children let routes = res.permissionMenu[0].children
Setting.dynamicRoute && addRoutes(routes) Setting.dynamicRoute && addRoutes(routes)
this.initMenu() this.initMenu()
}).catch(err => { }).catch(err => {

@ -6,20 +6,16 @@ import store from '@/store';
export default function(data){ export default function(data){
let result = [] let result = []
data.map(e => { data.map(e => {
if(e.select){ e.children.map(n => {
e.children.map(n => { if(n.children.length){
if(n.select){ // select为true,则表示拥有该权限 result.push(`${e.name}:${n.name}`)
if(n.children.length){ n.children.map(j => {
result.push(`${e.name}:${n.name}`) e.path ? result.push(`${e.path}:${n.name}:${j.name}`) : result.push(`${n.path}:${j.name}`)
n.children.map(j => { })
j.select && (e.path ? result.push(`${e.path}:${n.name}:${j.name}`) : result.push(`${n.path}:${j.name}`)) }else{
}) result.push(`${e.path}:${n.name}`)
}else{ }
result.push(`${e.path}:${n.name}`) })
}
}
})
}
}) })
store.dispatch('auth/addBtnAuth',result) store.dispatch('auth/addBtnAuth',result)
} }

@ -11,7 +11,7 @@ function createMeta(item){
function createRoute(data){ function createRoute(data){
data.map(e => { data.map(e => {
if(e.select && e.path){ // select为true,则表示拥有该权限,同时path不为空,才生成路由集合 if(e.path){ // select为true,则表示拥有该权限,同时path不为空,才生成路由集合
let meta = createMeta(e) let meta = createMeta(e)
newRoutes.push({ newRoutes.push({
name: e.path, name: e.path,

@ -1,7 +1,7 @@
<template> <template>
<div class="wrap"> <div class="wrap">
<div class="left"> <div class="left">
<el-menu class="menu" ref="type" @open="openType" @select="selectType" unique-opened :default-active="defaultType" :default-openeds="defaultOpenType"> <el-menu class="menu" ref="type" @open="selectType" @select="selectType" unique-opened :default-active="defaultType" :default-openeds="defaultOpenType">
<template v-for="item in typeList"> <template v-for="item in typeList">
<!-- 如果第一层有子菜单则继续循环 --> <!-- 如果第一层有子菜单则继续循环 -->
<template v-if="item.children.length"> <template v-if="item.children.length">
@ -43,11 +43,21 @@
<template v-if="subItem4.children"> <template v-if="subItem4.children">
<el-submenu :index="subItem4.id" :key="subItem4.id"> <el-submenu :index="subItem4.id" :key="subItem4.id">
<template slot="title"> <template slot="title">
<!-- <i :class="item.icon"></i> -->
<!-- <span slot="title">{{ subItem2.title }}</span> -->
{{ subItem4.categoryName }} {{ subItem4.categoryName }}
</template> </template>
<el-menu-item v-for="(fiveItem,i) in subItem4.children" :key="i" :index="fiveItem.id">{{ fiveItem.categoryName }}</el-menu-item> <el-menu-item class="level-6" v-for="(subItem5,i) in subItem4.children" :key="i" :index="subItem5.id">
<!-- 如果第六层有子菜单则继续循环 -->
<template v-if="subItem5.children">
<el-submenu :index="subItem5.id" :key="subItem5.id">
<template slot="title">
{{ subItem5.categoryName }}
</template>
<el-menu-item v-for="(fiveItem,i) in subItem5.children" :key="i" :index="fiveItem.id">{{ fiveItem.categoryName }}</el-menu-item>
</el-submenu>
</template>
<!-- 如果第五层没有子菜单 -->
<el-menu-item v-else :index="subItem5.id" :key="subItem5.id">{{ subItem5.categoryName }}</el-menu-item>
</el-menu-item>
</el-submenu> </el-submenu>
</template> </template>
<!-- 如果第五层没有子菜单 --> <!-- 如果第五层没有子菜单 -->
@ -92,7 +102,7 @@
</div> </div>
<div class="page-content"> <div class="page-content">
<div class="desc">{{introduce}}</div> <div class="desc">{{introduce}}</div>
<div style="margin-bottom: 30px"><span class="source">数据来源</span>{{dataSource}}</div>
<el-table :data="listData" class="table" ref="table" stripe header-align="center" row-key="id" highlight-current-row @current-change="previewCurrentChange"> <el-table :data="listData" class="table" ref="table" stripe header-align="center" row-key="id" highlight-current-row @current-change="previewCurrentChange">
<el-table-column type="index" width="100" label="序号" align="center"></el-table-column> <el-table-column type="index" width="100" label="序号" align="center"></el-table-column>
<el-table-column prop="showName" label="数据表名称" align="center"></el-table-column> <el-table-column prop="showName" label="数据表名称" align="center"></el-table-column>
@ -168,8 +178,6 @@ import { mapState } from 'vuex'
import axios from 'axios' import axios from 'axios'
import util from '@/libs/util' import util from '@/libs/util'
import Setting from '@/setting' import Setting from '@/setting'
import bus from '@/libs/bus'
let startTimeLimit = '' let startTimeLimit = ''
let endTimeLimit = '' let endTimeLimit = ''
export default { export default {
@ -177,11 +185,12 @@ export default {
return { return {
that: this, that: this,
token: util.local.get(Setting.tokenKey), token: util.local.get(Setting.tokenKey),
typeId: this.$route.query.typeId, typeId: this.$route.query.typeId, // id
typeList: [], typeList: [],
defaultType: '', defaultType: '',
defaultOpenType: [], defaultOpenType: [],
introduce: '', introduce: '',
dataSource: '',
keyword: '', keyword: '',
search:'', search:'',
listData: [], listData: [],
@ -249,11 +258,6 @@ export default {
}, },
}, },
mounted() { mounted() {
// bus.$on('initData',keyword => {
// this.keyword = keyword
// this.initData()
// })
this.getType() this.getType()
// , // ,
if(this.$route.query.download){ if(this.$route.query.download){
@ -266,78 +270,41 @@ export default {
}, },
methods: { methods: {
getType(){ getType(){
// //
this.$post(this.api.getTableByClassification).then(res => {// this.$post(this.api.getTableByClassification).then(res => {
let typeId = this.typeId // id let typeId = this.typeId // id
let introduce = ''// children let introduce = ''// children
res.map(n => {// let dataSource = '' //
n.id = String(n.id) let action
if(typeId && n.id == typeId) introduce = n.introduce //
n.children.map(e => { // function actionId(arr){//res
arr && arr.map((e, i) => {
e.id = String(e.id) e.id = String(e.id)
if(typeId && e.id == typeId){ if (!i) {
if(e.introduce){ //
introduce = e.introduce if (e.introduce) introduce = e.introduce
}else{ if (e.dataSource) dataSource = e.dataSource
introduce = n.introduce if (!action) action = e.children[0].children.length ? String(e.children[0].children[0].id) : String(e.children[0].id)
}
}
if(e.children.length && typeId == e.id){
this.defaultOpenType = [n.id,e.id]
} }
e.children.map(j => {// if(typeId && e.id == typeId) {// id
if(typeId && j.id == typeId && j.introduce){ action = String(e.id)
if(j.introduce){ if(e.children.length){//
introduce = j.introduce if(!e.children[0].children.length){//
}else if(e.introduce){ action = String(e.children[0].id)
introduce = e.introduce }else{//
}else{ action = String(e.children[0].children[0].id)
introduce = n.introduce
} }
} }
j.id = String(j.id) }else if(e.children.length){// id
}) actionId(e.children)
}
}) })
})
let action
//
function actionId(arr){//res
if(arr&&arr.length>0){
arr.map(e=>{
if(typeId && e.id == typeId) {// id
action = e.id
if(e.children.length>0){//
if(e.children[0].children.length===0){//
action = e.children[0].id
}else{//
action = e.children[0].children[0].id
}
}
}else if(e.children.length>0){// id
actionId(e.children)
}
})
}
} }
this.typeList = res this.typeList = res
actionId(res)
if(this.typeId){ this.defaultType = action
actionId(res)
this.defaultType = action
// this.defaultType = this.typeId
}else{
if(res[0].children.length && res[0].children[0].children.length){
this.defaultType = res[0].children[0].children[0].id
introduce = res[0].children[0].children[0].introduce
}else if(res[0].children.length){
this.defaultType = res[0].children[0].id
if(!introduce) introduce = res[0].children[0].introduce
}else{
this.defaultType = res[0].id
if(!introduce) introduce = res[0].introduce
}
}
this.introduce = introduce this.introduce = introduce
this.dataSource = dataSource
this.getData() this.getData()
}).catch(res => {}) }).catch(res => {})
}, },
@ -358,82 +325,35 @@ export default {
this.$refs.table.clearSelection() this.$refs.table.clearSelection()
this.getData() this.getData()
}, },
selectType(index,indexPath){// //
selectType(index,indexPath){
let introduce = '' let introduce = ''
let dataSource = ''
this.keyword = '' this.keyword = ''
let list = this.typeList let list = this.typeList
list.map(n => { let select = ''
if(n.id == index){ function handleData(data) {
introduce = n.introduce data.map((n, i) => {
}else{ //
n.children.map(n => { if(n.id == index){
if(n.id == index){ if (n.introduce) introduce = n.introduce
introduce = n.introduce if (n.dataSource) dataSource = n.dataSource
}else{ if (!select) select = n.children.length ? (n.children[0].children.length ? n.children[0].children[0].id : n.children[0].id) : n.id
n.children.map(n => {
if(n.id == index) introduce = n.introduce
})
}
})
}
})
if(!introduce) introduce = list.find(n => n.id == indexPath[0]).introduce
if(indexPath.length>=2){
let clikckId = indexPath[indexPath.length-1]
let select
function getSelect(arr){
if(arr.length>0){
arr.map(e=>{
if(e.id==clikckId){
if(e.children.length===0){
select = e.id
}else{
if(e.children[0].children.length>0){
select = e.children[0].children[0].id
}else{
select = e.children[0].id
}
}
}else{
getSelect(e.children)
}
})
}else{ }else{
return handleData(n.children)
} }
} })
getSelect(this.typeList)
console.log(select,'dig');
this.defaultType = select
}else{
this.defaultType = index
} }
handleData(list)
if(!introduce) introduce = list.find(n => n.id == indexPath[0]).introduce
if(!dataSource) dataSource = list.find(n => n.id == indexPath[0]).dataSource
this.defaultType = select
this.introduce = introduce this.introduce = introduce
this.dataSource = dataSource
this.previewHead = [] this.previewHead = []
this.previewData = [] this.previewData = []
this.initData() this.initData()
}, },
findId(data,id){
let result = ''
data.forEach(n => {
if(n.id == id){
if(n.children[0].children.length){
return result = n.children[0].children[0].id
}else{
return result = n.children[0].id
}
}else{
this.findId(n.children,id)
}
})
return result
},
openType(index,indexPath){
console.log(11,this.typeList)
let id = this.findId(this.typeList,index)
this.selectType(id,indexPath)
},
previewCurrentChange(val){ previewCurrentChange(val){
this.currentRow = val this.currentRow = val
}, },
@ -629,6 +549,12 @@ export default {
.el-menu-item.is-active{ .el-menu-item.is-active{
color: $main-color; color: $main-color;
} }
.level-6 {
padding-right: 0;
.el-submenu__title {
padding-left: 10px !important;
}
}
} }
} }
.right{ .right{
@ -637,9 +563,12 @@ export default {
.page{ .page{
margin-bottom: 20px; margin-bottom: 20px;
.desc{ .desc{
margin-bottom: 30px; margin-bottom: 20px;
color: #333; color: #333;
} }
.source {
color: #568DF2;
}
} }
} }
} }

@ -116,9 +116,9 @@ export default {
}, },
methods: { methods: {
getData() { getData() {
this.$get(`${this.api.listRole}/${this.page}/${this.pageSize}?name=${this.keyword}&clientId=`).then(res => { this.$get(`${this.api.listRole}?page=${this.page}&size=${this.pageSize}&name=${this.keyword}`).then(res => {
this.listData = res.items this.listData = res.rolePage.records
this.total = res.total this.total = res.rolePage.total
if(!this.listData.length && this.total){ if(!this.listData.length && this.total){
this.page-- this.page--
this.getData() this.getData()
@ -147,8 +147,8 @@ export default {
// //
getPer(){ getPer(){
if(!this.permissions.length){ if(!this.permissions.length){
this.$get(this.api.queryPermissionMenu).then(res => { this.$get(`${this.api.getPermissions}?platformId=${Setting.platformId}`).then(res => {
this.permissions = res[0].children this.permissions = res.permissionMenu[0].children
}).catch(res => {}) }).catch(res => {})
} }
}, },
@ -175,14 +175,10 @@ export default {
}, },
async getDetail(row){ async getDetail(row){
this.getPer() this.getPer()
this.$get(`${this.api.getRole}/${row.id}`).then(res => { this.$get(`${this.api.getRole}?id=${row.id}`).then(res => {
this.form = res this.form = res.role
this.$get(this.api.toAssign,{ this.checkedIds = this.handleRolePer(res.permissionList,this.permissions)
roleId: row.id this.$refs.per.setCheckedNodes(this.checkedIds)
}).then(res => {
this.checkedIds = this.handleRolePer(res,this.permissions)
this.$refs.per.setCheckedNodes(this.checkedIds)
}).catch(res => {})
}).catch(res => {}) }).catch(res => {})
}, },
showRole(row){ showRole(row){
@ -202,25 +198,16 @@ export default {
// if(!this.$refs.per.getCheckedKeys().length) return util.warningMsg('') // if(!this.$refs.per.getCheckedKeys().length) return util.warningMsg('')
let data = { let data = {
clientId: this.clientId,
id: this.form.id, id: this.form.id,
roleName: this.form.roleName, roleName: this.form.roleName,
remark: this.form.remark, remark: this.form.remark,
isPort: 2 platformId: Setting.platformId,
permissionId: [...this.$refs.per.getHalfCheckedKeys(),...this.$refs.per.getCheckedKeys()] // ,(),
} }
this.$post(this.api.saveOrUpdate,data).then(res => { this.$post(this.api.saveOrUpdate,data).then(res => {
// ,(), util.successMsg(this.form.id ? '修改成功' : '新增成功')
let permissionId = [...this.$refs.per.getHalfCheckedKeys(),...this.$refs.per.getCheckedKeys()] this.getData()
let perData = { this.roleVisible = false
roleId: res.roleId,
permissionId,
isPort: 2
}
this.$post(this.api.doAssign,perData).then(res => {
util.successMsg(this.form.id ? '修改成功' : '新增成功')
this.getData()
this.roleVisible = false
}).catch(res => {})
}).catch(res => {}) }).catch(res => {})
}, },
handleDelete(row) { handleDelete(row) {
@ -246,7 +233,7 @@ export default {
this.$confirm(msg, '提示', { this.$confirm(msg, '提示', {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$post(`${this.api.removeRole}/${row.id}`).then(res => { this.$post(`${this.api.batchRemove}?roleIds=${row.id}`).then(res => {
util.successMsg('删除成功') util.successMsg('删除成功')
this.getData() this.getData()
}).catch(res => {}) }).catch(res => {})
@ -260,12 +247,12 @@ export default {
if(this.multipleSelection.length != ''){ if(this.multipleSelection.length != ''){
let newArr = this.multipleSelection let newArr = this.multipleSelection
let delList = newArr.map(item => { let delList = newArr.map(item => {
return item.id return `roleIds=${item.id}`
}) })
this.$confirm(`此批量删除操作不可逆,是否确认删除?`, '提示', { this.$confirm(`此批量删除操作不可逆,是否确认删除?`, '提示', {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$post(`${this.api.batchRemove}?roleIds=${delList.join()}`).then(res => { this.$post(`${this.api.batchRemove}?${delList.join('&')}`).then(res => {
this.$refs.table.clearSelection() this.$refs.table.clearSelection()
util.successMsg('删除成功') util.successMsg('删除成功')
this.getData() this.getData()

@ -306,8 +306,8 @@ export default {
this.getData() this.getData()
}, },
getRole(){ getRole(){
this.$get(this.api.getRoles).then(res => { this.$get(`${this.api.listRole}?page=1&size=1000&name=`).then(res => {
this.roleList = res.list this.roleList = res.rolePage.records
}).catch(res => {}) }).catch(res => {})
}, },
resetPassword(row){ resetPassword(row){

Loading…
Cancel
Save