修复用户界面问题
This commit is contained in:
parent
d2e29d9537
commit
d729451133
|
|
@ -21,8 +21,10 @@ router.beforeEach((to, from, next) => {
|
||||||
to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
|
to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
|
||||||
/* has token*/
|
/* has token*/
|
||||||
if (to.path === '/login' || to.path === '/admin-login') {
|
if (to.path === '/login' || to.path === '/admin-login') {
|
||||||
// 已登录,统一跳回首页
|
// 已登录,根据角色跳转到相应页面
|
||||||
next({ path: '/' })
|
const userRoles = store.getters.roles || []
|
||||||
|
const isStudentRole = userRoles.some(role => role === 'student' || role.includes('学员'))
|
||||||
|
next({ path: isStudentRole ? '/student/tests' : '/' })
|
||||||
NProgress.done()
|
NProgress.done()
|
||||||
} else if (isWhiteList(to.path)) {
|
} else if (isWhiteList(to.path)) {
|
||||||
next()
|
next()
|
||||||
|
|
@ -39,21 +41,22 @@ router.beforeEach((to, from, next) => {
|
||||||
const isStudentRole = userRoles.some(role => role === 'student' || role.includes('学员'))
|
const isStudentRole = userRoles.some(role => role === 'student' || role.includes('学员'))
|
||||||
|
|
||||||
if (isStudentRole) {
|
if (isStudentRole) {
|
||||||
const allowPaths = [
|
// 学员访问首页时重定向到测试题列表
|
||||||
'/',
|
if (to.path === '/' || to.path === '/index') {
|
||||||
'/index'
|
next({ path: '/student/tests', replace: true })
|
||||||
]
|
return
|
||||||
|
}
|
||||||
const allowPrefixes = [
|
const allowPrefixes = [
|
||||||
'/student',
|
'/student',
|
||||||
'/psychology/assessment/taking',
|
'/psychology/assessment/taking',
|
||||||
'/psychology/questionnaire',
|
'/psychology/questionnaire',
|
||||||
'/psychology/assessment/report'
|
'/psychology/assessment/report'
|
||||||
]
|
]
|
||||||
const isAllowed = allowPaths.includes(to.path) || allowPrefixes.some(prefix => to.path.startsWith(prefix))
|
const isAllowed = allowPrefixes.some(prefix => to.path.startsWith(prefix))
|
||||||
if (isAllowed) {
|
if (isAllowed) {
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
next({ path: '/' })
|
next({ path: '/student/tests' })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 管理员角色,生成路由
|
// 管理员角色,生成路由
|
||||||
|
|
@ -77,21 +80,22 @@ router.beforeEach((to, from, next) => {
|
||||||
const isStudentRole = userRoles.some(role => role === 'student' || role.includes('学员'))
|
const isStudentRole = userRoles.some(role => role === 'student' || role.includes('学员'))
|
||||||
|
|
||||||
if (isStudentRole) {
|
if (isStudentRole) {
|
||||||
const allowPaths = [
|
// 学员访问首页时重定向到测试题列表
|
||||||
'/',
|
if (to.path === '/' || to.path === '/index') {
|
||||||
'/index'
|
next({ path: '/student/tests', replace: true })
|
||||||
]
|
return
|
||||||
|
}
|
||||||
const allowPrefixes = [
|
const allowPrefixes = [
|
||||||
'/student',
|
'/student',
|
||||||
'/psychology/assessment/taking',
|
'/psychology/assessment/taking',
|
||||||
'/psychology/questionnaire',
|
'/psychology/questionnaire',
|
||||||
'/psychology/assessment/report'
|
'/psychology/assessment/report'
|
||||||
]
|
]
|
||||||
const isAllowed = allowPaths.includes(to.path) || allowPrefixes.some(prefix => to.path.startsWith(prefix))
|
const isAllowed = allowPrefixes.some(prefix => to.path.startsWith(prefix))
|
||||||
if (isAllowed) {
|
if (isAllowed) {
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
next({ path: '/' })
|
next({ path: '/student/tests' })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
next()
|
next()
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ const getters = {
|
||||||
permission_routes: state => state.permission.routes,
|
permission_routes: state => state.permission.routes,
|
||||||
topbarRouters: state => state.permission.topbarRouters,
|
topbarRouters: state => state.permission.topbarRouters,
|
||||||
defaultRoutes: state => state.permission.defaultRoutes,
|
defaultRoutes: state => state.permission.defaultRoutes,
|
||||||
sidebarRouters: state => state.permission.sidebarRouters
|
sidebarRouters: state => state.permission.sidebarRouters,
|
||||||
|
infoNumber: state => state.user.infoNumber
|
||||||
}
|
}
|
||||||
export default getters
|
export default getters
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { MessageBox, } from 'element-ui'
|
import { MessageBox, } from 'element-ui'
|
||||||
import { login, logout, getInfo, studentLogin } from '@/api/login'
|
import { login, logout, getInfo, studentLogin } from '@/api/login'
|
||||||
import { getToken, setToken, removeToken, getRole, setRole } from '@/utils/auth'
|
import { getToken, setToken, removeToken, getRole, setRole, getInfoNumber, setInfoNumber } from '@/utils/auth'
|
||||||
import { isHttp, isEmpty } from "@/utils/validate"
|
import { isHttp, isEmpty } from "@/utils/validate"
|
||||||
import defAva from '@/assets/images/profile.jpg'
|
import defAva from '@/assets/images/profile.jpg'
|
||||||
|
|
||||||
|
|
@ -22,7 +22,8 @@ const user = {
|
||||||
nickName: '',
|
nickName: '',
|
||||||
avatar: '',
|
avatar: '',
|
||||||
roles: initRoles(),
|
roles: initRoles(),
|
||||||
permissions: []
|
permissions: [],
|
||||||
|
infoNumber: getInfoNumber() || '' // 学员信息编号,从 Cookie 中恢复
|
||||||
},
|
},
|
||||||
|
|
||||||
mutations: {
|
mutations: {
|
||||||
|
|
@ -58,6 +59,11 @@ const user = {
|
||||||
},
|
},
|
||||||
SET_PERMISSIONS: (state, permissions) => {
|
SET_PERMISSIONS: (state, permissions) => {
|
||||||
state.permissions = permissions
|
state.permissions = permissions
|
||||||
|
},
|
||||||
|
SET_INFO_NUMBER: (state, infoNumber) => {
|
||||||
|
state.infoNumber = infoNumber
|
||||||
|
// 持久化到 Cookie
|
||||||
|
setInfoNumber(infoNumber)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -132,6 +138,7 @@ const user = {
|
||||||
commit('SET_TOKEN', '')
|
commit('SET_TOKEN', '')
|
||||||
commit('SET_ROLES', [])
|
commit('SET_ROLES', [])
|
||||||
commit('SET_PERMISSIONS', [])
|
commit('SET_PERMISSIONS', [])
|
||||||
|
commit('SET_INFO_NUMBER', '')
|
||||||
removeToken()
|
removeToken()
|
||||||
resolve()
|
resolve()
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|
@ -145,6 +152,7 @@ const user = {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
commit('SET_TOKEN', '')
|
commit('SET_TOKEN', '')
|
||||||
commit('SET_ROLES', [])
|
commit('SET_ROLES', [])
|
||||||
|
commit('SET_INFO_NUMBER', '')
|
||||||
removeToken()
|
removeToken()
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
|
|
@ -165,6 +173,8 @@ const user = {
|
||||||
// 设置学员token
|
// 设置学员token
|
||||||
setToken(res.token)
|
setToken(res.token)
|
||||||
commit('SET_TOKEN', res.token)
|
commit('SET_TOKEN', res.token)
|
||||||
|
// 保存信息编号到 store
|
||||||
|
commit('SET_INFO_NUMBER', infoNumber)
|
||||||
// 学员登录成功后,需要调用GetInfo获取用户信息(因为学员也是系统用户,只是角色不同)
|
// 学员登录成功后,需要调用GetInfo获取用户信息(因为学员也是系统用户,只是角色不同)
|
||||||
// 这里不设置角色,等GetInfo获取后再设置
|
// 这里不设置角色,等GetInfo获取后再设置
|
||||||
resolve()
|
resolve()
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import Cookies from 'js-cookie'
|
||||||
|
|
||||||
const TokenKey = 'Admin-Token'
|
const TokenKey = 'Admin-Token'
|
||||||
const RoleKey = 'User-Role'
|
const RoleKey = 'User-Role'
|
||||||
|
const InfoNumberKey = 'Info-Number'
|
||||||
|
|
||||||
export function getToken() {
|
export function getToken() {
|
||||||
return Cookies.get(TokenKey)
|
return Cookies.get(TokenKey)
|
||||||
|
|
@ -14,6 +15,7 @@ export function setToken(token) {
|
||||||
export function removeToken() {
|
export function removeToken() {
|
||||||
Cookies.remove(TokenKey)
|
Cookies.remove(TokenKey)
|
||||||
Cookies.remove(RoleKey)
|
Cookies.remove(RoleKey)
|
||||||
|
Cookies.remove(InfoNumberKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户角色
|
// 获取用户角色
|
||||||
|
|
@ -29,3 +31,17 @@ export function setRole(role) {
|
||||||
return Cookies.remove(RoleKey)
|
return Cookies.remove(RoleKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取信息编号
|
||||||
|
export function getInfoNumber() {
|
||||||
|
return Cookies.get(InfoNumberKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置信息编号
|
||||||
|
export function setInfoNumber(infoNumber) {
|
||||||
|
if (infoNumber) {
|
||||||
|
return Cookies.set(InfoNumberKey, infoNumber)
|
||||||
|
} else {
|
||||||
|
return Cookies.remove(InfoNumberKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,9 +74,6 @@
|
||||||
<span v-if="!loading">登 录</span>
|
<span v-if="!loading">登 录</span>
|
||||||
<span v-else>登 录 中...</span>
|
<span v-else>登 录 中...</span>
|
||||||
</el-button>
|
</el-button>
|
||||||
<div style="float: right;" v-if="register">
|
|
||||||
<router-link class="link-type" :to="'/register'">立即注册</router-link>
|
|
||||||
</div>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item style="width:100%; text-align: center; margin-top: 10px;">
|
<el-form-item style="width:100%; text-align: center; margin-top: 10px;">
|
||||||
<a class="student-login-link" @click="switchToStudent">
|
<a class="student-login-link" @click="switchToStudent">
|
||||||
|
|
@ -250,7 +247,8 @@ export default {
|
||||||
this.$store.dispatch("StudentLogin", loginData).then(() => {
|
this.$store.dispatch("StudentLogin", loginData).then(() => {
|
||||||
// 学员登录成功后,需要调用GetInfo获取用户信息
|
// 学员登录成功后,需要调用GetInfo获取用户信息
|
||||||
this.$store.dispatch("GetInfo").then(() => {
|
this.$store.dispatch("GetInfo").then(() => {
|
||||||
const targetPath = this.resolveRedirect("/")
|
// 学员登录后跳转到测试题页面,如果有redirect参数则跳转到指定页面
|
||||||
|
const targetPath = this.resolveRedirect("/student/tests")
|
||||||
this.$router.push(targetPath).catch(()=>{})
|
this.$router.push(targetPath).catch(()=>{})
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,10 @@ export default {
|
||||||
this.assessmentId = this.$route.query.assessmentId;
|
this.assessmentId = this.$route.query.assessmentId;
|
||||||
if (!this.assessmentId) {
|
if (!this.assessmentId) {
|
||||||
this.$modal.msgError("测评ID不能为空");
|
this.$modal.msgError("测评ID不能为空");
|
||||||
this.$router.push('/psychology/assessment');
|
// 根据用户角色跳转到相应页面
|
||||||
|
const roles = this.$store.getters.roles || [];
|
||||||
|
const isStudent = roles.some(role => role === 'student' || role.includes('学员'));
|
||||||
|
this.$router.push(isStudent ? '/student/tests' : '/psychology/assessment');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loadAssessment();
|
this.loadAssessment();
|
||||||
|
|
@ -162,7 +165,10 @@ export default {
|
||||||
const assessment = assessmentRes.data;
|
const assessment = assessmentRes.data;
|
||||||
if (!assessment) {
|
if (!assessment) {
|
||||||
this.$modal.msgError("测评不存在");
|
this.$modal.msgError("测评不存在");
|
||||||
this.$router.push('/psychology/assessment');
|
// 根据用户角色跳转到相应页面
|
||||||
|
const roles = this.$store.getters.roles || [];
|
||||||
|
const isStudent = roles.some(role => role === 'student' || role.includes('学员'));
|
||||||
|
this.$router.push(isStudent ? '/student/tests' : '/psychology/assessment');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,7 +178,10 @@ export default {
|
||||||
// 检查题目列表是否为空
|
// 检查题目列表是否为空
|
||||||
if (this.itemList.length === 0) {
|
if (this.itemList.length === 0) {
|
||||||
this.$modal.msgWarning("该量表暂无题目,请联系管理员添加题目");
|
this.$modal.msgWarning("该量表暂无题目,请联系管理员添加题目");
|
||||||
this.$router.push('/psychology/assessment');
|
// 根据用户角色跳转到相应页面
|
||||||
|
const roles = this.$store.getters.roles || [];
|
||||||
|
const isStudent = roles.some(role => role === 'student' || role.includes('学员'));
|
||||||
|
this.$router.push(isStudent ? '/student/tests' : '/psychology/assessment');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,14 +318,20 @@ export default {
|
||||||
this.$modal.confirm('确定要暂停测评吗?您可以稍后继续完成。').then(() => {
|
this.$modal.confirm('确定要暂停测评吗?您可以稍后继续完成。').then(() => {
|
||||||
pauseAssessment(this.assessmentId).then(() => {
|
pauseAssessment(this.assessmentId).then(() => {
|
||||||
this.$modal.msgSuccess("测评已暂停");
|
this.$modal.msgSuccess("测评已暂停");
|
||||||
this.$router.push('/psychology/assessment');
|
// 根据用户角色跳转到相应页面
|
||||||
|
const roles = this.$store.getters.roles || [];
|
||||||
|
const isStudent = roles.some(role => role === 'student' || role.includes('学员'));
|
||||||
|
this.$router.push(isStudent ? '/student/tests' : '/psychology/assessment');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 退出 */
|
/** 退出 */
|
||||||
handleExit() {
|
handleExit() {
|
||||||
this.$modal.confirm('确定要退出测评吗?已答题目将会保存。').then(() => {
|
this.$modal.confirm('确定要退出测评吗?已答题目将会保存。').then(() => {
|
||||||
this.$router.push('/psychology/assessment');
|
// 根据用户角色跳转到相应页面
|
||||||
|
const roles = this.$store.getters.roles || [];
|
||||||
|
const isStudent = roles.some(role => role === 'student' || role.includes('学员'));
|
||||||
|
this.$router.push(isStudent ? '/student/tests' : '/psychology/assessment');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 提交测评 */
|
/** 提交测评 */
|
||||||
|
|
@ -331,7 +346,10 @@ export default {
|
||||||
this.$modal.confirm('确定要提交测评吗?提交后将不能修改。').then(() => {
|
this.$modal.confirm('确定要提交测评吗?提交后将不能修改。').then(() => {
|
||||||
submitAssessment(this.assessmentId).then(response => {
|
submitAssessment(this.assessmentId).then(response => {
|
||||||
this.$modal.msgSuccess(response.msg || "测评已提交,报告已生成");
|
this.$modal.msgSuccess(response.msg || "测评已提交,报告已生成");
|
||||||
this.$router.push('/psychology/assessment');
|
// 根据用户角色跳转到相应页面
|
||||||
|
const roles = this.$store.getters.roles || [];
|
||||||
|
const isStudent = roles.some(role => role === 'student' || role.includes('学员'));
|
||||||
|
this.$router.push(isStudent ? '/student/tests' : '/psychology/assessment');
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.$modal.msgError(error.msg || "提交失败,请重试");
|
this.$modal.msgError(error.msg || "提交失败,请重试");
|
||||||
});
|
});
|
||||||
|
|
@ -461,7 +479,10 @@ export default {
|
||||||
submitAssessment(this.assessmentId).then(response => {
|
submitAssessment(this.assessmentId).then(response => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.$modal.msgSuccess(response.msg || "测评已提交,报告已生成");
|
this.$modal.msgSuccess(response.msg || "测评已提交,报告已生成");
|
||||||
this.$router.push('/psychology/assessment');
|
// 根据用户角色跳转到相应页面
|
||||||
|
const roles = this.$store.getters.roles || [];
|
||||||
|
const isStudent = roles.some(role => role === 'student' || role.includes('学员'));
|
||||||
|
this.$router.push(isStudent ? '/student/tests' : '/psychology/assessment');
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.$modal.msgError(error.msg || "提交失败,请重试");
|
this.$modal.msgError(error.msg || "提交失败,请重试");
|
||||||
|
|
|
||||||
|
|
@ -39,14 +39,6 @@
|
||||||
<el-option label="老年" value="senior" />
|
<el-option label="老年" value="senior" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="身份证号" prop="idCard">
|
|
||||||
<el-input
|
|
||||||
v-model="queryParams.idCard"
|
|
||||||
placeholder="请输入身份证号"
|
|
||||||
clearable
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="信息编号" prop="infoNumber">
|
<el-form-item label="信息编号" prop="infoNumber">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.infoNumber"
|
v-model="queryParams.infoNumber"
|
||||||
|
|
@ -57,7 +49,6 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
|
|
@ -72,16 +63,6 @@
|
||||||
v-hasPermi="['psychology:profile:add']"
|
v-hasPermi="['psychology:profile:add']"
|
||||||
>新增档案</el-button>
|
>新增档案</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.8">
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
plain
|
|
||||||
icon="el-icon-user"
|
|
||||||
size="mini"
|
|
||||||
@click="handleAddUser"
|
|
||||||
v-hasPermi="['psychology:profile:add']"
|
|
||||||
>创建用户</el-button>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="success"
|
type="success"
|
||||||
|
|
@ -123,7 +104,6 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="姓名" align="center" prop="userName" width="100" />
|
<el-table-column label="姓名" align="center" prop="userName" width="100" />
|
||||||
<el-table-column label="电话" align="center" prop="phone" width="120" />
|
<el-table-column label="电话" align="center" prop="phone" width="120" />
|
||||||
<el-table-column label="身份证号" align="center" prop="idCard" width="180" />
|
|
||||||
<el-table-column label="生日" align="center" prop="birthday" width="120">
|
<el-table-column label="生日" align="center" prop="birthday" width="120">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{ parseTime(scope.row.birthday, '{y}-{m}-{d}') }}</span>
|
<span>{{ parseTime(scope.row.birthday, '{y}-{m}-{d}') }}</span>
|
||||||
|
|
@ -147,13 +127,6 @@
|
||||||
@click="handleUpdate(scope.row)"
|
@click="handleUpdate(scope.row)"
|
||||||
v-hasPermi="['psychology:profile:edit']"
|
v-hasPermi="['psychology:profile:edit']"
|
||||||
>档案</el-button>
|
>档案</el-button>
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-user"
|
|
||||||
@click="handleEditUser(scope.row)"
|
|
||||||
v-hasPermi="['psychology:profile:edit']"
|
|
||||||
>用户</el-button>
|
|
||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
|
|
@ -177,21 +150,6 @@
|
||||||
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item prop="userId">
|
|
||||||
<template slot="label">
|
|
||||||
用户ID
|
|
||||||
<span style="color:#909399;font-size:12px;">(留空自动创建)</span>
|
|
||||||
</template>
|
|
||||||
<el-input-number
|
|
||||||
v-model="form.userId"
|
|
||||||
:min="1"
|
|
||||||
:disabled="form.profileId != undefined"
|
|
||||||
:controls="false"
|
|
||||||
placeholder="不填将自动创建用户"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="档案类型" prop="profileType">
|
<el-form-item label="档案类型" prop="profileType">
|
||||||
<el-select v-model="form.profileType" placeholder="请选择档案类型">
|
<el-select v-model="form.profileType" placeholder="请选择档案类型">
|
||||||
|
|
@ -202,6 +160,9 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<!-- 用户ID已隐藏,会通过信息编号自动填充 -->
|
||||||
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
|
|
@ -542,10 +503,27 @@ export default {
|
||||||
}
|
}
|
||||||
this.resetForm("form")
|
this.resetForm("form")
|
||||||
},
|
},
|
||||||
// 处理信息编号输入,只允许数字
|
// 处理信息编号输入,只允许数字,并同时更新userId
|
||||||
handleInfoNumberInput(value) {
|
handleInfoNumberInput(value) {
|
||||||
// 移除所有非数字字符
|
// 移除所有非数字字符
|
||||||
this.form.infoNumber = value.replace(/\D/g, '')
|
const numericValue = value.replace(/\D/g, '')
|
||||||
|
this.form.infoNumber = numericValue
|
||||||
|
// 将信息编号同时赋值给userId,确保两者保持一致
|
||||||
|
if (numericValue) {
|
||||||
|
this.form.userId = parseInt(numericValue)
|
||||||
|
} else {
|
||||||
|
this.form.userId = undefined
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 同步userId和infoNumber,确保两者保持一致
|
||||||
|
syncUserIdWithInfoNumber() {
|
||||||
|
if (this.form.infoNumber) {
|
||||||
|
// 如果有信息编号,将其同步到userId
|
||||||
|
this.form.userId = parseInt(this.form.infoNumber)
|
||||||
|
} else if (this.form.userId) {
|
||||||
|
// 如果没有信息编号但有userId,将userId同步到信息编号
|
||||||
|
this.form.infoNumber = this.form.userId.toString()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 处理姓名输入,只允许汉字
|
// 处理姓名输入,只允许汉字
|
||||||
handleUserNameInput(value) {
|
handleUserNameInput(value) {
|
||||||
|
|
@ -712,6 +690,8 @@ export default {
|
||||||
getProfile(row.profileId).then(response => {
|
getProfile(row.profileId).then(response => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
this.form = response.data
|
this.form = response.data
|
||||||
|
// 确保 userId 和 infoNumber 保持一致
|
||||||
|
this.syncUserIdWithInfoNumber()
|
||||||
this.open = true
|
this.open = true
|
||||||
this.title = "修改用户档案"
|
this.title = "修改用户档案"
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -734,6 +714,8 @@ export default {
|
||||||
if (response.data && response.data.profileId) {
|
if (response.data && response.data.profileId) {
|
||||||
// 找到了档案,修改档案
|
// 找到了档案,修改档案
|
||||||
this.form = response.data
|
this.form = response.data
|
||||||
|
// 确保 userId 和 infoNumber 保持一致
|
||||||
|
this.syncUserIdWithInfoNumber()
|
||||||
this.open = true
|
this.open = true
|
||||||
this.title = "修改用户档案"
|
this.title = "修改用户档案"
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,10 @@ export default {
|
||||||
startAnswerDirectly() {
|
startAnswerDirectly() {
|
||||||
if (!this.form.questionnaireId) {
|
if (!this.form.questionnaireId) {
|
||||||
this.$modal.msgError("问卷ID不能为空");
|
this.$modal.msgError("问卷ID不能为空");
|
||||||
this.$router.push('/psychology/scale');
|
// 根据用户角色跳转到相应页面
|
||||||
|
const roles = this.$store.getters.roles || [];
|
||||||
|
const isStudent = roles.some(role => role === 'student' || role.includes('学员'));
|
||||||
|
this.$router.push(isStudent ? '/student/tests' : '/psychology/scale');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,7 +134,10 @@ export default {
|
||||||
},
|
},
|
||||||
/** 返回 */
|
/** 返回 */
|
||||||
handleBack() {
|
handleBack() {
|
||||||
this.$router.push('/psychology/scale');
|
// 根据用户角色跳转到相应页面
|
||||||
|
const roles = this.$store.getters.roles || [];
|
||||||
|
const isStudent = roles.some(role => role === 'student' || role.includes('学员'));
|
||||||
|
this.$router.push(isStudent ? '/student/tests' : '/psychology/scale');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,10 @@ export default {
|
||||||
this.answerId = this.$route.query.answerId;
|
this.answerId = this.$route.query.answerId;
|
||||||
if (!this.answerId) {
|
if (!this.answerId) {
|
||||||
this.$modal.msgError("答题ID不能为空");
|
this.$modal.msgError("答题ID不能为空");
|
||||||
this.$router.push('/psychology/scale');
|
// 根据用户角色跳转到相应页面
|
||||||
|
const roles = this.$store.getters.roles || [];
|
||||||
|
const isStudent = roles.some(role => role === 'student' || role.includes('学员'));
|
||||||
|
this.$router.push(isStudent ? '/student/tests' : '/psychology/scale');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loadAnswer();
|
this.loadAnswer();
|
||||||
|
|
@ -232,7 +235,10 @@ export default {
|
||||||
const answer = answerRes.data;
|
const answer = answerRes.data;
|
||||||
if (!answer) {
|
if (!answer) {
|
||||||
this.$modal.msgError("答题记录不存在");
|
this.$modal.msgError("答题记录不存在");
|
||||||
this.$router.push('/psychology/scale');
|
// 根据用户角色跳转到相应页面
|
||||||
|
const roles = this.$store.getters.roles || [];
|
||||||
|
const isStudent = roles.some(role => role === 'student' || role.includes('学员'));
|
||||||
|
this.$router.push(isStudent ? '/student/tests' : '/psychology/scale');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -256,7 +262,10 @@ export default {
|
||||||
|
|
||||||
if (this.itemList.length === 0) {
|
if (this.itemList.length === 0) {
|
||||||
this.$modal.msgWarning("该问卷暂无题目,请联系管理员添加题目");
|
this.$modal.msgWarning("该问卷暂无题目,请联系管理员添加题目");
|
||||||
this.$router.push('/psychology/scale');
|
// 根据用户角色跳转到相应页面
|
||||||
|
const roles = this.$store.getters.roles || [];
|
||||||
|
const isStudent = roles.some(role => role === 'student' || role.includes('学员'));
|
||||||
|
this.$router.push(isStudent ? '/student/tests' : '/psychology/scale');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -449,7 +458,10 @@ export default {
|
||||||
/** 退出 */
|
/** 退出 */
|
||||||
handleExit() {
|
handleExit() {
|
||||||
this.$modal.confirm('确定要退出答题吗?已答题目将会保存。').then(() => {
|
this.$modal.confirm('确定要退出答题吗?已答题目将会保存。').then(() => {
|
||||||
this.$router.push('/psychology/scale');
|
// 根据用户角色跳转到相应页面
|
||||||
|
const roles = this.$store.getters.roles || [];
|
||||||
|
const isStudent = roles.some(role => role === 'student' || role.includes('学员'));
|
||||||
|
this.$router.push(isStudent ? '/student/tests' : '/psychology/scale');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 提交问卷 */
|
/** 提交问卷 */
|
||||||
|
|
@ -480,7 +492,10 @@ export default {
|
||||||
submitQuestionnaireAnswer(this.answerId).then(response => {
|
submitQuestionnaireAnswer(this.answerId).then(response => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.$modal.msgSuccess(response.msg || "问卷已提交");
|
this.$modal.msgSuccess(response.msg || "问卷已提交");
|
||||||
this.$router.push('/psychology/scale');
|
// 根据用户角色跳转到相应页面
|
||||||
|
const roles = this.$store.getters.roles || [];
|
||||||
|
const isStudent = roles.some(role => role === 'student' || role.includes('学员'));
|
||||||
|
this.$router.push(isStudent ? '/student/tests' : '/psychology/scale');
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.$modal.msgError(error.msg || "提交失败,请重试");
|
this.$modal.msgError(error.msg || "提交失败,请重试");
|
||||||
|
|
|
||||||
|
|
@ -72,11 +72,14 @@ export default {
|
||||||
return {
|
return {
|
||||||
loading: false,
|
loading: false,
|
||||||
testList: [],
|
testList: [],
|
||||||
searchText: "",
|
searchText: ""
|
||||||
studentNo: ""
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
// 学员编号 - 从 store 实时获取,优先使用 infoNumber
|
||||||
|
studentNo() {
|
||||||
|
return this.$store.getters.infoNumber || this.$store.getters.name || "未知"
|
||||||
|
},
|
||||||
// 过滤后的测试题列表
|
// 过滤后的测试题列表
|
||||||
filteredTestList() {
|
filteredTestList() {
|
||||||
if (!this.searchText) {
|
if (!this.searchText) {
|
||||||
|
|
@ -89,8 +92,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
// 获取学员编号
|
|
||||||
this.studentNo = this.$store.getters.name || "未知"
|
|
||||||
// 加载测试题列表
|
// 加载测试题列表
|
||||||
this.loadTestList()
|
this.loadTestList()
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user