ExamManage.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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') &&
  109. scope.row.examModel !== 'MODEL4'
  110. "
  111. class="btn-primary"
  112. type="text"
  113. @click="toEditConfig(scope.row)"
  114. >设置</el-button
  115. >
  116. <el-button
  117. v-if="checkPrivilege('link', 'Enable')"
  118. :class="scope.row.enable ? 'btn-danger' : 'btn-primary'"
  119. type="text"
  120. @click="toEnable(scope.row)"
  121. >{{ scope.row.enable ? "禁用" : "启用" }}</el-button
  122. >
  123. <el-button
  124. v-if="checkPrivilege('link', 'Delete')"
  125. class="btn-danger"
  126. type="text"
  127. @click="toDelete(scope.row)"
  128. >删除</el-button
  129. >
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. <div class="part-page">
  134. <el-pagination
  135. background
  136. layout="total, sizes, prev, pager, next, jumper"
  137. :pager-count="5"
  138. :current-page="current"
  139. :total="total"
  140. :page-size="size"
  141. @current-change="toPage"
  142. @size-change="pageSizeChange"
  143. >
  144. </el-pagination>
  145. </div>
  146. </div>
  147. <!-- modify-exam -->
  148. <modify-exam
  149. ref="ModifyExam"
  150. v-if="checkPrivilege('link', 'edit')"
  151. :instance="curExam"
  152. @modified="examModified"
  153. ></modify-exam>
  154. <!-- modify-exam-config-detail -->
  155. <modify-exam-config-detail
  156. ref="ModifyExamConfigDetail"
  157. v-if="checkPrivilege('link', 'Set')"
  158. :exam="curExam"
  159. ></modify-exam-config-detail>
  160. </div>
  161. </template>
  162. <script>
  163. import { examListQuery, deleteExam, ableExam } from "../api";
  164. import { ABLE_TYPE, EXAM_MODE_TYPE } from "@/constants/enumerate";
  165. import ModifyExam from "../components/ModifyExam";
  166. import ModifyExamConfigDetail from "../components/ModifyExamConfigDetail";
  167. export default {
  168. name: "exam-manage",
  169. components: { ModifyExam, ModifyExamConfigDetail },
  170. data() {
  171. return {
  172. filter: {
  173. semesterId: "",
  174. enable: "",
  175. },
  176. ABLE_TYPE,
  177. EXAM_MODE_TYPE,
  178. current: 1,
  179. size: this.GLOBAL.pageSize,
  180. total: 0,
  181. exams: [],
  182. curExam: {},
  183. };
  184. },
  185. mounted() {
  186. this.getList();
  187. },
  188. methods: {
  189. async getList() {
  190. if (!this.checkPrivilege("list", "list")) return;
  191. const datas = {
  192. ...this.filter,
  193. pageNumber: this.current,
  194. pageSize: this.size,
  195. };
  196. if (datas.enable !== null && datas.enable !== "")
  197. datas.enable = !!datas.enable;
  198. const data = await examListQuery(datas);
  199. this.exams = data.records;
  200. this.total = data.total;
  201. },
  202. toPage(page) {
  203. this.current = page;
  204. this.getList();
  205. },
  206. toAdd() {
  207. this.curExam = {};
  208. this.$refs.ModifyExam.open();
  209. },
  210. toEdit(row) {
  211. this.curExam = row;
  212. this.$refs.ModifyExam.open();
  213. },
  214. examModified({ isEdit, exam }) {
  215. if (!isEdit && exam.examModel != "MODEL4") {
  216. this.toEditConfig(exam);
  217. }
  218. this.getList();
  219. },
  220. toEditConfig(row) {
  221. this.curExam = row;
  222. this.$refs.ModifyExamConfigDetail.open();
  223. },
  224. toDelete(row) {
  225. this.$confirm(`确定要删除考试【${row.name}】吗?`, "提示", {
  226. type: "warning",
  227. })
  228. .then(async () => {
  229. await deleteExam(row.id);
  230. this.$message.success("删除成功!");
  231. this.deletePageLastItem();
  232. })
  233. .catch(() => {});
  234. },
  235. toEnable(row) {
  236. const action = row.enable ? "禁用" : "启用";
  237. this.$confirm(`确定要${action}考试【${row.name}】吗?`, "提示", {
  238. type: "warning",
  239. })
  240. .then(async () => {
  241. const enable = !row.enable;
  242. await ableExam({
  243. id: row.id,
  244. enable,
  245. });
  246. row.enable = enable;
  247. this.$message.success("操作成功!");
  248. })
  249. .catch(() => {});
  250. },
  251. },
  252. };
  253. </script>