Commit b6265c9a authored by 杨硕's avatar 杨硕

优化中间页面权限问题

parent 76128e0e
import request from '@/utils/request'
import Qs from 'qs'
// 查询操作日志列表
// 查询登录日志列表
export function list(query) {
return request({
url: '/monitor/operLog/queryOperLogListByPagination',
url: '/monitor/loginInfo/querySysLoginListByPagination',
method: 'get',
params: query
})
}
// 删除操作日志
export function delOperLog(data) {
// 删除登录日志
export function delLogininfo(data) {
// data = Qs.stringify(data)
return request({
url: '/monitor/operLog/delete',
url: '/monitor/loginInfo/delete',
method: 'post',
data,
headers: {
......@@ -23,21 +23,22 @@ export function delOperLog(data) {
})
}
// 清空操作日志
export function cleanOperLog(query) {
// 清空登录日志
export function cleanLogininfo(query) {
return request({
url: '/monitor/operLog/clean',
url: '/monitor/loginInfo/clean',
method: 'delete',
params: query
params: query,
})
}
// 导出操作日志
export function exportOperLog(query) {
// 导出登录日志
export function exportLogininfo(query) {
return request({
url: '/monitor/operLog/export',
url: '/monitor/loginInfo/export',
method: 'get',
params: query,
responseType: 'blob'
})
}
......@@ -28,8 +28,6 @@ router.beforeEach((to, from, next) => {
if (store.getters.roles.length === 0) {
// 判断当前用户是否已拉取完user_info信息
store.dispatch('GetInfo').then(res => {
// TODO: clear this log
console.log(`res=wei`, res)
// 判断用户是否有权限 有角色
if (res.data.permissions && res.data.permissions.length > 0) {
// 拉取user_info
......@@ -42,7 +40,15 @@ router.beforeEach((to, from, next) => {
// store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => {
// 根据roles权限生成可访问的路由表
router.addRoutes(routers.accessedRoutes) // 动态添加可访问路由表
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
// TODO: clear this log
console.log(`routers.accessedRoutes`, routers.accessedRoutes)
// 如果是从中间页面跳转系统首页,默认打开第一个菜单
if (to.path === '/welcome') {
next({ path: routers.accessedRoutes[0].children[0].path, replace: true })
} else {
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
}
// next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
}
// else {
// alert('用户无权限')
......
......@@ -18,11 +18,7 @@ const permission = {
// 生成路由
GenerateRoutes({ commit }, menuName) {
return new Promise(resolve => {
// TODO: clear this log
console.log(`menuName`, menuName)
const menuList = menuName.menuName.split(',')
// TODO: clear this log
console.log(`menuList`, menuList)
// 向后端请求路由数据
getInfo().then(res => {
const newRoute = []
......@@ -42,8 +38,6 @@ const permission = {
commit('SET_ROUTES', accessedRoutes)
}
const routers = { accessedRoutes: accessedRoutes, getRouters: newRoute }
// TODO: clear this log
console.log(`routers`, routers)
resolve(routers)
})
})
......
......@@ -84,8 +84,6 @@ const user = {
GetInfoMessage({ commit, state }, menuName) {
return new Promise((resolve, reject) => {
// TODO: clear this log
console.log(`menuName-getInfo`, menuName)
commit('SET_MENUNAME', menuName) // 存入菜单名
const b = menuName.join(',')
Cookies.set('menuname', b)
......
......@@ -46,10 +46,16 @@ export default {
name: 'Home',
data() {
return {
// 系统管理分组
systemManage: ['系统管理'],
// 日志管理分组
logManage: ['日志管理'],
// 生产管理分组
productionManage: ['生产管理'],
equipmentManage: ['设备管理', '工序管理']
// 设备管理分组
equipmentManage: ['设备管理', '工序管理'],
// 路由跳转路径
routerPath: ''
}
},
created() {
......@@ -60,23 +66,30 @@ export default {
this.$store.dispatch('removeRole')
},
gotoIndex(menuName) {
// TODO: clear this log
console.log(`menuName`, menuName)
getInfo().then(res => {
if (res.data.permissions) {
// 判断用户是否有点击菜单的权限
var index = 0
const routerItem = []
res.data.menus.forEach(item => {
menuName.forEach(menuItem => {
if (item.meta.title === menuItem) {
index = index + 1
routerItem.push(item)
}
})
})
if (index > 0) {
this.routerPath = routerItem[0].children[0].path
// TODO: clear this log
console.log(`router`, this.routerPath)
// this.$message.success('用户有权限')
// 存入点击的菜单名,便于后边路由跳转
this.$store.dispatch('GetInfoMessage', menuName).then(() => {
// this.$nextTick(() => {
// this.$router.push(this.routerPath)
// }, 5000)
console.log('路由跳转')
this.$router.push('/welcome')
})
} else {
......
......@@ -324,7 +324,16 @@ export default {
// 类型数据字典
typeOptions: [],
// 类型数据字典
statusOptions: [],
statusOptions: [
{
dictLabel: '启用',
dictValue: '1'
},
{
dictLabel: '停用',
dictValue: '0'
}
],
// 日期范围
dateRange: '',
// 表单参数
......@@ -359,9 +368,9 @@ export default {
}
// this.queryParams.operTime = this.$parseDate(new Date(), 'YYYY-MM')
this.getList()
this.getDicts('sys_oper_type'.toUpperCase()).then(response => {
this.typeOptions = response.data
})
// this.getDicts('sys_oper_type'.toUpperCase()).then(response => {
// this.typeOptions = response.data
// })
// this.getDicts('sys_common_status'.toUpperCase()).then(response => {
// this.statusOptions = response.data
// })
......@@ -452,10 +461,10 @@ export default {
}
})
},
// 操作日志状态字典翻译
statusFormat(row, column) {
return this.selectDictLabel(this.statusOptions, row.status)
},
// // 操作日志状态字典翻译
// statusFormat(row, column) {
// return this.selectDictLabel(this.statusOptions, row.status)
// },
// 操作日志类型字典翻译
typeFormat(row, column) {
return this.selectDictLabel(this.typeOptions, row.businessType)
......
......@@ -270,7 +270,16 @@ export default {
// 表格数据
list: [],
// 状态数据字典
statusOptions: [],
statusOptions: [
{
dictLabel: '启用',
dictValue: '1'
},
{
dictLabel: '停用',
dictValue: '0'
}
],
// 日期范围
dateRange: [],
// 查询参数
......@@ -302,9 +311,9 @@ export default {
}
// this.queryParams.loginTime = this.$parseDate(new Date(), 'YYYY-MM-DD HH:mm:ss')
this.getList()
this.getDicts(dictCons['COMMON_STATUS']).then(response => {
this.statusOptions = response.data
})
// this.getDicts(dictCons['COMMON_STATUS']).then(response => {
// this.statusOptions = response.data
// })
},
methods: {
// 清空和导出弹出框的日期选择器禁用当前月份之后的月份
......@@ -336,9 +345,9 @@ export default {
},
// 登录状态字典翻译
statusFormat(row, column) {
return this.selectDictLabel(this.statusOptions, row.status)
},
// statusFormat(row, column) {
// return this.selectDictLabel(this.statusOptions, row.status)
// },
/** 查询按钮操作 */
handleQuery() {
this.queryParams.page = 1
......
......@@ -323,7 +323,16 @@ export default {
// 类型数据字典
typeOptions: [],
// 类型数据字典
statusOptions: [],
statusOptions: [
{
dictLabel: '启用',
dictValue: '1'
},
{
dictLabel: '停用',
dictValue: '0'
}
],
// 日期范围
dateRange: '',
// 表单参数
......@@ -359,9 +368,9 @@ export default {
}
// this.queryParams.operTime = this.$parseDate(new Date(), 'YYYY-MM')
this.getList()
this.getDicts('sys_oper_type'.toUpperCase()).then(response => {
this.typeOptions = response.data
})
// this.getDicts('sys_oper_type'.toUpperCase()).then(response => {
// this.typeOptions = response.data
// })
// this.getDicts('sys_common_status'.toUpperCase()).then(response => {
// this.statusOptions = response.data
// })
......@@ -452,9 +461,9 @@ export default {
})
},
// 操作日志状态字典翻译
statusFormat(row, column) {
return this.selectDictLabel(this.statusOptions, row.status)
},
// statusFormat(row, column) {
// return this.selectDictLabel(this.statusOptions, row.status)
// },
// 操作日志类型字典翻译
typeFormat(row, column) {
return this.selectDictLabel(this.typeOptions, row.businessType)
......
<template>
<div>
生产数据
</div>
</template>
<script>
export default {
name: 'Index'
}
</script>
<style scoped>
</style>
......@@ -284,7 +284,16 @@ export default {
// 是否显示弹出层
open: false,
// 状态数据字典
statusOptions: [],
statusOptions: [
{
dictLabel: '启用',
dictValue: '1'
},
{
dictLabel: '停用',
dictValue: '0'
}
],
// 类型数据字典
typeOptions: [],
// 查询参数
......
......@@ -127,7 +127,7 @@
<div v-else>-</div>
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="flag" :formatter="statusFormat">
<el-table-column label="状态" align="center" prop="flag">
<template slot-scope="scope">
<el-switch
v-model="scope.row.flag"
......@@ -350,7 +350,16 @@ export default {
// 是否显示弹出层
open: false,
// 状态数据字典
statusOptions: [],
statusOptions: [
{
dictLabel: '启用',
dictValue: '1'
},
{
dictLabel: '停用',
dictValue: '0'
}
],
// 日期范围
dateRange: [],
// 查询参数
......@@ -400,9 +409,9 @@ export default {
this.queryParams = { ...param }
}
this.getList()
this.getDicts(dictCons['NORMAL_DISABLE']).then(response => {
this.statusOptions = response.data
})
// this.getDicts(dictCons['NORMAL_DISABLE']).then(response => {
// this.statusOptions = response.data
// })
// optionselect().then(response => {
// this.options = response.data
// })
......@@ -455,9 +464,9 @@ export default {
})
},
// 字典状态字典翻译
statusFormat(row, column) {
return this.selectDictLabel(this.statusOptions, row.flag)
},
// statusFormat(row, column) {
// return this.selectDictLabel(this.statusOptions, row.flag)
// },
// 取消按钮
cancel() {
this.open = false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment