TaskApplyManage.vue 11 KB

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