PaperManage.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <div class="paper-manage page-container-flex">
  3. <div class="part-box part-box-filter part-box-head">
  4. <div class="part-box-head-left">
  5. <Form ref="FilterForm" label-position="left" inline>
  6. <FormItem>
  7. <Select
  8. v-model="filter.subject"
  9. @on-change="subjectChange"
  10. placeholder="科目"
  11. >
  12. <Option
  13. v-for="(item, index) in subjects"
  14. :key="index"
  15. :value="item.subject"
  16. :label="item.name"
  17. ></Option>
  18. </Select>
  19. </FormItem>
  20. <FormItem>
  21. <Select v-model="filter.areaCode" placeholder="选择考区" clearable>
  22. <Option
  23. v-for="area in areas"
  24. :key="area.id"
  25. :value="area.areaCode"
  26. :label="area.areaName"
  27. ></Option>
  28. </Select>
  29. </FormItem>
  30. <FormItem>
  31. <Input
  32. v-model="filter.startNumber"
  33. type="text"
  34. placeholder="输入开始编号"
  35. clearable
  36. />
  37. </FormItem>
  38. <FormItem>
  39. <Input
  40. v-model="filter.endNumber"
  41. type="text"
  42. placeholder="输入结束编号"
  43. clearable
  44. />
  45. </FormItem>
  46. <FormItem>
  47. <Select
  48. v-model="paperType"
  49. @on-change="typeChange"
  50. placeholder="类型"
  51. >
  52. <Option
  53. v-for="(val, key) in CAFA_EXCEPTION_TYPE"
  54. :key="key"
  55. :value="key"
  56. :label="val"
  57. ></Option>
  58. </Select>
  59. </FormItem>
  60. <FormItem>
  61. <Select
  62. v-model="filter.scanUserId"
  63. placeholder="选择采集账号"
  64. clearable
  65. >
  66. <Option
  67. v-for="user in scanUsers"
  68. :key="user.id"
  69. :value="user.name"
  70. :label="user.name"
  71. ></Option>
  72. </Select>
  73. </FormItem>
  74. <FormItem>
  75. <Input
  76. v-model.trim="filter.studentName"
  77. placeholder="输入姓名"
  78. clearable
  79. ></Input>
  80. </FormItem>
  81. <FormItem>
  82. <Select v-model="filter.sortBy" placeholder="排序方式" clearable>
  83. <Option
  84. v-for="(val, key) in SORT_RULE_TYPE"
  85. :key="key"
  86. :value="key"
  87. :label="val"
  88. ></Option>
  89. </Select>
  90. </FormItem>
  91. <FormItem>
  92. <Button
  93. size="small"
  94. class="btn-form-search"
  95. type="primary"
  96. @click="toPage(1)"
  97. >查询</Button
  98. >
  99. </FormItem>
  100. </Form>
  101. </div>
  102. <div class="part-box-head-right">
  103. <Button
  104. type="success"
  105. shape="circle"
  106. icon="upload-white icon"
  107. @click="toExportMark"
  108. >导出标记试卷</Button
  109. >
  110. </div>
  111. </div>
  112. <image-action-list
  113. v-if="papers.length"
  114. :data="papers"
  115. :actions="actions"
  116. @on-review="toReview"
  117. ref="ImageActionList"
  118. ></image-action-list>
  119. <div class="part-page" v-if="total > size">
  120. <Page
  121. :current="current"
  122. :total="total"
  123. :page-size="size"
  124. show-total
  125. show-elevator
  126. @on-change="toPage"
  127. ></Page>
  128. </div>
  129. <!-- image-preview -->
  130. <simple-image-preview
  131. :cur-image="curPaper"
  132. @on-prev="toPrevPaper"
  133. @on-next="toNextPaper"
  134. ref="SimpleImagePreview"
  135. ></simple-image-preview>
  136. </div>
  137. </template>
  138. <script>
  139. import { paperPageList, subjectList, areaList, clientUserQuery } from "@/api";
  140. import { SORT_RULE_TYPE, CAFA_EXCEPTION_TYPE } from "@/constants/enumerate";
  141. import ImageActionList from "./components/ImageActionList";
  142. import SimpleImagePreview from "@/components/SimpleImagePreview";
  143. export default {
  144. name: "paper-manage",
  145. components: { ImageActionList, SimpleImagePreview },
  146. data() {
  147. return {
  148. filter: {
  149. workId: this.$route.params.workId,
  150. studentName: "",
  151. areaCode: "",
  152. startNumber: null,
  153. endNumber: null,
  154. subject: "",
  155. sortBy: "",
  156. scanUserId: "",
  157. isManual: null,
  158. missing: null,
  159. isRelate: null,
  160. isMark: null
  161. },
  162. SORT_RULE_TYPE,
  163. CAFA_EXCEPTION_TYPE: {},
  164. paperType: "9",
  165. confirmPaperType: "9",
  166. current: 1,
  167. size: this.GLOBAL.pageSize,
  168. total: 0,
  169. totalPage: 0,
  170. papers: [],
  171. subjects: [],
  172. scanUsers: [],
  173. areas: [],
  174. curPaper: {},
  175. curPaperIndex: 0
  176. };
  177. },
  178. computed: {
  179. actions() {
  180. return this.confirmPaperType === "1"
  181. ? ["mark"]
  182. : ["rotate", "absent", "mark"];
  183. }
  184. },
  185. mounted() {
  186. this.CAFA_EXCEPTION_TYPE = {
  187. ...CAFA_EXCEPTION_TYPE,
  188. 8: "已标记",
  189. 9: "全部"
  190. };
  191. this.initData();
  192. },
  193. methods: {
  194. async initData() {
  195. await this.getSubjects();
  196. this.filter.subject = this.subjects[0].subject;
  197. this.filter.areaCode = "";
  198. this.areas = [];
  199. await this.getAreaList();
  200. if (!this.filter.areaCode) {
  201. this.filter.areaCode = this.areas[0].areaCode;
  202. }
  203. this.getScanUsers();
  204. this.toPage(1);
  205. },
  206. async getList() {
  207. const datas = {
  208. ...this.filter,
  209. page: this.current - 1,
  210. size: this.size
  211. };
  212. this.papers = [];
  213. const data = await paperPageList(datas);
  214. this.papers = data.data.map(paper => {
  215. const title = paper.manual
  216. ? `${paper.examNumber} ${paper.studentName}`
  217. : paper.examNumber;
  218. return {
  219. id: paper.id,
  220. key: this.$randomCode(),
  221. title,
  222. imgSrc: paper.imgSrc,
  223. thumbSrc: paper.thumbSrc,
  224. missing: paper.missing,
  225. isMark: paper.isMark,
  226. stage: paper.stage,
  227. styles: {},
  228. deg: 0
  229. };
  230. });
  231. this.total = data.totalCount;
  232. this.totalPage = data.pageCount;
  233. },
  234. toPage(page) {
  235. if (!this.filter.subject || !this.filter.areaCode) {
  236. this.$Message.error("请选择科目和考区!");
  237. return;
  238. }
  239. this.confirmPaperType = this.paperType;
  240. this.current = page;
  241. this.getList();
  242. },
  243. subjectChange() {
  244. this.filter.areaCode = "";
  245. this.areas = [];
  246. if (!this.filter.subject) return;
  247. this.getAreaList();
  248. },
  249. async getAreaList() {
  250. const data = await areaList({
  251. workId: this.filter.workId,
  252. subject: this.filter.subject
  253. });
  254. this.areas = data.map(item => {
  255. return {
  256. id: item.id,
  257. areaName: item.areaName,
  258. areaCode: item.areaCode
  259. };
  260. });
  261. if (this.areas.length === 1) {
  262. this.filter.areaCode = this.areas[0].areaCode;
  263. }
  264. },
  265. async getSubjects() {
  266. const data = await subjectList(this.filter.workId);
  267. this.subjects = data.filter(item => item.enable);
  268. },
  269. async getScanUsers() {
  270. const data = await clientUserQuery(this.filter.workId);
  271. this.scanUsers = data.data;
  272. },
  273. typeChange() {
  274. const typeToField = {
  275. 0: "missing",
  276. 1: "isManual",
  277. 2: "isRelate",
  278. 8: "isMark"
  279. };
  280. Object.values(typeToField).forEach(val => {
  281. this.filter[val] = typeToField[this.paperType] === val ? true : null;
  282. });
  283. },
  284. toExportMark() {
  285. window.open(
  286. this.urlAddAuthor(
  287. `${this.GLOBAL.domain}/api/export/paper/${this.filter.workId}/mark`
  288. )
  289. );
  290. },
  291. // paper view
  292. toReview(index) {
  293. this.selectPaper(index);
  294. this.$refs.SimpleImagePreview.open();
  295. },
  296. selectPaper(index) {
  297. let nindex = index;
  298. if (!this.papers.length) {
  299. nindex = 0;
  300. } else if (index > this.papers.length - 1) {
  301. nindex = this.papers.length - 1;
  302. } else if (index < 0) {
  303. nindex = 0;
  304. }
  305. this.curPaperIndex = nindex;
  306. this.curPaper = this.papers[nindex] ? { ...this.papers[nindex] } : {};
  307. },
  308. async toPrevPaper() {
  309. if (this.curPaperIndex === 0) {
  310. if (this.current > 1) {
  311. this.current--;
  312. this.curPaperIndex = this.size - 1;
  313. await this.getList();
  314. } else {
  315. this.$Message.warning("当前已经是第一条数据了");
  316. return;
  317. }
  318. } else {
  319. this.curPaperIndex--;
  320. }
  321. this.selectPaper(this.curPaperIndex);
  322. },
  323. async toNextPaper() {
  324. if (this.curPaperIndex === this.papers.length - 1) {
  325. if (this.current === this.totalPage) {
  326. this.$Message.warning("当前已经是最后一条数据了");
  327. return;
  328. } else {
  329. this.current++;
  330. this.curPaperIndex = 0;
  331. await this.getList();
  332. }
  333. } else {
  334. this.curPaperIndex++;
  335. }
  336. this.selectPaper(this.curPaperIndex);
  337. }
  338. }
  339. };
  340. </script>