|
@@ -1,7 +1,63 @@
|
|
|
import { WEBSOCKET_FOR_AUDIO } from "@/constants/constants";
|
|
|
import { useWebSocket } from "@/setups/useWebSocket";
|
|
|
import { store } from "@/store/store";
|
|
|
-import { watch } from "vue";
|
|
|
+import { watch, ref } from "vue";
|
|
|
+import { httpApp } from "@/plugins/axiosApp";
|
|
|
+
|
|
|
+import { debounce, throttle } from "lodash-es";
|
|
|
+
|
|
|
+interface HandGetResult {
|
|
|
+ examRecordDataId: number;
|
|
|
+ questionOrder: number;
|
|
|
+ filePath: string;
|
|
|
+ status: "UNCONFIRMED" | "CONFIRMED" | "DISCARDED";
|
|
|
+ transferFileType: "PIC" | "AUDIO";
|
|
|
+}
|
|
|
+export const useHandGetAnswer = () => {
|
|
|
+ const loading = ref(false);
|
|
|
+ function handGetAnswer(data: {
|
|
|
+ examRecordDataId: number | string;
|
|
|
+ questionOrder: number | string;
|
|
|
+ }) {
|
|
|
+ loading.value = true;
|
|
|
+ httpApp
|
|
|
+ .post<any>(
|
|
|
+ `/api/ecs_oe_student/examControl/getUploadedFile?examRecordDataId=${data.examRecordDataId}&questionOrder=${data.questionOrder}`,
|
|
|
+ {},
|
|
|
+ {
|
|
|
+ setGlobalMask: true,
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then((res: { data: HandGetResult }) => {
|
|
|
+ console.log("手动获取小程序作答成功:", res);
|
|
|
+ store.setQuestionFileAnswerUrl({
|
|
|
+ order: res.data.questionOrder,
|
|
|
+ fileUrl: res.data.filePath,
|
|
|
+ transferFileType: res.data.transferFileType,
|
|
|
+ });
|
|
|
+
|
|
|
+ logger({
|
|
|
+ cnl: ["local", "server"],
|
|
|
+ pgn: "ExamRecordData",
|
|
|
+ dtl: "手动获取小程序作答成功",
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ logger({
|
|
|
+ cnl: ["local", "server"],
|
|
|
+ pgn: "ExamRecordData",
|
|
|
+ dtl: "手动获取小程序作答失败",
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ loading.value = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ loading,
|
|
|
+ handler: throttle(handGetAnswer, 3000),
|
|
|
+ };
|
|
|
+};
|
|
|
|
|
|
function onAudioAnswer(event: MessageEvent<string>) {
|
|
|
let res: {
|