Преглед на файлове

Merge branch 'refs/heads/20240604-dev' into 20240904-zyy

# Conflicts:
#	src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskVisualTraining/components/wordWord/index.vue
周玉佂 преди 1 седмица
родител
ревизия
327e1e82ef
променени са 12 файла, в които са добавени 288 реда и са изтрити 11 реда
  1. 1 1
      .env.development
  2. BIN
      public/static/image/cognitiveAbility/SpeechTraining/verify-bg.png
  3. 110 0
      src/api/tester/evaluation/speechTraining.ts
  4. 146 3
      src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskAuditoryTraining/CATAuditoryTrainingRecognition/index.vue
  5. 9 0
      src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskAuditoryTraining/CATAuditoryTrainingRecognition/topics.json
  6. 16 1
      src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskAuditoryTraining/index.vue
  7. 1 1
      src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskVisualTraining/components/Words/index.vue
  8. 1 1
      src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskVisualTraining/components/diagramMap/index.vue
  9. 1 1
      src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskVisualTraining/components/essay/index.vue
  10. 1 1
      src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskVisualTraining/components/execute/index.vue
  11. 1 1
      src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskVisualTraining/components/mapWord/index.vue
  12. 1 1
      src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskVisualTraining/components/wordMap/index.vue

+ 1 - 1
.env.development

@@ -12,7 +12,7 @@ VITE_APP_BASE_API = '/dev-api'
 # VITE_APP_API_URL = 'http://192.168.1.8:8001'
 
 # 公司本地
-VITE_APP_API_URL = 'http://192.168.1.4:8107'
+VITE_APP_API_URL = 'http://192.168.1.10:8107'
 
 # 家里本地
 # VITE_APP_API_URL = 'http://192.168.1.11:8107'

BIN
public/static/image/cognitiveAbility/SpeechTraining/verify-bg.png


+ 110 - 0
src/api/tester/evaluation/speechTraining.ts

@@ -0,0 +1,110 @@
+import request from '@/utils/request'
+
+const SPEECH_TRAINING_BASE_URL = '/taskRoutine'
+
+/**
+ * 患者常规训练子任务记录接口
+ */
+class SpeechTrainingAPI {
+  /**
+   * 获取常规训练子任务列表
+   *
+   * @returns 常规训练子任务名称、编码等
+   */
+  static getPage(queryParams: SpeechTrainingQuery) {
+    return request<any, PageResult<SpeechTrainingVO[]>>({
+      url: SPEECH_TRAINING_BASE_URL + '/findPage',
+      method: 'get',
+      params: queryParams
+    })
+  }
+  /**
+   * 获取常规训练子任务列表
+   *
+   * @returns 常规训练子任务名称、编码等
+   */
+  static findList() {
+    return request<any, SpeechTrainingVO[]>({
+      url: SPEECH_TRAINING_BASE_URL + '/findList',
+      method: 'get'
+    })
+  }
+
+  /**
+   * 添加常规训练子任务
+   *
+   * @param data 常规训练子任务表单数据
+   */
+  static add(data: SpeechTrainingVO) {
+    return request({
+      url: `${SPEECH_TRAINING_BASE_URL}/save`,
+      method: 'post',
+      data: data
+    })
+  }
+
+  /**
+   * 修改常规训练子任务
+   *
+   * @param data 常规训练子任务表单数据
+   */
+  static update(data: SpeechTrainingVO) {
+    return request({
+      url: `${SPEECH_TRAINING_BASE_URL}/update`,
+      method: 'put',
+      data: data
+    })
+  }
+
+  /**
+   * 删除常规训练子任务
+   *
+   * @param id 常规训练子任务Id
+   */
+  static deleteById(id: string) {
+    return request({
+      url: `${SPEECH_TRAINING_BASE_URL}/delete/${id}`,
+      method: 'delete'
+    })
+  }
+}
+
+export default SpeechTrainingAPI
+
+/** 常规训练子任务信息 */
+export interface SpeechTrainingVO {
+  /** 常规训练子任务ID */
+  id?: string
+  /** 子任务中具体题目相关内容 */
+  content?: string
+  /** 认知任务标识 */
+  flag?: string
+  /** 时长 */
+  min?: string
+  /** 受试者ID */
+  patId?: string
+  /** 评定 认知任务关联表Id */
+  parentId?: string
+  /** 所属题号名称 */
+  questionName?: string
+  /** 所属题号 */
+  questionNo?: string
+  /** 测试记录ID */
+  recordId?: string
+  /** 状态:1-多项测试;0-单项测试 */
+  type?: string
+}
+
+/**
+ * 常规训练子任务 查询参数
+ */
+export interface SpeechTrainingQuery extends PageQuery {
+  /** 所属题号名称 */
+  questionName?: string
+  /** 认知任务ID **/
+  taskId?: string
+  /** 模式:1-多项测试;0-单项测试 **/
+  type?: string
+  /** 测试记录ID **/
+  recordId?: string
+}

+ 146 - 3
src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskAuditoryTraining/CATAuditoryTrainingRecognition/index.vue

@@ -1,8 +1,44 @@
 <template>
-  <section class="auditory-recognition-container flex-center wh-full relative">
+  <section class="auditory-recognition-container flex-center flex-col wh-full relative">
     <water-title title="语音辨识" />
     <div v-if="isMainWin" class="text-[42px]">接下来会给你听一些声音,请在这些声音中选择出屏幕中呈现的词语</div>
 
+    <div v-if="!isMainWin && showTopics" class="flex-center flex-col text-100px text-[#15FAF2]">
+      {{ TopicsVal[currentIndex].correct }}
+    </div>
+    <div class="w-80% h-60% my-20px flex-center flex-row justify-between">
+      <template v-if="showTopics">
+        <div
+          v-for="(item, index) in TopicsVal[currentIndex].choices"
+          :key="index"
+          class="w-320px h-360px flex-center rounded-8px shadow-2xl text-140px cursor-pointer"
+          :class="{ 'bg-[#15FAF2] text-white': useClickIndex === index || item === TopicsVal[currentIndex].userAnswer }"
+          @click="handleItemClick(item, index)"
+        >
+          <div v-if="isMainWin">{{ item }}</div>
+          <div v-else>{{ index + 1 }}</div>
+        </div>
+      </template>
+    </div>
+
+    <div v-if="!isMainWin" class="w-[300px] h-[140px]">
+      <el-image
+        v-if="showSubmitBtn"
+        src="/static/image/cognitiveAbility/SpeechTraining/verify-bg.png"
+        fit="contain"
+        class="w-[300px] h-[140px] cursor-pointer hover:scale-101"
+        @click="handleSubmit"
+      />
+    </div>
+
+    <el-image
+      v-if="showNextBtn"
+      src="/static/image/cognitiveAbility/SpeechTraining/next.png"
+      fit="contain"
+      class="!absolute bottom-[24px] right-[140px] w-[300px] h-[140px] cursor-pointer hover:scale-101"
+      @click="handleNext()"
+    />
+
     <VoiceImp ref="VoiceImpRef" />
   </section>
 </template>
@@ -15,19 +51,88 @@
  * 编写者: JutarryWu
  */
 
+import { isJSON } from '@/utils'
+
 defineOptions({
   name: 'CATAuditoryTrainingRecognition',
   inheritAttrs: false
 })
+
+import Topics from './topics.json'
+
+interface TopicsType {
+  question: string
+  choices: string[]
+  correct: string
+  userAnswer: string
+}
+
 const props = defineProps({})
-const emits = defineEmits([])
+const emits = defineEmits(['gameOver'])
 
 const isMainWin = ref(false)
+const showNextBtn = ref(false) // 主屏 - 显示下一题按钮标识
+const showSubmitBtn = ref(false) // 副屏 - 显示确定按钮标识
+let isSubmitting = false // 是否正在提交标识
+const showTopics = ref(false) // 显示题目选项标识
 const VoiceImpRef = ref()
+const currentIndex = ref(0)
+const TopicsVal = ref<TopicsType[]>([])
+const useClickIndex = ref(-1) // 副屏 - 用户点击的选项索引
+
+const handleNext = () => {
+  if (TopicsVal.value[currentIndex.value].userAnswer === '') {
+    showTopics.value = true
+    showNextBtn.value = false
+    localStorage.setItem('tow-win-auditory-recognition-show-topics', 'YES')
+  } else {
+    let tempCount = TopicsVal.value.filter((item) => item.userAnswer !== '').length
+    if (tempCount === TopicsVal.value.length) {
+      isSubmitting = true
+      localStorage.setItem('tow-win-auditory-recognition-isSubmitting', 'YES')
+    } else {
+      currentIndex.value++
+      handleNext()
+    }
+  }
+}
+
+const handleItemClick = (item: string, index: number) => {
+  if (isSubmitting) return // 如果再提交进程中,不响应点击事件
+  if (isMainWin.value) {
+    localStorage.setItem('two-win-auditory-recognition-item-check', item)
+  } else {
+    TopicsVal.value[currentIndex.value].userAnswer = item
+    useClickIndex.value = index
+    showSubmitBtn.value = true
+    localStorage.setItem('two-win-auditory-recognition-submit-answer', TopicsVal.value[currentIndex.value].userAnswer)
+  }
+}
+
+const handleSubmit = () => {
+  if (TopicsVal.value[currentIndex.value].userAnswer === '') {
+    ElMessage.warning('请先完成当前题目!')
+    return
+  }
+  VoiceImpRef.value.videoPlay(
+    TopicsVal.value[currentIndex.value].userAnswer === TopicsVal.value[currentIndex.value].correct ? 'right' : 'error'
+  )
+  showSubmitBtn.value = false
+  localStorage.setItem('two-win-auditory-recognition-try-over', 'YES')
+}
 
 async function exec() {
   isMainWin.value = window.location.href.includes('win=main')
-  if (!isMainWin.value) {
+  if (isMainWin.value) {
+    TopicsVal.value = Topics.map((item) => {
+      item.choices = item.choices.sort(() => Math.random() - 0.5)
+      return item
+    })
+    localStorage.setItem('two-win-auditory-recognition-init-data', JSON.stringify(TopicsVal.value))
+    setTimeout(() => {
+      showNextBtn.value = true
+    }, 6600)
+  } else {
     VoiceImpRef.value.videoPlay(
       'Speech-Auditory',
       'static/voice/cognitiveAbility/SpeechTraining/Auditory/Recognition/1.mp3'
@@ -37,6 +142,44 @@ async function exec() {
 
 onMounted(() => {
   exec()
+
+  window.addEventListener('storage', (val) => {
+    if (isMainWin.value) {
+      if (val.key === 'two-win-auditory-recognition-submit-answer') {
+        TopicsVal.value[currentIndex.value].userAnswer = val.newValue!
+        localStorage.removeItem('two-win-auditory-recognition-submit-answer')
+      }
+
+      if (val.key === 'two-win-auditory-recognition-try-over') {
+        showNextBtn.value = true
+        localStorage.removeItem('two-win-auditory-recognition-try-over')
+      }
+    } else {
+      if (val.key === 'two-win-auditory-recognition-init-data' && isJSON(val.newValue!)) {
+        TopicsVal.value = JSON.parse(val.newValue!) as TopicsType[]
+        localStorage.removeItem('two-win-auditory-recognition-init-data')
+      }
+
+      if (val.key === 'tow-win-auditory-recognition-show-topics' && val.newValue === 'YES') {
+        showTopics.value = true
+        localStorage.removeItem('tow-win-auditory-recognition-show-topics')
+      }
+
+      if (val.key === 'two-win-auditory-recognition-item-check') {
+        VoiceImpRef.value.videoPlay(
+          'Speech-Auditory',
+          `static/voice/cognitiveAbility/SpeechTraining/Auditory/Recognition/${val.newValue}.mp3`
+        )
+        localStorage.removeItem('two-win-auditory-recognition-item-check')
+      }
+
+      if (val.key === 'tow-win-auditory-recognition-isSubmitting' && val.newValue === 'YES') {
+        isSubmitting = true
+        emits('gameOver', JSON.stringify(TopicsVal.value))
+        localStorage.removeItem('tow-win-auditory-recognition-isSubmitting')
+      }
+    }
+  })
 })
 </script>
 

+ 9 - 0
src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskAuditoryTraining/CATAuditoryTrainingRecognition/topics.json

@@ -0,0 +1,9 @@
+[
+  {
+    "question": "接下来会给你听一些声音,请在这些声音中选择出屏幕中呈现的词语",
+    "choices": ["雷声", "狗叫", "葡萄"],
+    "correct": "葡萄",
+    "userAnswer": ""
+  }
+]
+

+ 16 - 1
src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskAuditoryTraining/index.vue

@@ -19,7 +19,10 @@
     >
       <template v-if="taskBegin">
         <!-- 语音辨识 -->
-        <c-a-t-auditory-training-recognition v-if="checkItems[0].active && checkItems[0].isTraining" />
+        <c-a-t-auditory-training-recognition
+          v-if="checkItems[0].active && checkItems[0].isTraining"
+          @game-over="childTaskOver"
+        />
       </template>
       <template v-else>
         <!--模式选择-->
@@ -198,6 +201,18 @@ const startTask = useThrottleFn(() => {
   }
 })
 
+const childTaskOver = (content: string) => {
+  console.log(content)
+  // TODO 提交本次结果 在提交成功的回调中再进行下面的逻辑
+  if (!isMainWin.value) {
+    if (modeSelect.value === 0) {
+      // TODO 结束本次任务
+    } else {
+      startTask()
+    }
+  }
+}
+
 const countDownEnd = () => {
   countDownBegin.value = false
   showCountDown.value = false

+ 1 - 1
src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskVisualTraining/components/Words/index.vue

@@ -347,7 +347,7 @@ onMounted(() => {
     text-align: center;
   }
   .question-imgStart {
-    background-image: url('/static/image/cognitiveAbility/SpeechTraining/Visual/verify-bg.png');
+    background-image: url('/static/image/cognitiveAbility/SpeechTraining/verify-bg.png');
     background-size: 100% 100%;
     background-position: center center;
     background-repeat: repeat;

+ 1 - 1
src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskVisualTraining/components/diagramMap/index.vue

@@ -347,7 +347,7 @@ onMounted(() => {
     text-align: center;
   }
   .question-imgStart {
-    background-image: url('/static/image/cognitiveAbility/SpeechTraining/Visual/verify-bg.png');
+    background-image: url('/static/image/cognitiveAbility/SpeechTraining/verify-bg.png');
     background-size: 100% 100%;
     background-position: center center;
     background-repeat: repeat;

+ 1 - 1
src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskVisualTraining/components/essay/index.vue

@@ -347,7 +347,7 @@ onMounted(() => {
     text-align: center;
   }
   .question-imgStart {
-    background-image: url('/static/image/cognitiveAbility/SpeechTraining/Visual/verify-bg.png');
+    background-image: url('/static/image/cognitiveAbility/SpeechTraining/verify-bg.png');
     background-size: 100% 100%;
     background-position: center center;
     background-repeat: repeat;

+ 1 - 1
src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskVisualTraining/components/execute/index.vue

@@ -347,7 +347,7 @@ onMounted(() => {
     text-align: center;
   }
   .question-imgStart {
-    background-image: url('/static/image/cognitiveAbility/SpeechTraining/Visual/verify-bg.png');
+    background-image: url('/static/image/cognitiveAbility/SpeechTraining/verify-bg.png');
     background-size: 100% 100%;
     background-position: center center;
     background-repeat: repeat;

+ 1 - 1
src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskVisualTraining/components/mapWord/index.vue

@@ -347,7 +347,7 @@ onMounted(() => {
     text-align: center;
   }
   .question-imgStart {
-    background-image: url('/static/image/cognitiveAbility/SpeechTraining/Visual/verify-bg.png');
+    background-image: url('/static/image/cognitiveAbility/SpeechTraining/verify-bg.png');
     background-size: 100% 100%;
     background-position: center center;
     background-repeat: repeat;

+ 1 - 1
src/views/tester/components/RehabilitationEvaluation/CognitiveAbilityTask/CognitiveAbilityTaskVisualTraining/components/wordMap/index.vue

@@ -347,7 +347,7 @@ onMounted(() => {
     text-align: center;
   }
   .question-imgStart {
-    background-image: url('/static/image/cognitiveAbility/SpeechTraining/Visual/verify-bg.png');
+    background-image: url('/static/image/cognitiveAbility/SpeechTraining/verify-bg.png');
     background-size: 100% 100%;
     background-position: center center;
     background-repeat: repeat;