|
@@ -20,7 +20,13 @@
|
|
|
<template v-if="taskBegin">
|
|
|
<!-- 语音辨识 -->
|
|
|
<c-a-t-auditory-training-recognition
|
|
|
- v-if="checkItems[0].active && checkItems[0].isTraining"
|
|
|
+ v-if="checkItems[0].active && checkItems[0].isTraining && !checkItems[0].isFinish"
|
|
|
+ @game-over="childTaskOver"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!-- 词图匹配 -->
|
|
|
+ <c-a-t-auditory-training-word-img-matching
|
|
|
+ v-if="checkItems[1].active && checkItems[1].isTraining && !checkItems[1].isFinish"
|
|
|
@game-over="childTaskOver"
|
|
|
/>
|
|
|
</template>
|
|
@@ -83,15 +89,16 @@
|
|
|
* 创建日期: 2024/7/16
|
|
|
* 编写者: JutarryWu
|
|
|
*/
|
|
|
-import EvaluationSTRecordInfoAPI from '@/api/tester/evaluation/stRecord'
|
|
|
+import SpeechTrainingAPI, { SpeechTrainingVO } from '@/api/tester/evaluation/speechTraining'
|
|
|
import { useThrottleFn } from '@vueuse/core'
|
|
|
import { useUserStore } from '@/store'
|
|
|
import { isJSON } from '@/utils'
|
|
|
interface CheckItem {
|
|
|
key: number
|
|
|
name: string
|
|
|
- active: boolean
|
|
|
- isTraining: boolean
|
|
|
+ active: boolean // 是否选中
|
|
|
+ isTraining: boolean // 是否为当前训练
|
|
|
+ isFinish: boolean // 是否完成
|
|
|
}
|
|
|
|
|
|
const isMainWin = ref(false)
|
|
@@ -102,9 +109,17 @@ defineOptions({
|
|
|
})
|
|
|
|
|
|
const props = defineProps({
|
|
|
+ taskId: {
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
parentId: {
|
|
|
type: String,
|
|
|
default: ''
|
|
|
+ },
|
|
|
+ flag: {
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
}
|
|
|
})
|
|
|
|
|
@@ -119,16 +134,16 @@ const VoiceImpRef = ref()
|
|
|
|
|
|
const modeSelect = ref(-1) // -1: 未选择,0: 单流程模式,1: 全流程模式
|
|
|
const modeActive = ref(-1) // -1: 未选择,0: 单流程模式,1: 全流程模式
|
|
|
-let modeSingleIndex = -1 // 单流程模式下,选中的索引
|
|
|
+let modeCurrentIndex = -1 // 当前子任务索引
|
|
|
|
|
|
const dialogVisible = ref(false) // 学历弹窗
|
|
|
const checkItems = ref<CheckItem[]>([
|
|
|
- { key: 1, name: '语音辨识', active: false, isTraining: false },
|
|
|
- { key: 2, name: '词图匹配', active: false, isTraining: false },
|
|
|
- { key: 3, name: '句图匹配', active: false, isTraining: false },
|
|
|
- { key: 4, name: '是非反应', active: false, isTraining: false },
|
|
|
- { key: 5, name: '执行指令', active: false, isTraining: false },
|
|
|
- { key: 6, name: '听短文回答故事', active: false, isTraining: false }
|
|
|
+ { key: 1, name: '语音辨识', active: false, isTraining: false, isFinish: false },
|
|
|
+ { key: 2, name: '词图匹配', active: false, isTraining: false, isFinish: false },
|
|
|
+ { key: 3, name: '句图匹配', active: false, isTraining: false, isFinish: false },
|
|
|
+ { key: 4, name: '是非反应', active: false, isTraining: false, isFinish: false },
|
|
|
+ { key: 5, name: '执行指令', active: false, isTraining: false, isFinish: false },
|
|
|
+ { key: 6, name: '听短文回答故事', active: false, isTraining: false, isFinish: false }
|
|
|
])
|
|
|
|
|
|
const closeDialog = () => {
|
|
@@ -156,9 +171,9 @@ const checkItemFn = useThrottleFn((item: CheckItem, flag: number = 0) => {
|
|
|
let tempIndex = -1
|
|
|
checkItems.value.forEach((item2, index) => {
|
|
|
item2.active = false
|
|
|
- if (item2.key === item.key) modeSingleIndex = index
|
|
|
+ if (item2.key === item.key) modeCurrentIndex = index
|
|
|
})
|
|
|
- checkItems.value[modeSingleIndex].active = true
|
|
|
+ checkItems.value[modeCurrentIndex].active = true
|
|
|
if (!isMainWin.value) {
|
|
|
VoiceImpRef.value.videoPlay()
|
|
|
localStorage.setItem('two-win-auditory-item-check', JSON.stringify(item))
|
|
@@ -181,6 +196,7 @@ const modeSelectFn = useThrottleFn((mode: number, flag: number = 0) => {
|
|
|
setTimeout(() => {
|
|
|
modeSelect.value = mode
|
|
|
if (mode === 1) {
|
|
|
+ modeCurrentIndex = 0
|
|
|
checkItems.value.forEach((item) => {
|
|
|
item.active = true
|
|
|
})
|
|
@@ -190,9 +206,9 @@ const modeSelectFn = useThrottleFn((mode: number, flag: number = 0) => {
|
|
|
|
|
|
const startTask = useThrottleFn(() => {
|
|
|
if (modeSelect.value === 0) {
|
|
|
- checkItems.value[modeSingleIndex].isTraining = true
|
|
|
+ checkItems.value[modeCurrentIndex].isTraining = true
|
|
|
} else {
|
|
|
- let tempIndex = checkItems.value.findIndex((item: CheckItem) => item.active && !item.isTraining)
|
|
|
+ let tempIndex = checkItems.value.findIndex((item: CheckItem) => item.active && !item.isTraining && !item.isFinish)
|
|
|
checkItems.value[tempIndex].isTraining = true
|
|
|
}
|
|
|
taskBegin.value = true
|
|
@@ -201,14 +217,45 @@ const startTask = useThrottleFn(() => {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-const childTaskOver = (content: string) => {
|
|
|
- console.log(content)
|
|
|
- // TODO 提交本次结果 在提交成功的回调中再进行下面的逻辑
|
|
|
+let tempRecordId: string = '' // 第一个子任务提交的时候没有值,传'', 提交成功后的返回值既是recordId
|
|
|
+const childTaskOver = (taskData: SpeechTrainingVO) => {
|
|
|
if (!isMainWin.value) {
|
|
|
- if (modeSelect.value === 0) {
|
|
|
- // TODO 结束本次任务
|
|
|
- } else {
|
|
|
+ if (checkItems.value[modeCurrentIndex].isFinish) {
|
|
|
+ modeCurrentIndex++
|
|
|
startTask()
|
|
|
+ } else {
|
|
|
+ SpeechTrainingAPI.add({
|
|
|
+ ...{
|
|
|
+ flag: props.flag,
|
|
|
+ taskId: props.taskId,
|
|
|
+ patId: userStore.user.id,
|
|
|
+ parentId: props.parentId,
|
|
|
+ questionName: checkItems.value[modeCurrentIndex].name,
|
|
|
+ questionNo: checkItems.value[modeCurrentIndex].key + '',
|
|
|
+ recordId: tempRecordId,
|
|
|
+ type: modeSelect.value + ''
|
|
|
+ },
|
|
|
+ ...taskData
|
|
|
+ }).then((data) => {
|
|
|
+ checkItems.value[modeCurrentIndex].isFinish = true
|
|
|
+ localStorage.setItem('tow-win-auditory-change-status', JSON.stringify(taskData))
|
|
|
+ if (modeSelect.value === 0) {
|
|
|
+ ElMessage.success('提交成功!')
|
|
|
+ emits('showResult', data)
|
|
|
+
|
|
|
+ localStorage.setItem('tow-win-auditory-show-result', data)
|
|
|
+ } else {
|
|
|
+ if (modeCurrentIndex === checkItems.value.length - 1) {
|
|
|
+ ElMessage.success('提交成功!')
|
|
|
+ emits('showResult', data)
|
|
|
+
|
|
|
+ localStorage.setItem('tow-win-auditory-show-result', data)
|
|
|
+ } else {
|
|
|
+ tempRecordId = data
|
|
|
+ childTaskOver(taskData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -237,7 +284,6 @@ onMounted(() => {
|
|
|
|
|
|
window.addEventListener('storage', (val) => {
|
|
|
if (isMainWin.value) {
|
|
|
- console.log(val.key)
|
|
|
if (val.key === 'two-win-auditory-mode-select') {
|
|
|
modeSelectFn(Number(val.newValue))
|
|
|
localStorage.removeItem('two-win-auditory-mode-select')
|
|
@@ -251,8 +297,19 @@ onMounted(() => {
|
|
|
startTask()
|
|
|
localStorage.removeItem('two-win-auditory-task-begin')
|
|
|
}
|
|
|
+
|
|
|
+ if (val.key === 'tow-win-auditory-show-result') {
|
|
|
+ ElMessage.success('提交成功!')
|
|
|
+ emits('showResult', val.newValue!)
|
|
|
+ localStorage.removeItem('tow-win-auditory-show-result')
|
|
|
+ }
|
|
|
+
|
|
|
+ if (val.key === 'tow-win-auditory-change-status') {
|
|
|
+ checkItems.value[modeCurrentIndex].isFinish = true
|
|
|
+ childTaskOver(JSON.parse(val.newValue!))
|
|
|
+ }
|
|
|
} else {
|
|
|
- console.log('')
|
|
|
+ // console.log('')
|
|
|
}
|
|
|
})
|
|
|
})
|