examInfo.vue 20 KB

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