TaskApplyManage.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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="openCollege"
  94. label="开课学院"
  95. min-width="160"
  96. ></el-table-column>
  97. <el-table-column
  98. prop="userName"
  99. label="命题老师"
  100. min-width="120"
  101. ></el-table-column>
  102. <el-table-column prop="startTime" label="命题开始时间" width="170">
  103. <span slot-scope="scope">{{
  104. scope.row.startTime | timestampFilter
  105. }}</span>
  106. </el-table-column>
  107. <el-table-column prop="endTime" label="命题结束时间" width="170">
  108. <span slot-scope="scope">{{
  109. scope.row.endTime | timestampFilter
  110. }}</span>
  111. </el-table-column>
  112. <el-table-column prop="auditStatus" label="审核状态" width="100">
  113. <template slot-scope="scope">
  114. {{ scope.row.auditStatus | auditStatusFilter }}
  115. </template>
  116. </el-table-column>
  117. <el-table-column
  118. class-name="action-column"
  119. label="操作"
  120. width="160px"
  121. fixed="right"
  122. >
  123. <template slot-scope="scope">
  124. <el-button
  125. v-if="checkPrivilege('link', 'preview')"
  126. class="btn-primary"
  127. type="text"
  128. @click="toPreview(scope.row)"
  129. >预览</el-button
  130. >
  131. <el-button
  132. v-if="
  133. ((!scope.row.review &&
  134. scope.row.auditStatus === null &&
  135. scope.row.status === 'STAGE') ||
  136. (scope.row.review &&
  137. (scope.row.auditStatus === 'START' ||
  138. scope.row.auditStatus === 'REJECT' ||
  139. scope.row.auditStatus === 'CANCEL'))) &&
  140. checkPrivilege('link', 'edit')
  141. "
  142. class="btn-primary"
  143. type="text"
  144. @click="toEdit(scope.row)"
  145. >立即申请</el-button
  146. >
  147. <el-button
  148. v-if="
  149. scope.row.auditStatus === 'AUDITING' &&
  150. scope.row.setup === 2 &&
  151. checkPrivilege('link', 'end')
  152. "
  153. class="btn-danger"
  154. type="text"
  155. @click="toCancel(scope.row)"
  156. >撤销申请</el-button
  157. >
  158. <el-button
  159. v-if="
  160. scope.row.approveFormStatus &&
  161. checkPrivilege('link', 'download')
  162. "
  163. class="btn-primary"
  164. type="text"
  165. @click="toDownloadForm(scope.row)"
  166. >下载审批表</el-button
  167. >
  168. <el-button
  169. v-if="checkPrivilege('link', 'delete')"
  170. class="btn-danger"
  171. type="text"
  172. @click="toDelete(scope.row)"
  173. >删除</el-button
  174. >
  175. </template>
  176. </el-table-column>
  177. </el-table>
  178. <div class="part-page">
  179. <el-pagination
  180. v-if="examTasks.length"
  181. background
  182. layout="total, sizes, prev, pager, next, jumper"
  183. :pager-count="5"
  184. :current-page="current"
  185. :total="total"
  186. :page-size="size"
  187. @current-change="toPage"
  188. @size-change="pageSizeChange"
  189. >
  190. </el-pagination>
  191. </div>
  192. </div>
  193. <!-- ModifyTaskApply -->
  194. <modify-task-apply
  195. v-if="checkPrivilege('link', 'edit') || checkPrivilege('link', 'preview')"
  196. ref="ModifyTaskApply"
  197. :type="editType"
  198. :row-data="curExamTask"
  199. @modified="taskModified"
  200. ></modify-task-apply>
  201. <!-- CreateExamAndPrintTask -->
  202. <create-exam-and-print-task
  203. v-if="checkPrivilege('button', 'ExamTaskApplyManage')"
  204. ref="CreateExamAndPrintTask"
  205. @modified="taskModified"
  206. ></create-exam-and-print-task>
  207. <!-- PaperApproveTable -->
  208. <paper-approve-table
  209. :instance="curExamTask"
  210. ref="PaperApproveTable"
  211. ></paper-approve-table>
  212. </div>
  213. </template>
  214. <script>
  215. import ModifyTaskApply from "../components/taskApply/ModifyTaskApply.vue";
  216. import CreateExamAndPrintTask from "../components/createExamAndPrintTask/CreateExamAndPrintTask.vue";
  217. import PaperApproveTable from "../components/PaperApproveTable.vue";
  218. import { AUDITING_STATUS } from "@/constants/enumerate";
  219. import pickerOptions from "@/constants/datePickerOptions";
  220. import {
  221. taskApplyListPage,
  222. cancelOrRestartTaskApply,
  223. deleteTaskApply,
  224. } from "../api";
  225. export default {
  226. name: "task-apply-manage",
  227. components: {
  228. ModifyTaskApply,
  229. CreateExamAndPrintTask,
  230. PaperApproveTable,
  231. },
  232. data() {
  233. return {
  234. filter: {
  235. semesterId: "",
  236. examId: "",
  237. openCollegeId: "",
  238. auditStatus: "",
  239. reviewStatus: "",
  240. cardRuleId: "",
  241. courseId: "",
  242. userName: "",
  243. paperNumber: "",
  244. startTime: "",
  245. endTime: "",
  246. },
  247. current: 1,
  248. size: this.GLOBAL.pageSize,
  249. total: 0,
  250. editType: "APPLY",
  251. AUDITING_STATUS,
  252. examTasks: [],
  253. curExamTask: {},
  254. curUserId: this.$ls.get("user", { id: "" }).id,
  255. userRoles: this.$ls.get("user", { roleList: [] }).roleList,
  256. // date-picker
  257. createTime: [],
  258. pickerOptions,
  259. };
  260. },
  261. watch: {
  262. "filter.examId": {
  263. handler(val, oldval) {
  264. if (val && val !== oldval) this.toPage(1);
  265. },
  266. immediate: true,
  267. },
  268. },
  269. created() {
  270. this.initData();
  271. },
  272. methods: {
  273. async initData() {
  274. const cachePageInfo = this.$ls.get("cachePageInfo");
  275. if (cachePageInfo) {
  276. this.filter = this.$objAssign(this.filter, cachePageInfo.filter);
  277. if (this.filter.startTime && this.filter.endTime)
  278. this.createTime = [this.filter.startTime, this.filter.endTime];
  279. this.current = cachePageInfo.page;
  280. await this.getList();
  281. this.$nextTick(() => {
  282. const curRow = this.examTasks.find(
  283. (item) => item.id === cachePageInfo.curRowId
  284. );
  285. if (!curRow) return;
  286. this.toEdit(curRow);
  287. });
  288. } else {
  289. // this.toPage(1);
  290. }
  291. this.$ls.remove("cachePageInfo");
  292. },
  293. async getList() {
  294. if (!this.checkPrivilege("list", "list")) return;
  295. const datas = {
  296. ...this.filter,
  297. pageNumber: this.current,
  298. pageSize: this.size,
  299. };
  300. if (this.createTime) {
  301. datas.startTime = this.createTime[0];
  302. datas.endTime = this.createTime[1];
  303. }
  304. const data = await taskApplyListPage(datas);
  305. this.examTasks = data.records;
  306. this.total = data.total;
  307. },
  308. toPage(page) {
  309. this.current = page;
  310. this.getList();
  311. },
  312. toCancel(row) {
  313. this.$confirm("确定要撤销当前申请吗?", "提示", {
  314. type: "warning",
  315. })
  316. .then(async () => {
  317. const data = await cancelOrRestartTaskApply({
  318. id: row.id,
  319. }).catch(() => {});
  320. if (!data) return;
  321. this.$message.success("操作成功!");
  322. this.getList();
  323. })
  324. .catch(() => {});
  325. },
  326. toEdit(row) {
  327. this.curExamTask = row;
  328. this.editType = "APPLY";
  329. this.$refs.ModifyTaskApply.open();
  330. },
  331. toPreview(row) {
  332. this.curExamTask = row;
  333. this.editType = "PREVIEW";
  334. this.$refs.ModifyTaskApply.open();
  335. },
  336. taskModified() {
  337. this.getList();
  338. },
  339. toAddExamAndPrintTask() {
  340. this.$refs.CreateExamAndPrintTask.open();
  341. },
  342. toDownloadForm(row) {
  343. this.curExamTask = { ...row, examTaskId: row.id };
  344. this.$refs.PaperApproveTable.open();
  345. },
  346. async toDelete(row) {
  347. const result = await this.$confirm(`确定要删除入库申请吗?`, "提示", {
  348. type: "warning",
  349. }).catch(() => {});
  350. if (result !== "confirm") return;
  351. await deleteTaskApply(row.id);
  352. this.$message.success("操作成功!");
  353. this.deletePageLastItem();
  354. },
  355. },
  356. beforeRouteLeave(to, from, next) {
  357. if (to.name === "CardEdit") {
  358. this.$ls.set("cachePageInfo", {
  359. page: this.current,
  360. filter: this.filter,
  361. curRowId: this.curExamTask.id,
  362. });
  363. } else {
  364. this.$ls.remove("cachePageInfo");
  365. }
  366. next();
  367. },
  368. };
  369. </script>