Scan.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <div class="task-manage">
  3. <div class="part-box part-box-filter">
  4. <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
  5. <el-form-item>
  6. <h3 class="filter-title">选择考试</h3>
  7. </el-form-item>
  8. <el-form-item>
  9. <sec-select
  10. v-model="filter"
  11. default-select-course
  12. @course-default="search"
  13. ></sec-select>
  14. </el-form-item>
  15. <el-form-item label-width="0px">
  16. <el-button type="primary" :disabled="!searchEnable" @click="search"
  17. >查询</el-button
  18. >
  19. <el-button type="success" @click="toSetOrcArea"
  20. >设置条码识别区</el-button
  21. >
  22. <el-button type="success" :disabled="setDisabled" @click="toSetScan"
  23. >设置扫描仪</el-button
  24. >
  25. </el-form-item>
  26. </el-form>
  27. </div>
  28. <el-row class="task-parts" :gutter="16" type="flex">
  29. <el-col :span="16">
  30. <div class="part-box part-box-pad">
  31. <div class="task-part-head">
  32. <h3>试卷扫描</h3>
  33. </div>
  34. <div class="task-part-body box-justify">
  35. <div class="task-chart">
  36. <el-progress
  37. type="circle"
  38. :percentage="percentage"
  39. :width="140"
  40. :stroke-width="20"
  41. color="#165dff"
  42. ></el-progress>
  43. </div>
  44. <div class="task-infos">
  45. <div class="task-info-item">
  46. <div class="task-info-title">
  47. <i class="icon icon-person-grid"></i>
  48. <span>考生总数</span>
  49. </div>
  50. <div class="task-info-cont">
  51. {{ task.studentCount || "0" }}
  52. </div>
  53. </div>
  54. <div class="task-info-item">
  55. <div class="task-info-title">
  56. <i class="icon icon-right-grid"></i>
  57. <span>已扫人数<span class="mlr-1">/</span>张数</span>
  58. </div>
  59. <div class="task-info-cont">
  60. <span>{{ task.scanStudentCount || "0" }}</span>
  61. <span class="mlr-1">/</span>
  62. <span>{{ task.scanCount || "0" }}</span>
  63. </div>
  64. </div>
  65. <div class="task-info-item">
  66. <div class="task-info-title">
  67. <i class="icon icon-close-grid"></i>
  68. <span>未扫人数</span>
  69. </div>
  70. <div class="task-info-cont">{{ unScanStudentCount }}</div>
  71. </div>
  72. </div>
  73. </div>
  74. <div class="task-part-foot box-justify">
  75. <div class="tips-info tips-error">待上传:{{ unuploadNo }}</div>
  76. <div class="task-btn" @click="toScan(true)">
  77. <span>开始扫描</span>
  78. <i class="icon icon-narrow-right"></i>
  79. </div>
  80. </div>
  81. </div>
  82. </el-col>
  83. <el-col :span="8">
  84. <div class="part-box part-box-pad">
  85. <div class="task-part-head">
  86. <h3>其他文件扫描</h3>
  87. </div>
  88. <div class="task-part-body"></div>
  89. <div class="task-part-foot box-justify">
  90. <div></div>
  91. <div class="task-btn" @click="toScan(false)">
  92. <span>开始扫描</span>
  93. <i class="icon icon-narrow-right"></i>
  94. </div>
  95. </div>
  96. </div>
  97. </el-col>
  98. </el-row>
  99. <!-- OcrAreaSetDialog -->
  100. <ocr-area-set-dialog ref="OcrAreaSetDialog" @modified="getOcrArea">
  101. </ocr-area-set-dialog>
  102. </div>
  103. </template>
  104. <script>
  105. import db from "../../../plugins/db";
  106. import { taskInfos } from "../api";
  107. import SecSelect from "@/components/SecSelect.vue";
  108. import OcrAreaSetDialog from "../components/OcrAreaSetDialog.vue";
  109. import { setScanner } from "../../../plugins/scanner";
  110. export default {
  111. name: "scan",
  112. components: { OcrAreaSetDialog, SecSelect },
  113. data() {
  114. return {
  115. filter: {
  116. semesterId: "",
  117. examId: "",
  118. courseCode: "",
  119. },
  120. searchFilter: {},
  121. task: {},
  122. ocrArea: null,
  123. setDisabled: false,
  124. };
  125. },
  126. computed: {
  127. unScanStudentCount() {
  128. return (this.task.studentCount || 0) - (this.task.scanStudentCount || 0);
  129. },
  130. searchEnable() {
  131. return (
  132. this.filter.semesterId && this.filter.examId && this.filter.courseCode
  133. );
  134. },
  135. percentage() {
  136. const studentCount = this.task.studentCount || 0;
  137. const scanStudentCount = this.task.scanStudentCount || 0;
  138. if (!studentCount) return 0;
  139. return ((scanStudentCount * 100) / studentCount).toFixed(2) * 1;
  140. },
  141. unuploadNo() {
  142. return this.$store.state.client.unuploadNo;
  143. },
  144. },
  145. activated() {
  146. if (this.task.examId) {
  147. this.search();
  148. }
  149. },
  150. mounted() {
  151. this.$store.commit("setBreadcrumbs", [{ url: "Scan", name: "扫描" }]);
  152. this.getOcrArea();
  153. },
  154. methods: {
  155. async search() {
  156. this.task = {};
  157. const res = await taskInfos(this.filter);
  158. this.task = { ...res, semesterId: this.filter.semesterId };
  159. this.searchFilter = { ...this.filter };
  160. },
  161. async getOcrArea() {
  162. const ocrArea = await db.getDict("ocrArea", "").catch(() => {});
  163. this.ocrArea = ocrArea || null;
  164. this.$store.commit(
  165. "client/setOcrArea",
  166. ocrArea ? JSON.parse(ocrArea) : {}
  167. );
  168. },
  169. toScan(isFormal) {
  170. if (!this.searchEnable) {
  171. this.$message.error("请选择课程!");
  172. return;
  173. }
  174. if (!this.task.id) {
  175. this.$message.error("请先查询任务!");
  176. return;
  177. }
  178. if (isFormal && !this.ocrArea) {
  179. this.$message.error("请先设置条形码识别区!");
  180. return;
  181. }
  182. const scanName = isFormal ? "ScanPaper" : "ScanOther";
  183. this.$ls.set("task", this.task);
  184. this.$router.push({ name: scanName });
  185. },
  186. toSetOrcArea() {
  187. this.$refs.OcrAreaSetDialog.open();
  188. },
  189. async toSetScan() {
  190. if (this.setDisabled) return;
  191. this.setDisabled = true;
  192. await setScanner().catch((error) => {
  193. console.dir(error);
  194. this.$message.error("连接扫描仪异常");
  195. });
  196. setTimeout(() => {
  197. this.setDisabled = false;
  198. }, 5000);
  199. },
  200. },
  201. };
  202. </script>