index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div class="data-check">
  3. <div class="check-menu">
  4. <div class="check-menu-body">
  5. <ul>
  6. <li
  7. v-for="item in studentList"
  8. :key="item.id"
  9. @click="onSelectStudent(item)"
  10. >
  11. {{ item.examNumber }}
  12. </li>
  13. </ul>
  14. </div>
  15. <div class="check-menu-page">
  16. <SimplePagination
  17. :total="total"
  18. :page-size="pageSize"
  19. @change="onChangeListPage"
  20. />
  21. </div>
  22. </div>
  23. <div class="check-body">
  24. <ScanImage
  25. v-if="dataCheckStore.curPage && isOriginImage && recogList.length"
  26. :key="dataCheckStore.curPage.kid"
  27. :img-src="dataCheckStore.curPage.sheetUri"
  28. :recog-data="recogList"
  29. @prev="onPrevPage"
  30. @next="onNextPage"
  31. @recog-block-modified="onRecogEditConfirm"
  32. />
  33. <SliceImage v-if="dataCheckStore.curPage && !isOriginImage" />
  34. </div>
  35. <CheckAction @search="onSearch" />
  36. </div>
  37. </template>
  38. <script setup lang="ts">
  39. import { ref, reactive, onMounted, computed } from "vue";
  40. import { message } from "ant-design-vue";
  41. import { CaretLeftOutlined, CaretRightOutlined } from "@ant-design/icons-vue";
  42. import { DataCheckListFilter, DataCheckListItem } from "@/ap/types/dataCheck";
  43. import { dataCheckList } from "@/ap/dataCheck";
  44. import { StudentPage } from "./types";
  45. import { useDataCheckStore } from "@/store";
  46. import SimplePagination from "@/components/SimplePagination/index.vue";
  47. import ScanImage from "./ScanImage/index.vue";
  48. import SliceImage from "./SliceImage/index.vue";
  49. import CheckAction from "./CheckAction.vue";
  50. defineOptions({
  51. name: "DataCheck",
  52. });
  53. const dataCheckStore = useDataCheckStore();
  54. let searchModel = {} as DataCheckListFilter;
  55. const pageNumber = ref(1);
  56. const pageSize = ref(20);
  57. const total = ref(0);
  58. const studentList = ref<DataCheckListItem[]>([]);
  59. const dataList = ref<StudentPage[]>([]);
  60. const loading = ref(false);
  61. async function getList() {
  62. loading.value = true;
  63. const datas = {
  64. ...searchModel,
  65. pageNumber: pageNumber.value,
  66. pageSize: pageSize.value,
  67. };
  68. const res = await dataCheckList(datas).catch(() => null);
  69. loading.value = false;
  70. if (!res) return;
  71. total.value = res.totalCount;
  72. studentList.value = res.result;
  73. parseStudentPageList(res.result);
  74. }
  75. function parseStudentPageList(students: DataCheckListItem[]) {
  76. dataList.value = [];
  77. students.forEach((student, studentIndex) => {
  78. student.papers.forEach((paper, paperIndex) => {
  79. if (!paper.pages) return;
  80. paper.pages.forEach((page, pageIndex) => {
  81. dataList.value.push({
  82. ...page,
  83. paperId: paper.id as number,
  84. pageIndex,
  85. paperIndex,
  86. studentIndex,
  87. studentId: student.id,
  88. examId: searchModel.examId,
  89. kid: `${student.id}-${studentIndex}-${paperIndex}-${pageIndex}`,
  90. });
  91. });
  92. });
  93. });
  94. }
  95. function onSelectStudent(record: DataCheckListItem) {
  96. const pageIndex = dataList.value.findIndex(
  97. (item) => item.studentId === record.id
  98. );
  99. if (pageIndex === -1) return;
  100. selectPage(pageIndex);
  101. }
  102. // imageType
  103. const isOriginImage = computed(() => {
  104. return dataCheckStore.imageType === "ORIGIN";
  105. });
  106. // table
  107. async function onChangeListPage(index: number) {
  108. pageNumber.value = index;
  109. await getList();
  110. selectPage(0);
  111. }
  112. async function onSearch(datas: DataCheckListFilter) {
  113. searchModel = { ...datas };
  114. pageNumber.value = 1;
  115. await getList();
  116. selectPage(0);
  117. }
  118. // page
  119. const curStudentInfo = ref({
  120. examNumber: "",
  121. name: "",
  122. examSite: "",
  123. seatNumber: "",
  124. paperType: "",
  125. });
  126. const curPageQuestions = ref<string[]>([]);
  127. function selectPage(index: number) {
  128. dataCheckStore.setInfo({
  129. curPage: dataList.value[index],
  130. curPageIndex: index,
  131. });
  132. if (!dataCheckStore.curPage) return;
  133. const curStudent = studentList.value[
  134. dataCheckStore.curPage.studentIndex
  135. ] as DataCheckListItem;
  136. dataCheckStore.setInfo({ curStudent });
  137. }
  138. async function onPrevPage() {
  139. if (dataCheckStore.curPageIndex <= 0) {
  140. if (pageNumber.value === 1) {
  141. message.error("没有上一张了");
  142. return;
  143. }
  144. pageNumber.value--;
  145. await getList();
  146. selectPage(dataList.value.length - 1);
  147. return;
  148. }
  149. selectPage(dataCheckStore.curPageIndex - 1);
  150. }
  151. async function onNextPage() {
  152. if (dataCheckStore.curPageIndex >= dataList.value.length - 1) {
  153. if (pageNumber.value >= total.value) {
  154. message.error("没有下一张了");
  155. return;
  156. }
  157. pageNumber.value++;
  158. await getList();
  159. selectPage(0);
  160. return;
  161. }
  162. selectPage(dataCheckStore.curPageIndex + 1);
  163. }
  164. </script>