Procházet zdrojové kódy

修改h5端问卷填写的头部信息和问卷查看逻辑

lm před 1 týdnem
rodič
revize
8b6a61be33

+ 22 - 5
src/layout/components/AppHeader.vue

@@ -1,16 +1,33 @@
 <template>
     <div class="app_header">
         <el-icon v-if="showBack" class="left_back" @click="$router.go(-1)"><ArrowLeftBold /></el-icon>
-        智能教学评价系统
+        {{ headerTitle }}
     </div>
 </template>
 
 <script setup lang="ts">
+import {computed,ref} from 'vue'
+import { useRoute } from 'vue-router'
 
-const props = defineProps({
-    showBack:{
-        type:Boolean,
-        default:true
+import { useStore } from 'vuex'
+
+const route = useRoute()
+const store = useStore()
+
+const showBack = computed(()=>{
+  if(route.path.startsWith('/app') && route.path !== '/app' 
+      && route.path !== '/app/' && !route.path.startsWith('/app/questionnaireTaskListPage')){
+    return true
+  }else{
+    return false
+  }
+})
+
+const headerTitle = computed(()=>{
+    if( route.path.startsWith('/app/questionnaireCommit') ){
+        return store.state.subjectQuestionnaireTitle
+    }else{
+        return '智能教学评价系统'
     }
 })
 

+ 1 - 12
src/layout/index.vue

@@ -1,9 +1,7 @@
 <template>
   <div class="layout">
     <component :is="finalHeader" 
-      :horizontalNavList="horizontalNavList" 
-      :showBack="showBack" 
-    />
+      :horizontalNavList="horizontalNavList"/>
     <AppMain :menuItems="menuList"/>
   </div>
 </template>
@@ -29,15 +27,6 @@ const horizontalNavList = computed(()=>{
   return []
 })
 
-const showBack = computed(()=>{
-  if(route.path.startsWith('/app') && route.path !== '/app' 
-      && route.path !== '/app/' && !route.path.startsWith('/app/questionnaireTaskListPage')){
-    return true
-  }else{
-    return false
-  }
-})
-
 const finalHeader = computed(()=>{
   if(route.path.startsWith('/main')){
     return Header

+ 7 - 0
src/store/index.ts

@@ -7,6 +7,7 @@ import type { App } from 'vue'
 interface RootState {
   count: number,
   managerHorizontalMenuItems:any[],
+  subjectQuestionnaireTitle:string
 }
 
 
@@ -18,11 +19,17 @@ const store = createStore<RootState>({
     count: 0,
     // 管理员 评教评学 的访问菜单
     managerHorizontalMenuItems:[],
+    // 科目问卷标题(科目)
+    subjectQuestionnaireTitle:''
   }),
   mutations: {
     increment(state: RootState) {
       state.count++
     },
+    // 更新科目问卷标题
+    updateSubjectQuestionnaireTitle(state:RootState,newVal){
+      state.subjectQuestionnaireTitle = newVal
+    }
   },
   actions: {
     increment({ commit }) {

+ 30 - 1
src/views/appView/QuestionnaireCommit.vue

@@ -23,6 +23,7 @@
 <script setup lang="ts">
 import { ref, computed, onMounted } from 'vue';
 import { ElMessage } from 'element-plus';
+import { useStore } from 'vuex'
 
 import AppQuestionnaireQuestionList from '@/components/AppQuestionnaireQuestionList.vue';
 
@@ -31,6 +32,8 @@ import {getEvaluationProcessMsgApi} from '@/api/selfQuestionnaireProcess'
 import { getEvaluationQuestionDataApi, saveEvaluationQuestionDataApi } from '@/api/questionnaireCommit'
 
 
+const store = useStore()
+
 interface TeacherItm {
     id: string|number
     evaluationClassName: string     //班级
@@ -101,6 +104,7 @@ const HandleFinishReview = async ()=>{
             }
             // 跳转到下一个教师的问卷
             currentActiveTeacherId.value = teacherList.value?.[currentIndex + 1]?.id || ''
+            store.commit('updateSubjectQuestionnaireTitle',teacherList.value?.[currentIndex + 1]?.evaluationSubjectName + '-' + teacherList.value?.[currentIndex + 1]?.teacherName + '问卷')
         }else{
             // 重新查询教师状态和问卷状态
             await ReloadPageData()
@@ -206,7 +210,25 @@ const GetFullQuestionnaireData = async ()=>{
     if(currentActiveTeacherId.value){
         return
     }
-    currentActiveTeacherId.value = teacherList.value?.[0]?.id || ''
+
+
+    
+    // 获取第一个 进行中
+    const firstActiveIndex =  teacherList.value.findIndex(item => item.evaluationStatus === 1);
+    const hasActive = firstActiveIndex !== -1;
+
+    // 获取第一个待评价
+    const firstPendingIndex = hasActive 
+        ? -1 
+        : teacherList.value.findIndex(item => item.evaluationStatus === 0);
+    const hasPending = firstPendingIndex != -1
+
+    let finalIndex = hasActive ? firstActiveIndex :
+                    (hasPending ? firstPendingIndex : 0)
+                    
+    // 这个要默认打开最新的 第一个进行中  或第一个待评价 
+    currentActiveTeacherId.value = teacherList.value?.[finalIndex]?.id || ''
+    store.commit('updateSubjectQuestionnaireTitle',teacherList.value?.[finalIndex]?.evaluationSubjectName + '-' + teacherList.value?.[finalIndex]?.teacherName + '问卷')
 }
 
 // 重新加载页面数据
@@ -216,6 +238,13 @@ const ReloadPageData = async ()=>{
 }
 
 onMounted(()=>{
+    let currentEditTeacherQuestionnaire = sessionStorage.getItem('currentEditTeacherQuestionnaire')
+    if(currentEditTeacherQuestionnaire){
+        let localQuestionnaire = JSON.parse(currentEditTeacherQuestionnaire || '{}')
+        currentActiveTeacherId.value = localQuestionnaire?.id
+        store.commit('updateSubjectQuestionnaireTitle',localQuestionnaire?.subjectName + '-' + localQuestionnaire?.teacherName+ '问卷')
+        sessionStorage.removeItem('currentEditTeacherQuestionnaire')
+    }
     ReloadPageData()
 })
 

+ 14 - 2
src/views/appView/SelfQuestionnaireProcess.vue

@@ -29,7 +29,7 @@
         <ul class="teacher_list">
             <li  v-for="(item) in teacherList" 
                 :key="item.id"  
-                class="teacher_card">
+                class="teacher_card" @click="HandleQuestoinnaireOpen(item)">
                 <div class="card_header">
                     <div class="subject_tag" :style="{ backgroundColor: subjectToColor(item.evaluationSubjectName)?.color }">
                         {{ item.evaluationSubjectName }}
@@ -93,10 +93,22 @@ const GoToElectiveSubject = ()=>{
 
 // 跳转到填写问卷页
 const GoToFillOutQuestionnaire = ()=>{
-    // 模拟数据
     router.push('/app/questionnaireCommit')
 }
 
+// 查看已完成的问卷 信息
+const HandleQuestoinnaireOpen = (teacher)=>{
+    // evaluationStatus  0-待评价  1-进行中  2-已评价
+    if(teacher.evaluationStatus === 2){
+        // 跳转到问卷评价页
+        sessionStorage.setItem('currentEditTeacherQuestionnaire',JSON.stringify({
+            id:teacher.id,
+            subjectName:teacher.evaluationSubjectName,
+            teacherName:teacher.teacherName
+        }))
+        router.push('/app/questionnaireCommit')
+    }
+}
 
 onMounted( async()=>{
     let res = await getEvaluationProcessMsgApi()

+ 16 - 1
src/views/questionnaireCommit/QuestionnaireCommit.vue

@@ -491,7 +491,22 @@ const GetFullQuestionnaireData = async ()=>{
     if(currentActiveTeacherId.value){
         return
     }
-    currentActiveTeacherId.value = teacherList.value?.[0]?.id || ''
+
+    // 获取第一个 进行中
+    const firstActiveIndex =  teacherList.value.findIndex(item => item.evaluationStatus === 1);
+    const hasActive = firstActiveIndex !== -1;
+
+    // 获取第一个待评价
+    const firstPendingIndex = hasActive 
+        ? -1 
+        : teacherList.value.findIndex(item => item.evaluationStatus === 0);
+    const hasPending = firstPendingIndex != -1
+
+    let finalIndex = hasActive ? firstActiveIndex :
+                    (hasPending ? firstPendingIndex : 0)
+         
+    // 这个要默认打开最新的 第一个进行中  或第一个待评价 
+    currentActiveTeacherId.value = teacherList.value?.[finalIndex]?.id || ''
 }
 
 // 获取按题填写问卷数据