|
|
@@ -3,8 +3,8 @@
|
|
|
<TopBackNav>
|
|
|
<template #topRight>
|
|
|
<span class="paper_score">阅卷总分:<span class="score">{{questionTotalScore}}分</span></span>
|
|
|
- <el-button class="button_refresh">预览问卷</el-button>
|
|
|
- <el-button class="button_background" @click="HandleQuestionnaireSave">保存问卷</el-button>
|
|
|
+ <el-button class="button_refresh" @click="PreviewQuestionnaire">预览问卷</el-button>
|
|
|
+ <el-button class="button_background" @click="SaveQuestionnaire">保存问卷</el-button>
|
|
|
</template>
|
|
|
</TopBackNav>
|
|
|
|
|
|
@@ -59,57 +59,17 @@
|
|
|
{{index + 1}}.{{ question.title }}
|
|
|
<span class="question_type">[{{ qustionTypeToName(question.questionType) }}]</span>
|
|
|
</div>
|
|
|
-
|
|
|
- <!-- 单选 -->
|
|
|
- <el-radio-group
|
|
|
- v-if="[0,3].includes(Number(question.questionType))"
|
|
|
- :class="{vertical:!question.extraConfig.includes('isHorizontal')}">
|
|
|
-
|
|
|
- <el-radio v-for="radioItem in question.options" :key="radioItem.value" :value="radioItem.value">{{ radioItem.label }}</el-radio>
|
|
|
- </el-radio-group>
|
|
|
-
|
|
|
- <!-- 多选 -->
|
|
|
- <el-checkbox-group
|
|
|
- v-else-if="Number(question.questionType) === 1"
|
|
|
- :class="{vertical:!question.extraConfig.includes('isHorizontal')}">
|
|
|
-
|
|
|
- <el-checkbox
|
|
|
- v-for="checkItem in question.options"
|
|
|
- :key="checkItem.value"
|
|
|
- :label="checkItem.label"
|
|
|
- :value="checkItem.value"
|
|
|
- />
|
|
|
- </el-checkbox-group>
|
|
|
-
|
|
|
- <!-- 问答题 -->
|
|
|
- <el-input
|
|
|
- v-else-if="Number(question.questionType) === 2"
|
|
|
- :autosize="{ minRows:5, maxRows: 5 }"
|
|
|
- type="textarea"
|
|
|
- :rows="5"
|
|
|
- placeholder="不超过2000字"
|
|
|
- />
|
|
|
-
|
|
|
- <!-- 评价(分)题 4 -->
|
|
|
- <template v-else-if="Number(question.questionType) === 4 ">
|
|
|
- <ul class="num_score" v-if="Number(question.scoreReviewType) === 0 && Number(question.titleScore)">
|
|
|
- <li v-for="value in Number(question.titleScore)">
|
|
|
- {{ value }}分
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
- <div class="star_score" v-else-if="Number(question.scoreReviewType) === 1 && Number(question.titleScore)">
|
|
|
- 非常不满意
|
|
|
- <el-rate size="large"
|
|
|
- :max="Number(question.titleScore)"
|
|
|
- clearable />
|
|
|
- 非常满意
|
|
|
- </div>
|
|
|
- </template>
|
|
|
+ <QuestionTypeShow
|
|
|
+ :isHorizontal="question.extraConfig.includes('isHorizontal')"
|
|
|
+ :questionType="Number(question.questionType)"
|
|
|
+ :questionSubOptions="question.options"
|
|
|
+ :scoreReviewType="Number(question.scoreReviewType)"
|
|
|
+ :titleScore="Number(question.titleScore)"
|
|
|
+ ></QuestionTypeShow>
|
|
|
</li>
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
-
|
|
|
<!-- 题目添加区域 -->
|
|
|
<div class=" add_question_area">
|
|
|
<div v-if="!selectedQuestionType" class="add_question">
|
|
|
@@ -119,7 +79,7 @@
|
|
|
<QuestionConfig
|
|
|
:displayMode="selectedQuestionGetScore ? 'scored' : 'statistic'"
|
|
|
:questionType="selectedQuestionType"
|
|
|
- @confirm="HandleAddQuesiton"
|
|
|
+ @confirm="AddQuesiton"
|
|
|
></QuestionConfig>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -159,6 +119,8 @@ import { ElMessage } from 'element-plus';
|
|
|
import { unioformDateTransform } from '@/utils/dateTransform';
|
|
|
import { useHandleMoveUpAndDown } from '@/baseComponents/useHandleMoveUpAndDown';
|
|
|
|
|
|
+import QuestionTypeShow from '@/components/QuestionTypeShow.vue';
|
|
|
+
|
|
|
import moveUpDownIcon from '@/assets/icon/move_up_down.png'
|
|
|
|
|
|
|
|
|
@@ -189,6 +151,9 @@ const router = useRouter()
|
|
|
|
|
|
// 试卷头表单
|
|
|
const questionnaireBaseFormRef = ref()
|
|
|
+// 已存储的试卷整体信息
|
|
|
+const questionnaireMsg = ref()
|
|
|
+
|
|
|
// 试卷头基本信息
|
|
|
const questionnaireInfo = ref<QuestionnaireInfo>({
|
|
|
questionnaireTitle:'',
|
|
|
@@ -206,6 +171,8 @@ const addedQuestionList = ref<QuestionItm[]>([
|
|
|
scoreReviewType:''
|
|
|
}
|
|
|
])
|
|
|
+
|
|
|
+
|
|
|
// 当前选中的题型
|
|
|
const selectedQuestionType = ref('')
|
|
|
// 选中题型 是否得分 // 得分题 true 非得分题 false
|
|
|
@@ -249,7 +216,7 @@ const { HandleDragStart, HandleDragEnd } = useHandleMoveUpAndDown(addedQuestionL
|
|
|
|
|
|
const addedIndex = ref(1)
|
|
|
// 添加试题信息
|
|
|
-const HandleAddQuesiton = (params)=>{
|
|
|
+const AddQuesiton = (params)=>{
|
|
|
const {formRef,formData} = params
|
|
|
console.log('获取到试题信息了',formData)
|
|
|
|
|
|
@@ -272,7 +239,7 @@ const HandleAddQuesiton = (params)=>{
|
|
|
|
|
|
|
|
|
// 保存试卷
|
|
|
-const HandleQuestionnaireSave = async ()=>{
|
|
|
+const SaveQuestionnaire = async ()=>{
|
|
|
// 试卷总表单
|
|
|
let formRef = questionnaireBaseFormRef.value
|
|
|
|
|
|
@@ -280,27 +247,23 @@ const HandleQuestionnaireSave = async ()=>{
|
|
|
await formRef.validate(async(valid) => {
|
|
|
if (valid) {
|
|
|
if(addedQuestionList.value.length > 0){
|
|
|
- let finalQuestionMsg = {
|
|
|
- ...(questionnaireInfo.value),
|
|
|
- quetionList:addedQuestionList.value
|
|
|
- }
|
|
|
- console.log('最终提交的表单信息',finalQuestionMsg)
|
|
|
-
|
|
|
/**
|
|
|
* 模拟数据
|
|
|
*/
|
|
|
// 模拟保存数据 和页面跳转
|
|
|
let questionnaireList = JSON.parse(localStorage.getItem('questionnaireList') || '[]')
|
|
|
- questionnaireList.push({
|
|
|
- ...finalQuestionMsg,
|
|
|
+
|
|
|
+ questionnaireMsg.value = {
|
|
|
+ ...(questionnaireInfo.value),
|
|
|
+ quetionList:addedQuestionList.value,
|
|
|
id:Number(questionnaireList[questionnaireList.length - 1]?.id || 0) + 1,
|
|
|
createTime:unioformDateTransform(new Date()),
|
|
|
createBy:'管理员',
|
|
|
totalScore:questionTotalScore.value,
|
|
|
useStatus:1
|
|
|
- })
|
|
|
- localStorage.setItem('questionnaireList',JSON.stringify(questionnaireList))
|
|
|
- router.push('/main')
|
|
|
+ }
|
|
|
+ questionnaireList.push(questionnaireMsg.value)
|
|
|
+ localStorage.setItem('questionnaireList',JSON.stringify(questionnaireList.value || []))
|
|
|
}else{
|
|
|
ElMessage.warning('请添加问卷题目')
|
|
|
}
|
|
|
@@ -308,9 +271,15 @@ const HandleQuestionnaireSave = async ()=>{
|
|
|
}).catch(err=>{
|
|
|
console.log('报错信息',err)
|
|
|
})
|
|
|
+}
|
|
|
|
|
|
|
|
|
+// 预览试卷
|
|
|
+const PreviewQuestionnaire =()=>{
|
|
|
+ sessionStorage.setItem('questionnaire',JSON.stringify(questionnaireMsg.value || '{}'))
|
|
|
+ router.push(`/main/previewQuestionnaire`)
|
|
|
}
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
@@ -428,49 +397,6 @@ const HandleQuestionnaireSave = async ()=>{
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- .el-checkbox-group.vertical,
|
|
|
- .el-radio-group.vertical{
|
|
|
- display: flex;
|
|
|
- flex-direction: column;
|
|
|
- justify-content: flex-start;
|
|
|
- align-items: flex-start;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- .num_score,
|
|
|
- .star_score
|
|
|
- {
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- gap:16px;
|
|
|
- color: #CCCCCC;
|
|
|
- line-height: 1;
|
|
|
- }
|
|
|
- .num_score{
|
|
|
- flex-wrap: wrap;
|
|
|
- li{
|
|
|
- display: flex;
|
|
|
- justify-content: center;
|
|
|
- align-items: center;
|
|
|
- border-radius: 4px ;
|
|
|
- border: 1px solid #CCCCCC;
|
|
|
- width: 44px;
|
|
|
- height: 32px;
|
|
|
- font-size: 14px;
|
|
|
- background-color: white;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- .star_score{
|
|
|
- word-break: keep-all;
|
|
|
- .el-rate{
|
|
|
- display: flex;
|
|
|
- flex-wrap: wrap;
|
|
|
- gap:10px 20px;
|
|
|
- height: auto;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|