|
@@ -47,7 +47,7 @@
|
|
|
<QuestionnaireBaseForm
|
|
<QuestionnaireBaseForm
|
|
|
v-model:formRef="questionnaireBaseFormRef"
|
|
v-model:formRef="questionnaireBaseFormRef"
|
|
|
:defaultFormData="{}"
|
|
:defaultFormData="{}"
|
|
|
- @formChage="SyncQuestionnaireFormData"
|
|
|
|
|
|
|
+ @formChange="SyncQuestionnaireFormData"
|
|
|
></QuestionnaireBaseForm>
|
|
></QuestionnaireBaseForm>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
@@ -56,8 +56,16 @@
|
|
|
<li v-for="(question,index) in addedQuestionList" :key="question.id">
|
|
<li v-for="(question,index) in addedQuestionList" :key="question.id">
|
|
|
<div class="question_title"
|
|
<div class="question_title"
|
|
|
:class="{required:question.extraConfig.includes('required')}">
|
|
:class="{required:question.extraConfig.includes('required')}">
|
|
|
- {{index + 1}}.{{ question.questionTitleName }}
|
|
|
|
|
|
|
+ <span>{{index + 1}}.{{ question.questionTitleName }}</span>
|
|
|
<span class="question_type">[{{ qustionTypeToName(question.questionType) }}]</span>
|
|
<span class="question_type">[{{ qustionTypeToName(question.questionType) }}]</span>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <div class="operation table_row_option">
|
|
|
|
|
+ <span class="el_button_editor" @click="EditQuestion(question)">编辑</span>
|
|
|
|
|
+ <span class="el_button_delete" @click="DeleteQuestion(question)">删除</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
</div>
|
|
</div>
|
|
|
<QuestionTypeShow
|
|
<QuestionTypeShow
|
|
|
:isHorizontal="question.extraConfig.includes('isHorizontal')"
|
|
:isHorizontal="question.extraConfig.includes('isHorizontal')"
|
|
@@ -78,8 +86,9 @@
|
|
|
<div v-else class="question_itm_edit">
|
|
<div v-else class="question_itm_edit">
|
|
|
<QuestionConfig
|
|
<QuestionConfig
|
|
|
:displayMode="selectedQuestionGetScore ? 'scored' : 'statistic'"
|
|
:displayMode="selectedQuestionGetScore ? 'scored' : 'statistic'"
|
|
|
- :questionType="selectedQuestionType"
|
|
|
|
|
@confirm="AddQuesiton"
|
|
@confirm="AddQuesiton"
|
|
|
|
|
+ :defaultFormData="defaultQuestionData"
|
|
|
|
|
+ @formChange="HandleQuestionChange"
|
|
|
></QuestionConfig>
|
|
></QuestionConfig>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
@@ -111,7 +120,7 @@
|
|
|
import {computed, onMounted, ref} from 'vue'
|
|
import {computed, onMounted, ref} from 'vue'
|
|
|
import { useRouter } from 'vue-router';
|
|
import { useRouter } from 'vue-router';
|
|
|
import TopBackNav from '@/components/TopBackNav.vue';
|
|
import TopBackNav from '@/components/TopBackNav.vue';
|
|
|
-import {statisticQuestionType,scoredQuestionType,qustionTypeToName} from '../../../components/questionConfig/questionTypeList'
|
|
|
|
|
|
|
+import {statisticQuestionType,scoredQuestionType,qustionTypeToName} from '@/components/questionConfig/questionTypeList'
|
|
|
import QuestionConfig from '@/components/questionConfig/QuestionConfig.vue';
|
|
import QuestionConfig from '@/components/questionConfig/QuestionConfig.vue';
|
|
|
import QuestionnaireBaseForm from '@/components/questionConfig/QuestionnaireBaseForm.vue';
|
|
import QuestionnaireBaseForm from '@/components/questionConfig/QuestionnaireBaseForm.vue';
|
|
|
import { ElMessage } from 'element-plus';
|
|
import { ElMessage } from 'element-plus';
|
|
@@ -173,6 +182,14 @@ const addedQuestionList = ref<QuestionItm[]>([
|
|
|
}
|
|
}
|
|
|
])
|
|
])
|
|
|
|
|
|
|
|
|
|
+// 默认的试题信息
|
|
|
|
|
+// questionTitleName: '',
|
|
|
|
|
+// questionScore: '',
|
|
|
|
|
+// questionType: '',
|
|
|
|
|
+// extraConfig: ['required'], //默认勾选必答题
|
|
|
|
|
+// options: [],
|
|
|
|
|
+// evaluationType:0 //默认展示 数字式
|
|
|
|
|
+const defaultQuestionData = ref({})
|
|
|
|
|
|
|
|
// 当前选中的题型
|
|
// 当前选中的题型
|
|
|
const selectedQuestionType = ref('')
|
|
const selectedQuestionType = ref('')
|
|
@@ -192,15 +209,18 @@ const questionTotalScore = computed(()=>{
|
|
|
|
|
|
|
|
// 选中题型时的处理
|
|
// 选中题型时的处理
|
|
|
const CheckedQuestionType = (type:any) => {
|
|
const CheckedQuestionType = (type:any) => {
|
|
|
|
|
+ console.log('触发操作了',type)
|
|
|
selectedQuestionType.value = type
|
|
selectedQuestionType.value = type
|
|
|
- switch(type){
|
|
|
|
|
- case '0':
|
|
|
|
|
- case '1':
|
|
|
|
|
- case '2':
|
|
|
|
|
|
|
+ resetQuestionForm(type)
|
|
|
|
|
+
|
|
|
|
|
+ switch(Number(type)){
|
|
|
|
|
+ case 0:
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ case 2:
|
|
|
selectedQuestionGetScore.value = false
|
|
selectedQuestionGetScore.value = false
|
|
|
break
|
|
break
|
|
|
- case '3':
|
|
|
|
|
- case '4':
|
|
|
|
|
|
|
+ case 3:
|
|
|
|
|
+ case 5:
|
|
|
selectedQuestionGetScore.value = true
|
|
selectedQuestionGetScore.value = true
|
|
|
break
|
|
break
|
|
|
}
|
|
}
|
|
@@ -211,6 +231,26 @@ const SyncQuestionnaireFormData = (params)=>{
|
|
|
questionnaireInfo.value = {...params}
|
|
questionnaireInfo.value = {...params}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 重置试题表单数据
|
|
|
|
|
+const resetQuestionForm = (questionType)=>{
|
|
|
|
|
+ defaultQuestionData.value = {
|
|
|
|
|
+ questionTitleName: '',
|
|
|
|
|
+ questionScore: '',
|
|
|
|
|
+ questionType: questionType,
|
|
|
|
|
+ extraConfig: ['required'], //默认勾选必答题
|
|
|
|
|
+ options: [],
|
|
|
|
|
+ evaluationType:0 //默认展示 数字式
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+const HandleQuestionChange = (params)=>{
|
|
|
|
|
+ const { key, val, formData: data } = params
|
|
|
|
|
+ switch(key){
|
|
|
|
|
+ case 'question_type':{
|
|
|
|
|
+ resetQuestionForm(val)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 处理试题排序
|
|
// 处理试题排序
|
|
|
const { HandleDragStart, HandleDragEnd } = useHandleMoveUpAndDown(addedQuestionList,42)
|
|
const { HandleDragStart, HandleDragEnd } = useHandleMoveUpAndDown(addedQuestionList,42)
|
|
|
|
|
|
|
@@ -239,6 +279,20 @@ const AddQuesiton = (params)=>{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+const DeleteQuestion = (row)=>{
|
|
|
|
|
+ // 删除当前题目
|
|
|
|
|
+ addedQuestionList.value = addedQuestionList.value.filter(item=>{
|
|
|
|
|
+ return item.id !== row.id
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+const EditQuestion = (row)=>{
|
|
|
|
|
+
|
|
|
|
|
+ console.log('当前编辑的行',row)
|
|
|
|
|
+ // 待完善
|
|
|
|
|
+ defaultQuestionData.value = row
|
|
|
|
|
+ CheckedQuestionType(row.questionType)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 保存试卷
|
|
// 保存试卷
|
|
|
const SaveQuestionnaire = async ()=>{
|
|
const SaveQuestionnaire = async ()=>{
|
|
|
// 试卷总表单
|
|
// 试卷总表单
|
|
@@ -249,7 +303,29 @@ const SaveQuestionnaire = async ()=>{
|
|
|
if (valid) {
|
|
if (valid) {
|
|
|
if(addedQuestionList.value.length > 0){
|
|
if(addedQuestionList.value.length > 0){
|
|
|
|
|
|
|
|
- // addQuestionnaireApi()
|
|
|
|
|
|
|
+ let questionData = addedQuestionList.value.map((item,index)=>{
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ questionAnswerType:item.extraConfig.includes('required') ? 1 : 0, // 是否必答,0-否,1-是
|
|
|
|
|
+ questionSortRole:item.extraConfig.includes('isHorizontal') ? 1 : 0, // 0-竖排,1-横排
|
|
|
|
|
+ questionSortCode:index + 1,
|
|
|
|
|
+ answerData:item.options.map((opt,optIndex)=>{
|
|
|
|
|
+ return {
|
|
|
|
|
+ questionSortCode: optIndex + 1,
|
|
|
|
|
+ answerName: opt.label,
|
|
|
|
|
+ answerScore: opt.score
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ ...(questionnaireInfo.value),
|
|
|
|
|
+ questionData:questionData,
|
|
|
|
|
+ assessmentScore:questionTotalScore.value
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let res = await addQuestionnaireApi(params)
|
|
|
/**
|
|
/**
|
|
|
* 模拟数据
|
|
* 模拟数据
|
|
|
*/
|
|
*/
|
|
@@ -259,10 +335,11 @@ const SaveQuestionnaire = async ()=>{
|
|
|
questionnaireMsg.value = {
|
|
questionnaireMsg.value = {
|
|
|
...(questionnaireInfo.value),
|
|
...(questionnaireInfo.value),
|
|
|
questionData:addedQuestionList.value,
|
|
questionData:addedQuestionList.value,
|
|
|
- id:Number(questionnaireList[questionnaireList.length - 1]?.id || 0) + 1,
|
|
|
|
|
- createTime:unioformDateTransform(new Date()),
|
|
|
|
|
- createBy:'管理员',
|
|
|
|
|
assessmentScore:questionTotalScore.value,
|
|
assessmentScore:questionTotalScore.value,
|
|
|
|
|
+
|
|
|
|
|
+ id:Number(questionnaireList[questionnaireList.length - 1]?.id || 0) + 1,
|
|
|
|
|
+ createdAt:unioformDateTransform(new Date()),
|
|
|
|
|
+ teacherName:'管理员',
|
|
|
useStatus:1
|
|
useStatus:1
|
|
|
}
|
|
}
|
|
|
questionnaireList.push(questionnaireMsg.value)
|
|
questionnaireList.push(questionnaireMsg.value)
|
|
@@ -378,11 +455,16 @@ const PreviewQuestionnaire =()=>{
|
|
|
display: flex;
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
flex-direction: column;
|
|
|
gap:20px;
|
|
gap:20px;
|
|
|
- padding:20px;
|
|
|
|
|
- font-size: 14px;
|
|
|
|
|
|
|
+ padding-top:10px;
|
|
|
|
|
+ font-size: 16px;
|
|
|
color:#000;
|
|
color:#000;
|
|
|
li{
|
|
li{
|
|
|
|
|
+ padding:10px 20px;
|
|
|
|
|
+
|
|
|
.question_title{
|
|
.question_title{
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: flex-start;
|
|
|
|
|
+ word-break: keep-all;
|
|
|
margin-bottom: 20px;
|
|
margin-bottom: 20px;
|
|
|
.question_type{
|
|
.question_type{
|
|
|
color:#2E64FA;
|
|
color:#2E64FA;
|
|
@@ -399,6 +481,22 @@ const PreviewQuestionnaire =()=>{
|
|
|
color:#F56C6C;
|
|
color:#F56C6C;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ .operation{
|
|
|
|
|
+ display: none;
|
|
|
|
|
+ flex: 1 1;
|
|
|
|
|
+ justify-content: flex-end;
|
|
|
|
|
+ gap:20px;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ &:hover{
|
|
|
|
|
+ box-shadow: 0px 10px 20px 0px rgba(46,100,250,0.1),
|
|
|
|
|
+ 0px -10px 20px 0px rgba(46,100,250,0.1);
|
|
|
|
|
+ .question_title .operation{
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|