接口联调

ui1
yujialong 3 years ago
parent 7f3fc93d8a
commit 0c45e5dd8a
  1. 2
      src/App.vue
  2. 111
      src/api/index.js
  3. BIN
      src/assets/img/code.png
  4. BIN
      src/assets/img/password.png
  5. BIN
      src/assets/img/setting.png
  6. 2
      src/layouts/footer/index.vue
  7. 58
      src/layouts/header/index.vue
  8. 63
      src/layouts/navbar/index.vue
  9. 6
      src/libs/auth/generateBtnPermission.js
  10. 14
      src/libs/route/addRoutes.js
  11. 2
      src/libs/route/generateRoutes.js
  12. 69
      src/pages/account/login/index.vue
  13. 24
      src/pages/data/list/index.vue
  14. 54
      src/pages/index/list/index.vue
  15. 19
      src/pages/role/list/index.vue
  16. 8
      src/pages/setting/person/download.vue
  17. 19
      src/pages/setting/person/index.vue
  18. 504
      src/pages/setting/person/info.vue
  19. 25
      src/pages/stat/list/index.vue
  20. 115
      src/pages/user/list/index.vue
  21. 10
      src/plugins/auth/index.js
  22. 111
      src/plugins/requests/index.js
  23. 16
      src/router/permission.js
  24. 2
      src/setting.js
  25. 8
      src/store/getters.js
  26. 26
      src/store/modules/auth.js
  27. 32
      src/store/modules/data.js
  28. 19
      src/store/modules/role.js
  29. 47
      src/store/modules/stat.js
  30. 86
      src/store/modules/user.js

@ -17,7 +17,7 @@
//vuexlocalStorage
window.addEventListener("beforeunload",()=>{
util.local.get(Setting.usernameKey) && util.local.set(Setting.storeKey,this.$store.state)
util.local.get(Setting.tokenKey) && util.local.set(Setting.storeKey,this.$store.state)
})
}
}

@ -1,26 +1,31 @@
import Setting from '@/setting'
let uploadURL = Setting.upload.apiURL
let host = 'http://www.liuwanr.cn'
let host1 = 'http://192.168.31.125:9000'
let host1 = 'http://192.168.31.125:9000'//林
let host2 = 'http://192.168.31.140:9000'//7
let host3 = 'http://192.168.31.137:9000'//陈
export default {
// 登录注册
logins: `${host}/liuwanr/userInfo/adminLogins`,
logins: `${host3}/users/users/user/login`,
verification:`${host3}/users/users/user/captcha`,
uploadUserAvatars: `liuwanr/userInfo/uploadUserAvatars`,
queryProvince: `liuwanr/province/queryProvince`,
queryCity: `liuwanr/city/queryCity`,
querySchoolData: `liuwanr/customer/querySchool`,
queryAccountIsExist:`liuwanr/userInfo/queryAccountIsExist`,
// 公用接口
queryProvince: `${host3}/nakadai/nakadai/province/queryProvince`,
queryCity: `${host3}/nakadai/nakadai/city/queryCity`,
queryWorkNumberIsExist:`evaluation/tms/userInfo/queryWorkNumberIsExist`,
queryStaffWorkNumberIsExist:`evaluation/tms/system/queryStaffWorkNumberIsExist`,
querySchool: `liuwanr/customer/querySchool`,
querySchool: `${host3}/nakadai/nakadai/school/querySchool`,
queryCourseDiscipline: `${host2}/nakadai/nakadai/discipline/queryDiscipline`,
queryCourseProfessionalClass: `${host2}/nakadai/nakadai/professionalClass/queryProfessionalClass`,
queryCourseProfessional: `${host2}/nakadai/nakadai/professional/queryProfessional`,
// 个人中心
userInfo:`${host1}/data/userInfo/userInfo`,
updateUser:`${host1}/data/userInfo/updateUser`,
findPasswordByEmail:`/data/userInfo/findPasswordByEmail`,
findPasswordByPhone:`/data/userInfo/findPasswordByPhone`,
uploadUserAvatars: `${host1}/users/users/userAccount/updateUserAvatars`,
userInfo:`${host1}/users/users/userInfo/getUserInfo`,
updateUser:`${host1}/users/users/userInfo/updateUser`,
findPasswordByEmail:`/users/users/userAccount/findPasswordByEmail`,
findPasswordByPhone:`/users/users/userAccount/findPasswordByPhone`,
bingEmail:`evaluation/tms/user/bingEmail`,
bindPhone:`evaluation/tms/user/bindPhone`,
@ -31,53 +36,55 @@ export default {
removeMoreVideo: `${uploadURL}/oss/manage/removeMoreVideo`,
removeVideo: `${uploadURL}/oss/manage/removeVideo`,
//查询电话是否存在
queryProvince: `cjEnterprise/province/queryProvince`,
queryCity: `cjEnterprise/city/queryCity`,
queryClient: `cjEnterprise/client/list`,
// 用户管理
saveUser: `/users/data/user/save`,
getUserList: `/users/data/user/getUserList`,
getUserTotalBySchoolId: `${host1}/users/data/user/getUserTotalBySchoolId`,
checkAccount:`/users/data/user/checkAccount`,
getDetail:`/users/data/user/getDetail`,
modifyUser:`/users/data/user/modify`,
export_failure:`${Setting.apiBaseURL}/users/data/user/export_failure`,
uploadFile:`${Setting.apiBaseURL}/users/data/user/uploadFile`,
saveUser: `/users/users/data/user/save`,
getUserList: `/users/users/data/user/getUserList`,
getUserTotalBySchoolId: `${host1}/users/users/data/user/getUserTotalBySchoolId`,
checkAccount:`/users/users/data/user/checkAccount`,
getDetail:`/users/users/data/user/getDetail`,
modifyUser:`/users/users/data/user/modify`,
export_failure:`${Setting.apiBaseURL}/users/users/data/user/export_failure`,
uploadFile:`${Setting.apiBaseURL}/users/users/data/user/uploadFile`,
deleteUser:`${Setting.apiBaseURL}/users/users/data/user/delete`,
resetPwd: `${host2}/users/users/userAccount/resetPwd`,
sendPhoneOrEmailCode: `${host2}/users/users/userAccount/sendPhoneOrEmailCode`,
bindPhoneOrEmail: `${host2}/users/users/userAccount/bindPhoneOrEmail`,
examinePassword: `${host1}/users/users/userAccount/examinePassword`,
// 角色管理
batchRemove:`/data/role/batchRemove`,
getRole:`/data/role/get`,
getName:`/data/role/getName`,
listRole:`/data/role/list`,
removeRole:`/data/role/remove`,
saveOrUpdate:`/data/role/saveOrUpdate`,
getRoles:`/data/role/getRole`,
batchRemove:`/data/data/role/batchRemove`,
getRole:`/data/data/role/get`,
getName:`/data/data/role/getName`,
listRole:`/data/data/role/list`,
removeRole:`/data/data/role/remove`,
saveOrUpdate:`/data/data/role/saveOrUpdate`,
getRoles:`/data/data/role/getRole`,
getPermissions:`/data/data/permission/getPermissions`,
// 权限菜单管理
doAssign:`/data/permission/doAssign`,
queryPermissionMenu:`/data/permission/queryPermissionMenu`,
savePer:`/data/permission/save`,
toAssign:`/data/permission/toAssign`,
doAssign:`/data/data/permission/doAssign`,
queryPermissionMenu:`/data/data/permission/queryPermissionMenu`,
savePer:`/data/data/permission/save`,
toAssign:`/data/data/permission/toAssign`,
// 表展示
getIdQueryTable:`/data/table/getIdQueryTable`,
getTableByClassification:`/data/table/getTableByClassification`,
getTableByCondition:`/data/table/getTableByCondition`,
downloadData:`${host1}/data/download`,
previewData:`${host1}/data/preview`,
downloadRecord:`${host1}/data/myDownload/downloadRecord`,
getDownloadRecord:`data/myDownload/getDownloadRecord`,
downloadAgain:`${host1}/data/downloadAgain`,
getIdQueryTable:`/data/data/table/getIdQueryTable`,
getTableByClassification:`/data/data/table/getTableByClassification`,
getTableByCondition:`/data/data/table/getTableByCondition`,
downloadData:`${host1}/data/data/download`,
previewData:`${host1}/data/data/preview`,
downloadRecord:`${host1}/data/data/myDownload/downloadRecord`,
getDownloadRecord:`/data/data/myDownload/getDownloadRecord`,
downloadAgain:`${host1}/data/data/downloadAgain`,
isDownload:`${host1}/data/data/product/isDownload`,
// 数据操作记录
queryAccumulate:`${host1}/data/dataRecord/queryAccumulate`,
queryDatabaseInfo:`${host1}/data/dataRecord/queryDatabaseInfo`,
queryDatabaseInfoByMonth:`${host1}/data/dataRecord/queryDatabaseInfoByMonth`,
saveRecord:`${host1}/data/dataRecord/saveRecord`,
databaseInfoExport:`${host1}/data/dataRecord/databaseInfoExport`,
databaseInfoByMonthExport:`${host1}/data/dataRecord/databaseInfoByMonthExport`,
onlineNumber:`${host1}/data/dataRecord/onlineNumber`,
getProductInfoBySchoolId:`${host1}/data/product/getProductInfoBySchoolId`,
queryAccumulate:`${host1}/data/data/dataRecord/queryAccumulate`,
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`,
onlineNumber:`${host1}/data/data/dataRecord/onlineNumber`,
getProductInfoBySchoolId:`${host1}/data/data/product/getProductInfoBySchoolId`,
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

@ -1,6 +1,6 @@
<template>
<div>
<div class="copyright">广州超竞教育投资有限公司版权所有</div>
<div class="copyright"></div>
</div>
</template>
<script>

@ -6,8 +6,9 @@
</a>
<div style="height: 80px;"></div>
<navbar ref="nav"></navbar>
<div class="action">
<img class="search" src="../../assets/img/search.png" alt="">
<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">
<el-dropdown class="user-wrap" @command="userCommand">
<div class="user">
<el-avatar :size="40" :src="avatar"></el-avatar>
@ -26,36 +27,69 @@
import navbar from '../navbar'
import { mapState,mapActions } from 'vuex'
import Setting from '@/setting'
import util from '@/libs/util'
export default {
data() {
return {
showBackList: Setting.layout.hideNavList,
token: util.local.get(Setting.tokenKey),
isUser: false
};
},
components: { navbar },
computed: {
...mapState('user', [
'userId','avatar','userName'
'avatar','userName','isManager','schoolId'
]),
showBack(){
let route = this.$route.name
if(this.showBackList.includes(route)) return true
return false
}
...mapState('auth', [
'routes'
])
},
mounted(){
if(this.token) (this.userName && this.avatar) || this.getUserInfo()
},
methods: {
...mapActions('user', [
'logout'
'setInfo','logout','setManager'
]),
getUserInfo(){
this.$get(this.api.userInfo).then(res => {
let userInfo = res.userInfo
let isManager = userInfo.roleId != '0'
this.isUser = isManager
let mg = this.$route.query.mg
if(mg && atob(decodeURI(mg)) === 'true'){
isManager = false
}
this.setInfo({
avatar: userInfo.userAvatars,
userName: userInfo.userName,
schoolId: res.userAccount.schoolId,
})
this.setManager(isManager)
}).catch(err => {})
},
toIndex(){
this.$refs.nav.jump({
index: '/index/list',
title: '首页'
})
},
toSearch(){
this.$refs.nav.jump({
index: '/index/list',
title: '首页'
})
},
toManager(){
let route = this.$router.resolve({
path: this.routes[0].name,
query: {
mg: btoa(true),
schoolId: btoa(this.schoolId),
}
})
window.open(route.href)
},
userCommand(command){
if(command == 'person'){
this.$router.push('/setting/person')
@ -89,7 +123,7 @@ export default {
.action{
display: inline-flex;
align-items: center;
.search{
.icon{
margin-right: 30px;
cursor: pointer;
}

@ -7,12 +7,15 @@
</template>
<script>
import { mapState } from 'vuex'
import bus from '@/libs/bus'
import { mapState,mapActions } from 'vuex'
import addRoutes from '@/libs/route/addRoutes'
import Setting from '@/setting'
import util from '@/libs/util'
export default {
data() {
return {
managerStr: this.$route.query.mg,
isManager: false,
active: this.$route.path,
defaultMenus: [
{
@ -21,7 +24,10 @@ export default {
},{
index: '/data/list',
title: '数据'
},{
}
],
managerMenus: [
{
index: '/stat/list',
title: '数据统计'
},{
@ -30,17 +36,17 @@ export default {
},{
index: '/role/list',
title: '角色权限'
},
}
],
menus: [],
actives: {
practice: ['practice-do','practice-randomDo'],
exam: ['exam-do'],
achievement: ['achievement-practice','achievement-assessment'],
wrongBook: ['wrongBook-do'],
}
actives: {}
};
},
computed: {
...mapState('auth', [
'routes'
])
},
watch: {
'$route'(to,from) {
let actives = this.actives
@ -50,32 +56,47 @@ export default {
this.active = this.$route.path
}
},
created() {
this.initMenu()
// Event Bus
bus.$on('collapse', msg => {
this.collapse = msg;
bus.$emit('collapse-content', msg);
});
mounted() {
if(util.local.get(Setting.tokenKey)){
this.getPer()
if(this.managerStr && atob(decodeURI(this.managerStr)) === 'true'){
this.isManager = true
this.setManager(false)
}
}
},
methods: {
...mapActions('user', [
'setManager'
]),
initMenu(){
if(this.isManager){
this.defaultMenus = this.managerMenus
if(Setting.dynamicRoute){
let routes = this.routes
let menus = []
this.defaultMenus.map(e => {
routes.find(n => n.path == e.index) && menus.push(e)
routes.find(n => n.name == e.index) && menus.push(e)
})
this.menus = menus
this.active = menus[0].index
}else{
this.menus = this.defaultMenus
}
}else{
this.menus = this.defaultMenus
}
},
jump(item){
this.active = item.index
this.$router.push(item.index)
}
this.$router.push(item.index).catch(err => {})
},
getPer(){
this.$post(this.api.getPermissions).then(res => {
let routes = res.permissions[0].children
Setting.dynamicRoute && addRoutes(routes)
this.initMenu()
}).catch(err => {})
},
}
};
</script>

@ -12,14 +12,14 @@ export default function(data){
if(n.children.length){
result.push(`${e.name}:${n.name}`)
n.children.map(j => {
j.select && (e.component ? result.push(`${e.component}:${n.name}:${j.name}`) : result.push(`${n.component}:${j.name}`))
j.select && (e.path ? result.push(`${e.path}:${n.name}:${j.name}`) : result.push(`${n.path}:${j.name}`))
})
}else{
result.push(`${e.component}:${n.name}`)
result.push(`${e.path}:${n.name}`)
}
}
})
}
})
store.commit('addBtnPerData',{btnPermissions: result})
store.dispatch('auth/addBtnAuth',result)
}

@ -11,12 +11,12 @@ function createMeta(item){
function createRoute(data){
data.map(e => {
if(e.select && e.component){
if(e.select && e.path){
let meta = createMeta(e)
newRoutes.push({
name: e.component,
path: e.component,
component: () => import(`@/pages/${e.component}.vue`),
name: e.path,
path: e.path,
path: () => import(`@/pages/${e.path}.vue`),
meta
})
}
@ -27,8 +27,6 @@ function createRoute(data){
export default function(data,path){
generateBtnPermission(data)
createRoute(data)
let routes = router.options.routes
routes[1].children = [...routes[1].children,...newRoutes]
store.commit("addRoutesData", { routes })
router.addRoutes(routes)
store.dispatch('auth/addRoutes',newRoutes)
// router.addRoutes(routes)
}

@ -3,7 +3,7 @@ import router from '@/router';
export default function(){
setTimeout(() => {
let routes = store.state.routes
let routes = store.state.auth.routes
routes.forEach(e => {
if(e.path == '/'){
e.component = () => import('@/layouts/home/index.vue')

@ -9,17 +9,19 @@
<div class="form">
<div class="title"><span>登录</span></div>
<el-form :model="loginForm" :rules="loginRules" ref="login" label-width="0px">
<el-form-item prop="username">
<el-form-item prop="account">
<label class="account"></label>
<el-input v-model="loginForm.username" placeholder="请输入账号/手机号" @keyup.enter.native="submitForm()"></el-input>
<el-input v-model="loginForm.account" placeholder="请输入账号/手机号" @keyup.enter.native="submitForm"></el-input>
</el-form-item>
<el-form-item prop="password">
<label class="password"></label>
<el-input type="password" placeholder="请输入密码" v-model="loginForm.password" @keyup.enter.native="submitForm()"></el-input>
<el-input type="password" placeholder="请输入密码" v-model="loginForm.password" @keyup.enter.native="submitForm"></el-input>
</el-form-item>
<el-form-item prop="code">
<label class="code"></label>
<el-input placeholder="请输入验证码" v-model="loginForm.code" @keyup.enter.native="submitForm"></el-input>
<img @click="getVerImg" :src="verificationIMG" class="ver-img" alt="">
</el-form-item>
<div class="check">
<el-checkbox v-model="remember">15天免费登录</el-checkbox>
</div>
<el-button class="submit" type="primary" @click="submitForm">登录</el-button>
</el-form>
</div>
@ -34,18 +36,24 @@ import util from '@/libs/util'
export default {
data: function() {
return {
verificationIMG: '',
loginForm: {
username: 'admin',
password: 'admin',
account: 'admin',
password: '111aaa',
random: '',
code: ''
},
loginRules: {
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
account: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
code: [{ required: true, message: '请输入验证码', trigger: 'blur' }],
},
remember: false
};
},
components: {vHead},
mounted(){
this.getVerImg()
},
methods: {
...mapActions('user', [
'login'
@ -53,18 +61,23 @@ export default {
submitForm() {
this.$refs.login.validate(valid => {
if (valid) {
let data = {
username: this.loginForm.username,
password: this.loginForm.password,
remember: this.remember
}
this.login(data).then(() => {
this.login(this.loginForm).then(() => {
let redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : '/index'
this.$router.replace(redirect)
}).catch(() => {})
}).catch(res => {
this.getVerImg()
this.loginForm.code = ''
})
}
})
},
getVerImg(){
if(!this.loginForm.account){
return this.verificationIMG = ''
}
this.loginForm.random = Math.floor(Math.random()*999999999)
this.verificationIMG = this.api.verification+'?random='+`${this.loginForm.random}`
}
},
};
</script>
@ -129,7 +142,7 @@ export default {
border-bottom: 1px solid #e4e4e4;
border-radius: 0 !important;
}
.account,.password{
.account,.password,.code{
z-index: 10;
position: absolute;
top: 11px;
@ -143,8 +156,15 @@ export default {
height: 24px;
background-image: url(../../../assets/img/password.png);
}
.check{
text-align: left;
.code{
width: 22px;
height: 24px;
background-image: url(../../../assets/img/code.png);
}
.ver-img{
position: absolute;
top: -10px;
right: 0;
}
/deep/.el-form-item__error{
top: 105%;
@ -163,15 +183,6 @@ export default {
border-radius: 8px;
border: 0;
}
.links{
margin: 20px 0 20px;
}
.login-tips{
margin-bottom: 20px;
font-size: 16px;
color: #105CB2;
text-align: center;
}
}
}
}

@ -131,13 +131,13 @@
</template>
<script>
import { mapState } from 'vuex'
import axios from 'axios'
import util from '@/libs/util'
export default {
data() {
return {
typeId: this.$route.query.typeId,
schoolId: 1001,
typeList: [],
defaultType: '',
defaultOpenType: [],
@ -179,6 +179,11 @@ export default {
],
}
},
computed: {
...mapState('user', [
'schoolId'
]),
},
mounted() {
this.getType()
if(this.$route.query.download){
@ -241,10 +246,8 @@ export default {
preview(row){
this.$get(`${this.api.previewData}?tableName=${row.name}&tableId=${row.id}`).then(res => {
this.$post(this.api.saveRecord,{
platformUserId: 4,
tableId: row.id,
type: 2,
schoolId: this.schoolId,
}).then(res => {}).catch(res => {})
let comment = res.comment
let previewHead = []
@ -284,7 +287,7 @@ export default {
this.startTime = ''
this.endTime = ''
this.frequency = ''
this.$router.push('/data')
this.$router.push('/data').catch(err => {})
},
handleOpen(){
@ -295,6 +298,8 @@ export default {
confirmDown(){
let fields = this.fields
if(!fields.length) return util.warningMsg('请选择字段')
if(!this.startTime) return util.warningMsg('请选择开始时间')
if(!this.endTime) return util.warningMsg('请选择结束时间')
if(!this.frequency) return util.warningMsg('请选择数据频率')
let invalid = false
if(this.startTime && this.endTime){
@ -327,6 +332,12 @@ export default {
if(invalid) return util.warningMsg('请选择完整区间')
this.$get(`${this.api.isDownload}`,{
tableId: this.curRow.id,
schoolId: this.schoolId,
}).then(res => {
if(res.status != 200) return util.warningMsg(res.message)
let newFields = []
let fieldsList = this.fieldsList
fields.map(n => {
@ -345,17 +356,16 @@ export default {
if(res.data.type != 'multipart/form-data') return util.warningMsg('数据总数为零!')
util.downloadFileDirect(`${this.curRow.showName}.xls`,new Blob([res.data]))
this.$get(`${this.api.downloadRecord}?platformUserId=4&tableId=${this.curRow.id}&fields=${newFields.join()}&startTime=${startTime}&endTime=${endTime}&frequency=${frequency}`).then(res => {}).catch(res => {})
this.$get(`${this.api.downloadRecord}?tableId=${this.curRow.id}&fields=${newFields.join()}` + (startTime ? `&startTime=${startTime}` : '') + (endTime ? `&endTime=${endTime}` : '') + `&frequency=${frequency}`).then(res => {}).catch(res => {})
this.$post(this.api.saveRecord,{
platformUserId: 4,
tableId: this.curRow.id,
type: 1,
schoolId: this.schoolId,
}).then(res => {}).catch(res => {})
}).catch(res => {
msgObj.close()
})
}).catch(res => {})
}
}
};

@ -42,11 +42,11 @@
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'index',
data() {
return {
schoolId: 1001,
keyword: '',
searchTimer: null,
listData:[],
@ -56,6 +56,11 @@ export default {
hotData: []
}
},
computed: {
...mapState('user', [
'schoolId'
]),
},
watch: {
keyword: function(val) {
clearTimeout(this.searchTimer)
@ -147,6 +152,27 @@ export default {
cursor: pointer;
}
}
.hot{
display: flex;
align-items: center;
width: 930px;
margin: 10px auto 0;
.name{
font-size: 14px;
color: #efefef;
}
.list{
flex: 1;
display: inline-flex;
margin-left: 20px;
li{
margin-right: 50px;
color: #568df2;
font-size: 16px;
cursor: pointer;
}
}
}
&.result{
padding: 70px 90px 50px;
background-color: #fff;
@ -160,6 +186,11 @@ export default {
&:-moz-placeholder{color: #999}
}
}
.hot{
.name{
color: #333;
}
}
.tips{
margin-bottom: 50px;
.result{
@ -173,26 +204,5 @@ export default {
}
}
}
.hot{
display: flex;
align-items: center;
width: 930px;
margin: 10px auto 0;
.name{
font-size: 14px;
color: #efefef;
}
.list{
flex: 1;
display: inline-flex;
margin-left: 20px;
li{
margin-right: 50px;
color: #568df2;
font-size: 16px;
cursor: pointer;
}
}
}
}
</style>

@ -10,8 +10,8 @@
</li>
</ul>
<div>
<el-button type="primary" size="small" round @click="addRole" v-auth="'/system/list:角色权限:新增角色'">新增角色</el-button>
<el-button type="primary" size="small" round @click="delAllSelection" v-auth="'/system/list:角色权限:批量删除'">批量删除</el-button>
<el-button type="primary" size="small" round @click="addRole" v-auth>新增角色</el-button>
<el-button type="primary" size="small" round @click="delAllSelection" v-auth>批量删除</el-button>
</div>
</div>
@ -28,10 +28,10 @@
</el-table-column>
<el-table-column label="操作" width="180" align="center">
<template slot-scope="scope">
<el-button type="text" @click="showRole(scope.row)" v-auth="'/system/list:角色权限:查看'">查看</el-button>
<el-button type="text" @click="showRole(scope.row)" v-auth>查看</el-button>
<template v-if="scope.row.id != 1">
<el-button type="text" @click="editRole(scope.row)" v-auth="'/system/list:角色权限:编辑'">编辑</el-button>
<el-button type="text" @click="handleDelete(scope.row)" v-auth="'/system/list:角色权限:删除'">删除</el-button>
<el-button type="text" @click="editRole(scope.row)" v-auth>编辑</el-button>
<el-button type="text" @click="handleDelete(scope.row)" v-auth>删除</el-button>
</template>
</template>
</el-table-column>
@ -42,7 +42,7 @@
</div>
<el-dialog :title="isDetail ? '查看角色' : (isAdd ? '新增角色' : '编辑角色')" :visible.sync="roleVisible" width="500px" @close="closeRole" class="dialog" :close-on-click-modal="false">
<el-form ref="form" :model="form" label-width="100px" label-suffix="" :disabled="isDetail">
<el-form ref="form" :model="form" label-width="85px" label-suffix="" :disabled="isDetail">
<el-form-item label="角色名称">
<el-input v-model="form.roleName " ref="account" placeholder="请输入角色名称"></el-input>
</el-form-item>
@ -57,7 +57,7 @@
</el-form>
<span slot="footer" class="dialog-footer" v-if="!isDetail">
<el-button size="small" @click="roleVisible = false"> </el-button>
<el-button size="small" type="primary" @click="saveData"> </el-button>
<el-button size="small" type="primary" @click="confirm"> </el-button>
</span>
</el-dialog>
</div>
@ -192,7 +192,7 @@ export default {
this.getDetail(row)
this.roleVisible = true
},
async saveData() {
confirm() {
if(!this.form.roleName) return util.warningMsg('请填写角色名称')
if(!this.form.remark) return util.warningMsg('请填写角色描述')
// if(!this.$refs.per.getCheckedKeys().length) return util.warningMsg('')
@ -212,8 +212,7 @@ export default {
isPort: 2
}
this.$post(this.api.doAssign,perData).then(res => {
// console.log(333)
util.successMsg('新增成功')
util.successMsg(this.form.id ? '修改成功' : '新增成功')
this.getData()
this.roleVisible = false
}).catch(res => {})

@ -37,6 +37,7 @@ export default {
name: 'role',
data() {
return {
schoolId: 1001,
keyword: '',
searchTimer: null,
isDetail: false,
@ -80,6 +81,12 @@ export default {
this.getData()
},
download(row){
this.$get(`${this.api.isDownload}`,{
tableId: row.id,
schoolId: this.schoolId,
}).then(res => {
if(res.status != 200) return util.warningMsg(res.message)
let msgObj = util.successMsg('数据正在生成中,请稍等片刻,生成后会自动下载,您可以先访问其他页面。',5000)
axios.get(`${this.api.downloadData}?tableName=${row.tableNme}&table_id=${row.id}&fields=${row.fields}&startTime=${row.startTime ? row.startTime : ''}&endTime=${row.endTime ? row.endTime : ''}&frequency=${row.frequency ? row.frequency : ''}`,{
responseType: 'blob'
@ -104,6 +111,7 @@ export default {
}).catch(res => {
msgObj.close()
})
}).catch(res => {})
}
}
};

@ -5,7 +5,7 @@
<div class="inner">
<div class="text-center">
<img :src="avatar" class="avatar" />
<el-upload :action="this.api.fileupload" :data="{userId: this.userId}" name="file" :limit="1" :on-success="changeAvatar">
<el-upload :headers="{token}" :action="this.api.uploadUserAvatars" name="file" :limit="1" :on-success="changeAvatar">
<el-button type="text" size="small">上传头像</el-button>
</el-upload>
</div>
@ -27,12 +27,15 @@
</template>
<script>
import Setting from '@/setting'
import { mapState,mapActions } from 'vuex'
import info from './info'
import download from './download'
import util from '@/libs/util'
export default {
data() {
return {
token: '',
typeList: [
{
index: '1',
@ -48,22 +51,20 @@ export default {
components: { info,download },
computed: {
...mapState('user', [
'userId','avatar','userName'
'avatar'
]),
},
mounted() {
this.token = util.local.get(Setting.tokenKey)
},
methods: {
//
...mapActions('user', [
'setAvatar'
]),
changeAvatar(res) {
this.setAvatar(res.data.filesResult.fileUrl)
},
uploadHeadImg: function() {
this.$el.querySelector('.hiddenInput').click();
this.setAvatar(res.message)
},
handleSelect(key, keyPath){
console.log(key, keyPath)
this.active = key
},
}

@ -6,13 +6,13 @@
<li>
<label>姓名</label>
<div>
<el-input v-model="personalInformation.userName" clearable></el-input>
<el-input v-model="form.userName" clearable></el-input>
</div>
</li>
<li>
<label>性别</label>
<div>
<el-select v-model="personalInformation.sex">
<el-select v-model="form.sex">
<el-option v-for="item in sexList" :key="item.value" :label="item.name" :value="item.value"></el-option>
</el-select>
</div>
@ -20,12 +20,7 @@
<li>
<label>出生年月日</label>
<div>
<el-date-picker
v-model="personalInformation.dateBirth"
:clearable="false"
class="block-right"
type="date">
</el-date-picker>
<el-date-picker v-model="form.dateBirth" :clearable="false" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd"></el-date-picker>
</div>
</li>
<li>
@ -34,15 +29,15 @@
<div class="child">
<span>国家</span>
<div>
<el-select v-model="personalInformation.countries" placeholder>
<el-option v-for="item in countryList" :key="item.value" :label="item.label" :value="item.value"></el-option>
<el-select v-model="form.countries" placeholder>
<el-option v-for="item in countryList" :key="item.value" :label="item.label" :value="item.label"></el-option>
</el-select>
</div>
</div>
<div class="child">
<span>省份</span>
<div>
<el-select v-model="personalInformation.provinceId" placeholder @change="id => getCity(id,1)">
<el-select v-model="form.provinceId" placeholder @change="id => getCity(id,1)">
<el-option v-for="item in provinceList" :key="item.provinceId" :label="item.provinceName" :value="item.provinceId"></el-option>
</el-select>
</div>
@ -50,7 +45,7 @@
<div class="child">
<span>城市</span>
<div>
<el-select v-model="personalInformation.cityId" placeholder :disabled="personalInformation.provinceId ? false : true">
<el-select v-model="form.cityId" placeholder :disabled="form.provinceId ? false : true">
<el-option v-for="item in cityList" :key="item.cityId" :label="item.cityName" :value="item.cityId"></el-option>
</el-select>
</div>
@ -60,13 +55,13 @@
<li>
<label>证件</label>
<div>
<el-input v-model="personalInformation.idnumber" clearable></el-input>
<el-input v-model="form.idNumber" clearable></el-input>
</div>
</li>
<li>
<label>教育程度</label>
<div>
<el-select v-model="personalInformation.educationDegree" placeholder="请选择教育程度">
<el-select v-model="form.educationDegree" placeholder="请选择教育程度">
<el-option v-for="(item,index) in educationDegreeList" :key="index" :label="item.name" :value="item.value"></el-option>
</el-select>
</div>
@ -84,32 +79,36 @@
<div class="archives" v-for="(archive,index) in archivesList" :key="index" v-show="index == 0 || showArch">
<ul class="list">
<li>
<label>职业</label>
<!-- <label>专业</label> -->
<div class="mul">
<div class="child">
<span>职业</span>
<div>
<el-select v-model="archive.personalCareerId" placeholder="选择职业">
<el-option v-for="item in occupationList" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
</div>
</li>
<li>
<label>国家</label>
</div>
<div class="child">
<span>国家</span>
<div>
<el-select v-model="personalInformation.countries" placeholder>
<el-option v-for="item in countryList" :key="item.value" :label="item.label" :value="item.value" ></el-option>
<el-select v-model="form.countries" placeholder>
<el-option v-for="item in countryList" :key="item.value" :label="item.label" :value="item.label" ></el-option>
</el-select>
</div>
</li>
<li>
<label>学校名称</label>
</div>
<div class="child">
<span>学校名称</span>
<div>
<el-select v-model="archive.schoolId" filterable placeholder="选择学校" @change="id => getSchoolName(id,index)">
<el-option v-for="item in schoolList" :key="item.value" :label="item.schoolName" :value="item.schoolId"></el-option>
</el-select>
</div>
</div>
</div>
</li>
<li>
<label>专业</label>
<div class="mul">
<div class="child">
<span>专业学科</span>
@ -148,20 +147,20 @@
<li>
<label>用户账号</label>
<div>
<el-input v-model="personalInformation.account" clearable></el-input>
<el-input v-model="form.account" clearable></el-input>
</div>
</li>
<li>
<label>手机号</label>
<div>
<span class="val" v-if="personalInformation.phone">{{personalInformation.phone}}</span>
<span class="val" v-if="form.phone">{{form.phone}}</span>
<el-button size="small" @click="bindPhone">更换</el-button>
</div>
</li>
<li>
<label>邮箱</label>
<div>
<span class="val" v-if="personalInformation.email">{{personalInformation.email}}</span>
<span class="val" v-if="form.email">{{form.email}}</span>
<el-button size="small" @click="bindEmail">更换</el-button>
</div>
</li>
@ -177,7 +176,7 @@
</div>
</div>
<el-dialog :title="personalInformation.email ? '更换邮箱' : '绑定邮箱'" :visible.sync="emailVisible" :close-on-click-modal="false" @close="closeEmail" width="30%">
<el-dialog :title="form.email ? '更换邮箱' : '绑定邮箱'" :visible.sync="emailVisible" :close-on-click-modal="false" @close="closeEmail" width="30%">
<el-form ref="form" :model="form" label-width="60px">
<el-form-item label="邮箱">
<el-input placeholder="请输入邮箱" v-model="email"></el-input>
@ -190,12 +189,12 @@
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="emailVisible = false"> </el-button>
<el-button type="primary" @click="emailSubmit"> </el-button>
<el-button size="small" @click="emailVisible = false"> </el-button>
<el-button size="small" type="primary" @click="emailSubmit"> </el-button>
</span>
</el-dialog>
<el-dialog :title="personalInformation.phone ? '更换手机号' : '绑定手机号'" :visible.sync="phoneVisible" :close-on-click-modal="false" @close="closePhone" width="30%">
<el-dialog :title="form.phone ? '更换手机号' : '绑定手机号'" :visible.sync="phoneVisible" :close-on-click-modal="false" @close="closePhone" width="30%">
<el-form ref="form" :model="form" label-width="60px">
<el-form-item label="手机号">
<el-input placeholder="请输入手机号" v-model="phone" maxlength="11"></el-input>
@ -208,8 +207,8 @@
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="phoneVisible = false"> </el-button>
<el-button type="primary" @click="phoneSubmit"> </el-button>
<el-button size="small" @click="phoneVisible = false"> </el-button>
<el-button size="small" type="primary" @click="phoneSubmit"> </el-button>
</span>
</el-dialog>
@ -226,8 +225,8 @@
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="passwordVisible = false"> </el-button>
<el-button type="primary" @click="editPassword"> </el-button>
<el-button size="small" @click="passwordVisible = false"> </el-button>
<el-button size="small" type="primary" @click="editPassword"> </el-button>
</span>
</el-dialog>
</div>
@ -239,7 +238,7 @@ import util from '@/libs/util'
export default {
data() {
return {
personalInformation: {
form: {
name:'',
workNumber:'',
password:"",
@ -249,6 +248,10 @@ export default {
cityName:'',
schoolName:'',
professionalName:'',
experimentName:'',
sex: 1,
dateBirth: '',
educationDegree: ''
},
emailVisible: false,
passwordVisible: false,
@ -274,7 +277,13 @@ export default {
label: '中国'
}
],
form: {},
occupationList: [{
value: 1,
label: '学生'
},{
value: 2,
label: '老师'
}],
provinceList:[],
cityList: [],
educationDegreeList: [
@ -299,23 +308,24 @@ export default {
value: 5
}
],
subjectList: [], //
ProfessionalClassList: [], //
ProfessionalList: [], //
schoolList: [],
curPassword: '',
accountRepeat: false,
archivesList: [],
archivesForm: {
//
personalCareerId: '', //
schoolId: '', //
schoolName: '', //
professionalClassId: '', //
professionalClassName: '', //
disciplineId: '', //
disciplineName: '', //
professionalId: '', //
professionalName: '', //
userId: this.userId
personalCareerId: '',
schoolId: '',
schoolName: '',
professionalClassId: '',
professionalClassName: '',
disciplineId: '',
disciplineName: '',
professionalId: '',
professionalName: '',
},
email: '',
emailBtnText: '发送验证码',
@ -329,15 +339,11 @@ export default {
phoneTimer: null
};
},
computed: {
...mapState('user', [
'userId','avatar','userName'
]),
},
mounted() {
this.getdata();
this.getProvince()
this.getSchoolData()
this.getSubject()
},
methods: {
...mapActions('user', [
@ -348,29 +354,28 @@ export default {
},
getProvince(){
this.$get(this.api.queryProvince).then(res => {
this.provinceList = res.data.list
this.provinceList = res.list
}).catch(res => {})
},
//
getCity(id,type){
this.personalInformation.cityId = 1
this.form.cityId = 1
this.getCityData()
},
getCityData(index){
let provinceId = this.personalInformation.provinceId
let provinceId = this.form.provinceId
this.$get(this.api.queryCity,{provinceId}).then(res => {
this.cityList = res.data.list
this.cityList = res.list
}).catch(res => {})
},
//
getCityName(id,index){
this.archivesList[index].cityName = this.archivesList[index].cityList[id-1].cityName
},
getSchoolName(id,index){
this.archivesList[index].schoolName = this.schoolList[id-1].schoolName
},
getSchoolData(){
let data = {
searchContent: '',
provinceId: '',
cityId: ''
}
this.$get(`${this.api.queryClient}/1/1000`,data).then(res => {
this.schoolList = res.data.list
this.$get(this.api.querySchool,{schoolName: '',provinceId: this.provinceId,cityId: this.cityId}).then(res => {
this.schoolList = res.list
}).catch(res => {})
},
accountChange(){
@ -384,50 +389,93 @@ export default {
}).catch(res => {})
},
getdata() {
this.$get(`${this.api.userInfo}/${this.userId}`)
.then(res => {
this.personalInformation = res.data.userInfo
this.personalInformation.countries = '中国'
this.curPassword = this.personalInformation.password
this.$get(this.api.userInfo).then(res => {
let userInfo = res.userInfo
this.form = Object.assign(userInfo,res.userAccount)
this.originAccount = this.form.account
this.archivesList = res.personalFiles
this.$nextTick(() => {
if(this.personalInformation.provinceId){
if(this.form.provinceId){
this.getCityData(1)
}
if(this.archivesList.length != 0){
this.archivesList.forEach((e,k) =>{
this.$set(e, 'subjectList', this.subjectList)
this.$set(e, 'disciplineId', e.disciplineId ? e.disciplineId : '')
this.$set(e, 'disciplineName', e.disciplineName ? e.disciplineName : '')
this.$set(e, 'professionalClassId', e.professionalClassId ? e.professionalClassId : '')
this.$set(e, 'professionalClassName', e.professionalClassName ? e.professionalClassName : '')
this.$set(e, 'professionalId', e.professionalId ? e.professionalId : '')
this.$set(e, 'professionalName', e.professionalName ? e.professionalName : '')
this.$set(e, 'schoolId', e.schoolId ? e.schoolId : '')
this.$set(e, 'schoolName', e.schoolName ? e.schoolName : '')
if(e.disciplineId){
this.$post(this.api.queryCourseProfessionalClass,[e.disciplineId]).then(res => {
this.$set(e, 'ProfessionalClassList', res.result)
}).catch(res => {})
}else{
this.$set(e, 'ProfessionalClassList', [])
}
if(e.professionalClassId){
this.$get(this.api.queryCourseProfessional,{ professionalClassId: e.professionalClassId }).then(res => {
this.$set(e, 'ProfessionalList', res.result)
}).catch(res => {})
}else{
this.$set(e, 'ProfessionalList', [])
}
})
}else{
this.concatArch()
}
})
.catch(err => {
console.log(err)
});
}).catch(err => {})
},
save() {
if(this.personalInformation.idnumber && !/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)/.test(this.personalInformation.idnumber)) return util.warningMsg('请输入正确的证件号码')
if(this.form.idNumber && !/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)/.test(this.form.idNumber)) return util.warningMsg('请输入正确的证件号码')
if(this.accountRepeat) return util.warningMsg('该账号已存在')
if(this.personalInformation.phone && !/^1[3456789]\d{9}$/.test(this.personalInformation.phone)) return util.warningMsg('请输入正确的手机号')
if(this.personalInformation.email && !/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.personalInformation.email)) return util.warningMsg('请输入正确的邮箱')
let personalInformation = this.personalInformation
let userInfoEntity = {
idnumber: personalInformation.idnumber,
account: personalInformation.account,
cityId: personalInformation.cityId,
countries: personalInformation.countries,
dateBirth: personalInformation.dateBirth,
educationDegree: personalInformation.educationDegree,
email: personalInformation.email,
phone: personalInformation.phone,
provinceId: personalInformation.provinceId,
clientId: personalInformation.clientId,
clientName: personalInformation.clientName,
sex: personalInformation.sex,
userId: personalInformation.userId,
userName: personalInformation.userName,
}
let form = this.form
let hrPersonalFileEntities = []
let archivesList = this.archivesList
archivesList.map(n => {
n.personalCareerId && hrPersonalFileEntities.push({
disciplineId: n.disciplineId,
disciplineName: n.disciplineName,
personalCareerId: n.personalCareerId,
personalFileId: n.personalFileId,
professionalClassId: n.professionalClassId,
professionalClassName: n.professionalClassName,
professionalId: n.professionalId,
professionalName: n.professionalName,
schoolId: n.schoolId,
schoolName: n.schoolName,
userId: form.userId,
})
})
let data = {
userInfoEntity,
personalFileEntities: this.archivesList
hrUserAccount: {
account: form.account,
userId: form.userId,
workNumber: form.workNumber,
},
hrUserInfo: {
cityId: form.cityId,
countries: form.countries,
dateBirth: form.dateBirth,
educationDegree: form.educationDegree,
idNumber: form.idNumber,
provinceId: form.provinceId,
schoolId: form.schoolId,
sex: form.sex,
userId: form.userId,
userName: form.userName,
},
hrPersonalFileEntities
}
this.$post(this.api.updateUser,data).then(res => {
if(res.success){
this.setUserName(personalInformation.userName)
if(res.status == 200){
this.setUserName(form.userName)
util.successMsg('提交成功')
this.$router.back()
}else{
@ -436,70 +484,61 @@ export default {
}).catch(res => {})
},
concatArch(isLoadData) {
concatArch() {
this.archivesList = this.archivesList.concat({
isNew: true,
personalCareerId: '', //
schoolId: '', //
schoolName: '', //
subjectList: this.subjectList, //
disciplineId: '', //
disciplineName: '', //
ProfessionalClassList: [], //
professionalClassId: '', //
professionalClassName: '', //
ProfessionalList: [], //
professionalId: '', //
professionalName: '', //
userId: this.userId,
countries: '中国',
personalCareerId: '',
schoolId: '',
schoolName: '',
subjectList: this.subjectList,
disciplineId: '',
disciplineName: '',
ProfessionalClassList: [],
professionalClassId: '',
professionalClassName: '',
ProfessionalList: [],
professionalId: '',
professionalName: '',
personalFileId: ''
})
if(!isLoadData){
this.$nextTick(() => {
document.body.scrollTop = document.querySelector('.content-box').scrollHeight
document.documentElement.scrollTop = document.querySelector('.content-box').scrollHeight
})
}
},
addArch() {
// let isEmpty = false
// this.archivesList.forEach((n,k) => {
// if(!n.personalCareerId) isEmpty = true
// })
// if(isEmpty) return this.$message.warning('')
let isEmpty = false
this.archivesList.forEach((n,k) => {
if(!n.personalCareerId) isEmpty = true
})
if(isEmpty) return util.warningMsg('请选择职业')
this.showArch = true
this.concatArch()
},
bindEmail() {
this.email = this.personalInformation.email
this.email = this.form.email
this.emailVisible = true
},
bindPhone() {
this.phone = this.personalInformation.phone
this.phone = this.form.phone
this.phoneVisible = true
},
bindPassword() {
this.passwordVisible = true
},
editPassword() {
if(!this.passwordForm.password) return this.$message.warning('请输入原密码')
if(!this.passwordForm.newPassword) return this.$message.warning('请输入新密码')
if(!this.passwordForm.reNewPassword) return this.$message.warning('请确认新密码')
if(this.passwordForm.newPassword.length < 6 || this.passwordForm.reNewPassword.length < 6) return this.$message.warning('请输入6位数以上的密码')
if(this.passwordForm.newPassword !== this.passwordForm.reNewPassword) return this.$message.warning('输入的新密码不一致,请重新确认')
if(this.passwordForm.password === this.passwordForm.newPassword) return this.$message.warning('原密码跟新密码不能一致')
if(!this.passwordForm.password) return util.warningMsg('请输入原密码')
if(!this.passwordForm.newPassword) return util.warningMsg('请输入新密码')
if(!this.passwordForm.reNewPassword) return util.warningMsg('请确认新密码')
if(this.passwordForm.newPassword.length < 6 || this.passwordForm.reNewPassword.length < 6) return util.warningMsg('请输入6位数以上的密码')
if(this.passwordForm.newPassword !== this.passwordForm.reNewPassword) return util.warningMsg('输入的新密码不一致,请重新确认')
if(this.passwordForm.password === this.passwordForm.newPassword) return util.warningMsg('原密码跟新密码不能一致')
let data = this.passwordForm
data.userid = this.userId
data.accountId = this.form.id
this.$post(this.api.examinePassword,data)
.then(res => {
if(res.errmessage == 'success'){
this.$message.success('更换成功')
if(res.status == 200){
util.successMsg('更换成功')
this.passwordVisible = false
}
}).catch(err => {
console.log(err)
})
}).catch(err => {})
},
closePassword() {
this.passwordForm = {
@ -515,6 +554,136 @@ export default {
document.documentElement.scrollTop = document.querySelector('.content-box').scrollHeight
})
},
//
getSubject(){
this.$post(this.api.queryCourseDiscipline).then(res => {
this.subjectList = res.result
}).catch(res => {})
},
//
clearClass(){
this.archivesForm.professionalClassId = '',
this.archivesForm.professionalId = ''
},
//
getProfessionalClass(val){
this.clearClass()
if(val){
let obj = {}
obj = this.subjectList.find((item)=>{
return item.disciplineId === val
});
this.archivesForm.disciplineName = obj.disciplineName
this.getProfessionalClassData(val)
}
},
clearItemClass(index){
this.archivesList[index].professionalClassId = ''
this.archivesList[index].professionalClassName = ''
this.archivesList[index].professionalId = ''
this.archivesList[index].professionalName = ''
// this.archivesList.map(e =>{
// if(e.disciplineId == item){
// e.professionalClassId = '',
// e.professionalClassName = '',
// e.professionalId = '',
// e.professionalName = ''
// }
// })
},
getItemProfessionalClass(item,index){
this.clearItemClass(index)
if(item){
let obj = {}
obj = this.subjectList.find(r =>{
return r.disciplineId === item
});
this.$post(this.api.queryCourseProfessionalClass,[item]).then(res => {
this.archivesList.map(e =>{
if(e.disciplineId == item){
e.ProfessionalClassList = res.result
e.disciplineName = obj.disciplineName
}
})
}).catch(res => {})
}
},
getProfessionalClassData(value){
this.$post(this.api.queryCourseProfessionalClass,[value]).then(res => {
this.ProfessionalClassList = res.result
}).catch(res => {})
},
//
clearProfess(){
this.archivesForm.professionalId = ''
},
//
getProfessional(val){
this.clearProfess()
if(val){
let obj = {}
obj = this.ProfessionalClassList.find((item)=>{
return item.professionalClassId === val
})
this.archivesForm.professionalClassName = obj.professionalClassName
this.getProfessionalData(val)
}
},
clearItemProfess(index){
this.archivesList[index].professionalId = ''
this.archivesList[index].professionalName = ''
// this.archivesList.map(e =>{
// if(e.professionalClassId == item){
// e.professionalId = '',
// e.professionalName = ''
// }
// })
},
getItemProfessional(item,index){
this.clearItemProfess(index)
if(item){
this.$get(this.api.queryCourseProfessional,{ professionalClassId: item }).then(res => {
this.archivesList.map(e =>{
if(e.professionalClassId == item){
let obj = {}
obj = e.ProfessionalClassList.find(r =>{
return r.professionalClassId === item
})
e.ProfessionalList = res.result
e.professionalClassName = obj.professionalClassName
}
})
}).catch(res => {})
}
},
getProfessionalData(value){
this.$get(this.api.queryCourseProfessional,{professionalClassId: value}).then(res => {
this.ProfessionalList = res.result
}).catch(res => {})
},
//
getStuGrade(val){
if(val){
let obj = {}
obj = this.ProfessionalList.find(r =>{
return r.professionalId === val;
})
this.archivesForm.professionalName = obj.professionalName
}
},
getItemStuGrade(item){
if(item){
this.archivesList.map(e =>{
if(e.professionalId == item){
let obj = {}
obj = e.ProfessionalList.find(r =>{
return r.professionalId === item;
})
e.professionalName = obj.professionalName
}
})
}
},
emailCountdown(){
let count = 60
if(!this.emailTimer){
@ -557,32 +726,36 @@ export default {
}
},
sendEmailCode(){
if(!this.email) return this.$message.warning('请输入邮箱')
if(!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.email)) return this.$message.warning('请输入正确的邮箱')
if(!this.email) return util.warningMsg('请输入邮箱')
if(!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.email)) return util.warningMsg('请输入正确的邮箱')
let data = {
userId: this.userId,
userId: this.form.userId,
email: this.email,
types: 1
}
this.$post(this.api.findPasswordByEmail,data).then(res => {
this.$post(this.api.sendPhoneOrEmailCode,data).then(res => {
if(res.message.opener){
this.emailCountdown()
this.emailOpener = res.data
this.emailOpener = res.message.opener
}else{
util.errorMsg(res.message)
}
}).catch(res => {})
},
emailSubmit(){
if(!this.email) return this.$message.warning('请输入邮箱')
if(!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.email)) return this.$message.warning('请输入正确的邮箱')
if(!this.emailCode) return this.$message.warning('请输入验证码')
if(!this.email) return util.warningMsg('请输入邮箱')
if(!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.email)) return util.warningMsg('请输入正确的邮箱')
if(!this.emailCode) return util.warningMsg('请输入验证码')
let data = {
userId: this.userId,
userId: this.form.userId,
email: this.email,
types: 1,
code: this.emailCode,
opener: this.emailOpener
}
this.$put(this.api.bingEmail,data).then(res => {
this.$message.success('绑定成功')
this.personalInformation.email = this.email
this.$post(this.api.bindPhoneOrEmail,data).then(res => {
util.successMsg('绑定成功')
this.form.email = this.email
this.emailVisible = false
}).catch(res => {})
},
@ -592,32 +765,37 @@ export default {
}
},
sendPhoneCode(){
if(!this.phone) return this.$message.warning('请输入手机号')
if(!/^1[3456789]\d{9}$/.test(this.phone)) return this.$message.warning('请输入正确的手机号')
if(!this.phone) return util.warningMsg('请输入手机号')
if(!/^1[3456789]\d{9}$/.test(this.phone)) return util.warningMsg('请输入正确的手机号')
let data = {
userId: this.userId,
userId: this.form.userId,
phone: this.phone,
types: 2
}
this.$post(this.api.sendPhoneCode,data).then(res => {
this.$post(this.api.sendPhoneOrEmailCode,data).then(res => {
if(res.message.opener){
this.phoneCountdown()
this.phoneOpener = res.data
this.phoneOpener = res.message.opener
}else{
util.errorMsg(res.message)
}
}).catch(res => {})
},
phoneSubmit(){
if(!this.phone) return this.$message.warning('请输入手机号')
if(!/^1[3456789]\d{9}$/.test(this.phone)) return this.$message.warning('请输入正确的手机号')
if(!this.phoneCode) return this.$message.warning('请输入验证码')
if(!this.phone) return util.warningMsg('请输入手机号')
if(!/^1[3456789]\d{9}$/.test(this.phone)) return util.warningMsg('请输入正确的手机号')
if(!this.phoneCode) return util.warningMsg('请输入验证码')
let data = {
userId: this.userId,
userId: this.form.userId,
phone: this.phone,
types: 2,
code: this.phoneCode,
opener: this.phoneOpener
}
this.$put(this.api.findPasswordByPhone,data).then(res => {
this.$message.success('绑定成功')
this.personalInformation.phone = this.phone
this.$post(this.api.bindPhoneOrEmail,data).then(res => {
util.successMsg('绑定成功')
this.form.phone = this.phone
this.phoneVisible = false
}).catch(res => {})
},

@ -7,7 +7,7 @@
<div class="date">
<span class="name">使用期限</span>
<div class="val">
{{item.startTime}}<br><br>{{item.endTime}}
{{item.endTime}}
</div>
</div>
<p class="surplus" v-if="item.deadline"><span class="name">剩余期限</span><span class="num">{{item.deadline}}</span> </p>
@ -63,7 +63,7 @@
<h6 class="title">按数据库统计使用概况</h6>
<div>
<el-button type="primary" size="small" v-auth="'/system/list:员工管理:批量导入'" @click="exportDatabase">导出数据</el-button>
<el-button type="primary" size="small" @click="exportDatabase" v-auth="'/stat/list:数据库统计导出'">导出数据</el-button>
</div>
</div>
@ -84,7 +84,7 @@
<div class="flex j-between">
<h6 class="title">按月份统计数据库使用概况</h6>
<div>
<el-button type="primary" size="small" v-auth="'/system/list:员工管理:批量导入'" @click="exportDatabaseByMonth">导出数据</el-button>
<el-button type="primary" size="small" @click="exportDatabaseByMonth" v-auth="'/stat/list:月份统计导出'">导出数据</el-button>
</div>
</div>
@ -111,12 +111,12 @@
</template>
<script>
import { mapState } from 'vuex'
import axios from 'axios'
import util from '@/libs/util'
export default {
data() {
return {
schoolId: 1001,
schoolName: '',
productList: [],
userCount: '',
@ -151,6 +151,11 @@ export default {
active: false
}
},
computed: {
...mapState('user', [
'schoolId'
]),
},
watch: {
keyword: function(val) {
clearTimeout(this.searchTimer)
@ -174,8 +179,8 @@ export default {
},
methods: {
getData(){
this.$get(`${this.api.getProductInfoBySchoolId}?schoolId=31`).then(res => {
let list = res.list
this.$get(`${this.api.getProductInfoBySchoolId}?schoolId=${this.schoolId}`).then(res => {
let list = res.message
list.map(n => {
n.startTime = util.formatDate('yyyy-MM-dd',new Date(n.startTime))
n.endTime = util.formatDate('yyyy-MM-dd',new Date(n.endTime))
@ -299,19 +304,21 @@ export default {
.left{
margin-right: 20px;
.school{
width: 200px;
margin-bottom: 15px;
font-size: 20px;
color: #568DF2;
text-align: center;
}
.product{
width: 200px;
padding: 15px;
margin-bottom: 15px;
background-color: #fff;
border-radius: 8px;
.product-name{
margin-bottom: 15px;
font-size: 16px;
font-weight: bold;
color: #568DF2;
}
.date{
@ -319,13 +326,13 @@ export default {
align-items: center;
.val{
text-align: center;
line-height: 1.8;
line-height: 1;
font-size: 15px;
color: $main-color;
}
}
.surplus{
margin-top: 15px;
margin-top: 10px;
.num{
font-size: 24px;
color: $main-color;

@ -33,9 +33,9 @@
</li>
</ul>
<div>
<el-button type="primary" size="small" round @click="addTeacher" v-auth="'/system/list:员工管理:新增员工'">新增员工</el-button>
<el-button type="primary" size="small" round @click="batchImport" v-auth="'/system/list:员工管理:批量导入'">批量导入</el-button>
<el-button type="primary" size="small" round @click="delAllSelection" v-auth="'/system/list:员工管理:批量删除'">批量删除</el-button>
<el-button type="primary" size="small" round @click="addTeacher" v-auth="'/user/list:新增用户'">新增账号</el-button>
<el-button type="primary" size="small" round @click="batchImport" v-auth>批量导入</el-button>
<el-button type="primary" size="small" round @click="delAllSelection" v-auth>批量删除</el-button>
</div>
</div>
@ -48,12 +48,12 @@
<el-table-column prop="workNumber" label="工号/学号" align="center"></el-table-column>
<el-table-column label="权限状态" align="center">
<template slot-scope="scope">
{{scope.row.disableAccount ? '禁用' : '启用'}}
{{scope.row.isEnable ? '启用' : '禁用'}}
</template>
</el-table-column>
<el-table-column label="账号角色" align="center">
<template slot-scope="scope">
{{roleList.find(n => n.id == scope.row.roleId) ? roleList.find(n => n.id == scope.row.roleId).roleName : ''}}
{{scope.row.roleId == '0' ? '用户' : (roleList.find(n => n.id == scope.row.roleId) ? roleList.find(n => n.id == scope.row.roleId).roleName : '')}}
</template>
</el-table-column>
<el-table-column prop="loginNumber" label="登录次数" align="center">
@ -64,11 +64,11 @@
<el-table-column prop="lastLoginTime" label="上次登录时间" width="160" align="center"></el-table-column>
<el-table-column label="操作" align="center" width="260">
<template slot-scope="scope">
<el-button type="text" @click="show(scope.row)" v-auth="'/system/list:员工管理:查看'">查看</el-button>
<el-button type="text" @click="edit(scope.row)" v-auth="'/system/list:员工管理:编辑'">编辑</el-button>
<el-button type="text" @click="resetPassword(scope.row)" v-auth="'/system/list:员工管理:重置密码'">重置密码</el-button>
<el-button type="text" @click="handleDelete(scope.row)" v-auth="'/system/list:员工管理:删除'">删除</el-button>
<el-switch v-model="scope.row.disableAccount" :active-value="0" :inactive-value="1" style="margin: 0 10px 0 5px" :active-text="scope.row.disableAccount ? '关' : '开'" @change="switchOff($event,scope.row,scope.$index)"></el-switch>
<el-button type="text" @click="show(scope.row)" v-auth>查看</el-button>
<el-button type="text" @click="edit(scope.row)" v-auth>编辑</el-button>
<el-button type="text" @click="resetPassword(scope.row)" v-auth>重置密码</el-button>
<el-button type="text" @click="handleDelete(scope.row)" v-auth>删除</el-button>
<el-switch v-model="scope.row.isEnable" :active-value="1" :inactive-value="0" style="margin: 0 10px 0 5px" :active-text="scope.row.isEnable ? '开' : '关'" @change="switchOff($event,scope.row,scope.$index)" v-auth="'/user/list:禁用'"></el-switch>
</template>
</el-table-column>
</el-table>
@ -76,8 +76,8 @@
<el-pagination background layout="total,prev, pager, next" :current-page="page" @current-change="handleCurrentChange" :total="total"></el-pagination>
</div>
<el-dialog :title="isDetail ? '查看员工' : (form.userId ? '编辑员工' : '新增员工')" :visible.sync="userVisible" width="500px" @close="closeUser" class="dialog" :close-on-click-modal="false">
<el-form ref="form" :model="form" :rules="rules" label-width="110px" label-suffix="" :disabled="isDetail">
<el-dialog :title="isDetail ? '查看账号' : (form.userId ? '编辑账号' : '新增账号')" :visible.sync="userVisible" width="500px" @close="closeUser" class="dialog" :close-on-click-modal="false">
<el-form ref="form" :model="form" :rules="rules" label-width="105px" label-suffix="" :disabled="isDetail">
<el-form-item prop="account" label="账号">
<el-input v-model="form.account" ref="account" placeholder="请输入职工账号" @change="accountChange"></el-input>
</el-form-item>
@ -85,9 +85,10 @@
<el-input v-model="form.userName" placeholder="请输入员工姓名"></el-input>
</el-form-item>
<el-form-item prop="roleId" label="账号角色">
<el-select v-model="form.roleId" placeholder="请选择账号角色">
<el-option v-for="(item,index) in roleList" :key="index" :label="item.roleName" :value="item.id"></el-option>
</el-select>
<el-radio v-model="defaultUser" label="user" disabled>用户</el-radio>
<el-radio-group v-model="form.roleId">
<el-radio v-for="(item,index) in roleList" :key="index" :label="item.id">{{item.roleName}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item prop="uniqueIdentification" label="唯一标识">
<el-input disabled v-model="form.uniqueIdentification" placeholder="唯一标识"></el-input>
@ -111,7 +112,7 @@
<el-dialog title="批量导入" :visible.sync="importVisible" width="400px" @close="closeImport" :close-on-click-modal="false">
<div class="upload-wrap" :class="{lg: uploadFaild}">
<el-button class="download" size="small" @click="downLoad"><img src="../../../assets/img/download.png" alt=""> 模板下载</el-button>
<el-upload ref="import" accept=".xls,.xlsx" :on-remove="handleRemove" :on-error="uploadError" :on-success="uploadSuccess" :before-remove="beforeRemove" :limit="1" :on-exceed="handleExceed" :action="this.api.uploadFile" :file-list="uploadList" :data="{schoolId: this.schoolId}" name="file" :auto-upload="false">
<el-upload ref="import" accept=".xls,.xlsx" :headers="{token}" :on-remove="handleRemove" :on-error="uploadError" :on-success="uploadSuccess" :before-remove="beforeRemove" :limit="1" :on-exceed="handleExceed" :action="this.api.uploadFile" :file-list="uploadList" :data="{schoolId: this.schoolId}" name="file" :auto-upload="false">
<el-button size="small"><img src="../../../assets/img/upload.png" alt=""> 上传文件</el-button>
</el-upload>
<div class="link" v-if="uploadFaild">
@ -134,7 +135,7 @@ import util from '@/libs/util'
export default {
data() {
return {
schoolId: 1001,
token: '',
month: '',
monthList: [
{
@ -171,11 +172,13 @@ export default {
isDetail: false,
userVisible: false,
roleList: [],
defaultUser: 'user',
form: {
platformId: Setting.platformId,
// type: 1, //
// type: 1, // 0-> 1->
account: '',
userId: '',
accountId: '',
userName: '',
roleId: '',
phone: '',
@ -183,7 +186,8 @@ export default {
workNumber: '',
email: '',
schoolId: this.schoolId,
password: ''
password: '',
isEnable: 1
},
rules: {
account: [
@ -197,9 +201,6 @@ export default {
userName: [
{ required: true, message: '请输入用户姓名', trigger: 'blur' }
],
roleId: [
{ required: true, message: '请选择账号角色', trigger: 'change' }
],
workNumber: [
{ required: true, message: '请输入工号/学号', trigger: 'blur' },
{
@ -239,11 +240,8 @@ export default {
},
computed: {
...mapState('user', [
'clientId','clientName'
'schoolId'
]),
...mapState('layout', [
'isIE'
])
},
watch: {
keyword: function(val) {
@ -272,6 +270,7 @@ export default {
}
},
mounted(){
this.token = util.local.get(Setting.tokenKey)
this.form.schoolId = this.schoolId
this.getData()
this.getRole()
@ -280,7 +279,7 @@ export default {
getData(){
this.$post(this.api.getUserList,{
createTime: this.startTime,
disableAccount: this.status,
isEnable: this.status,
endTime: this.endTime,
keyWord: this.keyword,
pageNum: this.page,
@ -310,15 +309,14 @@ export default {
type: 'info',
customClass: 'normal'
}).then(() => {
let data = {
this.$get(this.api.resetPwd,{
newPwd: Setting.initialPassword,
userId: row.userId,
password: Setting.initialPassword
}
this.$post(this.api.userinfoUpdate,data).then(res => {
if(res.success){
util.successMsg('重置成功')
}).then(res => {
if(res.message == 'success'){
this.$message.success('重置成功')
}else{
util.errorMsg('重置失败')
this.$message.error('重置失败')
}
}).catch(res => {})
}).catch(() => {})
@ -360,14 +358,15 @@ export default {
this.userVisible = true
this.isAddteacher = true
},
getDetail(userId){
getDetail(accountId){
this.userVisible = true
this.$post(`${this.api.getDetail}?userId=${userId}`).then(res => {
this.$post(`${this.api.getDetail}?accountId=${accountId}`).then(res => {
let data = res.data
this.form = {
platformId: Setting.platformId,
account: data.account,
userId: data.userId,
accountId,
userName: data.userName,
roleId: data.roleId,
phone: data.phone ? data.phone : '',
@ -375,7 +374,8 @@ export default {
workNumber: data.workNumber,
email: data.email,
schoolId: data.schoolId,
password: ''
password: '',
isEnable: data.isEnable
}
this.originalAccount = data.account
this.originalWorkNumber = data.workNumber
@ -384,11 +384,11 @@ export default {
edit(row){
this.isDetail = false
this.isAddteacher = false
this.getDetail(row.userId)
this.getDetail(row.accountId)
},
show(row){
this.isDetail = true
this.getDetail(row.userId)
this.getDetail(row.accountId)
},
confirm(){
this.$refs.form.validate((valid) => {
@ -397,6 +397,7 @@ export default {
if(this.workNumberRepeat) return util.warningMsg('该工号已存在')
let data = this.form
if(!data.userId) data.uniqueIdentification = new Date().getTime()
if(!data.roleId) data.roleId = '0'
if(this.form.userId){
this.$post(this.api.modifyUser,data).then(res => {
this.userVisible = false
@ -417,22 +418,27 @@ export default {
this.$confirm('此删除操作不可逆,是否确认删除选中项?', '提示', {
type: 'warning'
}).then(() => {
let data = {
staffIds: row.staffId
}
this.$del(this.api.deleteStaffs,data).then(res => {
this.$post(`${this.api.deleteUser}?accountIds=${row.accountId}`).then(res => {
util.successMsg('删除成功')
this.getData()
}).catch(res => {})
}).catch(() => {})
},
switchOff(val,row,index) {
let data = {
id: row.id,
isDisable: val
}
this.$post(this.api.updateClient,data).then((res) => {
val == 1 ? util.warningMsg('该用户权限已关闭') : util.successMsg('该用户权限已激活')
this.$post(this.api.modifyUser,{
account: row.account,
accountId: row.accountId,
isEnable: val,
roleId: row.roleId,
userId: row.userId,
userName: row.userName,
workNumber: row.workNumber,
platformId: Setting.platformId,
password: '',
schoolId: this.schoolId,
phone: ''
}).then((res) => {
val == 1 ? util.successMsg('启用成功') : util.successMsg('禁用成功')
}).catch((res) => {})
},
handleSelectionChange(val) {
@ -442,15 +448,12 @@ export default {
if(this.multipleSelection.length != ''){
let newArr = this.multipleSelection
let delList = newArr.map(item => {
return item.userId
return `accountIds=${item.accountId}`
})
this.$confirm(`此批量删除操作不可逆,是否确认删除${util.ellipsisStr(newArr[0].userName)}${newArr.length}个选中项`, '提示', {
this.$confirm(`此批量删除操作不可逆,是否确认删除?`, '提示', {
type: 'warning'
}).then(() => {
let data = {
staffIds: delList.join(',')
}
this.$del(this.api.deleteStaffs,data).then(res => {
this.$post(`${this.api.deleteUser}?${delList.join('&')}`).then(res => {
this.$refs.table.clearSelection()
util.successMsg('删除成功')
this.getData()
@ -474,6 +477,7 @@ export default {
location.href = this.api.downloadStaffTemp
},
showFaild(){
this.importVisible = false
location.href = `${this.api.export_failure}?token=${this.token}`
},
handleExceed(files, fileList) {
@ -485,6 +489,7 @@ export default {
this.uploadFaild = false
if(res.status == 200){
if(res.data.token){
util.errorMsg('导入失败,请下载失败模板查看原因')
this.token = res.data.token
this.uploadFaild = true
}else{

@ -3,7 +3,7 @@
* 当传入的权限当前用户没有时会移除该组件
* 用例<Tag v-auth>text</Tag> <Tag v-auth="'user:'">text</Tag>
* */
import store from '@/store';
import store from '@/store'
export default {
inserted (el, binding, vnode) {
@ -11,14 +11,14 @@ export default {
if(binding.value){
btnText = binding.value
}else{
btnText = `${vnode.context.$route.name}:${el.innerText}`
btnText = `${vnode.context.$route.path}:${el.innerText}`
}
const btnPermissions = store.state.btnPermissions;
const btnPermissions = store.state.auth.btns
if (btnText && btnPermissions && btnPermissions.length) {
const isPermission = btnPermissions.includes(btnText);
const isPermission = btnPermissions.includes(btnText)
if (!isPermission) {
el.parentNode && el.parentNode.removeChild(el);
el.parentNode && el.parentNode.removeChild(el)
}
}
}

@ -2,72 +2,78 @@ import axios from 'axios'
import util from '@/libs/util'
import router from '@/router/index'
import Setting from '@/setting'
import store from '@/store'
const service = axios.create({
baseURL: Setting.apiBaseURL,
timeout: 10000000
})
// post请求头
service.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'
// 请求拦截器
// service.interceptors.request.use(config => {
// if (sessionStorage.getItem('token')) {
// // 存在将token写入 request header
// config.headers.Authorization = `${sessionStorage.getItem('token')}`;
// }
// return config;
// }, err => {
// util.errorMsg({
// message: '退出登陆',
// onClose: function () {
// router.push({name: 'login'});
// }
// })
// return Promise.reject(err);
// })
service.interceptors.request.use(config => {
let token = util.local.get(Setting.tokenKey)
if(token) config.headers.token = token
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
return config
},err => {
util.errorMsg({
message: '退出登陆',
onClose: function () {
router.push({name: '/login'})
}
})
return Promise.reject(err)
})
// 响应拦截器
service.interceptors.response.use(
response => {
const res = response.data
// if (res.status == 200) {
if(res.status == 200) {
return Promise.resolve(res).catch(e => {})
}else if(!res.status){
return Promise.resolve(res).catch(e => {})
// } else {
// switch (res.code) {
// case 201:
// util.errorMsg(res.message ? res.message : '数据请求异常')
// break;
// default:
// Promise.reject(res).catch(e => {})
// }
// return Promise.reject(res).catch(e => {})
// }
}else {
util.errorMsg(res.message)
return Promise.reject(res)
}
},
// 服务器状态码不是200的情况
error => {
if (error.res.status) {
switch (error.res.status) {
if (error.response.status) {
switch (error.response.status) {
// 401: 未登录
// 未登录则跳转登录页面,并携带当前页面的路径
// 在登录成功后返回当前页面,这一步需要在登录页操作。
case 500:
case 401:
util.local.remove(Setting.storeKey)
util.local.remove(Setting.tokenKey)
util.errorMsg('登录过期,请重新登录')
setTimeout(() => {
router.replace({
path: '/login',
// query: { redirect: router.currentRoute.fullPath }
});
break;
query: {
redirect: router.currentRoute.fullPath
}
})
}, 1000)
break
case 500:
util.errorMsg('网络错误')
break
// 403 token过期
// 登录过期对用户进行提示
// 清除本地token和清空vuex中token对象
// 跳转登录页面
case 403:
// Toast({
// message: '登录过期,请重新登录',
// duration: 1000,
// forbidClick: true
// });
util.local.remove(Setting.storeKey)
util.local.remove(Setting.tokenKey)
util.errorMsg('登录过期,请重新登录')
// 清除token
// store.commit('loginSuccess', null);
// 跳转登录页面,并将要浏览的页面fullPath传过去,登录成功后跳转需要访问的页面
@ -77,20 +83,19 @@ service.interceptors.response.use(
query: {
redirect: router.currentRoute.fullPath
}
});
})
}, 1000)
break;
break
// 404请求不存在
case 404:
router.replace({
path: '/404',
})
break;
util.errorMsg('网络请求不存在!')
break
// 其他错误,直接抛出错误提示
default:
util.errorMsg(error.response.data.message)
Promise.reject(res)
}
return Promise.reject(error.res)
return Promise.reject(error.response)
}
}
);
@ -98,11 +103,7 @@ service.interceptors.response.use(
function get(url, params){
return new Promise((resolve, reject) =>{
service.get(url, {params: params}).then(res => {
if(res){
resolve(res)
}else{
reject(res)
}
}).catch(err => {
reject(err)
})
@ -112,11 +113,7 @@ function get(url, params){
function post(url, params){
return new Promise((resolve, reject) =>{
service.post(url,params).then(res => {
// if(res){
resolve(res)
// }else{
// reject()
// }
}).catch(err => {
reject(err.data)
})
@ -128,11 +125,7 @@ function del(url, params){
service.delete(url, {
params
}).then(res => {
if(res){
resolve(res)
}else{
reject()
}
}).catch(err => {
reject(err.data)
})
@ -144,11 +137,7 @@ function put(url, params){
service.put(url, {
params
}).then(res => {
if(res){
resolve(res)
}else{
reject()
}
}).catch(err => {
reject(err.data)
})

@ -3,13 +3,25 @@ import Setting from '@/setting'
import util from '@/libs/util'
router.beforeEach((to, from, next) => {
document.title = Setting.titleSuffix;
const role = util.local.get(Setting.usernameKey);
document.title = Setting.titleSuffix
const role = util.local.get(Setting.tokenKey)
if (!role && to.path !== '/login') {
next('/login')
} else if(role && to.path == '/login') {
next('/index')
} else {
let mg = from.query.mg
if(mg){
if(!to.query.mg){
next({
path: to.path,
query: {mg}
})
}else{
next()
}
}else{
next()
}
}
});

@ -64,7 +64,7 @@ const Setting = {
// 相同路由,不同参数间进行切换,是否强力更新
sameRouteForceUpdate: false,
// 是否使用动态路由
dynamicRoute: false,
dynamicRoute: true,
// 文件上传
upload: {
apiURL: 'http://8.134.8.197:8001',

@ -1,10 +1,4 @@
const getters = {
userId: state => state.user.info.userId,
roleId: state => state.user.info.roleId,
userName: state => state.user.info.userName,
account: state => state.user.info.account,
phone: state => state.user.info.phone,
clientId: state => state.user.info.clientId,
clientName: state => state.user.info.clientName,
}
export default getters

@ -0,0 +1,26 @@
/**
* 权限管理
* */
export default {
namespaced: true,
state: {
btns: [],
routes: []
},
mutations: {
SET_BTN_AUTH: (state, btns) => {
state.btns = btns
},
SET_ROUTE: (state, routes) => {
state.routes = routes
},
},
actions: {
addBtnAuth({ state,commit },btns) {
commit('SET_BTN_AUTH',btns)
},
addRoutes({ state,commit },routes) {
commit('SET_ROUTE',routes)
}
}
}

@ -1,32 +0,0 @@
/**
* 成绩管理
* */
export default {
namespaced: true,
state: {
id: '',
assessmentId: '',
assessmentName: '',
classId: '',
score: 0,
timeSpent: 0
},
getters: {
},
mutations: {
SET_INFO: (state, info) => {
state.id = info.id
state.assessmentId = info.assessmentId
state.assessmentName = info.assessmentName
state.classId = info.classId
state.score = info.score
state.timeSpent = info.timeSpent
},
},
actions: {
setInfo({ commit },info) {
commit('SET_INFO',info)
},
}
}

@ -1,19 +0,0 @@
/**
* 客户管理
* */
export default {
namespaced: true,
state: {
provinceList: []
},
mutations: {
SET_PROVINCE: (state, provinceList) => {
state.provinceList = provinceList
},
},
actions: {
setProvince({ commit, state, dispatch },provinceList) {
commit('SET_PROVINCE',provinceList)
},
}
}

@ -1,47 +0,0 @@
/**
* 试卷管理
* */
export default {
namespaced: true,
state: {
degreeList: [
{
id: 0,
label: '简单'
},{
id: 1,
label: '一般'
},{
id: 2,
label: '较难'
},{
id: 3,
label: '很难'
},
],
practiseId: '',
paperId: '',
practiseName: '',
isContinue: '',
identification: '',
},
getters: {
getDegreeName: state => id => {
return id != null ? state.degreeList.find(n => n.id == id).label : ''
}
},
mutations: {
SET_INFO: (state, info) => {
state.practiseId = info.practiseId
state.paperId = info.paperId
state.practiseName = info.practiseName
state.isContinue = info.isContinue
state.identification = info.identification
},
},
actions: {
setInfo({ commit },info) {
commit('SET_INFO',info)
},
}
}

@ -1,4 +1,4 @@
import addRoutes from '@/libs/route/addRoutes'
import Setting from '@/setting'
import util from '@/libs/util'
import { Message } from 'element-ui'
@ -12,79 +12,47 @@ export default {
namespaced: true,
state: {
avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
token: '',
userId: '',
roleId: '',
userName: '',
account: '',
phone: '',
clientId: '',
clientName: '',
schoolId: '',
isManager: false
},
mutations: {
SET_INFO: (state, info) => {
info.avatar && (state.avatar = info.avatar)
state.userId = info.userId
state.roleId = info.roleId
if(info.avatar) state.avatar = info.avatar
state.schoolId = info.schoolId
state.userName = info.userName
state.account = info.account
state.phone = info.phone
state.clientId = info.clientId
state.clientName = info.clientName
},
SET_TOKEN: (state, token) => {
state.token = token
},
SET_AVATAR: (state, avatar) => {
state.avatar = avatar
},
SET_USERNAME: (state, userName) => {
state.userName = userName
},
SET_ROLEID: (state, roleId) => {
state.roleId = roleId
SET_MANAGER: (state, isManager) => {
state.isManager = isManager
},
SET_CLIENTID: (state, clientId) => {
state.clientId = clientId
},
SET_CLIENTNAME: (state, clientName) => {
state.clientName = clientName
}
},
actions: {
login({ state,commit }, userInfo) {
// util.local.set('data-token','testfffff',1296000000)
const { username, password } = userInfo
const { account, password, code, random } = userInfo
return new Promise((resolve, reject) => {
get(api.logins,{ account: username.trim(), password: password, source: 0 }).then(res => {
console.log(333,res)
if(res.status == 200){
let user = res.message.retvalue
console.log(user)
// if(user.roleId == 1){
let routes = res.message.listValue
commit('SET_INFO',{
avatar: user.userAvatars,
userId: user.userId,
roleId: user.roleId,
userName: user.userName,
account: user.account,
phone: user.phone,
clientId: user.clientId,
clientName: user.clientName,
})
if(userInfo.remember) util.local.set(Setting.tokenKey,user.token,1296000000)
post(api.logins,{
account,
password,
code,
platform: Setting.platformId,
random,
}).then(res => {
setTimeout(() => {
post(api.saveRecord,{
type: 3,
}).then(res => {}).catch(res => {})
},3000)
Setting.dynamicRoute && addRoutes(routes)
util.local.set(Setting.usernameKey, user.userName)
if(res.status == 200){
util.local.set(Setting.tokenKey,res.data.token,1296000000)
util.successMsg('登录成功')
resolve()
// }else{
// util.errorMsg('该用户没有权限')
// }
}else{
util.errorMsg(res.message)
reject(res)
}
}).catch(error => {
reject(error)
@ -93,7 +61,6 @@ export default {
},
logout({ commit, state, dispatch }) {
return new Promise((resolve, reject) => {
util.local.remove(Setting.usernameKey)
util.local.remove(Setting.storeKey)
util.local.remove(Setting.tokenKey)
location.reload()
@ -108,8 +75,11 @@ export default {
}
post(api.userinfoUpdate,data).then(res => {}).catch(res => {})
},
setUserName({ state,commit },userName) {
commit('SET_USERNAME',userName)
setInfo({ state,commit },info) {
commit('SET_INFO',info)
},
setManager({ state,commit },isManager) {
commit('SET_MANAGER',isManager)
},
}
}
Loading…
Cancel
Save