ExamTaskManage.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <div class="exam-task-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. <el-form-item label="命题状态:">
  6. <el-select
  7. v-model="filter.status"
  8. style="width: 142px;"
  9. placeholder="请选择"
  10. clearable
  11. >
  12. <el-option
  13. v-for="(val, key) in EXAM_TASK_STATUS"
  14. :key="key"
  15. :value="key"
  16. :label="val"
  17. ></el-option>
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item label="题卡规则:">
  21. <card-rule-select
  22. ref="CardRuleSelect"
  23. v-model.trim="filter.cardRuleId"
  24. placeholder="请选择"
  25. clearable
  26. ></card-rule-select>
  27. </el-form-item>
  28. <el-form-item label="课程(代码):" label-width="110px">
  29. <course-select
  30. ref="CourseSelect"
  31. v-model.trim="filter.courseCode"
  32. placeholder="请选择"
  33. clearable
  34. ></course-select>
  35. </el-form-item>
  36. <el-form-item label="试卷编号:">
  37. <paper-number-select
  38. ref="PaperNumberSelect"
  39. v-model="filter.paperNumber"
  40. placeholder="请选择"
  41. clearable
  42. ></paper-number-select>
  43. </el-form-item>
  44. <el-form-item label="命题时间:">
  45. <el-date-picker
  46. v-model="createTime"
  47. type="datetimerange"
  48. :picker-options="pickerOptions"
  49. range-separator="至"
  50. start-placeholder="开始日期"
  51. end-placeholder="结束日期"
  52. value-format="timestamp"
  53. align="right"
  54. unlink-panels
  55. >
  56. </el-date-picker>
  57. </el-form-item>
  58. <el-form-item label="启用/禁用:" label-width="90px">
  59. <el-select
  60. v-model="filter.enable"
  61. style="width: 142px;"
  62. placeholder="请选择"
  63. clearable
  64. >
  65. <el-option
  66. v-for="(val, key) in ABLE_TYPE"
  67. :key="key"
  68. :value="key * 1"
  69. :label="val"
  70. ></el-option>
  71. </el-select>
  72. </el-form-item>
  73. <el-form-item label-width="0px">
  74. <el-button type="primary" icon="icon icon-search" @click="toPage(1)"
  75. >查询</el-button
  76. >
  77. </el-form-item>
  78. </el-form>
  79. <div class="part-box-action">
  80. <el-button icon="icon icon-plus" type="warning" @click="toBatchAdd">
  81. 批量新建命题任务
  82. </el-button>
  83. <el-button icon="icon icon-plus" type="primary" @click="toAdd">
  84. 新建命题任务
  85. </el-button>
  86. </div>
  87. </div>
  88. <div class="part-box">
  89. <el-table ref="TableList" :data="examTasks" border stripe>
  90. <el-table-column
  91. type="index"
  92. label="序号"
  93. width="70"
  94. align="center"
  95. :index="indexMethod"
  96. ></el-table-column>
  97. <el-table-column
  98. prop="paperNumber"
  99. label="试卷编号"
  100. width="120"
  101. ></el-table-column>
  102. <el-table-column prop="courseName" label="课程(代码)">
  103. <template slot-scope="scope">
  104. {{ scope.row.courseName }}({{ scope.row.courseCode }})
  105. </template>
  106. </el-table-column>
  107. <el-table-column
  108. prop="specialty"
  109. label="适用专业(方向)"
  110. ></el-table-column>
  111. <el-table-column prop="cardRuleName" label="题卡规则">
  112. </el-table-column>
  113. <el-table-column
  114. prop="userName"
  115. label="命题老师"
  116. width="100"
  117. ></el-table-column>
  118. <el-table-column prop="startTime" label="命题开始时间">
  119. <span slot-scope="scope">{{
  120. scope.row.startTime | timestampFilter
  121. }}</span>
  122. </el-table-column>
  123. <el-table-column prop="endTime" label="命题结束时间">
  124. <span slot-scope="scope">{{
  125. scope.row.endTime | timestampFilter
  126. }}</span>
  127. </el-table-column>
  128. <el-table-column prop="status" label="命题状态" width="100">
  129. <template slot-scope="scope">
  130. {{ scope.row.status | examTaskStatusFilter }}
  131. </template>
  132. </el-table-column>
  133. <el-table-column prop="enable" label="启用/禁用" width="100">
  134. <template slot-scope="scope">
  135. {{ scope.row.enable | enableFilter }}
  136. </template>
  137. </el-table-column>
  138. <el-table-column
  139. class-name="action-column"
  140. label="操作"
  141. align="center"
  142. width="120px"
  143. >
  144. <template slot-scope="scope">
  145. <el-button
  146. v-if="scope.row.status !== 'FINISH'"
  147. class="btn-table-icon"
  148. type="text"
  149. :icon="
  150. scope.row.enable
  151. ? 'icon icon-circle-stop'
  152. : 'icon icon-circle-caret-right'
  153. "
  154. @click="toEnable(scope.row)"
  155. :title="scope.row.enable ? '禁用' : '启用'"
  156. ></el-button>
  157. <el-button
  158. v-if="
  159. (scope.row.status === 'READY' && !scope.row.enable) ||
  160. scope.row.status === 'NEW'
  161. "
  162. class="btn-table-icon"
  163. type="text"
  164. icon="icon icon-edit"
  165. @click="toEdit(scope.row)"
  166. :title="scope.row.status === 'NEW' ? '指派' : '更改'"
  167. ></el-button>
  168. <el-button
  169. class="btn-table-icon"
  170. type="text"
  171. icon="icon icon-circle-right"
  172. @click="toPreview(scope.row)"
  173. title="查看"
  174. ></el-button>
  175. </template>
  176. </el-table-column>
  177. </el-table>
  178. <div class="part-page">
  179. <el-pagination
  180. background
  181. layout="total,prev, pager, next"
  182. :current-page="current"
  183. :total="total"
  184. :page-size="size"
  185. @current-change="toPage"
  186. >
  187. </el-pagination>
  188. </div>
  189. </div>
  190. <!-- ModifyExamTask -->
  191. <modify-exam-task
  192. ref="ModifyExamTask"
  193. :instance="curExamTask"
  194. :edit-type="editType"
  195. @modified="getList"
  196. ></modify-exam-task>
  197. <!-- BatchAddExamTask -->
  198. <batch-add-exam-task
  199. ref="BatchAddExamTask"
  200. @modified="getList"
  201. ></batch-add-exam-task>
  202. </div>
  203. </template>
  204. <script>
  205. import ModifyExamTask from "../components/ModifyExamTask";
  206. import BatchAddExamTask from "../components/BatchAddExamTask";
  207. import { ABLE_TYPE, EXAM_TASK_STATUS } from "@/constants/enumerate";
  208. import pickerOptions from "@/constants/datePickerOptions";
  209. import { examTaskListPage, ableExamTask } from "../api";
  210. export default {
  211. name: "exam-task-manage",
  212. components: {
  213. ModifyExamTask,
  214. BatchAddExamTask
  215. },
  216. data() {
  217. return {
  218. filter: {
  219. status: "",
  220. cardRuleId: "",
  221. courseCode: "",
  222. paperNumber: "",
  223. startTime: null,
  224. endTime: null,
  225. enable: null
  226. },
  227. current: 1,
  228. size: this.GLOBAL.pageSize,
  229. total: 0,
  230. editType: "ADD",
  231. ABLE_TYPE,
  232. EXAM_TASK_STATUS,
  233. examTasks: [],
  234. curExamTask: {},
  235. // date-picker
  236. createTime: [],
  237. pickerOptions
  238. };
  239. },
  240. created() {
  241. this.getList();
  242. },
  243. methods: {
  244. async getList() {
  245. const datas = {
  246. ...this.filter,
  247. pageNumber: this.current,
  248. pageSize: this.size
  249. };
  250. if (datas.enable !== null && datas.enable !== "")
  251. datas.enable = !!datas.enable;
  252. if (this.createTime) {
  253. datas.startTime = this.createTime[0];
  254. datas.endTime = this.createTime[1];
  255. }
  256. const data = await examTaskListPage(datas);
  257. this.examTasks = data.records;
  258. this.total = data.total;
  259. },
  260. toPage(page) {
  261. this.current = page;
  262. this.getList();
  263. },
  264. async toEnable(row) {
  265. const msgs = [
  266. [
  267. "命题任务取消后,有如下后果:",
  268. "1.命题老师将无法看到该命题任务;",
  269. "2.该任务无法审核和与考试计划关联;",
  270. "3.该任务已绑定的题卡将取消绑定。",
  271. "您确定要取消命题任务吗?"
  272. ],
  273. [
  274. "命题任务启用后:",
  275. "1.命题老师将重新看到该命题任务;",
  276. "2.该任务将允许继续审核及与考试计划关联;",
  277. "3.该任务需重新绑定题卡。",
  278. "您确定要启用命题任务吗?"
  279. ]
  280. ];
  281. const msg = row.enable ? msgs[0] : msgs[1];
  282. const msgHtml = msg
  283. .map(item => `<p class="text-left">${item}</p>`)
  284. .join("");
  285. this.$confirm(msgHtml, "提示", {
  286. cancelButtonClass: "el-button--danger is-plain",
  287. confirmButtonClass: "el-button--primary",
  288. dangerouslyUseHTMLString: true,
  289. type: "warning"
  290. })
  291. .then(async () => {
  292. const enable = !row.enable;
  293. await ableExamTask({
  294. id: row.id,
  295. enable
  296. });
  297. row.enable = enable;
  298. this.$message.success("操作成功!");
  299. // 启用之后,更新列表。
  300. // 因为禁用时会解绑题卡,影响命题任务状态。
  301. if (enable) this.getList();
  302. })
  303. .catch(() => {});
  304. },
  305. toBatchAdd() {
  306. this.$refs.BatchAddExamTask.open();
  307. },
  308. toAdd() {
  309. this.curExamTask = {};
  310. this.editType = "ADD";
  311. this.$refs.ModifyExamTask.open();
  312. },
  313. toEdit(row) {
  314. this.curExamTask = row;
  315. this.editType = "EDIT";
  316. this.$refs.ModifyExamTask.open();
  317. },
  318. toPreview(row) {
  319. this.curExamTask = row;
  320. this.editType = "PREVIEW";
  321. this.$refs.ModifyExamTask.open();
  322. }
  323. }
  324. };
  325. </script>