|
@@ -46,7 +46,7 @@
|
|
|
<div class="page_item questionnaire_base">
|
|
<div class="page_item questionnaire_base">
|
|
|
<QuestionnaireBaseForm
|
|
<QuestionnaireBaseForm
|
|
|
v-model:formRef="questionnaireBaseFormRef"
|
|
v-model:formRef="questionnaireBaseFormRef"
|
|
|
- :defaultFormData="{}"
|
|
|
|
|
|
|
+ :defaultFormData="defaultQuestionnaireInfo"
|
|
|
@formChange="SyncQuestionnaireFormData"
|
|
@formChange="SyncQuestionnaireFormData"
|
|
|
></QuestionnaireBaseForm>
|
|
></QuestionnaireBaseForm>
|
|
|
</div>
|
|
</div>
|
|
@@ -118,7 +118,7 @@
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import {computed, onMounted, ref} from 'vue'
|
|
import {computed, onMounted, ref} from 'vue'
|
|
|
-import { useRouter } from 'vue-router';
|
|
|
|
|
|
|
+import { useRouter,useRoute } 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';
|
|
@@ -132,7 +132,7 @@ import QuestionTypeShow from '@/components/QuestionTypeShow.vue';
|
|
|
import moveUpDownIcon from '@/assets/icon/move_up_down.png'
|
|
import moveUpDownIcon from '@/assets/icon/move_up_down.png'
|
|
|
|
|
|
|
|
|
|
|
|
|
-import {addQuestionnaireApi} from '@/api/surveyManagement'
|
|
|
|
|
|
|
+import {addQuestionnaireApi,editQuestionnaireApi, getQuestionnaireDetailApi} from '@/api/surveyManagement'
|
|
|
|
|
|
|
|
// 题目选项信息 参数
|
|
// 题目选项信息 参数
|
|
|
interface Option {
|
|
interface Option {
|
|
@@ -153,21 +153,32 @@ interface QuestionItm {
|
|
|
|
|
|
|
|
interface QuestionnaireInfo {
|
|
interface QuestionnaireInfo {
|
|
|
assessmentTitle:String,
|
|
assessmentTitle:String,
|
|
|
- assessmentIllustrate:String
|
|
|
|
|
|
|
+ assessmentIllustrate:String,
|
|
|
|
|
+ createdAt?:String,
|
|
|
|
|
+ teacherName?:String,
|
|
|
|
|
+ useStatus?:String | Number,
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
|
|
|
+const route = useRoute()
|
|
|
|
|
|
|
|
// 试卷头表单
|
|
// 试卷头表单
|
|
|
const questionnaireBaseFormRef = ref()
|
|
const questionnaireBaseFormRef = ref()
|
|
|
-// 已存储的试卷整体信息
|
|
|
|
|
|
|
+
|
|
|
|
|
+// 已存储的试卷整体信息 __本地保存_模拟预览用 ????
|
|
|
const questionnaireMsg = ref()
|
|
const questionnaireMsg = ref()
|
|
|
|
|
|
|
|
|
|
+// 试卷头的默认信息
|
|
|
|
|
+const defaultQuestionnaireInfo = ref<QuestionnaireInfo>({})
|
|
|
// 试卷头基本信息
|
|
// 试卷头基本信息
|
|
|
const questionnaireInfo = ref<QuestionnaireInfo>({
|
|
const questionnaireInfo = ref<QuestionnaireInfo>({
|
|
|
assessmentTitle:'',
|
|
assessmentTitle:'',
|
|
|
- assessmentIllustrate:''
|
|
|
|
|
|
|
+ assessmentIllustrate:'',
|
|
|
|
|
+ createdAt:'',
|
|
|
|
|
+ teacherName:'',
|
|
|
|
|
+ useStatus:''
|
|
|
})
|
|
})
|
|
|
// 已经添加的题型
|
|
// 已经添加的题型
|
|
|
const addedQuestionList = ref<QuestionItm[]>([
|
|
const addedQuestionList = ref<QuestionItm[]>([
|
|
@@ -343,7 +354,6 @@ const SaveQuestionnaire = async ()=>{
|
|
|
await formRef.validate(async(valid) => {
|
|
await formRef.validate(async(valid) => {
|
|
|
if (valid) {
|
|
if (valid) {
|
|
|
if(addedQuestionList.value.length > 0){
|
|
if(addedQuestionList.value.length > 0){
|
|
|
-
|
|
|
|
|
let questionData = addedQuestionList.value.map((item,index)=>{
|
|
let questionData = addedQuestionList.value.map((item,index)=>{
|
|
|
return {
|
|
return {
|
|
|
...item,
|
|
...item,
|
|
@@ -359,32 +369,23 @@ const SaveQuestionnaire = async ()=>{
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
-
|
|
|
|
|
|
|
+ // 不带id的基础信息
|
|
|
let params = {
|
|
let params = {
|
|
|
...(questionnaireInfo.value),
|
|
...(questionnaireInfo.value),
|
|
|
questionData:questionData,
|
|
questionData:questionData,
|
|
|
assessmentScore:questionTotalScore.value
|
|
assessmentScore:questionTotalScore.value
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- let res = await addQuestionnaireApi(params)
|
|
|
|
|
- /**
|
|
|
|
|
- * 模拟数据
|
|
|
|
|
- */
|
|
|
|
|
- // 模拟保存数据 和页面跳转
|
|
|
|
|
- let questionnaireList = JSON.parse(localStorage.getItem('questionnaireList') || '[]')
|
|
|
|
|
-
|
|
|
|
|
- questionnaireMsg.value = {
|
|
|
|
|
- ...(questionnaireInfo.value),
|
|
|
|
|
- questionData:addedQuestionList.value,
|
|
|
|
|
- assessmentScore:questionTotalScore.value,
|
|
|
|
|
-
|
|
|
|
|
- id:Number(questionnaireList[questionnaireList.length - 1]?.id || 0) + 1,
|
|
|
|
|
- createdAt:unioformDateTransform(new Date()),
|
|
|
|
|
- teacherName:'管理员',
|
|
|
|
|
- useStatus:1
|
|
|
|
|
|
|
+ let res = undefined
|
|
|
|
|
+ if(route.query.id){
|
|
|
|
|
+ // 编辑问卷
|
|
|
|
|
+ res = await editQuestionnaireApi({...params,id:route.query.id})
|
|
|
|
|
+ }else{
|
|
|
|
|
+ // 新增问卷
|
|
|
|
|
+ res = await addQuestionnaireApi(params)
|
|
|
|
|
+ }
|
|
|
|
|
+ if(res?.code == 200){
|
|
|
|
|
+ ElMessage.success(res?.msg)
|
|
|
}
|
|
}
|
|
|
- questionnaireList.push(questionnaireMsg.value)
|
|
|
|
|
- localStorage.setItem('questionnaireList',JSON.stringify(questionnaireList || []))
|
|
|
|
|
}else{
|
|
}else{
|
|
|
ElMessage.warning('请添加问卷题目')
|
|
ElMessage.warning('请添加问卷题目')
|
|
|
}
|
|
}
|
|
@@ -397,10 +398,61 @@ const SaveQuestionnaire = async ()=>{
|
|
|
|
|
|
|
|
// 预览试卷
|
|
// 预览试卷
|
|
|
const PreviewQuestionnaire =()=>{
|
|
const PreviewQuestionnaire =()=>{
|
|
|
- sessionStorage.setItem('questionnaire',JSON.stringify(questionnaireMsg.value || '{}'))
|
|
|
|
|
- router.push(`/main/previewQuestionnaire`)
|
|
|
|
|
|
|
+ if(route.query.id){
|
|
|
|
|
+ router.push(`/main/previewQuestionnaire?id=${route.query.id}`)
|
|
|
|
|
+ }else{
|
|
|
|
|
+ ElMessage.warning('请先保存后再预览')
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const GetQuestionnaireDetail =async ()=>{
|
|
|
|
|
+ let res = await getQuestionnaireDetailApi(route.query.id)
|
|
|
|
|
+ if(res?.code == 200){
|
|
|
|
|
+ const {assessmentTitle,assessmentIllustrate,questionData,
|
|
|
|
|
+ createdAt,teacherName,useStatus
|
|
|
|
|
+
|
|
|
|
|
+ } = res.data
|
|
|
|
|
+
|
|
|
|
|
+ defaultQuestionnaireInfo.value = {
|
|
|
|
|
+ assessmentTitle:assessmentTitle,
|
|
|
|
|
+ assessmentIllustrate:assessmentIllustrate,
|
|
|
|
|
+ createdAt,
|
|
|
|
|
+ teacherName,
|
|
|
|
|
+ useStatus
|
|
|
|
|
+ }
|
|
|
|
|
+ addedQuestionList.value = questionData.map(item=>{
|
|
|
|
|
+ let options = item.answerData.map(opt=>{
|
|
|
|
|
+ return{
|
|
|
|
|
+ content: opt.answerName,
|
|
|
|
|
+ score: opt.answerScore,
|
|
|
|
|
+ id: opt.questionId
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ let extraConfig = []
|
|
|
|
|
+ if(Number(item.questionAnswerType) === 1){
|
|
|
|
|
+ extraConfig.push('required')
|
|
|
|
|
+ }
|
|
|
|
|
+ if(Number(item.questionSortRole) === 1){
|
|
|
|
|
+ extraConfig.push('isHorizontal')
|
|
|
|
|
+ }
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ id:item.assessmentId,
|
|
|
|
|
+ extraConfig, // 是否必答 required, 是否横排 isHorizontal
|
|
|
|
|
+ options
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+onMounted(async ()=>{
|
|
|
|
|
+ if(route.query.id){
|
|
|
|
|
+ await GetQuestionnaireDetail()
|
|
|
|
|
+ }else{
|
|
|
|
|
+ // 创建问卷
|
|
|
|
|
+ }
|
|
|
|
|
+})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|