examInfo.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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="rolePrivileges.update_exam"
  120. size="mini"
  121. type="info"
  122. @click="editOrgSettings(scope.row)"
  123. >
  124. 学习中心特殊设置
  125. </el-button>
  126. <el-button
  127. v-if="
  128. !scope.row.enable &&
  129. rolePrivileges.change_exam_availability
  130. "
  131. size="mini"
  132. type="success"
  133. @click="enableById(scope.row)"
  134. >
  135. <i class="fa fa-check" aria-hidden="true"></i>启用
  136. </el-button>
  137. <el-button
  138. v-else-if="rolePrivileges.change_exam_availability"
  139. size="mini"
  140. type="warning"
  141. @click="disableById(scope.row)"
  142. >
  143. <i class="fa fa-close" aria-hidden="true"></i>禁用
  144. </el-button>
  145. </div>
  146. </template>
  147. </el-table-column>
  148. </el-table>
  149. <div class="page pull-right">
  150. <el-pagination
  151. @current-change="handleCurrentChange"
  152. :current-page="currentPage"
  153. :page-size="pageSize"
  154. layout="total, prev, pager, next, jumper"
  155. :total="total"
  156. >
  157. </el-pagination>
  158. </div>
  159. </div>
  160. </div>
  161. </section>
  162. </div>
  163. </template>
  164. <script>
  165. import { CORE_API, EXAM_WORK_API, EXAM_TYPE } from "@/constants/constants.js";
  166. import { mapState } from "vuex";
  167. export default {
  168. data() {
  169. return {
  170. rolePrivileges: {
  171. search_exam: false,
  172. add_exam: false,
  173. del_exam: false,
  174. update_exam: false,
  175. change_exam_availability: false,
  176. exam_course_setting: false,
  177. exam_org_setting: false
  178. },
  179. formSearch: {
  180. name: "",
  181. examType: ""
  182. },
  183. loading: false,
  184. examTypeList: EXAM_TYPE,
  185. tableData: [],
  186. currentPage: 1,
  187. pageSize: 10,
  188. total: 10,
  189. formLabelWidth: "120px",
  190. examInfoDialog: false,
  191. examId: "",
  192. selectedExamIds: [],
  193. button: {}
  194. };
  195. },
  196. computed: {
  197. ...mapState({ user: state => state.user }),
  198. examIds() {
  199. var examIds = "";
  200. for (let examId of this.selectedExamIds) {
  201. if (!examIds) {
  202. examIds += examId;
  203. } else {
  204. examIds += "," + examId;
  205. }
  206. }
  207. return examIds;
  208. }
  209. },
  210. methods: {
  211. selectChange(row) {
  212. this.selectedExamIds = [];
  213. row.forEach((element, index) => {
  214. console.log(index);
  215. this.selectedExamIds.push(element.id);
  216. });
  217. console.log(this.selectedExamIds);
  218. },
  219. getTag(status) {
  220. if (status == true) {
  221. return "success";
  222. } else if (status == false) {
  223. return "danger";
  224. }
  225. return status;
  226. },
  227. getEnable(enable) {
  228. if (enable == true) {
  229. return "启用";
  230. } else if (enable == false) {
  231. return "禁用";
  232. }
  233. return enable;
  234. },
  235. enableById(row) {
  236. this.$confirm("是否启用该考试?", "提示", {
  237. confirmButtonText: "确定",
  238. cancelButtonText: "取消",
  239. type: "warning"
  240. }).then(() => {
  241. var url = EXAM_WORK_API + "/exam/enable/" + row.id;
  242. this.$http
  243. .put(url, {})
  244. .then(response => {
  245. console.log(response);
  246. this.$notify({
  247. type: "success",
  248. message: "开启成功!"
  249. });
  250. this.searchForm();
  251. })
  252. .catch(response => {
  253. if (response.status == 500) {
  254. this.$notify({
  255. showClose: true,
  256. message: response.body.desc,
  257. type: "error"
  258. });
  259. }
  260. });
  261. });
  262. },
  263. disableById(row) {
  264. this.$confirm("是否禁用该考试?", "提示", {
  265. confirmButtonText: "确定",
  266. cancelButtonText: "取消",
  267. type: "error"
  268. }).then(() => {
  269. var url = EXAM_WORK_API + "/exam/disable/" + row.id;
  270. this.$http
  271. .put(url, {})
  272. .then(response => {
  273. console.log(response);
  274. this.$notify({
  275. type: "success",
  276. message: "禁用成功!"
  277. });
  278. this.searchForm();
  279. })
  280. .catch(response => {
  281. if (response.status == 500) {
  282. this.$notify({
  283. showClose: true,
  284. message: response.body.desc,
  285. type: "error"
  286. });
  287. }
  288. });
  289. });
  290. },
  291. handleCurrentChange(val) {
  292. this.currentPage = val;
  293. this.searchForm();
  294. },
  295. //查询方法
  296. searchForm() {
  297. var param = new URLSearchParams(this.formSearch);
  298. var url =
  299. EXAM_WORK_API +
  300. "/exam/queryPage/" +
  301. (this.currentPage - 1) +
  302. "/" +
  303. this.pageSize +
  304. "?" +
  305. param;
  306. this.loading = true;
  307. this.$http.get(url).then(response => {
  308. console.log(response);
  309. this.tableData = response.data.list;
  310. this.total = response.data.total;
  311. this.loading = false;
  312. });
  313. },
  314. addExamInfoDialog() {
  315. this.examInfoDialog = true;
  316. this.examId = "";
  317. },
  318. editExamInfoDialog(row) {
  319. if (row.examType == "ONLINE") {
  320. this.$router.push({ path: "/examwork/onlineExam/" + row.id });
  321. } else if (row.examType == "TRADITION") {
  322. this.$router.push({ path: "/examwork/traditionExam/" + row.id });
  323. } else if (row.examType == "PRACTICE") {
  324. this.$router.push({ path: "/examwork/practiceExam/" + row.id });
  325. } else if (row.examType == "OFFLINE") {
  326. this.$router.push({ path: "/examwork/offlineExam/" + row.id });
  327. } else if (row.examType == "PRINT_EXAM") {
  328. this.$router.push({ path: "/examwork/printExam/" + row.id });
  329. }
  330. },
  331. editOrgSettings(row) {
  332. if (row.examType == "OFFLINE") {
  333. this.$router.push({
  334. path: "/examwork/offlineExamOrgSettings/" + row.id
  335. });
  336. }
  337. },
  338. showExamCourseSettingsDialog(row) {
  339. this.$router.push({ path: "/examwork/examCourseSettings/" + row.id });
  340. },
  341. showExamOrgSettingsDialog(row) {
  342. this.$router.push({ path: "/examwork/examOrgSettings/" + row.id });
  343. },
  344. toTradition() {
  345. this.$router.push({ path: "/examwork/traditionExam/add" });
  346. },
  347. toOnline() {
  348. this.$router.push({ path: "/examwork/onlineExam/add" });
  349. },
  350. toPractice() {
  351. this.$router.push({ path: "/examwork/practiceExam/add" });
  352. },
  353. toOffline() {
  354. this.$router.push({ path: "/examwork/offlineExam/add" });
  355. },
  356. toPrint() {
  357. this.$router.push({ path: "/examwork/printExam/add" });
  358. },
  359. getExamType(examType) {
  360. for (let tempExamType of this.examTypeList) {
  361. if (tempExamType.value == examType) {
  362. return tempExamType.label;
  363. }
  364. }
  365. },
  366. initPrivileges() {
  367. let params = new URLSearchParams({
  368. privilegeCodes: Object.keys(this.rolePrivileges).toString()
  369. });
  370. let url = CORE_API + "/rolePrivilege/checkPrivileges?" + params;
  371. this.$http.post(url).then(response => {
  372. this.rolePrivileges = response.data;
  373. });
  374. }
  375. },
  376. //初始化查询
  377. created() {
  378. this.initPrivileges();
  379. this.searchForm();
  380. }
  381. };
  382. </script>