|
|
@@ -4,7 +4,7 @@
|
|
|
<div class="item_title">
|
|
|
<div class="item_step">1</div>
|
|
|
扫描标准答案:<el-button type="primary" @click="GotoScan()" :loading="scanLoading" style="width: 88px;">{{scanText}}</el-button>
|
|
|
- <!-- <span class="preview_btn">预览</span> -->
|
|
|
+ <span class="preview_btn" @click="OpenImage()">预览</span>
|
|
|
<!-- <el-button style="margin-left: 10px;width: 116px;">引用试题结构</el-button> -->
|
|
|
</div>
|
|
|
<div class="choose_template">
|
|
|
@@ -142,28 +142,7 @@
|
|
|
</div>
|
|
|
<ChooseTemplate v-model="showChooseTemplate"></ChooseTemplate>
|
|
|
<EditorQuestion ref="enterStandardEdit" @AnswerEnter="EditorAnswerEnter"></EditorQuestion>
|
|
|
- <div class="page_dialog">
|
|
|
- <el-dialog title="扫描答案预览" v-model="showScanAnswer" width="940px" @close="CloseScanAnswer()">
|
|
|
- <div class="max_height_650">
|
|
|
- <div class="dialog_center">
|
|
|
- <div class="pic_item_list">
|
|
|
-
|
|
|
- <div v-for="(image, index) in imageFilesList" :key="index" class="pic_item_img_detail">
|
|
|
-
|
|
|
-
|
|
|
- <img :src="image.url" />
|
|
|
-
|
|
|
-
|
|
|
- </div>
|
|
|
-
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div slot="footer" class="dialog-footer">
|
|
|
- <el-button type="primary" style="width: 96px;" :loading="scanAnswerLoading" @click="EnterSubmit()">确定</el-button>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
- </div>
|
|
|
+ <PaperPreview v-model="showPaperDialog" :imageList="previewImageList" :showDraw="true" :answerData="previewAnswerData"></PaperPreview>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
|
@@ -172,9 +151,10 @@ import { useRouter } from 'vue-router'
|
|
|
import { onMounted,computed ,onUnmounted,ref,nextTick } from 'vue';
|
|
|
import ChooseTemplate from './components/chooseTemplate.vue';
|
|
|
import EditorQuestion from './components/EditorQuestion.vue';
|
|
|
+import PaperPreview from './components/PaperPreview.vue'
|
|
|
|
|
|
import { ElMessageBox,ElMessage } from 'element-plus'
|
|
|
-import { getScanSetCertificate,getScanAnswerStates,getSmartQuestionList,getTemplateInfo,setQuestion,saveQuestion,deleteAllQuestion,deleteSingleQuestion,getExamProcess} from '@/api/exam'
|
|
|
+import { getScanSetCertificate,getScanAnswerPreview,getScanAnswerStates,getSmartQuestionList,getTemplateInfo,setQuestion,saveQuestion,deleteAllQuestion,deleteSingleQuestion,getExamProcess} from '@/api/exam'
|
|
|
import scanCommon from '@/utils/scanCommon.ts'
|
|
|
import { useThrottleFn } from '@vueuse/core';
|
|
|
import { useUserStore } from '@/store/user'
|
|
|
@@ -217,6 +197,9 @@ const showChooseTemplate=ref(false);// 弹出选择模板的弹窗
|
|
|
const tableData = ref<QuestionItem[]>([])
|
|
|
const tableLoading = ref(false)//表格loading状态
|
|
|
const enterStandardEdit=ref<HTMLElement>();//标准答案编辑组件实例
|
|
|
+const showPaperDialog=ref(false);//答案预览弹窗
|
|
|
+const previewImageList=ref<any[]>([]);//答案预览图片列表
|
|
|
+const previewAnswerData=ref<any>({});//答案预览数据
|
|
|
|
|
|
const tableHeight = ref(400)// 表格高度
|
|
|
const answerList=['A','B','C','D','E','F','G','H','I','J','K']//答案列表
|
|
|
@@ -298,42 +281,7 @@ const onScoreInput = (target: any, key: string, val: any) => {
|
|
|
// 组件顶层分数输入 ref 映射:当 obj 传 null 时,按 prop 名写入对应的 ref
|
|
|
const scoreRefMap: Record<string, any> = { shaoxuan }
|
|
|
|
|
|
-// 每小题分数输入验证(0.5 分制)
|
|
|
-// obj:目标对象,为 null 时表示组件顶层 ref(如 shaoxuan);prop:属性名;value:输入值
|
|
|
-const HandleScoreInput = (obj: any, prop: string, value: any) => {
|
|
|
- // 1. 移除所有非数字和非小数点的字符
|
|
|
- let newValue = String(value ?? '').replace(/[^\d.]/g, '')
|
|
|
-
|
|
|
- // 2. 确保只有一个小数点
|
|
|
- const parts = newValue.split('.')
|
|
|
- if (parts.length > 2) {
|
|
|
- newValue = parts[0] + '.' + parts.slice(1).join('')
|
|
|
- }
|
|
|
-
|
|
|
- // 3. 不允许以多个 0 开头(0.xx 的情况除外)
|
|
|
- if (newValue.length > 1 && newValue.startsWith('0') && !newValue.startsWith('0.')) {
|
|
|
- newValue = newValue.substring(1)
|
|
|
- }
|
|
|
-
|
|
|
- // 4. 校验是否为 0.5 的倍数:数值 ×2 应为整数,否则四舍五入到最近的 0.5 倍数
|
|
|
- if (newValue && newValue !== '.' && !isNaN(Number(newValue))) {
|
|
|
- const numValue = parseFloat(newValue)
|
|
|
- if (numValue > 0) {
|
|
|
- const doubled = numValue * 2
|
|
|
- if (Math.abs(doubled - Math.round(doubled)) > 0.0001) {
|
|
|
- newValue = (Math.round(doubled) / 2).toString()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- // 5. 动态赋值:obj 为 null 时写入顶层 ref,否则写入 obj[prop]
|
|
|
- if (obj == null) {
|
|
|
- const targetRef = scoreRefMap[prop]
|
|
|
- if (targetRef) targetRef.value = newValue
|
|
|
- } else {
|
|
|
- obj[prop] = newValue
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
// 少选得分校验(@change 触发):不能超过每题满分
|
|
|
const ScoreYanzheng = () => {
|
|
|
@@ -564,6 +512,41 @@ const EditorSingle=(item:any)=>{
|
|
|
console.log("打印编辑单个题目",item)
|
|
|
enterStandardEdit.value.InitData(item);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+// 打开预览图片
|
|
|
+const OpenImage=()=>{
|
|
|
+
|
|
|
+
|
|
|
+ let params={
|
|
|
+ examSubjectId:examSubjectId.value,
|
|
|
+ };
|
|
|
+ getScanAnswerPreview(params).then((res:any)=>{
|
|
|
+ console.log("打印预览图片返回结果",res);
|
|
|
+ if(res.code==200)
|
|
|
+ {
|
|
|
+ previewImageList.value=[];//初始清空
|
|
|
+ res.data.forEach((image:any)=>{
|
|
|
+ console.log("image",image);
|
|
|
+ let obj={
|
|
|
+ url:image,
|
|
|
+ pageNo:1,//页面页码
|
|
|
+ };
|
|
|
+ previewImageList.value.push(obj);
|
|
|
+ })
|
|
|
+ if(previewImageList.value.length>0)
|
|
|
+ {
|
|
|
+ showPaperDialog.value=true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ElMessage.warning('您还未扫描答案哦!');
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
// 打开扫描仪器
|
|
|
const GotoScan = useThrottleFn(() => {
|
|
|
|
|
|
@@ -776,6 +759,14 @@ const GetSmartQuestionList=()=>{
|
|
|
// tableData.value=res.data;
|
|
|
// 增加空值保护,确保 tableData 始终是数组
|
|
|
tableData.value = Array.isArray(res.data) ? res.data : [];
|
|
|
+ let result={};
|
|
|
+ for (const item of tableData.value) {
|
|
|
+ // name转数字作为key
|
|
|
+ const key = (item.questionName);
|
|
|
+ result[key] = item.standardAnswer;
|
|
|
+ }
|
|
|
+ previewAnswerData.value=result;
|
|
|
+ console.log("打印转换后的数据",result)
|
|
|
}
|
|
|
}).finally(()=>{
|
|
|
tableLoading.value = false;//关闭表格loading
|
|
|
@@ -956,6 +947,7 @@ onUnmounted(() => {
|
|
|
font-size: 16px;
|
|
|
color: #2E64FA;
|
|
|
cursor: pointer;
|
|
|
+ margin-left: 10px;
|
|
|
}
|
|
|
|
|
|
.delete_all
|