examInfo.vue 12 KB

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