diff --git a/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/index.vue b/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/index.vue index ca5b655..4d5f6ec 100644 --- a/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/index.vue +++ b/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/index.vue @@ -95,6 +95,7 @@ import QuesItem from "@/views/classTask/newClassTaskAssign/questionUpload/quesIt import useUserStore from '@/store/modules/user' const userStore = useUserStore().user const route = useRoute(); +const router = useRouter() const { proxy } = getCurrentInstance() const props = defineProps({ }) @@ -205,7 +206,7 @@ const handleImportImg = (uploadFile) => { console.log('uploadFile', uploadFile); // 假设你在渲染进程中 getBase64(uploadFile.raw).then(res => { - console.log('res-------', res); + // console.log('res-------', res); // 在 Electron 主进程中使用 URL.createObjectURL @@ -222,7 +223,7 @@ const handleImportImg = (uploadFile) => { // cropOption.img = URL.createObjectURL(new Blob([fs.readFileSync(filePath)])); // cropOption.img = URL.createObjectURL(new Blob([buffer])); cropOption.img = res; - console.log(cropOption.img); + // console.log(cropOption.img); @@ -283,7 +284,50 @@ const identifyOverallImg =()=>{ }) }); }; +/** 单题上传/纠错 抛上来的识别单项内容 */ +const cropperExamFormItem=(examType, curItem)=>{ + if (cropOption.img == null || cropOption.img == '') { + ElMessage({ + message: '识别区域中无图片, 禁止识别', + type: 'error', + }); + return; + } + let formValue = null; + proxy.$refs.cropper.getCropData(async (imgBase64) => { + formValue = await ocrImg2ItemByManualUpl(OCR_WORK_TEST, imgBase64, examType, curItem); + if (formValue == null) { + return; + } + nextTick( () => { + // 更新至[单体上传]中的单项内容 + let key = curItem; + if (examType === '复合题' && curItem=='workdesc') { + key = 'mulList'; + } + else if (curItem=='workdesc') { + key = 'list'; + } + proxy.$refs.refquesItem.cropperFormItemCallBack(key, formValue); + }) + }); +} +// 取消 +const onCancelExamSingleCallback=()=>{ + // 这个页面没啥作用 + // 关闭弹窗 + // this.dlgImportSingle.open = false; +}; +/** 单题上传/纠错 完成后的回调 */ +const onSubmitExamSingleCallback =(callback) =>{ + if (callback.submitType !== 1) { + console.log('999-999'); + return; + } + // 这里返回上一页,若果是纠错弹窗?则弹窗消失并刷新列表 + router.back() +}; diff --git a/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/quesItem/index.vue b/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/quesItem/index.vue index 15fa2fc..e905407 100644 --- a/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/quesItem/index.vue +++ b/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/quesItem/index.vue @@ -71,7 +71,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -91,7 +91,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -126,7 +126,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -155,7 +155,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -200,7 +200,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -227,7 +227,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -241,7 +241,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -285,7 +285,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -300,7 +300,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -324,7 +324,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -348,7 +348,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -382,7 +382,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -400,7 +400,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -418,7 +418,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -436,7 +436,7 @@ userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }" /> @@ -487,6 +487,7 @@ const props = defineProps({ default: false }, }) +const lessionid = ref(""); // 当前章节id const upFileParams = ref({}); // 表单选项参数 const fromOptions = reactive({ @@ -520,7 +521,7 @@ const initKonwPointFlagByUpdateForm = ref(true); // 表单[知识点]显示内容集合 const curKnowledgePointList = ref([]); // 表单数据参数 -const questForm = reactive({ +let questForm = reactive({ id: 0, title: '', worktype: '单选题', @@ -645,12 +646,13 @@ const localList = ref(['北京', '天津', '上海', '重庆', '河北', '山西 const loading = ref(false); onMounted(() => { + lessionid.value = props.bookobj.levelSecondId? props.bookobj.levelSecondId : props.bookobj.levelFirstId; // 获取课程id upFileParams.value = { deptId: userStore.deptId, userId: userStore.userId, edudegree: userStore.edudegree, edusubject: userStore.edusubject, - lessionId: props.activeLession.id, + lessionId: lessionid, fileAlias: '单题上传', }; // 获取最新年份 @@ -714,7 +716,7 @@ const checkBoxChangefh=(item, index, indexOp)=>{ console.log(questForm.mulList.params[index],'checkAnswer') }; /** 表单重置 */ -const reset = () =>{ +const resetForm = () =>{ questForm = { id: 0, title: '', @@ -766,9 +768,7 @@ const reset = () =>{ }, ], }, - }; - proxy.resetForm("questFormRef"); }; /** * @desc: 赋值表单 @@ -1034,8 +1034,10 @@ const updateForm= async(item, submitIndex=0, submitType=1) =>{ // 避免重复调用 initKonwPointFlagByUpdateForm.value = false; + lessionid.value = props.bookobj.levelSecondId? props.bookobj.levelSecondId : props.bookobj.levelFirstId; + console.log('lessionid', lessionid.value); // 拿到当前章节下得所有知识点 - const res = await getBindlist({ eid: props.activeLession.id }) + const res = await getBindlist({ eid: lessionid.value }) if (!res.data || res.data.length < 1) { ElMessage.warning('当前章节下未绑定知识点,暂不更新该试题知识点!'); curKnowledgePointList.value = []; @@ -1089,7 +1091,7 @@ const updateForm= async(item, submitIndex=0, submitType=1) =>{ params: newSubjListparams, }, }; - proxy.resetForm("questFormRef"); + // proxy.resetForm("questFormRef");? //上传完成反馈状态 // const updateStatus = { @@ -1584,26 +1586,26 @@ const submitForm=(formName) =>{ console.log('param', param); // TODO 待后续在提交新增与修改 - // if(questForm.id == 0){ - // // 新增 - // const res = await addEntpcoursework(param); - // param.id = res; - // console.log("单题上传", res) - // proxy.$modal.msgSuccess("单题上传成功"); - // }else{ - // // 纠错更改 - // const res = updateEntpcoursework(param); - // proxy.$modal.msgSuccess("单题修改成功"); - // } + if(questForm.id == 0){ + // 新增 + const res = await addEntpcoursework(param); + param.id = res; + console.log("单题上传", res) + proxy.$modal.msgSuccess("单题上传成功"); + }else{ + // 纠错更改 + const res = updateEntpcoursework(param); + proxy.$modal.msgSuccess("单题修改成功"); + } // 上传完成通知父组件(返回当前form内容, [扫描上传]时需以param的数据重新刷新至单题显示) - // param.submitIndex = questForm.submitIndex; - // param.submitType = questForm.submitType; - // emit('submit-exam-single-callback', param); + param.submitIndex = questForm.submitIndex; + param.submitType = questForm.submitType; + emit('submit-exam-single-callback', param); // form表单内容清空 - // proxy.reset(); - // proxy.resetForm("questFormRef"); + resetForm(); + // proxy.resetForm("questFormRef");? } else { myMessageShow('失败', '单题上传参数有误', 'error'); return; @@ -1693,7 +1695,7 @@ const myMessageShow=(title, msg, status)=>{ // initKonwPointFlagByUpdateForm.value = true; // // 3.拿到当前章节下得所有知识点 -// getBindlist({ eid: props.activeLession.id }).then( res => { +// getBindlist({ eid: lessionid }).then( res => { // if (!res.data || res.data.length < 1) { // ElMessage.warning('当前章节下未绑定知识点,请先绑定知识点!'); // curKnowledgePointList = []; @@ -1710,10 +1712,11 @@ const myMessageShow=(title, msg, status)=>{ // deep: true // 深度监听,适用于对象内部属性的变化 // }, // }, -// watch(() => props.bookobj.levelSecondId, (newVal, oldVal) => { -// console.log(props.bookobj,'课程选择') -// debounceQueryData(); -// }) +watch(() => props.bookobj.levelSecondId, (newVal, oldVal) => { + console.log(props.bookobj,'课程选择') + // props.bookobj.levelSecondId? props.bookobj.levelSecondId : props.bookobj.levelFirstId + lessionid.value = props.bookobj.levelSecondId? props.bookobj.levelSecondId : props.bookobj.levelFirstId; +}) // 暴露给父组件的参数和方法(外部需要什么,都可以从这里暴露出去)