yujialong 3 years ago
parent 0c45e5dd8a
commit a91e5f20ad
  1. 4
      src/api/index.js
  2. 30
      src/components/breadcrumb/index.vue
  3. 74
      src/layouts/header/index.vue
  4. 25
      src/layouts/navbar/index.vue
  5. 13
      src/pages/index/list/index.vue
  6. 4
      src/pages/setting/person/index.vue
  7. 6
      src/pages/setting/person/info.vue
  8. 14
      src/pages/stat/list/index.vue
  9. 7
      src/pages/user/list/index.vue
  10. 14
      src/plugins/requests/index.js
  11. 42
      src/router/permission.js
  12. 4
      src/setting.js
  13. 24
      src/store/modules/common.js
  14. 10
      src/store/modules/user.js

@ -83,8 +83,8 @@ export default {
queryDatabaseInfo:`${host1}/data/data/dataRecord/queryDatabaseInfo`, queryDatabaseInfo:`${host1}/data/data/dataRecord/queryDatabaseInfo`,
queryDatabaseInfoByMonth:`${host1}/data/data/dataRecord/queryDatabaseInfoByMonth`, queryDatabaseInfoByMonth:`${host1}/data/data/dataRecord/queryDatabaseInfoByMonth`,
saveRecord:`${host1}/data/data/dataRecord/saveRecord`, saveRecord:`${host1}/data/data/dataRecord/saveRecord`,
databaseInfoExport:`${host1}/data/data/dataRecord/data/databaseInfoExport`, databaseInfoExport:`${host1}/data/data/dataRecord/databaseInfoExport`,
databaseInfoByMonthExport:`${host1}/data/data/dataRecord/data/databaseInfoByMonthExport`, databaseInfoByMonthExport:`${host1}/data/data/dataRecord/databaseInfoByMonthExport`,
onlineNumber:`${host1}/data/data/dataRecord/onlineNumber`, onlineNumber:`${host1}/data/data/dataRecord/onlineNumber`,
getProductInfoBySchoolId:`${host1}/data/data/product/getProductInfoBySchoolId`, getProductInfoBySchoolId:`${host1}/data/data/product/getProductInfoBySchoolId`,
} }

@ -1,30 +0,0 @@
<template>
<div class="breadcrumb">
<span class="cur">当前位置</span>
<el-breadcrumb separator="/">
<el-breadcrumb-item :to="{ path: '/' }">超竞学生端</el-breadcrumb-item>
<el-breadcrumb-item v-for="(item,index) in pages" :key="index" :to="{ path: index == pages.length - 1 ? curRoute : path }">{{item}}</el-breadcrumb-item>
</el-breadcrumb>
</div>
</template>
<script>
export default {
props: ['data','route'],
data() {
return {
pages: this.data.split('/'),
curRoute: this.$route.path,
path: this.route ? this.route : 'list'
};
},
methods: {
update(data){
this.pages = data.split('/')
}
}
};
</script>
<style lang="scss" scoped>
</style>

@ -2,13 +2,12 @@
<div class="header"> <div class="header">
<div class="inner"> <div class="inner">
<a class="logo" @click="toIndex"> <a class="logo" @click="toIndex">
<img src="../../assets/img/logo.png" alt=""> <img src="@/assets/img/logo.png" alt="">
</a> </a>
<div style="height: 80px;"></div> <div style="height: 80px;"></div>
<navbar ref="nav"></navbar> <navbar ref="nav"></navbar>
<div class="action" v-if="token"> <div class="action" v-if="token">
<img v-if="isManager || !isUser" class="icon" src="../../assets/img/search.png" alt="" @click="toSearch"> <img v-if="isManager && showSetting" class="icon" src="../../assets/img/setting.png" alt="" @click="toManager">
<img v-if="isManager" class="icon" src="../../assets/img/setting.png" alt="" @click="toManager">
<el-dropdown class="user-wrap" @command="userCommand"> <el-dropdown class="user-wrap" @command="userCommand">
<div class="user"> <div class="user">
<el-avatar :size="40" :src="avatar"></el-avatar> <el-avatar :size="40" :src="avatar"></el-avatar>
@ -20,6 +19,15 @@
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div> </div>
<div v-else-if="!isLogin">
<div class="login" @click="toLogin">
<img src="@/assets/img/user.png" alt="">
<span>登录</span>
</div>
</div>
<div v-else>
<img class="search" src="../../assets/img/search.png" alt="" @click="toSearch">
</div>
</div> </div>
</div> </div>
</template> </template>
@ -32,20 +40,23 @@ export default {
data() { data() {
return { return {
token: util.local.get(Setting.tokenKey), token: util.local.get(Setting.tokenKey),
isUser: false isLogin: this.$route.path == '/login',
userName: '',
isUser: false,
showSetting: true
}; };
}, },
components: { navbar }, components: { navbar },
computed: { computed: {
...mapState('user', [ ...mapState('user', [
'avatar','userName','isManager','schoolId' 'avatar','isManager','schoolId'
]), ]),
...mapState('auth', [ ...mapState('auth', [
'routes' 'routes'
]) ])
}, },
mounted(){ mounted(){
if(this.token) (this.userName && this.avatar) || this.getUserInfo() this.token && this.getUserInfo()
}, },
methods: { methods: {
...mapActions('user', [ ...mapActions('user', [
@ -58,11 +69,11 @@ export default {
this.isUser = isManager this.isUser = isManager
let mg = this.$route.query.mg let mg = this.$route.query.mg
if(mg && atob(decodeURI(mg)) === 'true'){ if(mg && atob(decodeURI(mg)) === 'true'){
isManager = false this.showSetting = false
} }
this.userName = userInfo.userName
this.setInfo({ this.setInfo({
avatar: userInfo.userAvatars, avatar: userInfo.userAvatars,
userName: userInfo.userName,
schoolId: res.userAccount.schoolId, schoolId: res.userAccount.schoolId,
}) })
this.setManager(isManager) this.setManager(isManager)
@ -80,15 +91,26 @@ export default {
title: '首页' title: '首页'
}) })
}, },
toManager(){ toLogin(){
let route = this.$router.resolve({ this.$refs.nav.jump({
path: this.routes[0].name, index: '/login',
query: { title: '登录'
mg: btoa(true),
schoolId: btoa(this.schoolId),
}
}) })
window.open(route.href) },
toManager(){
let routes = this.routes
if(routes.length){
let route = this.$router.resolve({
path: this.routes[0].name,
query: {
mg: btoa(true),
schoolId: btoa(this.schoolId),
}
})
window.open(route.href)
}else{
util.warningMsg('该角色未开放模块,请联系管理员')
}
}, },
userCommand(command){ userCommand(command){
if(command == 'person'){ if(command == 'person'){
@ -120,13 +142,12 @@ export default {
} }
} }
.search{
cursor: pointer;
}
.action{ .action{
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
.icon{
margin-right: 30px;
cursor: pointer;
}
.user-wrap { .user-wrap {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@ -143,5 +164,18 @@ export default {
} }
} }
} }
.login{
display: inline-flex;
align-items: center;
cursor: pointer;
&:hover{
opacity: .9;
}
span{
margin-left: 10px;
color: #000;
font-size: 14px;
}
}
} }
</style> </style>

@ -17,15 +17,14 @@ export default {
managerStr: this.$route.query.mg, managerStr: this.$route.query.mg,
isManager: false, isManager: false,
active: this.$route.path, active: this.$route.path,
defaultMenus: [ defaultMenus: [{
{ index: '/index/list',
index: '/index/list', title: '首页'
title: '首页' }],
},{ dataMenu: [{
index: '/data/list', index: '/data/list',
title: '数据' title: '数据'
} }],
],
managerMenus: [ managerMenus: [
{ {
index: '/stat/list', index: '/stat/list',
@ -63,6 +62,8 @@ export default {
this.isManager = true this.isManager = true
this.setManager(false) this.setManager(false)
} }
}else{
this.menus = this.defaultMenus
} }
}, },
methods: { methods: {
@ -83,7 +84,7 @@ export default {
this.menus = this.defaultMenus this.menus = this.defaultMenus
} }
}else{ }else{
this.menus = this.defaultMenus this.menus = [...this.defaultMenus,...this.dataMenu]
} }
}, },
jump(item){ jump(item){
@ -95,7 +96,9 @@ export default {
let routes = res.permissions[0].children let routes = res.permissions[0].children
Setting.dynamicRoute && addRoutes(routes) Setting.dynamicRoute && addRoutes(routes)
this.initMenu() this.initMenu()
}).catch(err => {}) }).catch(err => {
this.menus = this.defaultMenus
})
}, },
} }
}; };

@ -9,7 +9,7 @@
</div> </div>
<img v-if="keyword" src="../../../assets/img/remove-gray.png" alt="" class="remove" @click="keyword = ''"> <img v-if="keyword" src="../../../assets/img/remove-gray.png" alt="" class="remove" @click="keyword = ''">
</div> </div>
<div class="hot"> <div class="hot" v-if="hotData.length">
<span class="name">热门下载</span> <span class="name">热门下载</span>
<ul class="list"> <ul class="list">
<li v-for="(item,index) in hotData" :key="index" @click="toData(item)">{{item.categoryTwo}}</li> <li v-for="(item,index) in hotData" :key="index" @click="toData(item)">{{item.categoryTwo}}</li>
@ -43,10 +43,13 @@
<script> <script>
import { mapState } from 'vuex' import { mapState } from 'vuex'
import Setting from '@/setting'
import util from '@/libs/util'
export default { export default {
name: 'index', name: 'index',
data() { data() {
return { return {
token: util.local.get(Setting.tokenKey),
keyword: '', keyword: '',
searchTimer: null, searchTimer: null,
listData:[], listData:[],
@ -70,7 +73,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.getHot() this.token && this.getHot()
}, },
methods: { methods: {
getData(){ getData(){
@ -101,7 +104,11 @@ export default {
this.getData() this.getData()
}, },
download(row){ download(row){
this.$router.push(`/data?download=true&id=${row.id}&name=${row.name}`) if(this.token){
this.$router.push(`/data?download=true&id=${row.id}&name=${row.name}`)
}else{
this.$router.push('/login')
}
}, },
toData(row){ toData(row){
this.$router.push(`/data?typeId=${row.categoryTwoId}`) this.$router.push(`/data?typeId=${row.categoryTwoId}`)

@ -35,7 +35,7 @@ import util from '@/libs/util'
export default { export default {
data() { data() {
return { return {
token: '', token: util.local.get(Setting.tokenKey),
typeList: [ typeList: [
{ {
index: '1', index: '1',
@ -55,7 +55,7 @@ export default {
]), ]),
}, },
mounted() { mounted() {
this.token = util.local.get(Setting.tokenKey)
}, },
methods: { methods: {
...mapActions('user', [ ...mapActions('user', [

@ -347,7 +347,7 @@ export default {
}, },
methods: { methods: {
...mapActions('user', [ ...mapActions('user', [
'setAvatar','setUserName' 'setAvatar','setInfo'
]), ]),
tabChange(index){ tabChange(index){
this.active = index this.active = index
@ -475,7 +475,9 @@ export default {
} }
this.$post(this.api.updateUser,data).then(res => { this.$post(this.api.updateUser,data).then(res => {
if(res.status == 200){ if(res.status == 200){
this.setUserName(form.userName) this.setInfo({
userName: form.userName
})
util.successMsg('提交成功') util.successMsg('提交成功')
this.$router.back() this.$router.back()
}else{ }else{

@ -112,11 +112,13 @@
<script> <script>
import { mapState } from 'vuex' import { mapState } from 'vuex'
import Setting from '@/setting'
import axios from 'axios' import axios from 'axios'
import util from '@/libs/util' import util from '@/libs/util'
export default { export default {
data() { data() {
return { return {
token: util.local.get(Setting.tokenKey),
schoolName: '', schoolName: '',
productList: [], productList: [],
userCount: '', userCount: '',
@ -280,6 +282,9 @@ export default {
let data = this.listDataAll let data = this.listDataAll
if(this.multipleSelection.length) data = this.multipleSelection if(this.multipleSelection.length) data = this.multipleSelection
axios.post(this.api.databaseInfoExport,data,{ axios.post(this.api.databaseInfoExport,data,{
headers: {
token: this.token
},
responseType: 'blob' responseType: 'blob'
}).then((res) => { }).then((res) => {
util.downloadFileDirect(`按数据库统计使用概况导出.xls`,new Blob([res.data])) util.downloadFileDirect(`按数据库统计使用概况导出.xls`,new Blob([res.data]))
@ -292,7 +297,14 @@ export default {
}else{ }else{
data = this.monthData.map(n => `yearList=${n.year}`) data = this.monthData.map(n => `yearList=${n.year}`)
} }
location.href = `${this.api.databaseInfoByMonthExport}?schoolId=${this.schoolId}&${Array.from(new Set(data)).join('&')}` axios.get(`${this.api.databaseInfoByMonthExport}?schoolId=${this.schoolId}&${Array.from(new Set(data)).join('&')}`,{
headers: {
token: this.token
},
responseType: 'blob'
}).then((res) => {
util.downloadFileDirect(`按月份统计数据库使用概况.xls`,new Blob([res.data]))
}).catch(res => {})
} }
} }
}; };

@ -18,6 +18,7 @@
<label>角色</label> <label>角色</label>
<el-select v-model="role" placeholder="请选择角色" size="small" clearable class="w-150" @change="initData"> <el-select v-model="role" placeholder="请选择角色" size="small" clearable class="w-150" @change="initData">
<el-option label="不限" value=""></el-option> <el-option label="不限" value=""></el-option>
<el-option label="用户" value="0"></el-option>
<el-option v-for="(item,index) in roleList" :key="index" :label="item.roleName" :value="item.id"></el-option> <el-option v-for="(item,index) in roleList" :key="index" :label="item.roleName" :value="item.id"></el-option>
</el-select> </el-select>
</li> </li>
@ -233,7 +234,7 @@ export default {
multipleSelection: [], multipleSelection: [],
uploadList: [], uploadList: [],
uploadFaild: false, uploadFaild: false,
token: '', importToken: '',
accountRepeat: false, accountRepeat: false,
workNumberRepeat: false, workNumberRepeat: false,
}; };
@ -478,7 +479,7 @@ export default {
}, },
showFaild(){ showFaild(){
this.importVisible = false this.importVisible = false
location.href = `${this.api.export_failure}?token=${this.token}` location.href = `${this.api.export_failure}?token=${this.importToken}`
}, },
handleExceed(files, fileList) { handleExceed(files, fileList) {
util.warningMsg( util.warningMsg(
@ -490,7 +491,7 @@ export default {
if(res.status == 200){ if(res.status == 200){
if(res.data.token){ if(res.data.token){
util.errorMsg('导入失败,请下载失败模板查看原因') util.errorMsg('导入失败,请下载失败模板查看原因')
this.token = res.data.token this.importToken = res.data.token
this.uploadFaild = true this.uploadFaild = true
}else{ }else{
util.successMsg('上传成功') util.successMsg('上传成功')

@ -18,7 +18,7 @@ service.interceptors.request.use(config => {
let storeSchoolId = store.state.user.schoolId let storeSchoolId = store.state.user.schoolId
let routeSchoolId = router.app._route.query.schoolId let routeSchoolId = router.app._route.query.schoolId
if(routeSchoolId) routeSchoolId = atob(decodeURI(routeSchoolId)) if(routeSchoolId) routeSchoolId = atob(decodeURI(routeSchoolId))
config.headers.schoolId = storeSchoolId ? storeSchoolId : routeSchoolId if(storeSchoolId || routeSchoolId) config.headers.schoolId = storeSchoolId ? storeSchoolId : routeSchoolId
return config return config
},err => { },err => {
util.errorMsg({ util.errorMsg({
@ -57,9 +57,9 @@ service.interceptors.response.use(
setTimeout(() => { setTimeout(() => {
router.replace({ router.replace({
path: '/login', path: '/login',
query: { // query: {
redirect: router.currentRoute.fullPath // redirect: router.currentRoute.fullPath
} // }
}) })
}, 1000) }, 1000)
break break
@ -80,9 +80,9 @@ service.interceptors.response.use(
setTimeout(() => { setTimeout(() => {
router.replace({ router.replace({
path: '/login', path: '/login',
query: { // query: {
redirect: router.currentRoute.fullPath // redirect: router.currentRoute.fullPath
} // }
}) })
}, 1000) }, 1000)
break break

@ -1,27 +1,49 @@
import router from './index' import router from './index'
import Setting from '@/setting' import Setting from '@/setting'
import util from '@/libs/util' import util from '@/libs/util'
import store from '@/store'
const managerPath = ['/stat/list','/user/list','/role/list'] // 管理员才能访问的页面路径
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
document.title = Setting.titleSuffix document.title = Setting.titleSuffix
const role = util.local.get(Setting.tokenKey) const role = util.local.get(Setting.tokenKey)
if (!role && to.path !== '/login') { if (!role && to.path !== '/login' && to.path !== '/index/list') {
next('/login') next('/login')
} else if(role && to.path == '/login') { } else if(role && to.path == '/login') {
next('/index') next('/index')
} else { } else {
let mg = from.query.mg let mg = from.query.mg
if(mg){ let routes = store.state.auth.routes
if(!to.query.mg){ let toPath = to.path
next({ // mg是判断是否是管理员的参数,base64解码后如果等于true则为管理员,否则为普通用户。
path: to.path, // 如果是管理员则需要从获取的路由权限里判断当前访问页面是否有权限访问,如果没权限访问则跳转到403
query: {mg} if((mg && atob(decodeURI(mg)) === 'true') || (to.query.mg && atob(decodeURI(to.query.mg)) === 'true')){
}) if(routes.length){
if(routes.find(n => n.name == toPath) || toPath == '/setting/person'){
if(!to.query.mg){
next({
path: toPath,
query: {mg}
})
}else{
next()
}
}else{
if(to.path != '/403'){
next('/403')
}else{
next()
}
}
}else{
next()
}
}else{// 如果是普通用户,则无法访问上面定义的常量里的3个页面路径
if(managerPath.includes(toPath)){
next('/403')
}else{ }else{
next() next()
} }
}else{
next()
} }
} }
}); })

@ -16,7 +16,7 @@ const Setting = {
showProgressBar: true, showProgressBar: true,
// 接口请求地址 // 接口请求地址
// apiBaseURL: env === 'development' ? 'http://192.168.31.125:8888' : 'http://39.108.250.202:8000', // apiBaseURL: env === 'development' ? 'http://192.168.31.125:8888' : 'http://39.108.250.202:8000',
apiBaseURL: env === 'development' ? 'http://192.168.31.151:9000' : 'http://www.liuwanr.cn', apiBaseURL: env === 'development' ? 'http://192.168.31.216:9000' : 'http://www.liuwanr.cn',
// 接口请求返回错误时,弹窗的持续时间,单位:秒 // 接口请求返回错误时,弹窗的持续时间,单位:秒
modalDuration: 3, modalDuration: 3,
// 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice // 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice
@ -40,7 +40,7 @@ const Setting = {
*/ */
initialPassword: '111aaa', initialPassword: '111aaa',
/** /**
* 所属平台1->职站 2->数据平台 * 所属平台1->职站 2->数据平台 3->中台
*/ */
platformId: 2, platformId: 2,
/** /**

@ -1,24 +0,0 @@
/**
* 通用
* */
const roleList = {
'1': '超级管理员',
'2': '管理员',
'3': '老师',
'4': '学生'
}
export default {
namespaced: true,
state: {
},
mutations: {
},
actions: {
getRole (id) {
return roleList[id] || '未知状态'
}
}
}

@ -1,7 +1,6 @@
import Setting from '@/setting' import Setting from '@/setting'
import util from '@/libs/util' import util from '@/libs/util'
import { Message } from 'element-ui'
import {post,get,del,put} from '@/plugins/requests/index.js' import {post,get,del,put} from '@/plugins/requests/index.js'
import api from '@/api' import api from '@/api'
@ -12,15 +11,13 @@ export default {
namespaced: true, namespaced: true,
state: { state: {
avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png', avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
userName: '',
schoolId: '', schoolId: '',
isManager: false isManager: false
}, },
mutations: { mutations: {
SET_INFO: (state, info) => { SET_INFO: (state, info) => {
if(info.avatar) state.avatar = info.avatar if(info.avatar) state.avatar = info.avatar
state.schoolId = info.schoolId if(info.schoolId) state.schoolId = info.schoolId
state.userName = info.userName
}, },
SET_AVATAR: (state, avatar) => { SET_AVATAR: (state, avatar) => {
state.avatar = avatar state.avatar = avatar
@ -69,11 +66,6 @@ export default {
}, },
setAvatar({ state,commit },avatar) { setAvatar({ state,commit },avatar) {
commit('SET_AVATAR',avatar) commit('SET_AVATAR',avatar)
let data = {
userId: state.userId,
userAvatars: avatar
}
post(api.userinfoUpdate,data).then(res => {}).catch(res => {})
}, },
setInfo({ state,commit },info) { setInfo({ state,commit },info) {
commit('SET_INFO',info) commit('SET_INFO',info)

Loading…
Cancel
Save