TaskApplyManage.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <div class="task-apply-manage">
  3. <div class="part-box part-box-filter part-box-flex">
  4. <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
  5. <template v-if="checkPrivilege('condition', 'condition')">
  6. <el-form-item label="学期:">
  7. <semester-select
  8. v-model="filter.semesterId"
  9. default-select
  10. @default-selected="getList"
  11. ></semester-select>
  12. </el-form-item>
  13. <el-form-item label="考试:">
  14. <exam-select
  15. v-model="filter.examId"
  16. :semester-id="filter.semesterId"
  17. ></exam-select>
  18. </el-form-item>
  19. <el-form-item label="审核状态:">
  20. <el-select
  21. v-model="filter.auditStatus"
  22. style="width: 142px;"
  23. placeholder="审核状态"
  24. clearable
  25. >
  26. <el-option
  27. v-for="(val, key) in AUDITING_STATUS"
  28. :key="key"
  29. :value="key"
  30. :label="val"
  31. ></el-option>
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="课程(代码):" label-width="110px">
  35. <course-select
  36. ref="CourseSelect"
  37. v-model.trim="filter.courseCode"
  38. placeholder="课程(代码)"
  39. clearable
  40. ></course-select>
  41. </el-form-item>
  42. <el-form-item label="命题老师:">
  43. <el-input
  44. v-model="filter.userName"
  45. placeholder="命题老师"
  46. clearable
  47. ></el-input>
  48. </el-form-item>
  49. <el-form-item label="试卷编号:">
  50. <paper-number-select
  51. ref="PaperNumberSelect"
  52. v-model="filter.paperNumber"
  53. placeholder="试卷编号"
  54. clearable
  55. ></paper-number-select>
  56. </el-form-item>
  57. <el-form-item label="命题时间:">
  58. <el-date-picker
  59. v-model="createTime"
  60. type="datetimerange"
  61. :picker-options="pickerOptions"
  62. range-separator="至"
  63. start-placeholder="命题开始时间"
  64. end-placeholder="命题结束时间"
  65. value-format="timestamp"
  66. align="right"
  67. unlink-panels
  68. >
  69. </el-date-picker>
  70. </el-form-item>
  71. </template>
  72. <el-form-item label-width="0px">
  73. <el-button
  74. v-if="checkPrivilege('button', 'select')"
  75. type="primary"
  76. @click="toPage(1)"
  77. >查询</el-button
  78. >
  79. </el-form-item>
  80. </el-form>
  81. <div class="part-box-action">
  82. <el-button
  83. v-if="checkPrivilege('button', 'addTask')"
  84. icon="el-icon-circle-plus-outline"
  85. type="primary"
  86. @click="toAddApply"
  87. >
  88. 新建命题申请
  89. </el-button>
  90. <el-button
  91. v-if="checkPrivilege('button', 'ExamTaskApplyManage')"
  92. icon="el-icon-circle-plus-outline"
  93. type="primary"
  94. @click="toAddExamAndPrintTask"
  95. >
  96. 新建任务
  97. </el-button>
  98. </div>
  99. </div>
  100. <div class="part-box part-box-pad">
  101. <el-table ref="TableList" :data="examTasks">
  102. <el-table-column
  103. type="index"
  104. label="序号"
  105. width="70"
  106. :index="indexMethod"
  107. ></el-table-column>
  108. <el-table-column
  109. prop="semesterName"
  110. label="学期"
  111. min-width="160"
  112. ></el-table-column>
  113. <el-table-column
  114. prop="examName"
  115. label="考试"
  116. min-width="160"
  117. ></el-table-column>
  118. <el-table-column
  119. prop="paperNumber"
  120. label="试卷编号"
  121. min-width="160"
  122. ></el-table-column>
  123. <el-table-column prop="courseName" label="课程(代码)" min-width="200">
  124. <template slot-scope="scope">
  125. {{ scope.row.courseName }}({{ scope.row.courseCode }})
  126. </template>
  127. </el-table-column>
  128. <el-table-column
  129. prop="userName"
  130. label="命题老师"
  131. min-width="100"
  132. ></el-table-column>
  133. <el-table-column prop="startTime" label="命题开始时间" width="170">
  134. <span slot-scope="scope">{{
  135. scope.row.startTime | timestampFilter
  136. }}</span>
  137. </el-table-column>
  138. <el-table-column prop="endTime" label="命题结束时间" width="170">
  139. <span slot-scope="scope">{{
  140. scope.row.endTime | timestampFilter
  141. }}</span>
  142. </el-table-column>
  143. <el-table-column prop="auditStatus" label="审核状态" width="100">
  144. <template slot-scope="scope">
  145. {{ scope.row.auditStatus | auditStatusFilter }}
  146. </template>
  147. </el-table-column>
  148. <el-table-column
  149. class-name="action-column"
  150. label="操作"
  151. width="160px"
  152. fixed="right"
  153. >
  154. <template slot-scope="scope">
  155. <el-button
  156. v-if="checkPrivilege('link', 'preview')"
  157. class="btn-primary"
  158. type="text"
  159. @click="toPreview(scope.row)"
  160. >查看详情</el-button
  161. >
  162. <el-button
  163. v-if="
  164. (scope.row.auditStatus === 'START' ||
  165. scope.row.auditStatus === 'REJECT' ||
  166. scope.row.auditStatus === 'CANCEL') &&
  167. checkPrivilege('link', 'edit')
  168. "
  169. class="btn-primary"
  170. type="text"
  171. @click="toEdit(scope.row)"
  172. >立即申请</el-button
  173. >
  174. <el-button
  175. v-if="
  176. scope.row.flowType === 'NEW' &&
  177. scope.row.approveCount === 2 &&
  178. checkPrivilege('link', 'end')
  179. "
  180. class="btn-danger"
  181. type="text"
  182. @click="toCancel(scope.row)"
  183. >撤销申请</el-button
  184. >
  185. <el-button
  186. v-if="
  187. scope.row.approveFormStatus &&
  188. checkPrivilege('link', 'download')
  189. "
  190. class="btn-primary"
  191. type="text"
  192. @click="toDownloadForm(scope.row)"
  193. >下载审批表</el-button
  194. >
  195. <el-button
  196. v-if="checkPrivilege('link', 'delete')"
  197. class="btn-danger"
  198. type="text"
  199. @click="toDelete(scope.row)"
  200. >删除申请</el-button
  201. >
  202. </template>
  203. </el-table-column>
  204. </el-table>
  205. <div class="part-page">
  206. <el-pagination
  207. v-if="examTasks.length"
  208. background
  209. layout="total, sizes, prev, pager, next, jumper"
  210. :pager-count="5"
  211. :current-page="current"
  212. :total="total"
  213. :page-size="size"
  214. @current-change="toPage"
  215. @size-change="pageSizeChange"
  216. >
  217. </el-pagination>
  218. </div>
  219. </div>
  220. <!-- ModifyTaskApply -->
  221. <modify-task-apply
  222. v-if="checkPrivilege('link', 'edit') || checkPrivilege('link', 'preview')"
  223. ref="ModifyTaskApply"
  224. :edit-type="editType"
  225. :instance="curExamTask"
  226. @modified="taskModified"
  227. ></modify-task-apply>
  228. <!-- CreateTaskApply -->
  229. <create-task-apply
  230. v-if="checkPrivilege('button', 'addTask')"
  231. ref="CreateTaskApply"
  232. @modified="taskModified"
  233. ></create-task-apply>
  234. <!-- CreateExamAndPrintTask -->
  235. <create-exam-and-print-task
  236. v-if="checkPrivilege('button', 'ExamTaskApplyManage')"
  237. ref="CreateExamAndPrintTask"
  238. @modified="taskModified"
  239. ></create-exam-and-print-task>
  240. <!-- PaperApproveTable -->
  241. <paper-approve-table
  242. :instance="curExamTask"
  243. ref="PaperApproveTable"
  244. ></paper-approve-table>
  245. </div>
  246. </template>
  247. <script>
  248. import ModifyTaskApply from "../components/ModifyTaskApply";
  249. import CreateExamAndPrintTask from "../components/createExamAndPrintTask/CreateExamAndPrintTask";
  250. import CreateTaskApply from "../components/CreateTaskApply";
  251. import PaperApproveTable from "../components/PaperApproveTable";
  252. import { AUDITING_STATUS } from "@/constants/enumerate";
  253. import pickerOptions from "@/constants/datePickerOptions";
  254. import {
  255. taskApplyListPage,
  256. cancelOrRestartTaskApply,
  257. deleteTaskApply
  258. } from "../api";
  259. import { mapActions } from "vuex";
  260. export default {
  261. name: "task-apply-manage",
  262. components: {
  263. ModifyTaskApply,
  264. CreateExamAndPrintTask,
  265. CreateTaskApply,
  266. PaperApproveTable
  267. },
  268. data() {
  269. return {
  270. filter: {
  271. semesterId: "",
  272. examId: "",
  273. auditStatus: "",
  274. reviewStatus: "",
  275. cardRuleId: "",
  276. courseCode: "",
  277. userName: "",
  278. paperNumber: "",
  279. startTime: "",
  280. endTime: ""
  281. },
  282. current: 1,
  283. size: this.GLOBAL.pageSize,
  284. total: 0,
  285. editType: "APPLY",
  286. AUDITING_STATUS,
  287. examTasks: [],
  288. curExamTask: {},
  289. curUserId: this.$ls.get("user", { id: "" }).id,
  290. userRoles: this.$ls.get("user", { roleList: [] }).roleList,
  291. // date-picker
  292. createTime: [],
  293. pickerOptions
  294. };
  295. },
  296. created() {
  297. this.initData();
  298. },
  299. methods: {
  300. ...mapActions("exam", ["updateWaitTaskCount"]),
  301. async initData() {
  302. const cachePageInfo = this.$ls.get("cachePageInfo");
  303. if (cachePageInfo) {
  304. this.filter = this.$objAssign(this.filter, cachePageInfo.filter);
  305. if (this.filter.startTime && this.filter.endTime)
  306. this.createTime = [this.filter.startTime, this.filter.endTime];
  307. this.current = cachePageInfo.page;
  308. await this.getList();
  309. this.$nextTick(() => {
  310. const curRow = this.examTasks.find(
  311. item => item.id === cachePageInfo.curRowId
  312. );
  313. if (!curRow) return;
  314. this.toEdit(curRow);
  315. });
  316. } else {
  317. // this.toPage(1);
  318. }
  319. this.$ls.remove("cachePageInfo");
  320. },
  321. async getList() {
  322. if (!this.checkPrivilege("list", "list")) return;
  323. const datas = {
  324. ...this.filter,
  325. pageNumber: this.current,
  326. pageSize: this.size
  327. };
  328. if (this.createTime) {
  329. datas.startTime = this.createTime[0];
  330. datas.endTime = this.createTime[1];
  331. }
  332. const data = await taskApplyListPage(datas);
  333. this.examTasks = data.records;
  334. this.total = data.total;
  335. },
  336. toPage(page) {
  337. this.current = page;
  338. this.getList();
  339. },
  340. toCancel(row) {
  341. this.$confirm("确定要撤销当前申请吗?", "提示", {
  342. type: "warning"
  343. })
  344. .then(async () => {
  345. const data = await cancelOrRestartTaskApply({
  346. id: row.id
  347. }).catch(() => {});
  348. if (!data) return;
  349. this.$message.success("操作成功!");
  350. this.getList();
  351. })
  352. .catch(() => {});
  353. },
  354. toEdit(row) {
  355. this.curExamTask = row;
  356. this.editType = "APPLY";
  357. this.$refs.ModifyTaskApply.open();
  358. },
  359. toPreview(row) {
  360. this.curExamTask = row;
  361. this.editType = "PREVIEW";
  362. this.$refs.ModifyTaskApply.open();
  363. },
  364. taskModified() {
  365. this.getList();
  366. this.updateWaitTaskCount(this.userRoles);
  367. },
  368. toAddApply() {
  369. this.$refs.CreateTaskApply.open();
  370. },
  371. toAddExamAndPrintTask() {
  372. this.$refs.CreateExamAndPrintTask.open();
  373. },
  374. toDownloadForm(row) {
  375. this.curExamTask = row;
  376. this.$refs.PaperApproveTable.open();
  377. },
  378. async toDelete(row) {
  379. const result = await this.$confirm(`确定要删除入库申请吗?`, "提示", {
  380. type: "warning"
  381. }).catch(() => {});
  382. if (result !== "confirm") return;
  383. await deleteTaskApply(row.id);
  384. this.$message.success("操作成功!");
  385. this.deletePageLastItem();
  386. }
  387. },
  388. beforeRouteLeave(to, from, next) {
  389. if (to.name === "CardEdit") {
  390. this.$ls.set("cachePageInfo", {
  391. page: this.current,
  392. filter: this.filter,
  393. curRowId: this.curExamTask.id
  394. });
  395. } else {
  396. this.$ls.remove("cachePageInfo");
  397. }
  398. next();
  399. }
  400. };
  401. </script>