Prechádzať zdrojové kódy

培训考试答题问题修复

jack.zhou 2 týždňov pred
rodič
commit
8b737827b5
3 zmenil súbory, kde vykonal 40 pridanie a 32 odobranie
  1. 10 10
      .env.development
  2. 0 20
      components.d.ts
  3. 30 2
      src/view/exam/index.vue

+ 10 - 10
.env.development

@@ -10,21 +10,21 @@
 # 本地环境
 ENV = development
 # 本地环境接口地址
-VITE_API_URL = http://192.168.0.216:9957/
+VITE_API_URL = http://192.168.0.216:9954/
 VITE_API_WECHAT = /wechat/
 VITE_TENANT = default
 
 # 微服务地址
-VITE_ADMIN = dashoo.labsop.admin-50000
-VITE_WORKFLOW = dashoo.labsop.workflow-50000
-VITE_FINANCE = dashoo.labsop.finance-50000
-VITE_SCI = dashoo.labsop.scientific-50000
-VITE_INSTR_ADMIN = dashoo.labsop.apparatus-50000
-VITE_LEARNING = dashoo.labsop.learning-50000
-VITE_PLATFORM_API = dashoo.labsop.platform-50000
-VITE_LABORATORY: dashoo.labsop.laboratory-50000
+VITE_ADMIN = dashoo.labsop.admin-34000
+VITE_WORKFLOW = dashoo.labsop.workflow-34000
+VITE_FINANCE = dashoo.labsop.finance-34000
+VITE_SCI = dashoo.labsop.scientific-34000
+VITE_INSTR_ADMIN = dashoo.labsop.apparatus-34000
+VITE_LEARNING = dashoo.labsop.learning-34000
+VITE_PLATFORM_API = dashoo.labsop.platform-34000
+VITE_LABORATORY: dashoo.labsop.laboratory-34000
 
 #公共配置
 VITE_UPLOAD = http://192.168.0.218:9933/weedfs/upload
 #图片回显域名
-VITE_IMAGE_BASE_URL = http://lims-demo.labsop.cn:50000
+VITE_IMAGE_BASE_URL = http://lims-demo.labsop.cn:34000

+ 0 - 20
components.d.ts

@@ -16,45 +16,25 @@ declare module 'vue' {
     VanActionBar: typeof import('vant/es')['ActionBar']
     VanActionBarButton: typeof import('vant/es')['ActionBarButton']
     VanActionBarIcon: typeof import('vant/es')['ActionBarIcon']
-    VanBackTop: typeof import('vant/es')['BackTop']
     VanButton: typeof import('vant/es')['Button']
-    VanCalendar: typeof import('vant/es')['Calendar']
     VanCell: typeof import('vant/es')['Cell']
     VanCellGroup: typeof import('vant/es')['CellGroup']
     VanCheckbox: typeof import('vant/es')['Checkbox']
     VanCheckboxGroup: typeof import('vant/es')['CheckboxGroup']
     VanCol: typeof import('vant/es')['Col']
-    VanCollapse: typeof import('vant/es')['Collapse']
-    VanCollapseItem: typeof import('vant/es')['CollapseItem']
-    VanDatePicker: typeof import('vant/es')['DatePicker']
     VanDialog: typeof import('vant/es')['Dialog']
-    VanEmpty: typeof import('vant/es')['Empty']
     VanField: typeof import('vant/es')['Field']
-    VanFloatingBubble: typeof import('vant/es')['FloatingBubble']
-    VanForm: typeof import('vant/es')['Form']
     VanIcon: typeof import('vant/es')['Icon']
-    VanImage: typeof import('vant/es')['Image']
     VanList: typeof import('vant/es')['List']
     VanNotify: typeof import('vant/es')['Notify']
-    VanPicker: typeof import('vant/es')['Picker']
-    VanPickerGroup: typeof import('vant/es')['PickerGroup']
-    VanPopup: typeof import('vant/es')['Popup']
     VanRadio: typeof import('vant/es')['Radio']
     VanRadioGroup: typeof import('vant/es')['RadioGroup']
     VanRow: typeof import('vant/es')['Row']
-    VanSearch: typeof import('vant/es')['Search']
-    VanStep: typeof import('vant/es')['Step']
-    VanStepper: typeof import('vant/es')['Stepper']
-    VanSteps: typeof import('vant/es')['Steps']
     VanSwipe: typeof import('vant/es')['Swipe']
     VanSwipeItem: typeof import('vant/es')['SwipeItem']
-    VanTab: typeof import('vant/es')['Tab']
     VanTabbar: typeof import('vant/es')['Tabbar']
     VanTabbarItem: typeof import('vant/es')['TabbarItem']
-    VanTabs: typeof import('vant/es')['Tabs']
     VanTag: typeof import('vant/es')['Tag']
     VanTextEllipsis: typeof import('vant/es')['TextEllipsis']
-    VanTimePicker: typeof import('vant/es')['TimePicker']
-    VanUploader: typeof import('vant/es')['Uploader']
   }
 }

+ 30 - 2
src/view/exam/index.vue

@@ -101,7 +101,7 @@
 
 <script name="home" lang="ts" setup>
   import to from 'await-to-js'
-  import { computed, onMounted, reactive, ref } from 'vue'
+  import { computed, nextTick, onMounted, reactive, ref } from 'vue'
   import { useRouter, useRoute } from 'vue-router'
   import { useDictApi } from '/@/api/system/dict'
   import { showConfirmDialog, showDialog, showNotify } from 'vant'
@@ -128,18 +128,42 @@
   })
   const checkboxRefs = ref([])
   const debounceTimer = ref(0)
+  const isClearingAnswer = ref(false)
   const toggle = (index) => {
     checkboxRefs.value[index].toggle()
   }
   
   // 处理答案变化,立即提交到后端
   const handleAnswerChange = () => {
+    if (isClearingAnswer.value) return
     // 使用防抖,避免频繁调用接口
     clearTimeout(debounceTimer.value)
     debounceTimer.value = setTimeout(() => {
       submitAnswer()
     }, 500)
   }
+  // 答题失败时清理当前题已输入答案
+  const clearQuestionAnswer = (question: any) => {
+    if (!question) return
+    isClearingAnswer.value = true
+    clearTimeout(debounceTimer.value)
+    const quType = String(question.quType)
+    if (quType == '4') {
+      question.quContent.forEach((item: any) => {
+        item.content = ''
+      })
+    } else if (quType == '5') {
+      question.answer = ''
+    } else if (quType == '1' || quType == '3') {
+      question.isCorrect = ''
+    } else {
+      question.answer = []
+      question.isCorrect = []
+    }
+    nextTick(() => {
+      isClearingAnswer.value = false
+    })
+  }
   const getDicts = () => {
     Promise.all([dictApi.getDictDataByType('sys_user_type')]).then(([type]) => {
       userTypeList.value = type.data.values || []
@@ -281,7 +305,10 @@
       params['answer'] = curAnswer.isCorrect.join(' ')
     }
     if (params.answer.length || params.fillAnswer.length) {
-      await trainingApi.submitDocAmswer(params)
+      const [err]: ToResponse = await to(trainingApi.submitDocAmswer(params))
+      if (err) {
+        clearQuestionAnswer(curAnswer)
+      }
     }
   }
   const handlePre = async () => {
@@ -315,6 +342,7 @@
       showConfirmDialog({
         message: '确认提交试卷?'
       }).then(() => {
+        params.auto = false
         submitAllAnswer(params)
       })
     }