Commit b6265c9a authored by 杨硕's avatar 杨硕

优化中间页面权限问题

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