examInfo.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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" sortable>
  84. </el-table-column>
  85. <el-table-column prop="code" label="考试编码"> </el-table-column>
  86. <el-table-column prop="name" label="考试名称"> </el-table-column>
  87. <el-table-column width="130" label="考试类型" sortable>
  88. <template slot-scope="scope">
  89. <div>
  90. <span>{{ getExamType(scope.row.examType) }}</span>
  91. </div>
  92. </template>
  93. </el-table-column>
  94. <el-table-column
  95. prop="beginTime"
  96. width="155"
  97. label="开始时间"
  98. sortable
  99. >
  100. </el-table-column>
  101. <el-table-column prop="endTime" width="155" label="结束时间" sortable>
  102. </el-table-column>
  103. <el-table-column
  104. prop="updateTime"
  105. width="155"
  106. label="更新时间"
  107. sortable
  108. >
  109. </el-table-column>
  110. <el-table-column width="50" label="状态">
  111. <span slot-scope="scope">
  112. <span v-if="scope.row.enable">
  113. <el-tooltip
  114. class="item"
  115. effect="dark"
  116. content="启用"
  117. placement="left"
  118. >
  119. <i class="el-icon-success" style="color:green;"></i>
  120. </el-tooltip>
  121. </span>
  122. <span v-else>
  123. <el-tooltip
  124. class="item"
  125. effect="dark"
  126. content="禁用"
  127. placement="left"
  128. >
  129. <i class="el-icon-error" style="color:red;"></i>
  130. </el-tooltip>
  131. </span>
  132. </span>
  133. </el-table-column>
  134. <el-table-column label="操作" width="190">
  135. <template slot-scope="scope">
  136. <div>
  137. <el-button
  138. v-if="rolePrivileges.update_exam"
  139. size="mini"
  140. plain
  141. type="primary"
  142. icon="el-icon-edit"
  143. @click="editExamInfoDialog(scope.row)"
  144. >
  145. 编辑
  146. </el-button>
  147. <el-dropdown
  148. style="margin-left: 10px;"
  149. v-if="
  150. rolePrivileges.change_exam_availability ||
  151. rolePrivileges.update_exam
  152. "
  153. >
  154. <el-button type="primary" plain size="mini">
  155. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  156. </el-button>
  157. <el-dropdown-menu slot="dropdown">
  158. <el-dropdown-item>
  159. <el-button
  160. v-if="
  161. !scope.row.enable &&
  162. rolePrivileges.change_exam_availability
  163. "
  164. size="mini"
  165. plain
  166. type="primary"
  167. icon="el-icon-check"
  168. @click="enableById(scope.row)"
  169. >
  170. <i class="fa fa-check" aria-hidden="true"></i>启用
  171. </el-button>
  172. <el-button
  173. v-else-if="rolePrivileges.change_exam_availability"
  174. size="mini"
  175. type="danger"
  176. icon="el-icon-close"
  177. @click="disableById(scope.row)"
  178. >
  179. <i class="fa fa-close" aria-hidden="true"></i>禁用
  180. </el-button></el-dropdown-item
  181. >
  182. <el-dropdown-item>
  183. <el-button
  184. :disabled="
  185. !(
  186. rolePrivileges.update_exam &&
  187. (scope.row.examType == 'OFFLINE' ||
  188. scope.row.examType == 'ONLINE')
  189. )
  190. "
  191. size="mini"
  192. type="primary"
  193. icon="el-icon-edit"
  194. @click="editOrgSettings(scope.row)"
  195. >
  196. 学习中心设置
  197. </el-button>
  198. <el-button
  199. size="mini"
  200. type="primary"
  201. icon="el-icon-edit"
  202. @click="showCopyExam(scope.row)"
  203. >复制</el-button
  204. ></el-dropdown-item
  205. >
  206. </el-dropdown-menu></el-dropdown
  207. >
  208. </div>
  209. </template>
  210. </el-table-column>
  211. </el-table>
  212. <div class="page pull-right">
  213. <el-pagination
  214. v-if="paginationShow"
  215. @current-change="handleCurrentChange"
  216. :current-page="currentPage"
  217. :page-size="pageSize"
  218. :page-sizes="[10, 20, 50, 100, 200, 300]"
  219. @size-change="handleSizeChange"
  220. layout="total, sizes, prev, pager, next, jumper"
  221. :total="total"
  222. >
  223. </el-pagination>
  224. </div>
  225. <!-- 考试复制弹窗 -->
  226. <el-dialog
  227. :title="examCopyTitle"
  228. width="500px"
  229. :visible.sync="copyExamDialog"
  230. @close="doBeforedialogClose"
  231. >
  232. <el-form
  233. :inline="true"
  234. inline-message
  235. :model="examCopyForm"
  236. :rules="examCopyFormRules"
  237. ref="examCopyForm"
  238. label-width="120px"
  239. >
  240. <el-row>
  241. <el-form-item label="考试编码" placeholder="">
  242. <el-input
  243. v-model="examCopyForm.destExamName"
  244. class="input"
  245. :disabled="true"
  246. maxlength="20"
  247. ></el-input>
  248. </el-form-item>
  249. </el-row>
  250. <el-row>
  251. <el-form-item
  252. label="考试名称"
  253. placeholder="请输入考试名称"
  254. prop="destExamName"
  255. >
  256. <el-input
  257. v-model="examCopyForm.destExamName"
  258. class="input"
  259. maxlength="20"
  260. ></el-input>
  261. </el-form-item>
  262. </el-row>
  263. <div style="text-align: center;">
  264. <el-button type="primary" @click="copyExam">确 定</el-button>
  265. <el-button @click="copyExamDialog = false">取 消</el-button>
  266. </div>
  267. </el-form>
  268. </el-dialog>
  269. </div>
  270. </div>
  271. </section>
  272. </template>
  273. <script>
  274. import { CORE_API, EXAM_WORK_API, EXAM_TYPE } from "@/constants/constants.js";
  275. import { mapState } from "vuex";
  276. let _this = null;
  277. let validateDestExamName = (rule, value, callback) => {
  278. let name = _this.examCopyForm.destExamName;
  279. if (null == name || name.trim() == "") {
  280. callback(new Error("请输入考试名称"));
  281. } else {
  282. callback();
  283. }
  284. };
  285. export default {
  286. data() {
  287. return {
  288. rolePrivileges: {
  289. search_exam: false,
  290. add_exam: false,
  291. del_exam: false,
  292. update_exam: false,
  293. change_exam_availability: false,
  294. exam_course_setting: false,
  295. exam_org_setting: false
  296. },
  297. formSearch: {
  298. name: "",
  299. examType: ""
  300. },
  301. loading: false,
  302. examTypeList: EXAM_TYPE,
  303. tableData: [],
  304. paginationShow: false,
  305. currentPage: 1,
  306. pageSize: 10,
  307. total: 10,
  308. formLabelWidth: "120px",
  309. examInfoDialog: false,
  310. examId: "",
  311. selectedExamIds: [],
  312. button: {},
  313. copyExamDialog: false,
  314. examCopyTitle: null,
  315. examCopyForm: {
  316. srcExamId: null,
  317. destExamCode: "",
  318. destExamName: "",
  319. copyOrgSettings: false
  320. },
  321. examCopyFormRules: {
  322. destExamName: [
  323. { required: true, validator: validateDestExamName, trigger: "blur" }
  324. ]
  325. }
  326. };
  327. },
  328. computed: {
  329. ...mapState({ user: state => state.user }),
  330. examIds() {
  331. var examIds = "";
  332. for (let examId of this.selectedExamIds) {
  333. if (!examIds) {
  334. examIds += examId;
  335. } else {
  336. examIds += "," + examId;
  337. }
  338. }
  339. return examIds;
  340. }
  341. },
  342. methods: {
  343. showCopyExam(row) {
  344. this.examCopyTitle = "复制考试:" + row.name;
  345. this.examCopyForm.srcExamId = row.id;
  346. this.examCopyForm.destExamCode = null;
  347. this.examCopyForm.destExamName = null;
  348. this.copyExamDialog = true;
  349. },
  350. doBeforedialogClose() {
  351. this.$refs.examCopyForm.clearValidate();
  352. },
  353. copyExam() {
  354. this.examCopyForm.destExamCode = this.examCopyForm.destExamName;
  355. var url = EXAM_WORK_API + "/exam/copyExam";
  356. this.$refs.examCopyForm.validate(valid => {
  357. if (valid) {
  358. this.$httpWithMsg.post(url, this.examCopyForm).then(response => {
  359. console.log(response);
  360. this.$notify({
  361. type: "success",
  362. message: "复制成功"
  363. });
  364. this.copyExamDialog = false;
  365. this.searchForm();
  366. });
  367. } else {
  368. return false;
  369. }
  370. });
  371. },
  372. selectChange(row) {
  373. this.selectedExamIds = [];
  374. row.forEach((element, index) => {
  375. console.log(index);
  376. this.selectedExamIds.push(element.id);
  377. });
  378. console.log(this.selectedExamIds);
  379. },
  380. enableById(row) {
  381. this.$confirm("是否启用该考试?", "提示", {
  382. confirmButtonText: "确定",
  383. cancelButtonText: "取消",
  384. type: "warning"
  385. }).then(() => {
  386. let url = EXAM_WORK_API + "/exam/enable/" + row.id;
  387. this.$httpWithMsg.put(url, {}).then(response => {
  388. console.log(response);
  389. this.$notify({
  390. type: "success",
  391. message: "开启成功!"
  392. });
  393. this.searchForm();
  394. });
  395. });
  396. },
  397. disableById(row) {
  398. this.$confirm("是否禁用该考试?", "提示", {
  399. confirmButtonText: "确定",
  400. cancelButtonText: "取消",
  401. type: "error"
  402. }).then(() => {
  403. var url = EXAM_WORK_API + "/exam/disable/" + row.id;
  404. this.$httpWithMsg.put(url, {}).then(response => {
  405. console.log(response);
  406. this.$notify({
  407. type: "success",
  408. message: "禁用成功!"
  409. });
  410. this.searchForm();
  411. });
  412. });
  413. },
  414. handleCurrentChange(val) {
  415. this.currentPage = val;
  416. this.searchForm();
  417. },
  418. handleSizeChange(val) {
  419. this.pageSize = val;
  420. this.searchForm();
  421. },
  422. resetPageAndSearchForm() {
  423. this.currentPage = 1;
  424. this.searchForm();
  425. },
  426. //查询方法
  427. searchForm() {
  428. var param = new URLSearchParams(this.formSearch);
  429. var url =
  430. EXAM_WORK_API +
  431. "/exam/queryPage/" +
  432. (this.currentPage - 1) +
  433. "/" +
  434. this.pageSize +
  435. "?" +
  436. param;
  437. this.loading = true;
  438. this.$httpWithMsg.get(url).then(response => {
  439. console.log(response);
  440. this.tableData = response.data.list;
  441. this.total = response.data.total;
  442. this.loading = false;
  443. this.paginationShow = true;
  444. });
  445. },
  446. addExamInfoDialog() {
  447. this.examInfoDialog = true;
  448. this.examId = "";
  449. },
  450. editExamInfoDialog(row) {
  451. this.setSearchParams();
  452. if (row.examType == "ONLINE") {
  453. this.$router.push({ path: "/examwork/onlineExam/" + row.id });
  454. } else if (row.examType == "TRADITION") {
  455. this.$router.push({ path: "/examwork/traditionExam/" + row.id });
  456. } else if (row.examType == "PRACTICE") {
  457. this.$router.push({ path: "/examwork/practiceExam/" + row.id });
  458. } else if (row.examType == "OFFLINE") {
  459. this.$router.push({ path: "/examwork/offlineExam/" + row.id });
  460. } else if (row.examType == "PRINT_EXAM") {
  461. this.$router.push({ path: "/examwork/printExam/" + row.id });
  462. }
  463. },
  464. editOrgSettings(row) {
  465. this.setSearchParams();
  466. if (row.examType == "OFFLINE") {
  467. this.$router.push({
  468. path: "/examwork/offlineExamOrgSettings/" + row.id
  469. });
  470. } else if (row.examType == "ONLINE") {
  471. this.$router.push({
  472. path: "/examwork/onlineExamOrgSettings/" + row.id
  473. });
  474. }
  475. },
  476. showExamCourseSettingsDialog(row) {
  477. this.setSearchParams();
  478. this.$router.push({ path: "/examwork/examCourseSettings/" + row.id });
  479. },
  480. showExamOrgSettingsDialog(row) {
  481. this.setSearchParams();
  482. this.$router.push({ path: "/examwork/examOrgSettings/" + row.id });
  483. },
  484. toTradition() {
  485. this.setSearchParams();
  486. this.$router.push({ path: "/examwork/traditionExam/add" });
  487. },
  488. toOnline() {
  489. this.setSearchParams();
  490. this.$router.push({ path: "/examwork/onlineExam/add" });
  491. },
  492. toPractice() {
  493. this.setSearchParams();
  494. this.$router.push({ path: "/examwork/practiceExam/add" });
  495. },
  496. toOffline() {
  497. this.setSearchParams();
  498. this.$router.push({ path: "/examwork/offlineExam/add" });
  499. },
  500. toPrint() {
  501. this.setSearchParams();
  502. this.$router.push({ path: "/examwork/printExam/add" });
  503. },
  504. setSearchParams() {
  505. sessionStorage.setItem(
  506. "E_EAXM_SEARCH_PARAMS",
  507. JSON.stringify(this.formSearch)
  508. );
  509. sessionStorage.setItem("E_EAXM_SEARCH_PAGE_SIZE", this.pageSize);
  510. sessionStorage.setItem("E_EAXM_SEARCH_CUR_PAGE", this.currentPage);
  511. },
  512. getExamType(examType) {
  513. for (let tempExamType of this.examTypeList) {
  514. if (tempExamType.value == examType) {
  515. return tempExamType.label;
  516. }
  517. }
  518. },
  519. initPrivileges() {
  520. let params = new URLSearchParams();
  521. params.append(
  522. "privilegeCodes",
  523. Object.keys(this.rolePrivileges).toString()
  524. );
  525. let url = CORE_API + "/rolePrivilege/checkPrivileges?" + params;
  526. this.$httpWithMsg.post(url).then(response => {
  527. this.rolePrivileges = response.data;
  528. });
  529. }
  530. },
  531. //初始化查询
  532. created() {
  533. _this = this;
  534. let sessionData = sessionStorage.getItem("E_EAXM_SEARCH_PARAMS");
  535. let pageSize = sessionStorage.getItem("E_EAXM_SEARCH_PAGE_SIZE");
  536. let currentPage = sessionStorage.getItem("E_EAXM_SEARCH_CUR_PAGE");
  537. sessionStorage.removeItem("E_EAXM_SEARCH_PARAMS");
  538. sessionStorage.removeItem("E_EAXM_SEARCH_PAGE_SIZE");
  539. sessionStorage.removeItem("E_EAXM_SEARCH_CUR_PAGE");
  540. if (sessionData) {
  541. this.formSearch = JSON.parse(sessionData);
  542. }
  543. if (pageSize) {
  544. this.pageSize = parseInt(pageSize);
  545. }
  546. if (currentPage) {
  547. this.currentPage = parseInt(currentPage);
  548. }
  549. this.initPrivileges();
  550. this.searchForm();
  551. }
  552. };
  553. </script>
  554. <style scoped>
  555. .input {
  556. width: 200px;
  557. }
  558. </style>