数据来源及角色接口更换

ui1
yujialong 3 years ago
parent d77081cf16
commit 4ab8483486
  1. 15
      src/api/index.js
  2. 4
      src/layouts/navbar/index.vue
  3. 6
      src/libs/auth/generateBtnPermission.js
  4. 2
      src/libs/route/addRoutes.js
  5. 189
      src/pages/data/list/index.vue
  6. 39
      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`,
// 角色管理
batchRemove:`/data/data/role/batchRemove`,
getRole:`/data/data/role/get`,
batchRemove:`/users/role/batchRemove`,
getRole:`/users/role/obtainDetails`,
getName:`/data/data/role/getName`,
listRole:`/data/data/role/list`,
listRole:`/users/role/list`,
removeRole:`/data/data/role/remove`,
saveOrUpdate:`/data/data/role/saveOrUpdate`,
getRoles:`/data/data/role/getRole`,
getPermissions:`/data/data/permission/getPermissions`,
saveOrUpdate:`/users/role/saveOrUpdate`,
getPermissions:`/users/user-role/getUserRolesPermissionMenu`,
// 权限菜单管理
doAssign:`/data/data/permission/doAssign`,
queryPermissionMenu:`/data/data/permission/queryPermissionMenu`,
savePer:`/data/data/permission/save`,
queryPermissionMenu:`/users/user-role/grantAllPermissions`,
savePer:`/users/user-role/rolePermissionService`,
toAssign:`/data/data/permission/toAssign`,
// 表展示

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

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

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

@ -1,7 +1,7 @@
<template>
<div class="wrap">
<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-if="item.children.length">
@ -43,11 +43,21 @@
<template v-if="subItem4.children">
<el-submenu :index="subItem4.id" :key="subItem4.id">
<template slot="title">
<!-- <i :class="item.icon"></i> -->
<!-- <span slot="title">{{ subItem2.title }}</span> -->
{{ subItem4.categoryName }}
</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>
</template>
<!-- 如果第五层没有子菜单 -->
@ -92,7 +102,7 @@
</div>
<div class="page-content">
<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-column type="index" width="100" 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 util from '@/libs/util'
import Setting from '@/setting'
import bus from '@/libs/bus'
let startTimeLimit = ''
let endTimeLimit = ''
export default {
@ -177,11 +185,12 @@ export default {
return {
that: this,
token: util.local.get(Setting.tokenKey),
typeId: this.$route.query.typeId,
typeId: this.$route.query.typeId, // id
typeList: [],
defaultType: '',
defaultOpenType: [],
introduce: '',
dataSource: '',
keyword: '',
search:'',
listData: [],
@ -249,11 +258,6 @@ export default {
},
},
mounted() {
// bus.$on('initData',keyword => {
// this.keyword = keyword
// this.initData()
// })
this.getType()
// ,
if(this.$route.query.download){
@ -266,78 +270,41 @@ export default {
},
methods: {
getType(){
//
this.$post(this.api.getTableByClassification).then(res => {//
//
this.$post(this.api.getTableByClassification).then(res => {
let typeId = this.typeId // id
let introduce = ''// children
res.map(n => {//
n.id = String(n.id)
if(typeId && n.id == typeId) introduce = n.introduce
n.children.map(e => { //
e.id = String(e.id)
if(typeId && e.id == typeId){
if(e.introduce){
introduce = e.introduce
}else{
introduce = n.introduce
}
}
if(e.children.length && typeId == e.id){
this.defaultOpenType = [n.id,e.id]
}
e.children.map(j => {//
if(typeId && j.id == typeId && j.introduce){
if(j.introduce){
introduce = j.introduce
}else if(e.introduce){
introduce = e.introduce
}else{
introduce = n.introduce
}
}
j.id = String(j.id)
})
})
})
let dataSource = '' //
let action
//
function actionId(arr){//res
if(arr&&arr.length>0){
arr.map(e=>{
arr && arr.map((e, i) => {
e.id = String(e.id)
if (!i) {
//
if (e.introduce) introduce = e.introduce
if (e.dataSource) dataSource = e.dataSource
if (!action) action = e.children[0].children.length ? String(e.children[0].children[0].id) : String(e.children[0].id)
}
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
action = String(e.id)
if(e.children.length){//
if(!e.children[0].children.length){//
action = String(e.children[0].id)
}else{//
action = e.children[0].children[0].id
action = String(e.children[0].children[0].id)
}
}
}else if(e.children.length>0){// id
}else if(e.children.length){// id
actionId(e.children)
}
})
}
}
this.typeList = res
if(this.typeId){
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.dataSource = dataSource
this.getData()
}).catch(res => {})
},
@ -358,82 +325,35 @@ export default {
this.$refs.table.clearSelection()
this.getData()
},
selectType(index,indexPath){//
//
selectType(index,indexPath){
let introduce = ''
let dataSource = ''
this.keyword = ''
let list = this.typeList
list.map(n => {
let select = ''
function handleData(data) {
data.map((n, i) => {
//
if(n.id == index){
introduce = n.introduce
if (n.introduce) introduce = n.introduce
if (n.dataSource) dataSource = n.dataSource
if (!select) select = n.children.length ? (n.children[0].children.length ? n.children[0].children[0].id : n.children[0].id) : n.id
}else{
n.children.map(n => {
if(n.id == index){
introduce = n.introduce
}else{
n.children.map(n => {
if(n.id == index) introduce = n.introduce
})
handleData(n.children)
}
})
}
})
handleData(list)
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{
return
}
}
getSelect(this.typeList)
console.log(select,'dig');
if(!dataSource) dataSource = list.find(n => n.id == indexPath[0]).dataSource
this.defaultType = select
}else{
this.defaultType = index
}
this.introduce = introduce
this.dataSource = dataSource
this.previewHead = []
this.previewData = []
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){
this.currentRow = val
},
@ -629,6 +549,12 @@ export default {
.el-menu-item.is-active{
color: $main-color;
}
.level-6 {
padding-right: 0;
.el-submenu__title {
padding-left: 10px !important;
}
}
}
}
.right{
@ -637,9 +563,12 @@ export default {
.page{
margin-bottom: 20px;
.desc{
margin-bottom: 30px;
margin-bottom: 20px;
color: #333;
}
.source {
color: #568DF2;
}
}
}
}

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

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

Loading…
Cancel
Save