TaskPaperManage.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <div class="task-paper-manage">
  3. <div class="part-box part-box-filter">
  4. <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
  5. <template v-if="checkPrivilege('condition', 'condition')">
  6. <secp-select
  7. v-model="filter"
  8. defaultSelectExam
  9. @exam-default="toPage(1)"
  10. ></secp-select>
  11. <el-form-item label="入库时间:">
  12. <el-date-picker
  13. v-model="createTime"
  14. type="datetimerange"
  15. :picker-options="pickerOptions"
  16. range-separator="至"
  17. start-placeholder="入库开始时间"
  18. end-placeholder="入库结束时间"
  19. value-format="timestamp"
  20. align="right"
  21. unlink-panels
  22. >
  23. </el-date-picker>
  24. </el-form-item>
  25. </template>
  26. <el-form-item label-width="0px">
  27. <el-button
  28. v-if="checkPrivilege('button', 'select')"
  29. type="primary"
  30. @click="toPage(1)"
  31. >查询</el-button
  32. >
  33. </el-form-item>
  34. </el-form>
  35. <div class="box-justify">
  36. <div></div>
  37. <div>
  38. <el-button
  39. v-if="checkPrivilege('button', 'BatchDownload')"
  40. icon="el-icon-download"
  41. type="primary"
  42. :loading="loading"
  43. @click="toBatchExport"
  44. >
  45. 批量下载试卷题卡
  46. </el-button>
  47. <el-button
  48. v-if="checkPrivilege('button', 'BatchDownload')"
  49. type="primary"
  50. icon="el-icon-s-order"
  51. @click="toDataTask"
  52. >下载结果查询</el-button
  53. >
  54. </div>
  55. </div>
  56. </div>
  57. <div class="part-box part-box-pad">
  58. <el-table ref="TableList" :data="papers">
  59. <el-table-column
  60. type="index"
  61. label="序号"
  62. width="70"
  63. :index="indexMethod"
  64. ></el-table-column>
  65. <el-table-column
  66. prop="semesterName"
  67. label="学期"
  68. min-width="210"
  69. ></el-table-column>
  70. <el-table-column
  71. prop="examName"
  72. label="考试"
  73. min-width="160"
  74. ></el-table-column>
  75. <el-table-column
  76. prop="paperNumber"
  77. label="试卷编号"
  78. min-width="160"
  79. ></el-table-column>
  80. <el-table-column prop="courseName" label="课程(代码)" min-width="200">
  81. <template slot-scope="scope">
  82. {{ scope.row.courseName }}({{ scope.row.courseCode }})
  83. </template>
  84. </el-table-column>
  85. <el-table-column
  86. prop="paperType"
  87. label="卷型"
  88. width="80"
  89. ></el-table-column>
  90. <el-table-column
  91. prop="userName"
  92. label="命题老师"
  93. min-width="100"
  94. ></el-table-column>
  95. <el-table-column prop="createTime" label="入库时间" width="170">
  96. <span slot-scope="scope">{{
  97. scope.row.createTime | timestampFilter
  98. }}</span>
  99. </el-table-column>
  100. <el-table-column prop="exposedPaperType" label="已曝光" width="80">
  101. <span slot-scope="scope">{{
  102. scope.row.exposedPaperType | defaultFieldFilter
  103. }}</span>
  104. </el-table-column>
  105. <el-table-column prop="unexposedPaperType" label="未曝光" width="80">
  106. <span slot-scope="scope">{{
  107. scope.row.unexposedPaperType | defaultFieldFilter
  108. }}</span>
  109. </el-table-column>
  110. <el-table-column prop="enable" label="启用/禁用" width="90">
  111. <template slot-scope="scope">
  112. {{ scope.row.enable | enableFilter }}
  113. </template>
  114. </el-table-column>
  115. <el-table-column
  116. class-name="action-column"
  117. label="操作"
  118. width="140px"
  119. fixed="right"
  120. >
  121. <template slot-scope="scope">
  122. <el-button
  123. v-if="checkPrivilege('link', 'preview')"
  124. class="btn-primary"
  125. type="text"
  126. @click="toPreview(scope.row)"
  127. >预览</el-button
  128. >
  129. <el-button
  130. v-if="checkPrivilege('link', 'edit')"
  131. class="btn-primary"
  132. type="text"
  133. @click="toEdit(scope.row)"
  134. >编辑</el-button
  135. >
  136. <el-button
  137. v-if="checkPrivilege('link', 'enable')"
  138. :class="scope.row.enable ? 'btn-danger' : 'btn-primary'"
  139. type="text"
  140. @click="toEnable(scope.row)"
  141. >{{ scope.row.enable ? "禁用" : "启用" }}</el-button
  142. >
  143. <el-button
  144. v-if="checkPrivilege('link', 'download')"
  145. class="btn-primary"
  146. type="text"
  147. :disabled="loading"
  148. @click="toDownload(scope.row)"
  149. >下载</el-button
  150. >
  151. <el-button
  152. v-if="checkPrivilege('link', 'publish')"
  153. class="btn-primary"
  154. type="text"
  155. @click="toPublishPrintTask(scope.row)"
  156. >发布印刷任务</el-button
  157. >
  158. <el-button
  159. v-if="checkPrivilege('link', 'cancel')"
  160. class="btn-danger"
  161. type="text"
  162. @click="toCancel(scope.row)"
  163. >作废</el-button
  164. >
  165. <el-button
  166. v-if="checkPrivilege('link', 'restart')"
  167. class="btn-danger"
  168. type="text"
  169. @click="toRestart(scope.row)"
  170. >打回</el-button
  171. >
  172. </template>
  173. </el-table-column>
  174. </el-table>
  175. <div class="part-page">
  176. <el-pagination
  177. v-if="papers.length"
  178. background
  179. layout="total, sizes, prev, pager, next, jumper"
  180. :pager-count="5"
  181. :current-page="current"
  182. :total="total"
  183. :page-size="size"
  184. @current-change="toPage"
  185. @size-change="pageSizeChange"
  186. >
  187. </el-pagination>
  188. </div>
  189. </div>
  190. <!-- ModifyTaskPaper -->
  191. <modify-task-paper
  192. v-if="checkPrivilege('link', 'edit') || checkPrivilege('link', 'preview')"
  193. :instance="curPaper"
  194. :edit-type="editType"
  195. ref="ModifyTaskPaper"
  196. @modified="getList"
  197. ></modify-task-paper>
  198. <!-- PublishPrintTask -->
  199. <publish-print-task
  200. v-if="checkPrivilege('link', 'publish')"
  201. :instance="curPaper"
  202. ref="PublishPrintTask"
  203. ></publish-print-task>
  204. <!-- data-task-dialog -->
  205. <data-task-dialog
  206. v-if="checkPrivilege('button', 'BatchDownload')"
  207. ref="DataTaskDialog"
  208. task-type="PAPER_AND_CARD_PDF_DOWNLOAD"
  209. ></data-task-dialog>
  210. </div>
  211. </template>
  212. <script>
  213. import {
  214. taskPaperListPage,
  215. ableTaskPaper,
  216. downloadPaper,
  217. paperAndCardBatchExport,
  218. cancelTaskPaper,
  219. restartTaskPaper,
  220. } from "../api";
  221. import pickerOptions from "@/constants/datePickerOptions";
  222. import { downloadByApi } from "@/plugins/download";
  223. import { CARD_SOURCE_TYPE } from "@/constants/enumerate";
  224. import ModifyTaskPaper from "../components/ModifyTaskPaper";
  225. import PublishPrintTask from "../components/PublishPrintTask";
  226. export default {
  227. name: "task-paper-manage",
  228. components: { ModifyTaskPaper, PublishPrintTask },
  229. data() {
  230. return {
  231. filter: {
  232. semesterId: "",
  233. examId: "",
  234. courseCode: "",
  235. paperNumber: "",
  236. cardRuleId: "",
  237. makeMethod: "",
  238. startTime: "",
  239. endTime: "",
  240. },
  241. current: 1,
  242. size: this.GLOBAL.pageSize,
  243. total: 0,
  244. papers: [],
  245. curPaper: {},
  246. loading: false,
  247. editType: "EDIT",
  248. CARD_SOURCE_TYPE,
  249. IS_QUESTION_TEACHER: this.$ls
  250. .get("user", { roleList: [] })
  251. .roleList.includes("QUESTION_TEACHER"),
  252. IS_EXAM_TEACHER: this.$ls
  253. .get("user", { roleList: [] })
  254. .roleList.includes("EXAM_TEACHER"),
  255. cancelRemark: "",
  256. // date-picker
  257. createTime: [],
  258. pickerOptions,
  259. };
  260. },
  261. mounted() {
  262. this.initData();
  263. },
  264. methods: {
  265. async initData() {
  266. const cachePageInfo = this.$ls.get("cachePageInfo");
  267. if (cachePageInfo) {
  268. this.filter = this.$objAssign(this.filter, cachePageInfo.filter);
  269. if (this.filter.startTime && this.filter.endTime)
  270. this.createTime = [this.filter.startTime, this.filter.endTime];
  271. this.current = cachePageInfo.page;
  272. await this.getList();
  273. this.$nextTick(() => {
  274. const curRow = this.papers.find(
  275. (item) => item.id === cachePageInfo.curRowId
  276. );
  277. if (!curRow) return;
  278. this.toEdit(curRow);
  279. });
  280. } else {
  281. // this.toPage(1);
  282. }
  283. this.$ls.remove("cachePageInfo");
  284. },
  285. async getList() {
  286. if (!this.checkPrivilege("list", "list")) return;
  287. const datas = {
  288. ...this.filter,
  289. pageNumber: this.current,
  290. pageSize: this.size,
  291. };
  292. if (this.createTime) {
  293. datas.startTime = this.createTime[0];
  294. datas.endTime = this.createTime[1];
  295. }
  296. const data = await taskPaperListPage(datas);
  297. this.papers = data.records;
  298. this.total = data.total;
  299. },
  300. toPage(page) {
  301. this.current = page;
  302. this.getList();
  303. },
  304. async toEnable(row) {
  305. const msgs = [
  306. ["命题任务禁用后,会触发试卷关联解除,您确定要禁用命题任务吗?"],
  307. [
  308. "命题任务启用后,触发试卷关联校验,若能匹配则自动关联试卷,您确定要启用命题任务吗?",
  309. ],
  310. ];
  311. const msg = row.enable ? msgs[0] : msgs[1];
  312. const msgHtml = msg
  313. .map((item) => `<p class="text-left">${item}</p>`)
  314. .join("");
  315. this.$confirm(msgHtml, "提示", {
  316. dangerouslyUseHTMLString: true,
  317. type: "warning",
  318. })
  319. .then(async () => {
  320. const enable = !row.enable;
  321. await ableTaskPaper({
  322. id: row.id,
  323. enable,
  324. });
  325. row.enable = enable;
  326. this.$message.success("操作成功!");
  327. })
  328. .catch(() => {});
  329. },
  330. async toCancel(row) {
  331. const res = await this.$prompt("确定要作废选中的命题任务吗", "提示", {
  332. type: "warning",
  333. showInput: true,
  334. inputPlaceholder: "请输入作废理由",
  335. inputValue: this.cancelRemark,
  336. inputValidator: (val) => {
  337. if (!val) return "请输入作废理由";
  338. if (val.length > 100) return "作废理由不得超过100个字符!";
  339. return true;
  340. },
  341. }).catch(() => {});
  342. if (!res || res.action !== "confirm") {
  343. return;
  344. }
  345. this.cancelRemark = res.value;
  346. const result = await cancelTaskPaper({
  347. id: row.id,
  348. cancelRemark: this.cancelRemark,
  349. }).catch(() => {});
  350. this.cancelRemark = "";
  351. if (!result) return;
  352. this.$message.success("操作成功!");
  353. this.getList();
  354. },
  355. async toRestart(row) {
  356. const res = await this.$confirm("确定要打回当前命题任务吗", "提示", {
  357. type: "warning",
  358. }).catch(() => {});
  359. if (res !== "confirm") return;
  360. const result = await restartTaskPaper({
  361. examTaskId: row.id,
  362. paperType: row.paperType,
  363. }).catch(() => {});
  364. if (!result) return;
  365. this.$message.success("操作成功!");
  366. this.getList();
  367. },
  368. toEdit(row) {
  369. this.curPaper = row;
  370. this.editType = "EDIT";
  371. this.$refs.ModifyTaskPaper.open();
  372. },
  373. toPreview(row) {
  374. this.curPaper = row;
  375. this.editType = "PREVIEW";
  376. this.$refs.ModifyTaskPaper.open();
  377. },
  378. toPublishPrintTask(row) {
  379. this.curPaper = row;
  380. this.$refs.PublishPrintTask.open();
  381. },
  382. async toDownload(row) {
  383. if (this.loading) return;
  384. this.loading = true;
  385. const res = await downloadByApi(() => {
  386. return downloadPaper(row.id);
  387. }, "").catch((e) => {
  388. this.$message.error(e || "下载失败,请重新尝试!");
  389. });
  390. this.loading = false;
  391. if (!res) return;
  392. this.$message.success("下载成功!");
  393. },
  394. async toBatchExport() {
  395. // 异步导出
  396. if (this.loading) return;
  397. this.loading = true;
  398. let datas = {
  399. ...this.filter,
  400. };
  401. if (this.createTime) {
  402. datas.startTime = this.createTime[0];
  403. datas.endTime = this.createTime[1];
  404. }
  405. const res = await paperAndCardBatchExport(datas).catch(() => {});
  406. this.loading = false;
  407. if (res) {
  408. this.$message.success("导出任务已提交!");
  409. } else {
  410. this.$message.error("导出任务提交失败,请重新尝试!");
  411. }
  412. },
  413. toDataTask() {
  414. this.$refs.DataTaskDialog.open();
  415. },
  416. },
  417. beforeRouteLeave(to, from, next) {
  418. if (to.name === "CardEdit") {
  419. this.$ls.set("cachePageInfo", {
  420. page: this.current,
  421. filter: this.filter,
  422. curRowId: this.curPaper.id,
  423. });
  424. } else {
  425. this.$ls.remove("cachePageInfo");
  426. }
  427. next();
  428. },
  429. };
  430. </script>