Kaynağa Gözat

多科目情况下,切换科目时小组列表未更新的bug修复

刘洋 1 yıl önce
ebeveyn
işleme
e85ac0def3
2 değiştirilmiş dosya ile 44 ekleme ve 19 silme
  1. 2 2
      server.config.ts
  2. 42 17
      src/hooks/useOptions.ts

+ 2 - 2
server.config.ts

@@ -3,11 +3,11 @@ import type { ServerOptions } from 'vite'
 const server: ServerOptions = {
   proxy: {
     '^/?(api|file)/': {
-      // target: 'http://192.168.10.41:8200',
+      target: 'http://192.168.10.41:8200',
       // target: 'http://192.168.10.178:8200',
       // target: 'http://192.168.10.108:8200',
       // target: 'http://cet-test.markingtool.cn',
-      target: 'http://192.168.10.136:80',
+      // target: 'http://192.168.10.136:80',
       // target: 'http://cet-dev.markingtool.cn:8200',
     },
   },

+ 42 - 17
src/hooks/useOptions.ts

@@ -193,27 +193,47 @@ const useOptions = (
     { immediate: true }
   )
 
+  const watchQuestionHandle = () => {
+    isChooseAllOptionMap.question = !dataModel.question
+    if (types.includes('group') && dataModel.subject && dataModel.question) {
+      // resetGroupList()
+      // changeModelValue('group')(void 0)
+      getQuestionGroupList({ subjectCode: dataModel.subject, mainNumber: dataModel.question }).then((res: any) => {
+        // if (!userInfo.value?.markingGroupNumber && res && res[0]) {
+        //   changeModelValue('group')(res[0])
+        // }
+        changeModelValue('group')(
+          multGroup && showAllLabel
+            ? groupList.value?.length && (isAdmin.value || isChief.value || isExpert.value || isLeader.value)
+              ? [void 0]
+              : []
+            : void 0
+        )
+      })
+    }
+  }
   watch(
     // [() => dataModel.question, () => dataModel.question],
     () => dataModel.question,
     () => {
-      isChooseAllOptionMap.question = !dataModel.question
-      if (types.includes('group') && dataModel.subject && dataModel.question) {
-        // resetGroupList()
-        // changeModelValue('group')(void 0)
-        getQuestionGroupList({ subjectCode: dataModel.subject, mainNumber: dataModel.question }).then((res: any) => {
-          // if (!userInfo.value?.markingGroupNumber && res && res[0]) {
-          //   changeModelValue('group')(res[0])
-          // }
-          changeModelValue('group')(
-            multGroup && showAllLabel
-              ? groupList.value?.length && (isAdmin.value || isChief.value || isExpert.value || isLeader.value)
-                ? [void 0]
-                : []
-              : void 0
-          )
-        })
-      }
+      watchQuestionHandle()
+      // isChooseAllOptionMap.question = !dataModel.question
+      // if (types.includes('group') && dataModel.subject && dataModel.question) {
+      //   // resetGroupList()
+      //   // changeModelValue('group')(void 0)
+      //   getQuestionGroupList({ subjectCode: dataModel.subject, mainNumber: dataModel.question }).then((res: any) => {
+      //     // if (!userInfo.value?.markingGroupNumber && res && res[0]) {
+      //     //   changeModelValue('group')(res[0])
+      //     // }
+      //     changeModelValue('group')(
+      //       multGroup && showAllLabel
+      //         ? groupList.value?.length && (isAdmin.value || isChief.value || isExpert.value || isLeader.value)
+      //           ? [void 0]
+      //           : []
+      //         : void 0
+      //     )
+      //   })
+      // }
     },
     { immediate: true }
   )
@@ -245,7 +265,12 @@ const useOptions = (
           !userInfo.value?.mainNumber
         ) {
           if (mainQuestionList.value.length) {
+            const oldQuestionNumber = dataModel.question
             changeModelValue('question')(mainQuestionList.value[0].value)
+            if (oldQuestionNumber == mainQuestionList.value[0].value) {
+              //防止切换科目前的大题号和切换科目后的大题号相同,watch question监听不执行
+              watchQuestionHandle()
+            }
           }
         }
       },