TaskApplyManage.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. </div>
  86. </div>
  87. <div class="part-box part-box-pad">
  88. <el-table ref="TableList" :data="examTasks">
  89. <el-table-column
  90. type="index"
  91. label="序号"
  92. width="70"
  93. :index="indexMethod"
  94. ></el-table-column>
  95. <el-table-column prop="paperNumber" label="试卷编号"></el-table-column>
  96. <el-table-column prop="courseName" label="课程(代码)">
  97. <template slot-scope="scope">
  98. {{ scope.row.courseName }}({{ scope.row.courseCode }})
  99. </template>
  100. </el-table-column>
  101. <el-table-column prop="cardRuleName" label="题卡规则"></el-table-column>
  102. <el-table-column
  103. prop="userName"
  104. label="命题老师"
  105. width="100"
  106. ></el-table-column>
  107. <el-table-column prop="startTime" label="命题开始时间">
  108. <span slot-scope="scope">{{
  109. scope.row.startTime | timestampFilter
  110. }}</span>
  111. </el-table-column>
  112. <el-table-column prop="endTime" label="命题结束时间">
  113. <span slot-scope="scope">{{
  114. scope.row.endTime | timestampFilter
  115. }}</span>
  116. </el-table-column>
  117. <el-table-column prop="auditStatus" label="审核状态" width="100">
  118. <template slot-scope="scope">
  119. {{ scope.row.auditStatus | auditStatusFilter }}
  120. </template>
  121. </el-table-column>
  122. <el-table-column class-name="action-column" label="操作" width="160px">
  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.setup === 1 || scope.row.setup === null) &&
  134. checkPrivilege('link', 'edit')
  135. "
  136. class="btn-primary"
  137. type="text"
  138. @click="toEdit(scope.row)"
  139. >立即申请</el-button
  140. >
  141. <el-button
  142. v-if="
  143. scope.row.auditStatus === 'AUDITED' &&
  144. scope.row.reviewStatus === 'NOT_PASS' &&
  145. checkPrivilege('link', 'edit')
  146. "
  147. class="btn-primary"
  148. type="text"
  149. @click="toEdit(scope.row)"
  150. >重新申请</el-button
  151. >
  152. <el-button
  153. v-if="scope.row.setup === 0 && checkPrivilege('link', 'end')"
  154. class="btn-danger"
  155. type="text"
  156. @click="toCancel(scope.row)"
  157. >撤销申请</el-button
  158. >
  159. </template>
  160. </el-table-column>
  161. </el-table>
  162. <div class="part-page">
  163. <el-pagination
  164. v-if="examTasks.length"
  165. background
  166. layout="total,prev, pager, next"
  167. :current-page="current"
  168. :total="total"
  169. :page-size="size"
  170. @current-change="toPage"
  171. >
  172. </el-pagination>
  173. </div>
  174. </div>
  175. <!-- ModifyTaskApply -->
  176. <modify-task-apply
  177. ref="ModifyTaskApply"
  178. :edit-type="editType"
  179. :instance="curExamTask"
  180. @modified="taskModified"
  181. ></modify-task-apply>
  182. <!-- CreateTaskApply -->
  183. <create-task-apply
  184. ref="CreateTaskApply"
  185. @modified="taskModified"
  186. ></create-task-apply>
  187. </div>
  188. </template>
  189. <script>
  190. import ModifyTaskApply from "../components/ModifyTaskApply";
  191. import CreateTaskApply from "../components/createTaskApply/CreateTaskApply";
  192. // import CreateTaskApply from "../components/CreateTaskApply";
  193. import { AUDITING_STATUS } from "@/constants/enumerate";
  194. import pickerOptions from "@/constants/datePickerOptions";
  195. import { taskApplyListPage, cancelOrRestartTaskApply } from "../api";
  196. import { mapActions } from "vuex";
  197. export default {
  198. name: "task-apply-manage",
  199. components: {
  200. ModifyTaskApply,
  201. CreateTaskApply
  202. },
  203. data() {
  204. return {
  205. filter: {
  206. auditStatus: "",
  207. reviewStatus: "",
  208. cardRuleId: "",
  209. courseCode: "",
  210. userName: "",
  211. paperNumber: "",
  212. startTime: "",
  213. endTime: ""
  214. },
  215. current: 1,
  216. size: this.GLOBAL.pageSize,
  217. total: 0,
  218. editType: "APPLY",
  219. AUDITING_STATUS,
  220. examTasks: [],
  221. curExamTask: {},
  222. curUserId: this.$ls.get("user", { id: "" }).id,
  223. userRoles: this.$ls.get("user", { roleList: [] }).roleList,
  224. // date-picker
  225. createTime: [],
  226. pickerOptions
  227. };
  228. },
  229. mounted() {
  230. this.initData();
  231. },
  232. methods: {
  233. ...mapActions("exam", ["updateWaitTaskCount"]),
  234. async initData() {
  235. const cachePageInfo = this.$ls.get("cachePageInfo");
  236. if (cachePageInfo) {
  237. this.filter = this.$objAssign(this.filter, cachePageInfo.filter);
  238. if (this.filter.startTime && this.filter.endTime)
  239. this.createTime = [this.filter.startTime, this.filter.endTime];
  240. this.current = cachePageInfo.page;
  241. await this.getList();
  242. this.$nextTick(() => {
  243. const curRow = this.examTasks.find(
  244. item => item.id === cachePageInfo.curRowId
  245. );
  246. if (!curRow) return;
  247. this.toEdit(curRow);
  248. });
  249. } else {
  250. this.toPage(1);
  251. }
  252. this.$ls.remove("cachePageInfo");
  253. },
  254. async getList() {
  255. if (!this.checkPrivilege("list", "list")) return;
  256. const datas = {
  257. ...this.filter,
  258. pageNumber: this.current,
  259. pageSize: this.size
  260. };
  261. if (this.createTime) {
  262. datas.startTime = this.createTime[0];
  263. datas.endTime = this.createTime[1];
  264. }
  265. const data = await taskApplyListPage(datas);
  266. this.examTasks = data.records;
  267. this.total = data.total;
  268. },
  269. toPage(page) {
  270. this.current = page;
  271. this.getList();
  272. },
  273. toCancel(row) {
  274. this.$confirm("确定要撤销当前申请吗?", "提示", {
  275. type: "warning"
  276. })
  277. .then(async () => {
  278. const data = await cancelOrRestartTaskApply({
  279. id: row.id,
  280. status: "CANCEL"
  281. }).catch(() => {});
  282. if (!data) return;
  283. this.$message.success("操作成功!");
  284. this.getList();
  285. })
  286. .catch(() => {});
  287. },
  288. toEdit(row) {
  289. this.curExamTask = row;
  290. this.editType = "APPLY";
  291. this.$refs.ModifyTaskApply.open();
  292. },
  293. toPreview(row) {
  294. this.curExamTask = row;
  295. this.editType = "PREVIEW";
  296. this.$refs.ModifyTaskApply.open();
  297. },
  298. taskModified() {
  299. this.getList();
  300. this.updateWaitTaskCount(this.userRoles);
  301. },
  302. toAddApply() {
  303. this.$refs.CreateTaskApply.open();
  304. }
  305. },
  306. beforeRouteLeave(to, from, next) {
  307. if (to.name === "CardDesign") {
  308. this.$ls.set("cachePageInfo", {
  309. page: this.current,
  310. filter: this.filter,
  311. curRowId: this.curExamTask.id
  312. });
  313. } else {
  314. this.$ls.remove("cachePageInfo");
  315. }
  316. next();
  317. }
  318. };
  319. </script>