examInfo.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <section class="content">
  3. <div class="box box-info">
  4. <!-- 正文信息 -->
  5. <div class="box-body">
  6. <el-form
  7. :inline="true"
  8. :model="formSearch"
  9. label-position="right"
  10. label-width="70px"
  11. >
  12. <el-form-item label="考试名称" class="pull-left">
  13. <el-input
  14. v-model="formSearch.name"
  15. auto-complete="off"
  16. class="input"
  17. ></el-input>
  18. </el-form-item>
  19. <el-form-item label="类型" class="pull-left">
  20. <el-select
  21. v-model="formSearch.examType"
  22. placeholder="请选择"
  23. clearable
  24. class="input"
  25. >
  26. <el-option
  27. v-for="item in examTypeList"
  28. :label="item.label"
  29. :value="item.value"
  30. :key="item.value"
  31. >
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item class="d-block">
  36. <el-button
  37. v-if="rolePrivileges.search_exam"
  38. size="small"
  39. type="primary"
  40. icon="el-icon-search"
  41. @click="resetPageAndSearchForm"
  42. >查询
  43. </el-button>
  44. <el-button
  45. v-if="rolePrivileges.add_exam"
  46. size="small"
  47. type="primary"
  48. icon="el-icon-plus"
  49. @click="addExamInfoDialog"
  50. >新增
  51. </el-button>
  52. </el-form-item>
  53. </el-form>
  54. <!-- 弹出窗口 -->
  55. <el-dialog
  56. title="请选择考试类型"
  57. width="650px"
  58. :visible.sync="examInfoDialog"
  59. >
  60. <div>
  61. <el-button @click="toTradition">传统考试</el-button>
  62. <el-button @click="toOnline">网络考试</el-button>
  63. <el-button @click="toPractice">练习考试</el-button>
  64. <el-button @click="toOffline">离线考试</el-button>
  65. <el-button @click="toPrint"> 分布式印刷考试</el-button>
  66. </div>
  67. <div style="margin-top: 10px;text-align: center;">
  68. <el-button type="primary" @click="examInfoDialog = false"
  69. >取 消</el-button
  70. >
  71. </div>
  72. </el-dialog>
  73. <!-- 页面列表 -->
  74. <el-table
  75. v-loading="loading"
  76. element-loading-text="拼命加载中"
  77. :data="tableData"
  78. border
  79. style="width: 100%;text-align:center;"
  80. @selection-change="selectChange"
  81. >
  82. <el-table-column type="selection" width="40"></el-table-column>
  83. <el-table-column prop="id" width="60" label="ID"> </el-table-column>
  84. <el-table-column prop="name" label="考试名称"> </el-table-column>
  85. <el-table-column width="80" label="考试类型">
  86. <template slot-scope="scope">
  87. <div>
  88. <span>{{ getExamType(scope.row.examType) }}</span>
  89. </div>
  90. </template>
  91. </el-table-column>
  92. <el-table-column prop="beginTime" width="155" label="开始时间">
  93. </el-table-column>
  94. <el-table-column prop="endTime" width="155" label="结束时间">
  95. </el-table-column>
  96. <el-table-column prop="updateTime" width="155" label="更新时间">
  97. </el-table-column>
  98. <el-table-column width="50" label="状态">
  99. <span slot-scope="scope">
  100. <span v-if="scope.row.enable">
  101. <el-tooltip
  102. class="item"
  103. effect="dark"
  104. content="启用"
  105. placement="left"
  106. >
  107. <i class="el-icon-success" style="color:green;"></i>
  108. </el-tooltip>
  109. </span>
  110. <span v-else>
  111. <el-tooltip
  112. class="item"
  113. effect="dark"
  114. content="禁用"
  115. placement="left"
  116. >
  117. <i class="el-icon-error" style="color:red;"></i>
  118. </el-tooltip>
  119. </span>
  120. </span>
  121. </el-table-column>
  122. <el-table-column label="操作" width="190">
  123. <template slot-scope="scope">
  124. <div>
  125. <el-button
  126. v-if="rolePrivileges.update_exam"
  127. size="mini"
  128. plain
  129. type="primary"
  130. icon="el-icon-edit"
  131. @click="editExamInfoDialog(scope.row)"
  132. >
  133. 编辑
  134. </el-button>
  135. <el-dropdown style="margin-left: 10px;">
  136. <el-button type="primary" plain size="mini">
  137. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  138. </el-button>
  139. <el-dropdown-menu slot="dropdown">
  140. <el-dropdown-item>
  141. <el-button
  142. v-if="
  143. !scope.row.enable &&
  144. rolePrivileges.change_exam_availability
  145. "
  146. size="mini"
  147. plain
  148. type="primary"
  149. icon="el-icon-check"
  150. @click="enableById(scope.row)"
  151. >
  152. <i class="fa fa-check" aria-hidden="true"></i>启用
  153. </el-button>
  154. <el-button
  155. v-else-if="rolePrivileges.change_exam_availability"
  156. size="mini"
  157. plain
  158. type="danger"
  159. icon="el-icon-close"
  160. @click="disableById(scope.row)"
  161. >
  162. <i class="fa fa-close" aria-hidden="true"></i>禁用
  163. </el-button></el-dropdown-item
  164. >
  165. <el-dropdown-item>
  166. <el-button
  167. :disabled="
  168. !(
  169. rolePrivileges.update_exam &&
  170. (scope.row.examType == 'OFFLINE' ||
  171. scope.row.examType == 'ONLINE')
  172. )
  173. "
  174. size="mini"
  175. type="primary"
  176. icon="el-icon-edit"
  177. @click="editOrgSettings(scope.row)"
  178. >
  179. 学习中心特殊设置
  180. </el-button></el-dropdown-item
  181. >
  182. </el-dropdown-menu></el-dropdown
  183. >
  184. </div>
  185. </template>
  186. </el-table-column>
  187. </el-table>
  188. <div class="page pull-right">
  189. <el-pagination
  190. @current-change="handleCurrentChange"
  191. :current-page="currentPage"
  192. :page-size="pageSize"
  193. :page-sizes="[10, 20, 50, 100]"
  194. @size-change="handleSizeChange"
  195. layout="total, sizes, prev, pager, next, jumper"
  196. :total="total"
  197. >
  198. </el-pagination>
  199. </div>
  200. </div>
  201. </div>
  202. </section>
  203. </template>
  204. <script>
  205. import { CORE_API, EXAM_WORK_API, EXAM_TYPE } from "@/constants/constants.js";
  206. import { mapState } from "vuex";
  207. export default {
  208. data() {
  209. return {
  210. rolePrivileges: {
  211. search_exam: false,
  212. add_exam: false,
  213. del_exam: false,
  214. update_exam: false,
  215. change_exam_availability: false,
  216. exam_course_setting: false,
  217. exam_org_setting: false
  218. },
  219. formSearch: {
  220. name: "",
  221. examType: ""
  222. },
  223. loading: false,
  224. examTypeList: EXAM_TYPE,
  225. tableData: [],
  226. currentPage: 1,
  227. pageSize: 10,
  228. total: 10,
  229. formLabelWidth: "120px",
  230. examInfoDialog: false,
  231. examId: "",
  232. selectedExamIds: [],
  233. button: {}
  234. };
  235. },
  236. computed: {
  237. ...mapState({ user: state => state.user }),
  238. examIds() {
  239. var examIds = "";
  240. for (let examId of this.selectedExamIds) {
  241. if (!examIds) {
  242. examIds += examId;
  243. } else {
  244. examIds += "," + examId;
  245. }
  246. }
  247. return examIds;
  248. }
  249. },
  250. methods: {
  251. selectChange(row) {
  252. this.selectedExamIds = [];
  253. row.forEach((element, index) => {
  254. console.log(index);
  255. this.selectedExamIds.push(element.id);
  256. });
  257. console.log(this.selectedExamIds);
  258. },
  259. enableById(row) {
  260. this.$confirm("是否启用该考试?", "提示", {
  261. confirmButtonText: "确定",
  262. cancelButtonText: "取消",
  263. type: "warning"
  264. }).then(() => {
  265. let url = EXAM_WORK_API + "/exam/enable/" + row.id;
  266. this.$httpWithMsg.put(url, {}).then(response => {
  267. console.log(response);
  268. this.$notify({
  269. type: "success",
  270. message: "开启成功!"
  271. });
  272. this.searchForm();
  273. });
  274. });
  275. },
  276. disableById(row) {
  277. this.$confirm("是否禁用该考试?", "提示", {
  278. confirmButtonText: "确定",
  279. cancelButtonText: "取消",
  280. type: "error"
  281. }).then(() => {
  282. var url = EXAM_WORK_API + "/exam/disable/" + row.id;
  283. this.$httpWithMsg.put(url, {}).then(response => {
  284. console.log(response);
  285. this.$notify({
  286. type: "success",
  287. message: "禁用成功!"
  288. });
  289. this.searchForm();
  290. });
  291. });
  292. },
  293. handleCurrentChange(val) {
  294. this.currentPage = val;
  295. this.searchForm();
  296. },
  297. handleSizeChange(val) {
  298. this.pageSize = val;
  299. this.searchForm();
  300. },
  301. resetPageAndSearchForm() {
  302. this.currentPage = 1;
  303. this.searchForm();
  304. },
  305. //查询方法
  306. searchForm() {
  307. var param = new URLSearchParams(this.formSearch);
  308. var url =
  309. EXAM_WORK_API +
  310. "/exam/queryPage/" +
  311. (this.currentPage - 1) +
  312. "/" +
  313. this.pageSize +
  314. "?" +
  315. param;
  316. this.loading = true;
  317. this.$httpWithMsg.get(url).then(response => {
  318. console.log(response);
  319. this.tableData = response.data.list;
  320. this.total = response.data.total;
  321. this.loading = false;
  322. });
  323. },
  324. addExamInfoDialog() {
  325. this.examInfoDialog = true;
  326. this.examId = "";
  327. },
  328. editExamInfoDialog(row) {
  329. if (row.examType == "ONLINE") {
  330. this.$router.push({ path: "/examwork/onlineExam/" + row.id });
  331. } else if (row.examType == "TRADITION") {
  332. this.$router.push({ path: "/examwork/traditionExam/" + row.id });
  333. } else if (row.examType == "PRACTICE") {
  334. this.$router.push({ path: "/examwork/practiceExam/" + row.id });
  335. } else if (row.examType == "OFFLINE") {
  336. this.$router.push({ path: "/examwork/offlineExam/" + row.id });
  337. } else if (row.examType == "PRINT_EXAM") {
  338. this.$router.push({ path: "/examwork/printExam/" + row.id });
  339. }
  340. },
  341. editOrgSettings(row) {
  342. if (row.examType == "OFFLINE") {
  343. this.$router.push({
  344. path: "/examwork/offlineExamOrgSettings/" + row.id
  345. });
  346. } else if (row.examType == "ONLINE") {
  347. this.$router.push({
  348. path: "/examwork/onlineExamOrgSettings/" + row.id
  349. });
  350. }
  351. },
  352. showExamCourseSettingsDialog(row) {
  353. this.$router.push({ path: "/examwork/examCourseSettings/" + row.id });
  354. },
  355. showExamOrgSettingsDialog(row) {
  356. this.$router.push({ path: "/examwork/examOrgSettings/" + row.id });
  357. },
  358. toTradition() {
  359. this.$router.push({ path: "/examwork/traditionExam/add" });
  360. },
  361. toOnline() {
  362. this.$router.push({ path: "/examwork/onlineExam/add" });
  363. },
  364. toPractice() {
  365. this.$router.push({ path: "/examwork/practiceExam/add" });
  366. },
  367. toOffline() {
  368. this.$router.push({ path: "/examwork/offlineExam/add" });
  369. },
  370. toPrint() {
  371. this.$router.push({ path: "/examwork/printExam/add" });
  372. },
  373. getExamType(examType) {
  374. for (let tempExamType of this.examTypeList) {
  375. if (tempExamType.value == examType) {
  376. return tempExamType.label;
  377. }
  378. }
  379. },
  380. initPrivileges() {
  381. let params = new URLSearchParams({
  382. privilegeCodes: Object.keys(this.rolePrivileges).toString()
  383. });
  384. let url = CORE_API + "/rolePrivilege/checkPrivileges?" + params;
  385. this.$httpWithMsg.post(url).then(response => {
  386. this.rolePrivileges = response.data;
  387. });
  388. }
  389. },
  390. //初始化查询
  391. created() {
  392. this.initPrivileges();
  393. this.searchForm();
  394. }
  395. };
  396. </script>
  397. <style scoped>
  398. .input {
  399. width: 200px;
  400. }
  401. </style>