scanList.vue 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353
  1. <template>
  2. <div class="page_list">
  3. <div class="search_content">
  4. <div class="content_left">
  5. <span class="scan_state_title"><span>客户端状态</span>:</span>
  6. <span class="scan_state_open" v-if="scanClientStates">
  7. <i class="iconfont icon_open"></i>已打开</span>
  8. <span class="scan_state_close" v-else>
  9. <i class="iconfont icon_close"></i>未打开</span>
  10. <span v-if="scanClientStates" class="scan_state_title" style="color: #999;">(当前客户端版本:{{scanClientVersion}})</span>
  11. <!-- <el-select v-model="params.batchNo" placeholder="选择批次" @change="GoSearch()" class="select_width" >
  12. <el-option label="全部批次" value=""></el-option>
  13. <el-option v-for="item in batchList"
  14. :key="item.value"
  15. :label="item.label" :value="item.value"></el-option>
  16. </el-select>
  17. <el-select v-model="params.batchNo" placeholder="选择状态" @change="GoSearch()" class="select_width" >
  18. <el-option label="全部状态" value=""></el-option>
  19. <el-option v-for="item in batchList"
  20. :key="item.value"
  21. :label="item.label" :value="item.value"></el-option>
  22. </el-select>
  23. <el-input placeholder="考试名称,编号" v-model="params.keyWord" @input="GoSearch" @change="GoSearch()" class="input_width" >
  24. <el-button @click="GoSearch()" slot="append" icon="el-icon-search"></el-button>
  25. </el-input> -->
  26. </div>
  27. <div class="content_right el_button">
  28. <el-button @click="Refresh" >
  29. <i class="iconfont icon_shuaxin"></i>刷新
  30. </el-button>
  31. <!-- <el-button class="delete_item" type="text" @click="OpenDeleteAllDialog" v-if="tableData.length>0">删除所有</el-button> -->
  32. <el-button @click="OpenReIdentify" >重新识别</el-button>
  33. <div @click="OpenImportDialog" class="editor_item" >导入扫描图片</div>
  34. <el-button @click="OpenEditExamList()" type="primary">编辑考场名单</el-button>
  35. <!-- <el-button @click="OpenImportStudent()" type="primary" v-else>导入考场名单</el-button> -->
  36. </div>
  37. </div>
  38. <div class="page_jg_20"></div>
  39. <div class="page_content" >
  40. <div class="content_table">
  41. <div class="page_table">
  42. <el-table :data="tableData" style="width: 100%" :height="tableHeight">
  43. <!-- <el-table-column prop="questionName" label="序号" width="100" align="center" >
  44. </el-table-column> -->
  45. <el-table-column prop="batchNo" label="批次" width="120" align="center">
  46. </el-table-column>
  47. <el-table-column prop="scannedPaperNum" label="扫描张数" align="center" min-width="90">
  48. </el-table-column>
  49. <el-table-column prop="uploadNum" label="待上传张数" align="center" min-width="100">
  50. <template v-slot="scope">
  51. <div class="table_row_answer" v-if="GetNoUploadNumber(scope.row)>0" @click="OpenUpload(scope.row)">
  52. <span style="color:red;text-decoration:underline;"> {{GetNoUploadNumber(scope.row)}}</span>
  53. <!-- {{scope.row.failedNumber || 0}} -->
  54. </div>
  55. <div v-else>0</div>
  56. </template>
  57. </el-table-column>
  58. <el-table-column prop="uploadNum" label="已上传张数" align="center" min-width="100">
  59. <template v-slot="scope">
  60. </template>
  61. </el-table-column>
  62. <el-table-column prop="scanUserName" label="扫描人" align="center" min-width="120" show-overflow-tooltip>
  63. <template v-slot="scope">
  64. </template>
  65. </el-table-column>
  66. <el-table-column prop="scanUserName" label="扫描时间" align="center" min-width="160" show-overflow-tooltip>
  67. <template v-slot="scope">
  68. {{formatTimestamp(scope.row.scannedTime) }}
  69. </template>
  70. </el-table-column>
  71. <el-table-column prop="name" label="操作" min-width="190" align="center" fixed="right">
  72. <template v-slot="scope">
  73. <div class="ele_button table_row_button" v-if="scope.row.uploadStatus==0" style="color:#2E64FA;">
  74. <i class="el-icon-loading"></i>{{loadingText}}……
  75. </div>
  76. <div class="ele_button table_row_button" v-else>
  77. <span class="btn_editor" @click="GotoBatchDetail(scope.row.batchNo)">详情</span>
  78. <span class="btn_delete" v-if="scope.row.scanUserName==currentUserName " @click="OptionDelete(scope.row)">删除</span>
  79. <span class="editor_disable" v-else>删除</span>
  80. </div>
  81. </template>
  82. </el-table-column>
  83. </el-table>
  84. </div>
  85. </div>
  86. <div class="content_right">
  87. <div class="right_header">
  88. <div class="scan_set scan_state_title" @click="OpenNumberSet()"> 考号设置</div>
  89. <div class="scan_set_scan_code">
  90. <!-- <el-select style="width: 100px;margin-right: 6px;" v-model="useDriveUI" placeholder="是否显示驱动弹窗" @change="ChangeDriveUI">
  91. <el-option v-for="item in scanTypeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
  92. </el-select> -->
  93. 识别号:
  94. <el-select style="width: 100px;margin-right: 6px;" v-model="scanIdentifyCode" placeholder="选择识别号" @change="ChangeCode" >
  95. <el-option v-for="item in scanIdentifyList" :key="item.value" :label="item.label" :value="item.value"></el-option>
  96. </el-select>
  97. </div>
  98. </div>
  99. <div class="right_center">
  100. <div class="page_jg_20">
  101. </div>
  102. <div class="scan_button_common scan_button">
  103. <ScanButton :process="scanProcess" :quekao="scanQuekao" :yichang="scanYichang" @click="OpenScan()"></ScanButton>
  104. </div>
  105. <div class="scan_list">
  106. <div class="list_item no_scan" >
  107. <div class="list_item_info" @click="GotoDetail(0)">
  108. <div class="item_info_title">
  109. 未扫描
  110. </div>
  111. <div class="item_info_number">
  112. <span class="number_no_scan">{{scanDataInfo.unScanned}}人</span>
  113. </div>
  114. </div>
  115. </div>
  116. <div class="list_item no_exam" >
  117. <div class="list_item_info " @click="GotoDetail(2)">
  118. <div class="item_info_title">
  119. 缺考
  120. </div>
  121. <div class="item_info_number">
  122. <span class="number_no_exam">{{scanDataInfo.examMissNum}}人</span>
  123. <!-- <span class="number_no_icon"><img src="../../assets/icon/miss_exam.png"></span> -->
  124. </div>
  125. </div>
  126. </div>
  127. <div class="list_item annormal_icon" >
  128. <div class="list_item_info " @click="GotoDetail(3)">
  129. <div class="item_info_title">
  130. 异常
  131. </div>
  132. <div class="item_info_number">
  133. <span class="number_abnormal">{{scanDataInfo.abnormalNum}}份</span>
  134. <!-- <span class="number_no_icon"><img src="../../assets/icon/abnormal_icon.png"></span> -->
  135. </div>
  136. </div>
  137. </div>
  138. <div class="list_item sucess_upload" >
  139. <div class="list_item_info " @click="GotoDetail(1)">
  140. <div class="item_info_title">
  141. 已上传
  142. </div>
  143. <div class="item_info_number">
  144. <span class="number_uploaded">{{scanDataInfo.scannedNum}}人</span>
  145. <!-- <span class="number_no_icon"><img src="../../assets/icon/sucess_upload.png"></span> -->
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. <div class="right_button">
  152. <el-button type="primary" @click="FinishScanned()" :loading="finishLoading" style="width:calc(100% - 40px);">扫描完成</el-button>
  153. </div>
  154. </div>
  155. </div>
  156. <div class="page_dialog">
  157. <el-dialog
  158. v-model="showNumberSetDialog"
  159. title="考号设置"
  160. width="480px"
  161. class="page_dialog"
  162. >
  163. <el-form ref="formRef" label-width="130px">
  164. <el-form-item label="考号识别顺序:" prop="examSubjectName">
  165. <el-select style="width: 60px;margin-right: 6px;" v-model="examCodeStart" placeholder="开始位置" >
  166. <el-option v-for="item in 10" :key="item" :label="item" :value="item"></el-option>
  167. </el-select>
  168. -
  169. <el-select style="width: 60px;margin-right: 6px;margin-left: 6px;" v-model="examCodeEnd" placeholder="结束位置">
  170. <el-option v-for="item in 10" :key="item" :label="item" :value="item"></el-option>
  171. </el-select>
  172. </el-form-item>
  173. </el-form>
  174. <template #footer>
  175. <span class="dialog-footer">
  176. <el-button @click="CloseNumberSet()">取消</el-button>
  177. <el-button type="primary" :loading="setLoading" @click="HandleSubmit">确定</el-button>
  178. </span>
  179. </template>
  180. </el-dialog>
  181. <ReIdentify v-model="isReIdentify" :reIdentifyTotal="reIdentifyTotal" justObjective="0" :schoolInfo="selectSchoolInfo" @ReIdentifyComplete="Refresh"></ReIdentify>
  182. <UploadImage v-if="showUploadImage" v-model="showUploadImage" :batchNumber="currentBatchNo" :isfilter="isfilter" :schoolInfo="selectSchoolInfo" @UploadProgress="UploadProgress" @UploadComplete="UploadComplete" @CancelUpload="CancelUpload"></UploadImage>
  183. <AbnormalDetail v-model="showAbnormalDialog" :scanState="scanState" @success="BackScan"></AbnormalDetail>
  184. </div>
  185. </div>
  186. </template>
  187. <script lang="ts" setup>
  188. import { useExamStore } from '@/store/exam'
  189. import { useUserStore } from '@/store/user'
  190. import { useAnalysisStore } from '@/store/analysis'
  191. import { useRouter } from 'vue-router'
  192. import { onMounted ,ref,computed,onUnmounted,nextTick } from 'vue';
  193. import ScanButton from './components/scanButton.vue'//扫描按钮
  194. import UploadImage from './components/UploadImage.vue'//导入扫描图片
  195. import {getExamProcess,setExamNumberPosition,finishScanned,getExamScoreSummary,hasImportStudent,getBatchList,getCurrentBatchNo,deleteBatch,updateScanCount,setExamScanSetting,saveChooseCode} from '@/api/exam'
  196. import { queryQuestionGroupByAiId } from '@/api/analysis'
  197. import scanCommon from '@/utils/scanCommon';
  198. import { ElMessageBox, ElMessage } from 'element-plus'
  199. import { formatTimestamp } from '@/utils/common';
  200. import AbnormalDetail from './abnormalDetail.vue';
  201. import ReIdentify from './components/ReIdentify.vue';//重新识别弹窗
  202. import WebSocketManager from '@/utils/webSocket'//后端websocket链接js
  203. // 实例化 Store
  204. const examStore = useExamStore()
  205. const userStore = useUserStore()
  206. const analysisStore = useAnalysisStore()
  207. const router = useRouter()
  208. // 考试科目 ID
  209. const examSubjectId = computed(() => {
  210. return examStore.currentExam?.id
  211. })//计算属性
  212. const userInfo=computed(() => {
  213. return userStore.userInfo;
  214. })//用户信息
  215. const schoolType=computed(() => {
  216. return ''
  217. })
  218. //考试科目code
  219. const examSubjectCode=computed(() => {
  220. return examStore.currentExam?.examSubjectCode
  221. })
  222. //当前登录人姓名
  223. const currentUserName=computed(() => {
  224. return userStore.userName;
  225. })
  226. const isShowGroupAnalysis = computed(() => analysisStore?.isShowGroupAnalysis || false);
  227. //查询是否导入了学生名单 此方法以注释
  228. const HasImportStudent = async () => {
  229. const params = {
  230. examSubjectId: examSubjectId.value,
  231. schoolId: 0,//单校 0
  232. };
  233. const res = await hasImportStudent(params);
  234. console.log("打印是否导入了学生名单",res);
  235. if(res.code==200)
  236. {
  237. isImportStudent.value=res.data;
  238. }
  239. else{
  240. isImportStudent.value=false;
  241. }
  242. if(!isImportStudent.value)
  243. {
  244. console.log("未导入学生名单,跳转到选择学生名单界面");
  245. //跳转导入学生名单界面
  246. router.push({
  247. name: 'selectExamination',
  248. });
  249. }
  250. }
  251. // 组件创建时立即执行
  252. // HasImportStudent();//查询是否导入了学生名单();
  253. const selectSchoolId=ref(0);//学校ID
  254. const showAbnormalDialog=ref(false);//异常弹窗
  255. const scanState = ref(0);//扫描状态//默认未扫描
  256. const showNumberSetDialog=ref(false);//考号识别顺序设置
  257. const examCodeStart=ref(1);//考号开始位置
  258. const examCodeEnd=ref(10);//考号结束位置
  259. const setLoading=ref(false);//考号设置加载中
  260. const isReIdentify=ref(false);//是否重新识别
  261. const reIdentifyTotal = ref(0);//需要识别的数
  262. const selectSchoolInfo=ref({
  263. schoolId:'',
  264. schoolName:''
  265. });//学校信息
  266. const params=ref({
  267. batchNo:'',
  268. keyWord:''
  269. })
  270. const scanClientStates=ref(false);//客户端状态
  271. const scanClientVersion=ref('');//客户端版本
  272. const isScanning=ref(false);//是否正在扫描 扫描状态
  273. const hasMakeTemplate=ref(false);//模版是否制作完成
  274. const currentBatchNo=ref('');//当前批次号
  275. const isfilter=ref(1);//是否过滤
  276. const currentBatchNoId=ref('');//当前批次号id
  277. const loadingText=ref('');//加载文本
  278. const baseUrl=import.meta.env.VITE_API_BASE_URL;
  279. let uploadUrl=`https://www.k12100.com/teaching/api/v1/ai_exam_scan/upload_multi_img`;//图片上传地址
  280. let updateCountUrl=`https://www.k12100.com/teaching/api/v1/ai_exam_scan/record_batch_scan_number`;
  281. const webSocket=ref<InstanceType<typeof WebSocketManager> | null>(null);//websocket
  282. let websocketUrl=import.meta.env.VITE_WEB_SOCKET_URL;//websocket链接地址
  283. // 定义数据类型接口
  284. interface BatchItem {
  285. id?: string | number;
  286. batchNo: string;
  287. batchTypeName?: string;
  288. scanUserName?: string;
  289. scannedPaperNum?: number;//扫描张数
  290. scannedTime?: number | string;
  291. uploadNum?: number;//上传张数
  292. uploadStatus?: number; // 确保包含此属性
  293. failedNumber?: number;
  294. [key: string]: any; // 允许其他动态属性
  295. }
  296. const tableData=ref<BatchItem[]>([]); //批次列表
  297. const tableHeight=ref(500);
  298. const scanIdentifyList=[
  299. {
  300. label:'考号',
  301. value:'2',
  302. },
  303. {
  304. label:'学号',
  305. value:'1',
  306. }
  307. ];//识别号列表
  308. const scanTypeList=[
  309. {
  310. label:'不弹窗',
  311. value:0,
  312. },
  313. {
  314. label:'弹窗',
  315. value:1,
  316. }
  317. ];
  318. const scanIdentifyCode=ref('1');////识别号 1-学号 2-考号
  319. const useDriveUI=ref(0);//1是会弹框,其他值或不写则不弹
  320. const isImportStudent=ref(false);//是否导入了学生名单
  321. const showSelectStudent=ref(false);//是否显示选择学生名单弹窗
  322. const showUploadImage=ref(false);//导入扫描图片弹窗
  323. const finishLoading=ref(false);//扫描完成加载中
  324. const scanDataInfo=ref({
  325. abnormalNum:0,//异常数量
  326. examMissNum:0,//缺考数量
  327. unScanned:0,//未扫描数量
  328. scannedNum:0,//已上传数量
  329. examTotal:0,//考试总人数
  330. });//扫描返回的数据信息
  331. const scanProcess= computed(() => {
  332. console.log("打印扫描数据",scanDataInfo);
  333. return Math.floor(((scanDataInfo.value.scannedNum+scanDataInfo.value.examMissNum)/scanDataInfo.value.examTotal)*100);
  334. });
  335. const scanQuekao=computed(() => {
  336. return Math.floor((scanDataInfo.value.examMissNum/scanDataInfo.value.examTotal)*100);
  337. });
  338. //异常进度
  339. const scanYichang=computed(() => {
  340. return Math.floor((scanDataInfo.value.abnormalNum/scanDataInfo.value.examTotal)*100);
  341. });
  342. //刷新
  343. const Refresh = () => {
  344. tableData.value=[];
  345. GetScanBatchList();
  346. }
  347. //上传进度设置
  348. const UploadProgress=(batchNumber:number,scanNumber:number)=>{
  349. console.log("图片上传扫描更新进度",batchNumber,scanNumber);
  350. const targetItem = tableData.value.find((item:any) => item.batchNo == batchNumber);
  351. if (targetItem) {
  352. }
  353. }
  354. //导入图片完成
  355. const UploadComplete=(batchNumber:number,scanNumber:number,currentBatchNOID:string) => {
  356. let count = scanNumber;
  357. // // 1:单面 2:双面
  358. // if (paperSchema.value == 2) {
  359. // // 双面扫描数量除以2(向下取整,防止奇数报错)
  360. // count = Math.floor(scanNumber / 2);
  361. // } else {
  362. // 单面不除以2
  363. count = scanNumber;
  364. // }
  365. currentBatchNo.value = batchNumber.toString();
  366. const newData = {
  367. batchNo: currentBatchNo.value,
  368. scanUserName: userInfo.value?.userName || '', // 增加空值保护
  369. scannedPaperNum: count, // 扫描张数
  370. scannedTime: Date.now(), // 扫描时间
  371. uploadNum: 0, // 上传张数
  372. uploadStatus: 0,
  373. };
  374. tableData.value.push(newData);
  375. loadingText.value = "正在上传中";
  376. // 建立与后端的websocket连接
  377. WebSocketLink();
  378. // 扫描完成更新扫描张数
  379. UpdateBatchScanNumber(currentBatchNOID, count);
  380. }
  381. //取消上传
  382. const CancelUpload=(batchNumber:number)=>{
  383. const targetItem = tableData.value.find((item:any)=> item.batchNo == batchNumber);
  384. setTimeout(() => {
  385. if (targetItem)
  386. {
  387. targetItem.uploadStatus = 1;
  388. }
  389. }, 5000);
  390. }
  391. //扫描异常返回
  392. const BackScan= () => {
  393. //更新列表
  394. GetScanBatchList();
  395. }
  396. //扫描完成
  397. const FinishScanned= async () =>{
  398. console.log("打印完成")
  399. ElMessageBox.confirm('确认完成吗?', '提示', {
  400. confirmButtonText: '确定',
  401. cancelButtonText: '取消',
  402. type: 'warning',
  403. customClass:'page_dialog'
  404. }).then(async () => {
  405. let param={
  406. id:examSubjectId.value
  407. };
  408. finishLoading.value=true;
  409. const res = await finishScanned(param)
  410. if(res.code == 200)
  411. {
  412. // ElMessage.success("完成成功!")
  413. let idList=res.data.split(",");
  414. let analysisParam = {
  415. examId:idList[0],
  416. examPaperIds:[idList[1]],//多科传0 单科传科目ID
  417. }
  418. //扫描完成 调用汇总接口
  419. const analysisRes = await getExamScoreSummary(analysisParam);
  420. if(analysisRes.code == 200)
  421. {
  422. ElMessage.success("完成成功!")
  423. finishLoading.value=false;
  424. //显示成绩查询
  425. const stepFlow=examStore.currentExam?.stepFlow < 2;
  426. if(stepFlow){
  427. examStore.setExamInfo({
  428. ...examStore.currentExam,
  429. stepFlow:2,
  430. })
  431. }
  432. //是否显示分组分析
  433. const res = await queryQuestionGroupByAiId(examSubjectId.value);
  434. const isShow = res.code === 200;
  435. analysisStore.setIsShowGroupAnalysis(isShow);
  436. GetExamStatus();//更新状态
  437. }
  438. else
  439. {
  440. ElMessage.error(analysisRes.msg);
  441. finishLoading.value=false;
  442. }
  443. }
  444. else
  445. {
  446. ElMessage.error(res.msg);
  447. finishLoading.value=false;
  448. }
  449. })
  450. }
  451. //获取考试状态
  452. const GetExamStatus=async ()=>{
  453. const param = {
  454. examSubjectId:examSubjectId.value
  455. }
  456. getExamProcess(param).then((res: any) => {
  457. console.log('打印考试流程状态返回', res)
  458. if (res.code === 200) {
  459. const newStateStr = res.data;
  460. console.log('打印考试流程状态', newStateStr)
  461. // 替换为 Store Commit/Action
  462. examStore.setExamState(newStateStr);//设置状态数据
  463. if(newStateStr.includes(2))
  464. {
  465. router.push('/exam/analysis/score')
  466. }
  467. else
  468. {
  469. }
  470. }
  471. })
  472. }
  473. const ConfigRequestUrlByEnv= () =>{
  474. console.log("打印环境", import.meta.env.MODE);
  475. if (import.meta.env.MODE === 'development')
  476. {
  477. //本地开发环境:写死测试环境地址
  478. websocketUrl = 'wss://index.k12100.net/teaching/api/v1/teaching/websocket/';
  479. uploadUrl = `https://index.k12100.net/teaching/api/v1/ai_exam_scan/upload_multi_img`;//图片上传地址
  480. updateCountUrl = `https://index.k12100.net/teaching/api/v1/ai_exam_scan/record_batch_scan_number`;//更新扫描数量地址
  481. }
  482. else
  483. {
  484. //线上环境(测试/生产):读取配置的环境变量
  485. websocketUrl = import.meta.env.VITE_WEB_SOCKET_URL;//websocket链接地址
  486. uploadUrl = `${import.meta.env.VITE_API_BASE_URL_API}/api/v1/ai_exam_scan/upload_multi_img`;//图片上传地址
  487. updateCountUrl = `${import.meta.env.VITE_API_BASE_URL_API}/api/v1/ai_exam_scan/record_batch_scan_number`;//更新扫描数量地址
  488. }
  489. console.log("设置webSocket地址", websocketUrl);
  490. console.log("打印上传图片地址", uploadUrl);
  491. }
  492. //打开考号位数设置
  493. const OpenNumberSet=()=>{
  494. console.log("打印考号位数设置");
  495. showNumberSetDialog.value=true;
  496. }
  497. //关闭考号位数设置
  498. const CloseNumberSet=()=>{
  499. showNumberSetDialog.value=false;
  500. }
  501. //确定考号设置
  502. const HandleSubmit=()=>{
  503. if(examCodeStart.value > examCodeEnd.value) {
  504. ElMessage.error("开始考号位置不能大于结束考号位置");
  505. return;
  506. }
  507. let params={
  508. examSubjectId:examSubjectId.value,
  509. examCodeStart:examCodeStart.value,
  510. examCodeEnd:examCodeEnd.value,
  511. };
  512. setExamNumberPosition(params).then(res => {
  513. if(res.code == 200)
  514. {
  515. ElMessage.success("设置成功!")
  516. showNumberSetDialog.value=false;
  517. }
  518. else
  519. {
  520. ElMessage.error(res.msg);
  521. }
  522. })
  523. }
  524. //切换弹窗模式
  525. const ChangeDriveUI=()=>{
  526. console.log("打印弹窗模式", useDriveUI.value);
  527. let params={
  528. alterWindow:useDriveUI.value
  529. };
  530. setExamScanSetting(params).then(res => {
  531. if(res.code == 200)
  532. {
  533. ElMessage.success("设置成功!")
  534. }
  535. else
  536. {
  537. ElMessage.error(res.msg);
  538. }
  539. })
  540. }
  541. //改变识别码
  542. const ChangeCode=()=>{
  543. let param={
  544. examSubjectId:examSubjectId.value,
  545. chooseCode:scanIdentifyCode.value//识别号 1-学号 2-平台号 3-学籍号 4-考号
  546. };
  547. saveChooseCode(param).then(res=>{
  548. console.log("打印识别码设置结果",res);
  549. if(res.code==200)
  550. {
  551. ElMessage.success("设置成功!")
  552. examCodeEnd.value=res.data;
  553. examCodeStart.value=1;
  554. }
  555. else
  556. {
  557. ElMessage.error(res.msg);
  558. }
  559. })
  560. }
  561. //获取未上传图片的数量
  562. const GetNoUploadNumber=(item:BatchItem)=>
  563. {
  564. const scannedPaperNum = item.scannedPaperNum ?? 0;
  565. const uploadNum = item.uploadNum ?? 0;
  566. const result = scannedPaperNum - uploadNum;
  567. return result > 0 ? result : 0;
  568. }
  569. // 跟后端websocket连接 1.建立socket连接 用户ID_考试科目ID_学校ID_批次号
  570. const WebSocketLink = () => {
  571. if(webSocket.value && webSocket.value.getSocketStatus() === WebSocket.OPEN)
  572. {
  573. webSocket.value.closeWebSocket();
  574. }
  575. let userCourseId='';
  576. let schoolIdValue = userInfo.value.schoolId; // 这里逻辑是 单校都取登录用户的学校ID 如果是联校账号 给单校扫描 传单校的学校id
  577. // if(schoolType.value == 1) {
  578. // //联校 盟主学校
  579. // schoolIdValue = selectSchoolId.value;
  580. // } else {
  581. // schoolIdValue = userInfo.value.schoolId;
  582. // }
  583. console.log("打印用户信息", userInfo.value);
  584. userCourseId = `${userInfo.value.userId}_${examSubjectId.value}_${schoolIdValue}_${currentBatchNo.value}`; //用户 科目 批次号
  585. console.log("websocketUrl",websocketUrl);
  586. const url = `${websocketUrl}${userCourseId}`;
  587. console.log("打印websocket链接地址url", url);
  588. webSocket.value = new WebSocketManager(url, MessageBack);
  589. webSocket.value.start();
  590. }
  591. //websocket消息返回
  592. const MessageBack = (data:any) => {
  593. // console.log("打印websocket返回数据", data);
  594. const msg=JSON.parse(data);
  595. console.log("Websocket消息返回处理",msg);
  596. //code 0 建立成功 200 业务成功 400 业务失败 异常 需要提示信息
  597. if(msg.code==0)
  598. {
  599. //建立成功
  600. console.log("和后端的websocket建立成功");
  601. }
  602. else if(msg.code==200)
  603. {
  604. //业务成功
  605. // console.log("打印当前tableData的数据",this.tableData);
  606. //正常扫描
  607. let currentData=msg.data[0];
  608. let targetItem = tableData.value.find(item => item.batchNo == currentData.batchNo);
  609. console.log("识别成功+1",targetItem);
  610. if(msg.abnormalNum==-1)
  611. {
  612. scanDataInfo.value.unScanned = msg.unScanned;
  613. scanDataInfo.value.examMissNum = msg.examMissNum;
  614. scanDataInfo.value.abnormalNum = msg.abnormalNum;
  615. scanDataInfo.value.scannedNum = msg.scannedNum;
  616. if (targetItem) {
  617. if(currentData.uploadNum==-1)
  618. {
  619. targetItem.uploadNum++;
  620. }
  621. }
  622. }
  623. else
  624. {
  625. if (targetItem) {
  626. targetItem.uploadNum = msg.data[0].uploadNum;
  627. }
  628. scanDataInfo.value.unScanned = msg.unScanned;
  629. scanDataInfo.value.examMissNum = msg.examMissNum;
  630. scanDataInfo.value.abnormalNum = msg.abnormalNum;
  631. scanDataInfo.value.scannedNum = msg.scannedNum;
  632. let process = (Number(scanDataInfo.value.scannedNum) + Number(scanDataInfo.value.examMissNum)) / Number(scanDataInfo.value.examTotal) * 100
  633. if (isNaN(process)) {
  634. process = 0
  635. }
  636. }
  637. if(targetItem)
  638. {
  639. if(Number(targetItem.scannedPaperNum) === Number(targetItem.uploadNum))
  640. {
  641. targetItem.uploadStatus=1;
  642. // loadingText.value='';
  643. isScanning.value=false;
  644. // removeBeforeUnloadListener();// 移除页面离开阻止监听器
  645. }
  646. else
  647. {
  648. }
  649. }
  650. }
  651. else if(msg.code==400)
  652. {
  653. //业务失败
  654. GetScanBatchList();
  655. ElMessage.error(msg.message);
  656. }
  657. }
  658. //重新识别弹窗
  659. const OpenReIdentify=() => {
  660. //判断是否在扫描
  661. if(isScanning.value)
  662. {
  663. //正在扫描中 不可重新识别
  664. ElMessage.error("正在扫描中,请等待扫描完成后再重新识别!");
  665. return;
  666. }
  667. //计算总识别张数
  668. let sumTotal=0;
  669. tableData.value.forEach((item:any) => {
  670. sumTotal+=item.uploadNum;
  671. });
  672. isReIdentify.value=true;
  673. // reIdentifyNumber.value=sumTotal;
  674. reIdentifyTotal.value=sumTotal;
  675. }
  676. //开始扫描
  677. const OpenScan = () => {
  678. if(isScanning.value)
  679. {
  680. //正在扫描
  681. ElMessage.warning('正在扫描中,请勿重复点击哦!');
  682. return;
  683. }
  684. //判断客户端是否已经连接
  685. if(scanClientStates.value)
  686. {
  687. //一打开客户端
  688. console.log('客户端已打开,开始扫描');
  689. // isScanning.value=true;//扫描状态
  690. const params={
  691. examSubjectId:examSubjectId.value,
  692. schoolId:selectSchoolId.value,
  693. };
  694. getCurrentBatchNo(params).then((res:any)=>{
  695. console.log("当前获取批次结果",res);
  696. if(res.code==200)
  697. {
  698. currentBatchNo.value=res.data.batchNo;
  699. currentBatchNoId.value=res.data.id;
  700. let newData={
  701. batchNo:currentBatchNo.value,
  702. id:currentBatchNoId.value,//批次号
  703. batchTypeName:'扫描',
  704. scanUserName:currentUserName.value,
  705. scannedPaperNum:0,//扫描张数
  706. scannedTime:Date.now(),//扫描时间
  707. uploadNum:0,//上传张数
  708. uploadStatus:0,//扫描状态
  709. };
  710. tableData.value.push(newData);
  711. //开始扫描
  712. let jsonParam={
  713. examSubjectId:examSubjectId.value,
  714. batchNumber:currentBatchNo.value,
  715. // sensitive: 35,//灵敏度参数 固定35
  716. filter:0,//是否过滤参数 1-是 0-否
  717. // heightRatio:this.heightRatio,//占打分框高度比例
  718. schoolId:selectSchoolId.value//学校id 联校单校都需要学校id
  719. };
  720. let json = {
  721. "action":"startScan",//交互指令参数
  722. "batchNumber":GetBatchStr(res.data.id,currentBatchNo.value),//批次号 这里传给客户端的批次号需要进行处理 截取批次id后5位拼接batchNumber
  723. "subjectCode":examSubjectCode.value,//科目编号
  724. "paperSchema":1,//this.paperSchema,// 单双面//页面类型 1 单面 2 双面
  725. "token":localStorage.getItem('token'),//token信息
  726. "uploadUrl":uploadUrl, // 图片上传地址
  727. "updateCountUrl":updateCountUrl,//更新扫描纸张数量接口 接口参数 批次id post 请求 id
  728. "batchId":currentBatchNoId.value,//批次号id
  729. "dpi":150,//dpi参数 设置图片清晰度质量的
  730. "isColor":1,//是否彩色图片 手阅卡扫描彩色图片 0 黑白 1 彩色
  731. "useDriveUI":0,//startScan和scanTemplate增加useDriveUI参数,=1时会弹框,其他值或不写则不弹
  732. "jsonParam":JSON.stringify(jsonParam),// 后端使用的参数 json字符串 后端接口固定三个参数 1:jsonParam 2:seqNumber(这个批次的图片序号:从1开始) 3:file 图片文件
  733. };//正式版参数
  734. console.log("打印发送的数据",JSON.stringify(json));
  735. setTimeout(() => {
  736. scanCommon.send(JSON.stringify(json))
  737. },100)
  738. // 建立与后端的websocket连接
  739. WebSocketLink();
  740. }
  741. else
  742. {
  743. ElMessage.error(res.msg);
  744. }
  745. });
  746. }
  747. else
  748. {
  749. //提示客户端未打开
  750. ElMessage.warning('请先打开客户端');
  751. }
  752. }
  753. //获取批次字符串
  754. const GetBatchStr=(batchId:any,batChNo:any)=>{
  755. const batchNoValue = batchId.substring(batchId.length - 5);
  756. const batchNo=String(batChNo).padStart(3, '0');
  757. const batchNumber=batchNoValue+batchNo;//传给客户端的图片批次号 id后五位数加上00批次号
  758. return batchNumber;
  759. }
  760. //根据处理后的批次号转换成处理前的批次号
  761. const GetBatchNumber=(batchNumber:any)=>{
  762. if (!batchNumber) {
  763. console.warn('批次号为空或未定义');
  764. return currentBatchNo.value;//返回当前的批次号
  765. }
  766. const batchStr = batchNumber.toString();
  767. if (batchStr.length < 3) {
  768. console.warn('批次号长度小于3位:', batchStr);
  769. return currentBatchNo.value;//返回当前的批次号
  770. }
  771. const lastThree = batchStr.slice(-3);
  772. const parsedNumber = parseInt(lastThree, 10);
  773. if (isNaN(parsedNumber)) {
  774. console.error('无法解析批次号:', lastThree);
  775. return currentBatchNo.value;//返回当前的批次号
  776. }
  777. console.log("打印最后的批次号",parsedNumber);
  778. return parsedNumber.toString();
  779. }
  780. //删除批次
  781. const OptionDelete=(row: any) => {
  782. console.log('删除批次', row);
  783. if(row.scanUserName==currentUserName.value)
  784. {
  785. ElMessageBox.confirm('确定要删除该批次吗?', '提示', {
  786. confirmButtonText: '确定',
  787. cancelButtonText: '取消',
  788. customClass:'page_dialog',
  789. type: 'warning'
  790. }).then(() => {
  791. // 删除操作
  792. console.log('删除', row);
  793. const params={
  794. examSubjectId:examSubjectId.value,
  795. batchNo:row.batchNo,
  796. schoolId:selectSchoolId.value,
  797. };
  798. deleteBatch(params).then((res:any)=>{
  799. if(res.code==200)
  800. {
  801. ElMessage.success("删除成功!")
  802. GetScanBatchList();
  803. }
  804. else
  805. {
  806. ElMessage.error(res.msg);
  807. }
  808. })
  809. }).catch(() => {
  810. // 取消操作
  811. console.log('取消删除');
  812. });
  813. }
  814. else
  815. {
  816. ElMessage.warning('只能删除自己上传的记录');
  817. }
  818. }
  819. //跳转到异常详情页
  820. const GotoDetail = (type: number) => {
  821. console.log('跳转到异常详情页', type);
  822. scanState.value=type;
  823. // 根据类型跳转到不同的详情页
  824. showAbnormalDialog.value=true;
  825. }
  826. //跳转到批次详情页
  827. const GotoBatchDetail=(batchNo:any)=>{
  828. router.push({
  829. path: '/exam/scanDetail',
  830. query: {
  831. examSubjectId: examSubjectId.value,
  832. batchNo: batchNo,
  833. },
  834. })
  835. }
  836. // 打开导入学生名单
  837. const OpenImportStudent = () => {
  838. showSelectStudent.value=true;
  839. }
  840. //打开上传图片
  841. const OpenImportDialog=() => {
  842. showUploadImage.value=true;
  843. }
  844. // 打开编辑考试名单
  845. const OpenEditExamList = () => {
  846. router.push({
  847. path: '/exam/examList',
  848. query: {
  849. examSubjectId: examSubjectId.value,
  850. },
  851. });
  852. }
  853. //学生名单导入成功
  854. const StudentSuccess = () => {
  855. HasImportStudent();
  856. }
  857. //获取批次列表 获取扫描批次列表
  858. const GetScanBatchList=async()=>{
  859. const params = {
  860. examSubjectId: examSubjectId.value,
  861. schoolId: 0,//单校 0
  862. };
  863. const res = await getBatchList(params);
  864. if(res.code==200)
  865. {
  866. selectSchoolId.value=res.data.schoolId;//获取学校id
  867. scanIdentifyCode.value=res.data.chooseCode;//获取识别码
  868. //1-单面 2-双面
  869. examCodeEnd.value=res.data.examCodeEnd;
  870. examCodeStart.value=res.data.examCodeStart;
  871. if(res.data.scannedWebSocketVO)
  872. {
  873. tableData.value=res.data.scannedWebSocketVO?.data || [];
  874. scanDataInfo.value.abnormalNum=res.data.scannedWebSocketVO.abnormalNum;//异常数量
  875. scanDataInfo.value.examMissNum=res.data.scannedWebSocketVO.examMissNum;//缺考数量
  876. scanDataInfo.value.scannedNum=res.data.scannedWebSocketVO.scannedNum;//已上传数量
  877. scanDataInfo.value.unScanned=res.data.scannedWebSocketVO.unScanned;//未扫描数量
  878. scanDataInfo.value.examTotal=res.data.scannedWebSocketVO.examTotal;//总人数
  879. let examInfoCount={
  880. unScanned:res.data.scannedWebSocketVO.unScanned,
  881. examMissNum:res.data.scannedWebSocketVO.examMissNum,
  882. scannedNum:res.data.scannedWebSocketVO.scannedNum,
  883. abnormalNum:res.data.scannedWebSocketVO.abnormalNum,
  884. examTotal:res.data.scannedWebSocketVO.examTotal,
  885. };
  886. examStore.setExamInfoCount(examInfoCount);//设置扫描数据信息
  887. }
  888. }
  889. }
  890. //计算高度的函数
  891. const CalculateTableHeight = () => {
  892. // nextTick 确保 DOM 更新后再获取尺寸
  893. nextTick(() => {
  894. // window.innerHeight 是浏览器可视区域高度
  895. // 简单算法:视窗高度 - 固定占用高度
  896. let computedHeight = window.innerHeight - 136;
  897. // 限制最小高度,防止太矮
  898. if (computedHeight < 200) {
  899. computedHeight = 200;
  900. }
  901. tableHeight.value = computedHeight;
  902. });
  903. };
  904. //更新扫描张数
  905. const UpdateBatchScanNumber = (batchId: any, scanNumber: Number) => {
  906. const params={
  907. id:batchId,
  908. recordNumber: scanNumber,
  909. };
  910. updateScanCount(params).then((res:any)=>{
  911. if(res.code==200)
  912. {
  913. console.log("第"+batchId+"批次更新扫描张数"+scanNumber+"成功", res);
  914. }
  915. })
  916. };
  917. // 处理扫描结果
  918. const HandleScanResult = (res: any) => {
  919. console.log('收到扫描数据', res);
  920. // 业务逻辑...
  921. if (res.action == 'uploading')
  922. {
  923. let batchNumber: any = '';
  924. if (res.batchNumber)
  925. {
  926. batchNumber = GetBatchNumber(res.batchNumber || res.data?.batchNumber);
  927. }
  928. const targetItem = tableData.value.find((item: any) => item.batchNo == batchNumber);
  929. if (typeof loadingText !== 'undefined') loadingText.value = "启动扫描仪中";
  930. ElMessage.success("正在启动扫描仪,请稍后…");
  931. if (targetItem)
  932. {
  933. targetItem.uploadStatus = 0; //更新上传状态 0 开始上传
  934. }
  935. }
  936. // 开始扫描指令
  937. if (res.action == 'startScan')
  938. {
  939. let batchNumber = GetBatchNumber(res?.batchNumber || res.data?.batchNumber);
  940. let currentItem = tableData.value.find((item: any) => item.batchNo == batchNumber);
  941. console.log("打印currentItem", currentItem);
  942. //开始扫描指令
  943. if (res.code == 200)
  944. {
  945. ElMessage.success("扫描仪启动成功,开始扫描…");
  946. if(typeof loadingText !== 'undefined') loadingText.value = "正在扫描中";
  947. }
  948. if (res.code == 502)
  949. {
  950. console.log("开始扫描指令502错误 未检测到纸张或者卡纸", res);
  951. console.log("打印currentItem", currentItem);
  952. if (currentItem) {
  953. currentItem.uploadStatus = 1; //更新上传状态
  954. }
  955. if (typeof loadingText !== 'undefined') loadingText.value = ""; //清空上传提示
  956. isScanning.value = false; //重置扫描状态
  957. ElMessage.error(res.msg);
  958. }
  959. if (res.code == 510)
  960. {
  961. console.log("启动扫描失败,上传正在进行中", res);
  962. isScanning.value = true; //重置扫描状态
  963. ElMessage.warning(res.msg + '请勿重复点击');
  964. }
  965. if (res.code == 509) {
  966. console.log("扫描仪正在使用中", res);
  967. if (res.msg == '未找到指定的扫描仪') {
  968. isScanning.value = false; //重置扫描状态
  969. }
  970. ElMessage.warning(res.msg + ',请稍后再试!');
  971. if (currentItem) {
  972. currentItem.uploadStatus = 1; //更新上传状态
  973. }
  974. }
  975. }
  976. // 扫描完成指令
  977. if (res.action == 'uploadFinish') {
  978. console.log("上传完成uploadFinish 更新上传动画状态", res);
  979. // 修复:直接调用 GetBatchNumber
  980. let batchNumber = GetBatchNumber(res?.batchNumber || res.data?.batchNumber);
  981. let targetItem = tableData.value.find((item: any) => item.batchNo == batchNumber);
  982. if (typeof loadingText !== 'undefined') loadingText.value = '正在上传中';
  983. if (targetItem) {
  984. targetItem.scannedPaperNum = res.scanNumber; //更新扫描张数
  985. targetItem.failedNumber = res.failedNumber; //更新失败张数
  986. if (typeof UpdateBatchScanNumber === 'function') {
  987. UpdateBatchScanNumber(targetItem.id, Number(targetItem.scannedPaperNum));
  988. }
  989. }
  990. isScanning.value = false; //重置扫描状态
  991. }
  992. if (res.action == 'uploadNumber') {
  993. console.log("上传完成uploadNumber 更新上传张数", res);
  994. // 逻辑已注释,保持原样
  995. }
  996. if (res.action == 'scanNumber') {
  997. console.log("扫描张数scanNumber 更新扫描张数");
  998. // 修复:直接调用 GetBatchNumber
  999. let batchNumber = GetBatchNumber(res.batchNumber || res.data?.batchNumber);
  1000. let targetItem = tableData.value.find((item: any) => item.batchNo == batchNumber);
  1001. console.log("打印targetItem", targetItem);
  1002. if (targetItem) {
  1003. targetItem.scannedPaperNum = res.number; //更新上传张数
  1004. targetItem.uploadStatus = 0; //更新上传状态 0 开始上传
  1005. }
  1006. // 修复:确保 UpdateBatchScanNumber 已定义
  1007. if (targetItem && typeof UpdateBatchScanNumber === 'function') {
  1008. UpdateBatchScanNumber(targetItem.id, Number(targetItem.scannedPaperNum));
  1009. }
  1010. }
  1011. if (res.action == 'loadImage') {
  1012. console.log("加载图片loadImage 获取图片数据", res);
  1013. // 修复:reImageList 必须是 ref
  1014. if (typeof reImageList !== 'undefined') {
  1015. reImageList.value = res.data || [];
  1016. reImageList.value.forEach((item: any) => {
  1017. item.uploadStatus = -2;
  1018. item.uploadProgress = 0;
  1019. });
  1020. }
  1021. let batchNumber = GetBatchNumber(res.batchNumber);
  1022. let targetItem = tableData.value.find((item: any) => item.batchNo == batchNumber);
  1023. console.log("打印重新上传图片列表", reImageList.value);
  1024. console.log("打印重新上传的批次Item", targetItem);
  1025. if (targetItem) {
  1026. targetItem.uploadStatus = 0;
  1027. }
  1028. if (typeof loadingText !== 'undefined') loadingText.value = '正在上传中';
  1029. if (typeof uploadDialogTitle !== 'undefined') uploadDialogTitle.value = '未上传的图片';
  1030. if (typeof showUploadDialog !== 'undefined') showUploadDialog.value = true;
  1031. }
  1032. if (res.action == 'finish') {
  1033. console.log("图片重传finish指令", res);
  1034. let batchNumber = GetBatchNumber(res.batchNumber);
  1035. let targetItem = tableData.value.find((item: any) => item.batchNo == batchNumber);
  1036. let fileIndex = res.fileIndex.split(",");
  1037. console.log("打印fileIndex", fileIndex);
  1038. fileIndex.forEach((index: string) => {
  1039. // 修复:reImageList.value
  1040. let reImageItem = reImageList.value.find((item: any) => item.fileIndex == index);
  1041. if (reImageItem) {
  1042. let progress = reImageItem.uploadProgress;
  1043. const interval = setInterval(() => {
  1044. progress += 5;
  1045. if (progress >= 100) {
  1046. progress = 100;
  1047. clearInterval(interval);
  1048. // 修复:Vue3 不需要 $set,直接赋值即可触发响应式
  1049. reImageItem.uploadStatus = res.uploadState;
  1050. }
  1051. reImageItem.uploadProgress = progress;
  1052. }, 100);
  1053. }
  1054. });
  1055. // 修复:reImageCount 可能是 ref 或计算属性
  1056. let currentReImageCount = typeof reImageCount !== 'undefined' ? reImageCount.value : reImageList.value.length;
  1057. if (currentReImageCount === 0) {
  1058. if (typeof showUploadDialog !== 'undefined') showUploadDialog.value = false;
  1059. if (targetItem) {
  1060. targetItem.uploadStatus = 1;
  1061. isScanning.value = false;
  1062. // 修复:确保 GetBatchList 已定义
  1063. if (typeof GetBatchList === 'function') GetBatchList();
  1064. }
  1065. }
  1066. }
  1067. if (res.action == 'getFailedImage') {
  1068. console.log("获取失败图片getFailedImage", res);
  1069. let failedList = res.data || [];
  1070. failedList.forEach((item: any) => {
  1071. let batchNumber = GetBatchNumber(item.batchNumber);
  1072. let currentItem = tableData.value.find((item1: any) => item1.batchNo == batchNumber);
  1073. if (currentItem) {
  1074. if (item.failedNumber == 0) {
  1075. if (currentItem.scannedPaperNum != currentItem.uploadNum) {
  1076. currentItem.scannedPaperNum = currentItem.uploadNum;
  1077. if (typeof UpdateBatchScanNumber === 'function') {
  1078. UpdateBatchScanNumber(currentItem.id, currentItem.uploadNum);
  1079. }
  1080. }
  1081. } else {
  1082. let number = currentItem.uploadNum + item.failedNumber;
  1083. currentItem.scannedPaperNum = number;
  1084. if (typeof UpdateBatchScanNumber === 'function') {
  1085. UpdateBatchScanNumber(currentItem.id, number);
  1086. }
  1087. }
  1088. }
  1089. });
  1090. }
  1091. if (res.action == 'scanFinishBatch')
  1092. {
  1093. if (typeof loadingText !== 'undefined') loadingText.value = '本次扫描结束';
  1094. console.log("本批次扫描完成scanFinishBatch 更新扫描张数", res);
  1095. }
  1096. };
  1097. onMounted(() => {
  1098. // 初始化连接
  1099. scanCommon.init(HandleScanResult);
  1100. // 监听连接状态
  1101. scanCommon.watchConnection((isOnline,clientVersion) => {
  1102. scanClientStates.value=isOnline;
  1103. scanClientVersion.value=clientVersion; //客户端版本号
  1104. // console.log("客户端版本",clientVersion);
  1105. });
  1106. if (!examStore.currentExam) {
  1107. console.warn('当前没有选中的考试信息')
  1108. // 可选:如果没有数据,可以重定向回列表页或提示用户
  1109. }
  1110. GetScanBatchList();//获取扫描批次列表
  1111. CalculateTableHeight();//初始化计算表格高度
  1112. console.log("打印当前的配置",import.meta.env.VUE_APP_BASE);
  1113. ConfigRequestUrlByEnv();//环境配置
  1114. // 监听窗口大小变化
  1115. window.addEventListener('resize', CalculateTableHeight);
  1116. });
  1117. // 卸载时移除监听,防止内存泄漏
  1118. onUnmounted(() => {
  1119. window.removeEventListener('resize', CalculateTableHeight);
  1120. // 组件销毁时务必停止,防止内存泄漏和后台重连
  1121. scanCommon.stop();
  1122. });
  1123. </script>
  1124. <style lang="scss" scoped>
  1125. .page_list
  1126. {
  1127. width: 100%;
  1128. height: 100%;
  1129. padding: 20px;
  1130. background-color: #fff;
  1131. border-radius: 4px;
  1132. box-sizing: border-box;
  1133. }
  1134. .scan_state_title
  1135. {
  1136. font-size: 14px;
  1137. color:#333;
  1138. font-weight: 400;
  1139. span
  1140. {
  1141. // text-emphasis-style: dot; /* 实心小圆点 • */
  1142. // // text-emphasis-style: circle; /* 空心圆圈 ○ */
  1143. // // text-emphasis-style: double-circle; /* 双圆圈 ◉ */
  1144. // // text-emphasis-style: triangle; /* 三角形 ▲ */
  1145. // /* 自定义字符 */
  1146. // // text-emphasis-style: '★'; /* 使用星号 */
  1147. // // text-emphasis-style: '※'; /* 使用参考标记 */
  1148. // text-emphasis-color: red;
  1149. // text-emphasis-position: under; /* 下方居中 */
  1150. }
  1151. }
  1152. .scan_state_open
  1153. { margin-left: 5px;
  1154. font-size: 14px;
  1155. font-weight: 400;
  1156. color: #2BC644;
  1157. i
  1158. {
  1159. margin-right: 5px;
  1160. }
  1161. }
  1162. .scan_state_close
  1163. {
  1164. font-size: 14px;
  1165. font-weight: 400;
  1166. margin-left: 5px;
  1167. color:#F56C6C;
  1168. i
  1169. {
  1170. margin-right: 5px;
  1171. }
  1172. }
  1173. </style>