TaskApplyManage.vue 11 KB

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