ExamManage.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <div class="exam-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. <semester-select
  8. v-model="filter.semesterId"
  9. placeholder="学期"
  10. clearable
  11. ></semester-select>
  12. </el-form-item>
  13. <el-form-item label="启用/禁用:" label-width="90px">
  14. <el-select
  15. v-model="filter.enable"
  16. style="width: 120px"
  17. placeholder="启用/禁用"
  18. clearable
  19. >
  20. <el-option
  21. v-for="(val, key) in ABLE_TYPE"
  22. :key="key"
  23. :value="key * 1"
  24. :label="val"
  25. ></el-option>
  26. </el-select>
  27. </el-form-item>
  28. </template>
  29. <el-form-item>
  30. <el-button
  31. v-if="checkPrivilege('button', 'select')"
  32. type="primary"
  33. @click="toPage(1)"
  34. >查询</el-button
  35. >
  36. </el-form-item>
  37. </el-form>
  38. <div class="part-box-action">
  39. <el-button
  40. v-if="checkPrivilege('button', 'add')"
  41. type="primary"
  42. icon="el-icon-circle-plus-outline"
  43. @click="toAdd"
  44. >新增</el-button
  45. >
  46. </div>
  47. </div>
  48. <div class="part-box part-box-pad">
  49. <el-table ref="TableList" :data="exams">
  50. <el-table-column
  51. type="index"
  52. label="序号"
  53. width="70"
  54. :index="indexMethod"
  55. ></el-table-column>
  56. <el-table-column
  57. prop="semesterName"
  58. label="学年学期"
  59. min-width="210"
  60. ></el-table-column>
  61. <el-table-column
  62. prop="name"
  63. label="考试名称"
  64. min-width="160"
  65. ></el-table-column>
  66. <el-table-column prop="category" label="考试类型" width="100">
  67. <span slot-scope="scope">
  68. {{ scope.row.category | examTypeFilter }}
  69. </span>
  70. </el-table-column>
  71. <el-table-column prop="examModel" label="业务模式" width="100">
  72. <template slot-scope="scope">
  73. <el-tooltip
  74. effect="dark"
  75. :content="EXAM_MODE_TYPE[scope.row.examModel]"
  76. placement="top-start"
  77. >
  78. <span>{{ scope.row.examModel }}</span>
  79. </el-tooltip>
  80. </template>
  81. </el-table-column>
  82. <el-table-column prop="createTime" label="创建时间" width="170">
  83. <span slot-scope="scope">{{
  84. scope.row.createTime | timestampFilter
  85. }}</span>
  86. </el-table-column>
  87. <el-table-column prop="enable" label="启用/禁用" width="100">
  88. <template slot-scope="scope">
  89. {{ scope.row.enable | enableFilter }}
  90. </template>
  91. </el-table-column>
  92. <el-table-column
  93. class-name="action-column"
  94. label="操作"
  95. width="180px"
  96. fixed="right"
  97. >
  98. <template slot-scope="scope">
  99. <el-button
  100. v-if="checkPrivilege('link', 'edit')"
  101. class="btn-primary"
  102. type="text"
  103. @click="toEdit(scope.row)"
  104. >编辑</el-button
  105. >
  106. <el-button
  107. v-if="
  108. checkPrivilege('link', 'Set') && scope.row.examModel != 'MODEL4'
  109. "
  110. class="btn-primary"
  111. type="text"
  112. @click="toEditConfig(scope.row)"
  113. >设置</el-button
  114. >
  115. <el-button
  116. v-if="checkPrivilege('link', 'Enable')"
  117. :class="scope.row.enable ? 'btn-danger' : 'btn-primary'"
  118. type="text"
  119. @click="toEnable(scope.row)"
  120. >{{ scope.row.enable ? "禁用" : "启用" }}</el-button
  121. >
  122. <el-button
  123. v-if="checkPrivilege('link', 'Delete')"
  124. class="btn-danger"
  125. type="text"
  126. @click="toDelete(scope.row)"
  127. >删除</el-button
  128. >
  129. </template>
  130. </el-table-column>
  131. </el-table>
  132. <div class="part-page">
  133. <el-pagination
  134. background
  135. layout="total, sizes, prev, pager, next, jumper"
  136. :pager-count="5"
  137. :current-page="current"
  138. :total="total"
  139. :page-size="size"
  140. @current-change="toPage"
  141. @size-change="pageSizeChange"
  142. >
  143. </el-pagination>
  144. </div>
  145. </div>
  146. <!-- modify-exam -->
  147. <modify-exam
  148. ref="ModifyExam"
  149. v-if="checkPrivilege('link', 'edit')"
  150. :instance="curExam"
  151. @modified="examModified"
  152. ></modify-exam>
  153. <!-- modify-exam-config-detail -->
  154. <modify-exam-config-detail
  155. ref="ModifyExamConfigDetail"
  156. v-if="checkPrivilege('link', 'Set')"
  157. :exam="curExam"
  158. ></modify-exam-config-detail>
  159. </div>
  160. </template>
  161. <script>
  162. import { examListQuery, deleteExam, ableExam } from "../api";
  163. import { ABLE_TYPE, EXAM_MODE_TYPE } from "@/constants/enumerate";
  164. import ModifyExam from "../components/ModifyExam";
  165. import ModifyExamConfigDetail from "../components/ModifyExamConfigDetail";
  166. export default {
  167. name: "exam-manage",
  168. components: { ModifyExam, ModifyExamConfigDetail },
  169. data() {
  170. return {
  171. filter: {
  172. semesterId: "",
  173. enable: "",
  174. },
  175. ABLE_TYPE,
  176. EXAM_MODE_TYPE,
  177. current: 1,
  178. size: this.GLOBAL.pageSize,
  179. total: 0,
  180. exams: [],
  181. curExam: {},
  182. };
  183. },
  184. mounted() {
  185. this.getList();
  186. },
  187. methods: {
  188. async getList() {
  189. if (!this.checkPrivilege("list", "list")) return;
  190. const datas = {
  191. ...this.filter,
  192. pageNumber: this.current,
  193. pageSize: this.size,
  194. };
  195. if (datas.enable !== null && datas.enable !== "")
  196. datas.enable = !!datas.enable;
  197. const data = await examListQuery(datas);
  198. this.exams = data.records;
  199. this.total = data.total;
  200. },
  201. toPage(page) {
  202. this.current = page;
  203. this.getList();
  204. },
  205. toAdd() {
  206. this.curExam = {};
  207. this.$refs.ModifyExam.open();
  208. },
  209. toEdit(row) {
  210. this.curExam = row;
  211. this.$refs.ModifyExam.open();
  212. },
  213. examModified({ isEdit, exam }) {
  214. if (!isEdit && exam.examModel != "MODEL4") {
  215. this.toEditConfig(exam);
  216. }
  217. this.getList();
  218. },
  219. toEditConfig(row) {
  220. this.curExam = row;
  221. this.$refs.ModifyExamConfigDetail.open();
  222. },
  223. toDelete(row) {
  224. this.$confirm(`确定要删除考试【${row.name}】吗?`, "提示", {
  225. type: "warning",
  226. })
  227. .then(async () => {
  228. await deleteExam(row.id);
  229. this.$message.success("删除成功!");
  230. this.deletePageLastItem();
  231. })
  232. .catch(() => {});
  233. },
  234. toEnable(row) {
  235. const action = row.enable ? "禁用" : "启用";
  236. this.$confirm(`确定要${action}考试【${row.name}】吗?`, "提示", {
  237. type: "warning",
  238. })
  239. .then(async () => {
  240. const enable = !row.enable;
  241. await ableExam({
  242. id: row.id,
  243. enable,
  244. });
  245. row.enable = enable;
  246. this.$message.success("操作成功!");
  247. })
  248. .catch(() => {});
  249. },
  250. },
  251. };
  252. </script>