提交 6ea9bc06 authored 作者: pengxiaohui's avatar pengxiaohui

修复bug

上级 3049d783
......@@ -13,7 +13,7 @@
id="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, shrink-to-fit=no, viewport-fit=cover"
/>
<script src="/static/tinymce/tinymce.min.js"></script>
<script src="../static/tinymce/tinymce.min.js"></script>
</head>
<body>
<div id="app"></div>
......
......@@ -35,7 +35,7 @@
<template v-slot:top-status="{ row }">
<div class="table-col-top">
<el-switch :active-value="1" :inactive-value="0" v-model="row.is_top" @change="handleTop(row)" :disabled="!hasCreate"></el-switch>
<el-select v-model="row.weight" placeholder="权重" size="mini" clearable :disabled="!hasCreate" @change="handleWeight(row)">
<el-select v-model="row.weight" placeholder="权重" size="mini" :disabled="!hasCreate" @change="handleWeight(row)">
<el-option v-for="item in 10" :label="item" :value="item" :key="item"></el-option>
</el-select>
</div>
......@@ -148,7 +148,7 @@ export default {
labelKey: 'name',
valueKey: 'id'
},
{ type: 'input', placeholder: 'ID', prop: 'id_title' },
{ type: 'input', placeholder: '标题/ID', prop: 'id_title' },
{
type: 'select',
placeholder: '类型',
......@@ -161,7 +161,7 @@ export default {
columns: [
{ type: 'selection', visible: this.hasDelete, fixed: 'left' },
{ prop: 'image_url', label: '图片', slots: 'image', minWidth: '80px', fixed: 'left' },
{ prop: 'id', label: '广告ID', slots: 'table-id', minWidth: '90px', fixed: 'left' },
{ prop: 'id', label: '广告ID', slots: 'table-id', minWidth: '95px', fixed: 'left' },
{ prop: 'title', label: '标题', minWidth: '100px' },
{
prop: 'start_time',
......@@ -198,7 +198,7 @@ export default {
return dateFormat(row.created_at) || '-'
}
},
{ prop: 'audit_status', label: '审核状态', slots: 'review-status', fixed: 'right' },
{ prop: 'audit_status', label: '审核状态', slots: 'review-status' },
{ prop: 'is_publish', label: '发布状态', slots: 'publish-status', fixed: 'right' },
{ prop: 'is_top', label: '置顶状态/权重', slots: 'top-status', minWidth: '140px', fixed: 'right' }
]
......
......@@ -35,7 +35,7 @@
<template v-slot:top-status="{ row }">
<div class="table-col-top">
<el-switch :active-value="1" :inactive-value="0" v-model="row.is_top" @change="handleTop(row)" :disabled="!hasCreate">></el-switch>
<el-select v-model="row.weight" placeholder="权重" size="mini" clearable :disabled="!hasCreate" @change="handleWeight(row)">
<el-select v-model="row.weight" placeholder="权重" size="mini" :disabled="!hasCreate" @change="handleWeight(row)">
<el-option v-for="item in 10" :label="item" :value="item" :key="item"></el-option>
</el-select>
</div>
......@@ -147,7 +147,7 @@ export default {
labelKey: 'name',
valueKey: 'id'
},
{ type: 'input', placeholder: 'ID', prop: 'id_title' },
{ type: 'input', placeholder: '标题/ID', prop: 'id_title' },
{
type: 'select',
placeholder: '类型',
......@@ -160,7 +160,7 @@ export default {
columns: [
{ type: 'selection', visible: this.hasDelete, fixed: 'left' },
{ prop: 'image_url', label: '图片', slots: 'image', minWidth: '80px', fixed: 'left' },
{ prop: 'id', label: '文章ID', slots: 'table-id', minWidth: '90px', fixed: 'left' },
{ prop: 'id', label: '文章ID', slots: 'table-id', minWidth: '95px', fixed: 'left' },
{ prop: 'title', label: '标题', minWidth: '100px' },
{
prop: 'start_time',
......
......@@ -16,7 +16,7 @@
</el-col>
</el-form-item>
<el-form-item label="标题:" prop="title" style="margin-right:15px;">
<el-input v-model="form.title" placeholder="请输入题" size="small" :disabled="isDetails"/>
<el-input v-model="form.title" placeholder="请输入题" size="small" :disabled="isDetails"/>
</el-form-item>
<el-form-item label="跳转链接:" style="margin-right:15px;">
<el-input v-model="form.uri" placeholder="请输入跳转链接" size="small" :disabled="isDetails"/>
......
......@@ -129,7 +129,7 @@ export default {
labelKey: 'name',
valueKey: 'id'
},
{ type: 'input', placeholder: 'ID', prop: 'id_title' },
{ type: 'input', placeholder: '标题/ID', prop: 'id_title' },
{
type: 'select',
placeholder: '类型',
......@@ -142,7 +142,7 @@ export default {
columns: [
{ type: 'selection', visible: this.hasDelete, fixed: 'left' },
{ prop: 'image_url', label: '图片', slots: 'image', minWidth: '80px', fixed: 'left' },
{ prop: 'id', label: '图文ID', slots: 'table-id', minWidth: '90px', fixed: 'left' },
{ prop: 'id', label: '图文ID', slots: 'table-id', minWidth: '95px', fixed: 'left' },
{ prop: 'title', label: '标题', minWidth: '100px' },
{
prop: 'start_time',
......
......@@ -199,11 +199,11 @@ export default {
filters: [
{
type: 'select',
placeholder: '项目',
placeholder: '项目类型',
prop: 'type_id',
options: this.projectList,
labelKey: 'project_name',
valueKey: 'project_id'
options: this.projectTypeList,
labelKey: 'name',
valueKey: 'id'
},
{ type: 'input', placeholder: '项目ID/项目名称', prop: 'name' },
{
......
......@@ -218,8 +218,8 @@ export default {
placeholder: '项目',
prop: 'project_id',
options: this.projectList,
labelKey: 'project_name',
valueKey: 'project_id'
labelKey: 'name',
valueKey: 'id'
},
{ type: 'input', placeholder: '手机号/邮箱', prop: 'id' },
{
......
......@@ -3,6 +3,11 @@ import Router from 'vue-router'
import routes from './routes'
Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
export const asyncRoutes = [...routes]
const createRouter = () => new Router({
mode: 'history', // require service support
......
......@@ -23,9 +23,6 @@ const user = {
setPermissions(state, permissions) {
state.permissions = permissions
},
setHasRolesPermissions(state, hasRolesPermissions) {
state.hasRolesPermissions = hasRolesPermissions
},
setProjects(state, projects) {
state.projects = projects
}
......@@ -37,6 +34,9 @@ const user = {
return logout().then(response => {
commit('setUser', {})
commit('setIsLogin', false)
commit('setRoles', null)
commit('setPermissions', null)
commit('projects', [])
resetRouter()
return response
})
......@@ -63,13 +63,14 @@ const user = {
},
// 检测角色权限
async checkRolesPermissions({ commit }) {
await getUserRolesPermissions().then(res => {
const obj = await getUserRolesPermissions().then(res => {
if (res.code === 0) {
const data = res.data
let roles = []
let permissions = []
let projects = []
if (data.roles && Array.isArray(data.roles)) {
roles = data.roles.forEach(it => it.name)
roles = data.roles.map(it => it.name)
}
commit('setRoles', roles)
if (data.permissions && Array.isArray(data.permissions)) {
......@@ -77,18 +78,26 @@ const user = {
}
commit('setPermissions', permissions)
if (data.projects && Array.isArray(data.projects)) {
commit('setProjects', data.projects)
projects = data.projects
commit('setProjects', projects)
} else {
commit('setProjects', [])
}
return {
roles,
permissions,
projects
}
} else {
// window.location.href = `${webConf.others.loginUrl}?rd=${encodeURIComponent(window.location.href)}`
return {}
}
}).catch(() => {
commit('setRoles', null)
commit('setPermissions', null)
commit('setProjects', [])
return {}
})
return obj
}
}
}
......
......@@ -9,30 +9,46 @@ export default class BeforeEnter {
const isLogin = store.state.user.isLogin || (await store.dispatch('checkLogin'))
if (!isLogin) {
window.location.href = `${webConf.others.loginUrl}?rd=${encodeURIComponent(window.location.href)}`
return
next()
} else {
const hasPermissions = store.state.user.permissions
const hasPermissions = store.state.user.permissions && store.state.user.permissions.length > 0
if (hasPermissions) {
next()
const permissions = store.state.user.permissions
if (to.path.includes('error-page')) {
next()
} else {
if (!permissions.includes(to.meta.permission)) {
router.push('/error-page/401')
}
next()
}
} else {
try {
await store.dispatch('checkRolesPermissions')
const permissions = store.state.user.permissions
// 基于权限获取可接入的路由
const accessRoutes = await store.dispatch('permission/routesByPermissions', permissions)
// 重新设置路由
resetRouter()
// dynamically add accessible routes
router.addRoutes(accessRoutes)
// hack method to ensure that addRoutes is complete
// set the replace: true, so the navigation will not leave a history record
next({ ...to, replace: true })
} catch (error) {
const { permissions } = await store.dispatch('checkRolesPermissions')
if (!permissions.length) {
window.location.href = `${webConf.others.loginUrl}?rd=${encodeURIComponent(window.location.href)}`
next()
} else {
try {
// 基于权限获取可接入的路由
const accessRoutes = await store.dispatch('permission/routesByPermissions', permissions)
// 重新设置路由
resetRouter()
// 动态添加路由
router.addRoutes(accessRoutes)
next({ ...to, replace: true })
} catch (error) {
next()
}
if (to.path.includes('error-page')) {
next()
} else {
if (!permissions.includes(to.meta.permission)) {
router.replace('/error-page/401')
}
next()
}
}
}
}
// store.dispatch('setUserRoles')
next()
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论