diff --git a/src/components/page/Achievement.vue b/src/components/page/Achievement.vue
index 84ddaa7..3701743 100644
--- a/src/components/page/Achievement.vue
+++ b/src/components/page/Achievement.vue
@@ -123,6 +123,7 @@ export default {
data() {
return {
userId: this.$store.state.userLoginId,
+ roleId: this.$store.state.userRoleId.includes(',') ? 13 : Number(this.$store.state.userRoleId),
keyword: '',
systemId: this.$config.systemId,
projectPermissions: 0,
@@ -213,6 +214,7 @@ export default {
type: '',
status: '',
classId: '',
+ role: this.roleId
}
this.$post(this.api.getAssessmentList,data).then(res => {
this.listData = res.data.list
diff --git a/src/components/page/ExperimentAss.vue b/src/components/page/ExperimentAss.vue
index 93aa294..0227d6a 100644
--- a/src/components/page/ExperimentAss.vue
+++ b/src/components/page/ExperimentAss.vue
@@ -114,10 +114,10 @@ export default {
not: 0,
reviewList: [
{
- id: 0,
+ id: 1,
name: '已批阅'
},{
- id: 1,
+ id: 0,
name: '待批阅'
}
]
@@ -132,25 +132,27 @@ export default {
let data = {
id: this.id,
classId: this.classId,
- isRead: this.isRead == 1 ? '' : (this.isRead == 2 ? 0 : 1), //全部:'',已批阅:0,待批阅:1
+ isRead: this.isRead == 1 ? '' : (this.isRead == 2 ? 1 : 0), //全部:'',已批阅:1,待批阅:0
searchContent: this.encodeString(this.keyword),
}
this.$get(this.api.getKdAchievement,data).then(res => {
let list = res.data
let score = 0
- let already = 0
- let not = 0
- list.map(n => {
- n.class = this.className
- score += n.score
- if(!n.isRead){
- already++
- }else{
- not++
- }
- })
- this.already = already
- this.not = not
+ if(this.isRead == '1'){
+ let already = 0
+ let not = 0
+ list.map(n => {
+ n.class = this.className
+ score += n.score
+ if(!n.isRead){
+ not++
+ }else{
+ already++
+ }
+ })
+ this.already = already
+ this.not = not
+ }
this.listDataAll = list
this.handlePage()
diff --git a/src/components/page/ExperimentTeach.vue b/src/components/page/ExperimentTeach.vue
index 5b61e84..2721611 100644
--- a/src/components/page/ExperimentTeach.vue
+++ b/src/components/page/ExperimentTeach.vue
@@ -67,6 +67,11 @@
+
+
+ {{reviewList.find(n => n.id == scope.row.isRead).name}}
+
+
批阅
@@ -103,6 +108,15 @@ export default {
pageSize: 10,
totals: 0,
avg: 0,
+ reviewList: [
+ {
+ id: 1,
+ name: '已批阅'
+ },{
+ id: 0,
+ name: '待批阅'
+ }
+ ]
};
},
mounted() {
diff --git a/src/components/page/Login.vue b/src/components/page/Login.vue
index 9b94317..23dbc46 100644
--- a/src/components/page/Login.vue
+++ b/src/components/page/Login.vue
@@ -99,9 +99,10 @@ export default {
// if(data.roleId == 1 || data.roleId == 2 || data.roleId == 3){
// this.$post(this.api.updateLogInNumber,{userId: data.userId}).then(res => {}).catch(res => {});
res.message.listValue && this.$config.dynamicRoute && addRoutes(res.message.listValue)
- this.$message.success('登录成功');
+ this.$message.success('登录成功');
sessionStorage.setItem('kd_server_username', this.activeName == '0' ? this.param.username : this.phoneParam.userphone);
res.message.retvalue.userAvatars && this.$store.commit("userPhoto", { avatar : res.message.retvalue.userAvatars})
+ this.$store.commit("dataTime", { dataTime : res.message.retvalue.dataTime});
this.$store.commit("userLoginData", { userLogin_id : data.userId,userRole_id: data.roleId,schoolId: data.schoolId,token: data.token,userName: data.userName});
let redirect = decodeURIComponent(this.$route.query.redirect || '/dashboard')
diff --git a/src/config/index.js b/src/config/index.js
index 254153d..789e340 100644
--- a/src/config/index.js
+++ b/src/config/index.js
@@ -25,6 +25,10 @@ export default {
* @description 系统id
*/
systemId: 3,
+ /**
+ * @description 长时间未操作,自动退出登录时间
+ */
+ autoLogoutTime: 3600000,
/**
* @description 是否使用动态路由
*/
diff --git a/src/main.js b/src/main.js
index 4f148db..0598b70 100644
--- a/src/main.js
+++ b/src/main.js
@@ -17,7 +17,7 @@ import store from './store'
import config from '@/config'
import permission from '@/router/permission';
import { systemStatus, systemTypeStatus, systemAttributionStatus, courseTypeStatus,
- hoursStatus, roleStatus, orderTypeFn, orderStatusFn, orderNatureFn, Percentage, removeByValue, formatDate, formateTime, orderRoleType, orderRoleAttribute, setCookie, encodeString } from './utils/core';
+ hoursStatus, roleStatus, orderTypeFn, orderStatusFn, orderNatureFn, Percentage, removeByValue, formatDate, formateTime, orderRoleType, orderRoleAttribute, setCookie, encodeString,logout } from './utils/core';
import preventReClick from './store/preventReClick' //防多次点击,重复提交
// 插件
@@ -50,6 +50,7 @@ Vue.prototype.orderRoleAttribute = orderRoleAttribute;
Vue.prototype.formateTime = formateTime;
Vue.prototype.setCookie = setCookie;
Vue.prototype.encodeString = encodeString;
+Vue.prototype.logout = logout;
Vue.config.productionTip = false;
Vue.use(VueI18n);
diff --git a/src/store/index.js b/src/store/index.js
index c603b01..06147cd 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -26,6 +26,7 @@ const store = new Vuex.Store({
userName: '',
routes: [],
btnPermissions: [],
+ dataTime: ''
},
mutations:{
userData (state, payload) {
@@ -35,6 +36,9 @@ const store = new Vuex.Store({
userPhoto(state,payload){
state.avatar = payload.avatar
},
+ dataTime(state,payload){
+ state.dataTime = payload.dataTime
+ },
customerData (state, payload) {
state.customerId = payload.customer_id
},
diff --git a/src/utils/api.js b/src/utils/api.js
index 73c21bc..a9b2b8a 100644
--- a/src/utils/api.js
+++ b/src/utils/api.js
@@ -13,6 +13,7 @@ if(process.env.NODE_ENV === 'development'){
export default {
logins: `${host}/liuwanr/userInfo/adminLogins`, //登录
+ queryToken: `${host}/liuwanr/userInfo/queryToken`,
fileupload: `${uploadURL}/oss/manage/fileupload`,
updateLogInNumber: `${host}/liuwanr/userInfo/updateLogInNumber`, //用户登录修改登录次数和登陆时间
diff --git a/src/utils/core.js b/src/utils/core.js
index c2ba4d3..86dddf1 100644
--- a/src/utils/core.js
+++ b/src/utils/core.js
@@ -1,3 +1,7 @@
+import config from '@/config'
+import store from '@/store'
+import { Message } from 'element-ui'
+
const pad2 = str => ('0' + str).substr(-2)
function fMoney (s, n) {
@@ -217,6 +221,27 @@ function setCookie(name, value, expiredays) {
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString+";path=/;";
}
+function logout(){
+ store.replaceState({})
+ sessionStorage.removeItem('kd_server_username')
+ location.reload()
+}
+
+function autoLogout(){
+ let lastTime = new Date().getTime()
+ document.onmousedown = () => {
+ lastTime = new Date().getTime()
+ }
+
+ setInterval(() => {
+ if(sessionStorage.getItem('kd_server_username') && (new Date().getTime() - lastTime) > config.autoLogoutTime){
+ Message.error('用户登录过期,请重新登录')
+ setTimeout(logout,1500)
+ }
+ },1000)
+}
+autoLogout()
+
export {
fMoney,
formateTime,
@@ -239,5 +264,6 @@ export {
removeByValue,
formatDate,
setCookie,
- encodeString
+ encodeString,
+ logout
}
\ No newline at end of file
diff --git a/src/utils/http.js b/src/utils/http.js
index a235384..285a36f 100644
--- a/src/utils/http.js
+++ b/src/utils/http.js
@@ -101,21 +101,26 @@ axios.interceptors.request.use(config => {
// }
// );
+function logouts(){
+ store.replaceState({})
+ sessionStorage.removeItem('kd_server_username')
+ location.reload()
+}
+
let logout = false
export function getToken(){
- // console.log(store.state.dataTime,logout)
if(process.env.NODE_ENV == 'production'){
- // if(store.state.dataTime && !logout){
- // axios.get(`${api.queryToken}?token=${store.state.token}`).then(res => {
- // if(store.state.dataTime && (res.data.message != store.state.dataTime)){
- // logout || Message.error('您已在另一台设备登录,本次登录已下线!')
- // logout = true
- // setTimeout(() => {
- // core.logout()
- // },1500)
- // }
- // }).catch(err => {})
- // }
+ if(store.state.dataTime && !logout){
+ axios.get(`${api.queryToken}?token=${store.state.token}`).then(res => {
+ if(store.state.dataTime && (res.data.message != store.state.dataTime)){
+ logout || Message.error('您已在另一台设备登录,本次登录已下线!')
+ logout = true
+ setTimeout(() => {
+ logouts()
+ },1500)
+ }
+ }).catch(err => {})
+ }
}
}