yujialong 3 years ago
parent 0c45e5dd8a
commit a91e5f20ad
  1. 4
      src/api/index.js
  2. 30
      src/components/breadcrumb/index.vue
  3. 58
      src/layouts/header/index.vue
  4. 17
      src/layouts/navbar/index.vue
  5. 11
      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. 30
      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`,
queryDatabaseInfoByMonth:`${host1}/data/data/dataRecord/queryDatabaseInfoByMonth`,
saveRecord:`${host1}/data/data/dataRecord/saveRecord`,
databaseInfoExport:`${host1}/data/data/dataRecord/data/databaseInfoExport`,
databaseInfoByMonthExport:`${host1}/data/data/dataRecord/data/databaseInfoByMonthExport`,
databaseInfoExport:`${host1}/data/data/dataRecord/databaseInfoExport`,
databaseInfoByMonthExport:`${host1}/data/data/dataRecord/databaseInfoByMonthExport`,
onlineNumber:`${host1}/data/data/dataRecord/onlineNumber`,
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="inner">
<a class="logo" @click="toIndex">
<img src="../../assets/img/logo.png" alt="">
<img src="@/assets/img/logo.png" alt="">
</a>
<div style="height: 80px;"></div>
<navbar ref="nav"></navbar>
<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" class="icon" src="../../assets/img/setting.png" alt="" @click="toManager">
<img v-if="isManager && showSetting" class="icon" src="../../assets/img/setting.png" alt="" @click="toManager">
<el-dropdown class="user-wrap" @command="userCommand">
<div class="user">
<el-avatar :size="40" :src="avatar"></el-avatar>
@ -20,6 +19,15 @@
</el-dropdown-menu>
</el-dropdown>
</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>
</template>
@ -32,20 +40,23 @@ export default {
data() {
return {
token: util.local.get(Setting.tokenKey),
isUser: false
isLogin: this.$route.path == '/login',
userName: '',
isUser: false,
showSetting: true
};
},
components: { navbar },
computed: {
...mapState('user', [
'avatar','userName','isManager','schoolId'
'avatar','isManager','schoolId'
]),
...mapState('auth', [
'routes'
])
},
mounted(){
if(this.token) (this.userName && this.avatar) || this.getUserInfo()
this.token && this.getUserInfo()
},
methods: {
...mapActions('user', [
@ -58,11 +69,11 @@ export default {
this.isUser = isManager
let mg = this.$route.query.mg
if(mg && atob(decodeURI(mg)) === 'true'){
isManager = false
this.showSetting = false
}
this.userName = userInfo.userName
this.setInfo({
avatar: userInfo.userAvatars,
userName: userInfo.userName,
schoolId: res.userAccount.schoolId,
})
this.setManager(isManager)
@ -80,7 +91,15 @@ export default {
title: '首页'
})
},
toLogin(){
this.$refs.nav.jump({
index: '/login',
title: '登录'
})
},
toManager(){
let routes = this.routes
if(routes.length){
let route = this.$router.resolve({
path: this.routes[0].name,
query: {
@ -89,6 +108,9 @@ export default {
}
})
window.open(route.href)
}else{
util.warningMsg('该角色未开放模块,请联系管理员')
}
},
userCommand(command){
if(command == 'person'){
@ -120,13 +142,12 @@ export default {
}
}
.search{
cursor: pointer;
}
.action{
display: inline-flex;
align-items: center;
.icon{
margin-right: 30px;
cursor: pointer;
}
.user-wrap {
display: inline-flex;
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>

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

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

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

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

@ -112,11 +112,13 @@
<script>
import { mapState } from 'vuex'
import Setting from '@/setting'
import axios from 'axios'
import util from '@/libs/util'
export default {
data() {
return {
token: util.local.get(Setting.tokenKey),
schoolName: '',
productList: [],
userCount: '',
@ -280,6 +282,9 @@ export default {
let data = this.listDataAll
if(this.multipleSelection.length) data = this.multipleSelection
axios.post(this.api.databaseInfoExport,data,{
headers: {
token: this.token
},
responseType: 'blob'
}).then((res) => {
util.downloadFileDirect(`按数据库统计使用概况导出.xls`,new Blob([res.data]))
@ -292,7 +297,14 @@ export default {
}else{
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>
<el-select v-model="role" placeholder="请选择角色" size="small" clearable class="w-150" @change="initData">
<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-select>
</li>
@ -233,7 +234,7 @@ export default {
multipleSelection: [],
uploadList: [],
uploadFaild: false,
token: '',
importToken: '',
accountRepeat: false,
workNumberRepeat: false,
};
@ -478,7 +479,7 @@ export default {
},
showFaild(){
this.importVisible = false
location.href = `${this.api.export_failure}?token=${this.token}`
location.href = `${this.api.export_failure}?token=${this.importToken}`
},
handleExceed(files, fileList) {
util.warningMsg(
@ -490,7 +491,7 @@ export default {
if(res.status == 200){
if(res.data.token){
util.errorMsg('导入失败,请下载失败模板查看原因')
this.token = res.data.token
this.importToken = res.data.token
this.uploadFaild = true
}else{
util.successMsg('上传成功')

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

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

@ -16,7 +16,7 @@ const Setting = {
showProgressBar: true,
// 接口请求地址
// 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,
// 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice
@ -40,7 +40,7 @@ const Setting = {
*/
initialPassword: '111aaa',
/**
* 所属平台1->职站 2->数据平台
* 所属平台1->职站 2->数据平台 3->中台
*/
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 util from '@/libs/util'
import { Message } from 'element-ui'
import {post,get,del,put} from '@/plugins/requests/index.js'
import api from '@/api'
@ -12,15 +11,13 @@ export default {
namespaced: true,
state: {
avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
userName: '',
schoolId: '',
isManager: false
},
mutations: {
SET_INFO: (state, info) => {
if(info.avatar) state.avatar = info.avatar
state.schoolId = info.schoolId
state.userName = info.userName
if(info.schoolId) state.schoolId = info.schoolId
},
SET_AVATAR: (state, avatar) => {
state.avatar = avatar
@ -69,11 +66,6 @@ export default {
},
setAvatar({ state,commit },avatar) {
commit('SET_AVATAR',avatar)
let data = {
userId: state.userId,
userAvatars: avatar
}
post(api.userinfoUpdate,data).then(res => {}).catch(res => {})
},
setInfo({ state,commit },info) {
commit('SET_INFO',info)

Loading…
Cancel
Save