examInfo.vue 19 KB

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