学校端代码提交
This commit is contained in:
parent
f024aa2b52
commit
bc7556bd4d
|
@ -23,4 +23,26 @@ export const getPublishAPI = () => {
|
|||
return request({
|
||||
url: '/web/scale/publish'
|
||||
})
|
||||
}
|
||||
|
||||
export const addRecordAPI = (record) => {
|
||||
return request({
|
||||
url: '/web/scale/record',
|
||||
method: 'POST',
|
||||
data: record
|
||||
})
|
||||
}
|
||||
|
||||
export const getAnswerAPI = (scaleId) => {
|
||||
return request({
|
||||
url: '/web/scale/answer/' + scaleId
|
||||
})
|
||||
}
|
||||
|
||||
export const addAnswerAPI = (answer) => {
|
||||
return request({
|
||||
url: '/web/scale/record/answer',
|
||||
method: 'POST',
|
||||
data: answer
|
||||
})
|
||||
}
|
|
@ -16,7 +16,7 @@ const router = createRouter({
|
|||
component: ScaleList
|
||||
},
|
||||
{
|
||||
path: '/exam/:scaleId',
|
||||
path: '/exam',
|
||||
component: Exam
|
||||
}
|
||||
],
|
||||
|
|
|
@ -18,7 +18,13 @@ http.interceptors.request.use(config => {
|
|||
}, e => Promise.reject(e))
|
||||
|
||||
// axios响应式拦截器
|
||||
http.interceptors.response.use(res => res.data, e => {
|
||||
http.interceptors.response.use(res => {
|
||||
if(res.data.code == 401) {
|
||||
localStorage.removeItem('token')
|
||||
window.location.href = '/login'
|
||||
}
|
||||
return res.data;
|
||||
}, e => {
|
||||
return Promise.reject(e)
|
||||
})
|
||||
|
||||
|
|
|
@ -8,17 +8,17 @@
|
|||
<el-card class="card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
SCL-90症状自评量表_专业焦虑与抑郁测试
|
||||
{{ scaleName }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-progress :percentage="10" :format="format" />
|
||||
|
||||
<div class="subject-content">
|
||||
<div class="subject-title">{{ questionNum + 1 + '、' + currentQuestion.question }}</div>
|
||||
<el-radio-group v-model="currentQuestion.answer">
|
||||
<el-radio :value="item.value" v-for="item in currentQuestion.options" :key="item.id">
|
||||
{{ item.name }}
|
||||
<div class="subject-title">{{ currentQuestion.questionContent }}</div>
|
||||
<el-radio-group v-model="currentQuestion.answerId" @change="handleChange">
|
||||
<el-radio :value="item.answerId" v-for="item in currentQuestion.answerList" :key="item.answerId">
|
||||
{{ item.answerOption }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
|
@ -30,7 +30,7 @@
|
|||
<ArrowLeft />
|
||||
</el-icon>上一题
|
||||
</el-button>
|
||||
<el-button v-if="nextDisable" type="primary" size="large" @click="next">
|
||||
<el-button v-if="nextDisable" type="primary" size="large" @click="submit">
|
||||
提交<el-icon class="el-icon--right">
|
||||
<ArrowRight />
|
||||
</el-icon>
|
||||
|
@ -48,53 +48,28 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import {useRoute} from 'vue-router'
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { getAnswerAPI, addAnswerAPI } from '@/apis/user'
|
||||
|
||||
const route = useRoute()
|
||||
console.log(route)
|
||||
const scaleId = route.query.scaleId
|
||||
const scaleName = route.query.scaleName
|
||||
const recordId = route.query.recordId
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const format = (percentage) => (percentage === 100 ? '90题' : `10/90题`)
|
||||
|
||||
const questionList = ref([
|
||||
{
|
||||
id: 1,
|
||||
question: '是否头疼',
|
||||
options: [
|
||||
{ id: 1, name: '没有', value: 1 },
|
||||
{ id: 2, name: '很轻', value: 2 },
|
||||
{ id: 3, name: '中等', value: 3 },
|
||||
{ id: 4, name: '偏重', value: 4 },
|
||||
{ id: 5, name: '严重', value: 5 },
|
||||
{ id: 6, name: '一般般', value: 6 },
|
||||
],
|
||||
answer: null
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
question: '经常感到神经过敏、心中不踏实',
|
||||
options: [
|
||||
{ id: 1, name: '没有', value: 1 },
|
||||
{ id: 2, name: '很轻', value: 2 },
|
||||
{ id: 3, name: '中等', value: 3 },
|
||||
{ id: 4, name: '偏重', value: 4 },
|
||||
{ id: 5, name: '严重', value: 5 },
|
||||
],
|
||||
answer: null
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
question: '测试',
|
||||
options: [
|
||||
{ id: 1, name: '没有', value: 1 },
|
||||
{ id: 2, name: '很轻', value: 2 }
|
||||
],
|
||||
answer: null
|
||||
}
|
||||
])
|
||||
const currentQuestion = ref(questionList.value[0])
|
||||
|
||||
const questionList = ref([])
|
||||
const questionNum = ref(0)
|
||||
const currentQuestion = ref({})
|
||||
|
||||
async function getAnswer() {
|
||||
const res = await getAnswerAPI(scaleId)
|
||||
questionList.value = res.data
|
||||
currentQuestion.value = questionList.value[0]
|
||||
}
|
||||
|
||||
const preDisable = computed(() => {
|
||||
return questionNum.value === 0
|
||||
|
@ -122,6 +97,31 @@ function next() {
|
|||
|
||||
currentQuestion.value = questionList.value[questionNum.value]
|
||||
}
|
||||
|
||||
function handleChange() {
|
||||
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getAnswer()
|
||||
})
|
||||
|
||||
async function submit() {
|
||||
const data = questionList.value.map(item => {
|
||||
return {
|
||||
recordId: recordId, answerId: item.answerId, questionId: item.questionId
|
||||
}
|
||||
})
|
||||
|
||||
const res = await addAnswerAPI(data)
|
||||
if (res.code == 200) {
|
||||
ElMessage({
|
||||
message: '提交成功',
|
||||
type: 'success'
|
||||
})
|
||||
router.replace({ path: '/' })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -31,18 +31,28 @@
|
|||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { getPublishAPI } from '@/apis/user'
|
||||
import { getPublishAPI, addRecordAPI } from '@/apis/user'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const scaleList = ref([])
|
||||
let batchNo;
|
||||
async function getScaleList() {
|
||||
const res = await getPublishAPI()
|
||||
scaleList.value = res.data.scaleList
|
||||
batchNo = res.data.batchNo
|
||||
}
|
||||
|
||||
function gotoExam(item) {
|
||||
router.push(`/exam/${item.scaleId}`)
|
||||
async function gotoExam(item) {
|
||||
const res = await addRecordAPI({ scaleId: item.scaleId, batchNo })
|
||||
router.push({
|
||||
path: '/exam',
|
||||
query: {
|
||||
scaleId: item.scaleId,
|
||||
scaleName: item.scaleName,
|
||||
recordId: res.data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
|
Loading…
Reference in New Issue