Переглянути джерело

添加按题填写问答题数据渲染

lm 2 тижнів тому
батько
коміт
46a161cbbf

+ 16 - 18
src/components/questionAndAnswerBatchFill/QuestionAndAnswerBatchFill.vue

@@ -47,6 +47,10 @@ const props = defineProps({
         type:Boolean,
         default:true
     },
+    defaultTableData:{
+        type:Array,
+        default:()=>[]
+    }
 })
 
 const emit = defineEmits(['questionAnswerChange'])
@@ -55,23 +59,11 @@ const isFinishEdit = defineModel('isFinishEdit')  //是否已经编辑完成,
 
 
 // 模拟数据
-const tableData = ref([
-    {
-        subject:'语文',
-        content:'',
-    },
-    {
-        subject:'数学',
-        content:'',
-    },
-    {
-        subject:'英语',
-        content:'',
-    },
-    {
-        subject:'物理',
-        content:'',
-    },
+const tableData = ref<any[]>([
+    // {
+    //     teacher:'语文',
+    //     content:'',
+    // },
 ])
 
 
@@ -97,7 +89,13 @@ watch(()=>tableData.value,(newVal)=>{
     // 当前问卷没有全部填写完成
         isFinishEdit.value = false
     }
-},{deep:true})
+},{deep:true,immediate:true})
+
+
+watch(()=>props.defaultTableData,(newVal)=>{
+    console.log('传递的表数据变化了---',newVal)
+    tableData.value = newVal
+},{immediate:true,deep:true})
 
 
 </script>

+ 2 - 2
src/components/questionAndAnswerBatchFill/table.ts

@@ -2,7 +2,7 @@ import { ref } from "vue"
 
 export const tableColumns = ref([
     {
-        name:'subject',
+        name:'teacher',
         label:'科目',
         width:'120',
         fixed:'',
@@ -11,7 +11,7 @@ export const tableColumns = ref([
     },
     {
         name:'content',
-        label:'得分',
+        label:'内容',
         width:'620',
         fixed:'',
         align:'left',

+ 10 - 9
src/views/questionnaireCommit/QuestionnaireCommit.vue

@@ -139,6 +139,7 @@
                         :titleMsg="currentEditQuestion"
                         :allowEdit="!isCurrentQuestionnaireTaskFinish"
                         @questionAnswerChange="HandleQuestionAnswerChange"
+                        :defaultTableData="questionTableData"
                     />
                    
 
@@ -649,7 +650,8 @@ const questionaireMsg = computed(()=>{
             id:item.questionId,
             extraConfig,    // 是否必答 required, 是否横排 isHorizontal
             options,
-            answer:undefined
+            answer:undefined,
+            evaluationType :item.questionAnswerClass
         }
     })
     return{
@@ -780,14 +782,13 @@ watch(()=>currentEditQuestion.value?.questionType,(newVal)=>{
                 }
             }) || []
 
+            // 表行数据获取
             questionTableData.value =  teacherList.value.map(item=>{
                 return {
                     teacher:item.teacherName,
                     ...rowKeys  //答案需要循环遍历
                 }
             })
-
-            console.log('准备渲染的表数据___',questionTableData.value)
         }    
         case 1:{    //多选
             let rowKeys = { }
@@ -810,8 +811,6 @@ watch(()=>currentEditQuestion.value?.questionType,(newVal)=>{
                     ...rowKeys  //答案需要循环遍历
                 }
             })
-            console.log('准备渲染的表数据___',questionTableColumns.value, 'dfdfff',questionTableData.value)
-
             break
         }    
         case 5:{
@@ -822,10 +821,12 @@ watch(()=>currentEditQuestion.value?.questionType,(newVal)=>{
             break
         }    
         case 2:{   //问答题 
-
-
-
-
+            questionTableData.value =  teacherList.value.map(item=>{
+                return {
+                    teacher:item.teacherName,
+                    content:'',
+                }
+            })
             break
         }   
     }