examManagementDetail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <div class="app-container" ref="tableBody">
  3. <div class="common-card exam-detail-body">
  4. <a-spin :spinning="loading">
  5. <!-- 考试详情 -->
  6. <div class="exam-detail-info" ref="filterCard">
  7. <div class="exam-detail-name">{{ examDetailData.examName }}</div>
  8. <div class="flex-between exam-detail-item">
  9. <div class="exam-detail-description">
  10. 考试描述:<span>{{ examDetailData.description }}</span>
  11. </div>
  12. <div class="exam-detail-type">
  13. 考试分类:<span>{{
  14. examDetailData.type | formateExamTypeFun
  15. }}</span>
  16. </div>
  17. </div>
  18. <div class="flex-between exam-detail-item">
  19. <div>
  20. <span class="exam-detail-title">考试工种:</span>
  21. <span class="exam-detail-txt">{{
  22. examDetailData.engineeringWork | formateEngineeringWorkTypeFun
  23. }}</span>
  24. </div>
  25. <div>
  26. <span class="exam-detail-title">考试时间:</span>
  27. <span class="exam-detail-txt">{{
  28. examDetailData.startTime | formatDate
  29. }}</span>
  30. </div>
  31. <div>
  32. <span class="exam-detail-title">考试时长:</span>
  33. <span class="exam-detail-txt">{{
  34. examDetailData.examLongTime
  35. }}</span>
  36. </div>
  37. <div>
  38. <span class="exam-detail-title">题目数量:</span>
  39. <span class="exam-detail-txt">{{ examQuestionList.length }}</span>
  40. </div>
  41. <div>
  42. <span class="exam-detail-title">状态:</span>
  43. <span
  44. class="exam-detail-txt"
  45. :class="
  46. examDetailData.status === '未开始'
  47. ? 'exam-status-green'
  48. : examDetailData.status === '正在考试'
  49. ? 'exam-status-yellow'
  50. : examDetailData.status === '已结束'
  51. ? 'exam-status-red'
  52. : ''
  53. "
  54. >{{ examDetailData.status }}</span
  55. >
  56. </div>
  57. </div>
  58. <div class="exam-detail-totalGrades exam-detail-item">总分:100</div>
  59. <div class="border-line"></div>
  60. </div>
  61. <!-- 考试题目列表:表单[自带分页功能] -->
  62. <a-table
  63. :columns="columns"
  64. :data-source="examQuestionList"
  65. :row-key="(record) => record.id"
  66. :scroll="{ y: tableHeight }"
  67. :pagination="pagination"
  68. @change="handleTableChange"
  69. >
  70. <template slot="status" slot-scope="text">
  71. <span
  72. :class="
  73. text === '未开始'
  74. ? 'exam-status-green'
  75. : text === '正在考试'
  76. ? 'exam-status-yellow'
  77. : text === '已结束'
  78. ? 'exam-status-red'
  79. : ''
  80. "
  81. >{{ text }}</span
  82. >
  83. </template>
  84. <template slot="questionType" slot-scope="text, record">
  85. <span>{{ record.questionTypeTxt }}</span>
  86. </template>
  87. <template slot="engineeringWork" slot-scope="text, record">
  88. <span>{{ record.engineeringWorkTxt }}</span>
  89. </template>
  90. <template slot="action" slot-scope="text, record">
  91. <a @click="toQuestionDetailFun(record)">详情</a>
  92. </template>
  93. </a-table>
  94. </a-spin>
  95. </div>
  96. </div>
  97. </template>
  98. <script>
  99. import { mapGetters } from 'vuex';
  100. import { formatTimeHoursMinuteSecondsFun } from '@/filters';
  101. import { ENGINEERING_WORK_LIST, EXAM_QUESTION_TYPE } from '@/common/Constant';
  102. export default {
  103. name: 'examManagementDetail',
  104. props: {},
  105. components: {},
  106. data() {
  107. return {
  108. tableHeight: 400, // 表格高度
  109. columns: [], // form表单的列参数
  110. pagination: {
  111. pageSize: 7,
  112. current: 1,
  113. total: 0,
  114. }, // 分页参数
  115. loading: false, // 是否展示加载动画
  116. examDetailData: {}, // 单场考试的详情信息
  117. examQuestionList: [], // 单场考试的试题列表
  118. };
  119. },
  120. created() {},
  121. mounted() {
  122. this.initDataFun(); //初始化数据
  123. },
  124. beforeDestroy() {},
  125. watch: {
  126. screenHeight() {
  127. this.initTableHeightFun(); // 初始化表单的高度
  128. },
  129. },
  130. computed: {
  131. // 是否选择了数据
  132. ...mapGetters(['screenHeight']),
  133. },
  134. methods: {
  135. // 初始化表单的高度
  136. initTableHeightFun() {
  137. this.tableHeight =
  138. this.$refs.tableBody.offsetHeight -
  139. (this.$refs.filterCard.offsetHeight + 48 * 3);
  140. },
  141. //初始化数据
  142. initDataFun() {
  143. if (!this.$route.query.id) {
  144. this.$message.error('页面异常,请重新进入');
  145. return;
  146. }
  147. this.loading = true;
  148. // 表单的列的配置参数
  149. this.columns = [
  150. {
  151. title: '题目编号',
  152. dataIndex: 'questionCode',
  153. key: 'questionCode',
  154. scopedSlots: { customRender: 'questionCode' },
  155. width: 150,
  156. },
  157. {
  158. title: '题目',
  159. dataIndex: 'questionDescription',
  160. key: 'questionDescription',
  161. },
  162. {
  163. title: '题目类别',
  164. dataIndex: 'questionType',
  165. key: 'questionType',
  166. scopedSlots: { customRender: 'questionType' },
  167. width: 150,
  168. },
  169. {
  170. title: '工种',
  171. dataIndex: 'engineeringWork',
  172. key: 'engineeringWork',
  173. scopedSlots: { customRender: 'engineeringWork' },
  174. width: 150,
  175. },
  176. {
  177. title: '分值',
  178. dataIndex: 'grade',
  179. key: 'grade',
  180. width: 100,
  181. },
  182. {
  183. title: '操作',
  184. dataIndex: 'action',
  185. key: 'action',
  186. scopedSlots: { customRender: 'action' },
  187. width: 100,
  188. },
  189. ];
  190. this.getExamDetailFun(); // 查询:考试详情
  191. },
  192. // 查询:考试详情
  193. getExamDetailFun() {
  194. let params = {
  195. id: this.$route.query.id,
  196. };
  197. console.log(params);
  198. // this.$_http
  199. // .get(this.$_API.INTERFACE_GET_EXAM_DETAIL, { params })
  200. // .then((res) => {
  201. // console.log(res);
  202. // this.tableData = res.data;
  203. // this.pagination.total = res.pagination.total;
  204. // })
  205. // .catch((err) => {
  206. // console.log(err);
  207. // })
  208. // .finally(() => {
  209. // this.loading = false;
  210. // });
  211. let resData = {
  212. id: 5,
  213. examCode: 'TradeCode 5',
  214. examName: '期末考试',
  215. startTime: '2021-06-20 12:00:00',
  216. examTimeMins: '201606',
  217. status: '未开始',
  218. description: '这里是考试描述',
  219. type: 'PuTongKaoShi',
  220. engineeringWork: 'QiaoSuiGong',
  221. };
  222. let tarTime = formatTimeHoursMinuteSecondsFun(resData.examTimeMins);
  223. resData.examLongTime =
  224. tarTime.hours + '时' + tarTime.minutes + '分' + tarTime.seconds + '秒';
  225. this.examDetailData = resData;
  226. this.getQusetionsListFun(resData.id); // 查询:题目列表数据
  227. },
  228. // 查询:题目列表数据
  229. getQusetionsListFun() {
  230. // 列表数据
  231. const resData = [
  232. {
  233. id: 1,
  234. questionCode: 'TradeCode 0',
  235. questionDescription:
  236. '这是一段描述,关于这个应用的描述文字内容,这是一段描述,关于这个应用的描述文字内容,这是一段描述,关于这个应用的描述文字内容',
  237. questionType: 'TianKong',
  238. engineeringWork: 'QiaoSuiGong',
  239. grade: 1,
  240. },
  241. {
  242. id: 2,
  243. questionCode: 'TradeCode 1',
  244. questionDescription: '这是一段描述,关于这个应用的描述文字内容',
  245. questionType: 'TianKong',
  246. engineeringWork: 'XianLuGong',
  247. grade: 2,
  248. },
  249. {
  250. id: 3,
  251. questionCode: 'TradeCode 2',
  252. questionDescription: '这是一段描述,关于这个应用的描述文字内容',
  253. questionType: 'DuoXuan',
  254. engineeringWork: 'XianLuGong',
  255. grade: 3,
  256. },
  257. {
  258. id: 4,
  259. questionCode: 'TradeCode 3',
  260. questionDescription: '这是一段描述,关于这个应用的描述文字内容',
  261. questionType: 'PanDuan',
  262. engineeringWork: 'QiaoSuiGong',
  263. grade: 4,
  264. },
  265. {
  266. id: 5,
  267. questionCode: 'TradeCode 4',
  268. questionDescription: '这是一段描述,关于这个应用的描述文字内容',
  269. questionType: 'DanXuan',
  270. engineeringWork: 'QiaoSuiGong',
  271. grade: 5,
  272. },
  273. {
  274. id: 6,
  275. questionCode: 'TradeCode 5',
  276. questionDescription: '这是一段描述,关于这个应用的描述文字内容',
  277. questionType: 'TianKong',
  278. engineeringWork: 'QiaoSuiGong',
  279. grade: 6,
  280. },
  281. {
  282. id: 7,
  283. questionCode: 'TradeCode 6',
  284. questionDescription: '这是一段描述,关于这个应用的描述文字内容',
  285. questionType: 'TianKong',
  286. engineeringWork: 'QiaoSuiGong',
  287. grade: 7,
  288. },
  289. {
  290. id: 8,
  291. questionCode: 'TradeCode 7',
  292. questionDescription: '这是一段描述,关于这个应用的描述文字内容',
  293. questionType: 'TianKong',
  294. engineeringWork: 'QiaoSuiGong',
  295. grade: 8,
  296. },
  297. {
  298. id: 9,
  299. questionCode: 'TradeCode 8',
  300. questionDescription: '这是一段描述,关于这个应用的描述文字内容',
  301. questionType: 'TianKong',
  302. engineeringWork: 'QiaoSuiGong',
  303. grade: 9,
  304. },
  305. {
  306. id: 10,
  307. questionCode: 'TradeCode 9',
  308. questionDescription: '这是一段描述,关于这个应用的描述文字内容',
  309. questionType: 'TianKong',
  310. engineeringWork: 'QiaoSuiGong',
  311. grade: 10,
  312. },
  313. {
  314. id: 11,
  315. questionCode: 'TradeCode 10',
  316. questionDescription: '这是一段描述,关于这个应用的描述文字内容',
  317. questionType: 'TianKong',
  318. engineeringWork: 'QiaoSuiGong',
  319. grade: 11,
  320. },
  321. {
  322. id: 12,
  323. questionCode: 'TradeCode 11',
  324. questionDescription: '这是一段描述,关于这个应用的描述文字内容',
  325. questionType: 'TianKong',
  326. engineeringWork: 'QiaoSuiGong',
  327. grade: 12,
  328. },
  329. {
  330. id: 13,
  331. questionCode: 'TradeCode 12',
  332. questionDescription: '这是一段描述,关于这个应用的描述文字内容',
  333. questionType: 'TianKong',
  334. engineeringWork: 'QiaoSuiGong',
  335. grade: 13,
  336. },
  337. {
  338. id: 14,
  339. questionCode: 'TradeCode 13',
  340. questionDescription: '这是一段描述,关于这个应用的描述文字内容',
  341. questionType: 'TianKong',
  342. engineeringWork: 'QiaoSuiGong',
  343. grade: 14,
  344. },
  345. ];
  346. setTimeout(() => {
  347. resData.forEach((item) => {
  348. EXAM_QUESTION_TYPE.forEach((it) => {
  349. if (item.questionType === it.code) {
  350. item.questionTypeTxt = it.title;
  351. }
  352. });
  353. ENGINEERING_WORK_LIST.forEach((it) => {
  354. if (item.engineeringWork === it.code) {
  355. item.engineeringWorkTxt = it.title;
  356. }
  357. });
  358. });
  359. this.pagination.total = resData.length;
  360. this.examQuestionList = [...resData];
  361. this.loading = false;
  362. }, 1500);
  363. },
  364. // 查询:表格某页的数据
  365. handleTableChange(pagination) {
  366. this.loading = true;
  367. const pager = { ...this.pagination };
  368. pager.current = pagination.current;
  369. this.pagination = pager;
  370. this.loading = false;
  371. // let params = {
  372. // pagination: pagination,
  373. // questionType: this.checkedExamType,
  374. // engineeringWork: this.engineeringWorkChooseValue
  375. // };
  376. // this.$_http
  377. // .get(this.$_API.INTERFACE_GET_USER_ADMIN_USERS, { params })
  378. // .then((res) => {
  379. // console.log(res);
  380. // this.tableData = res.data;
  381. // this.pagination.total = res.pagination.total;
  382. // })
  383. // .catch((err) => {
  384. // console.log(err);
  385. // })
  386. // .finally(() => {
  387. // this.loading = false;
  388. // });
  389. },
  390. // 操作:详情
  391. toQuestionDetailFun(record) {
  392. console.log('查看某个试题的详情', record);
  393. },
  394. },
  395. };
  396. </script>
  397. <style lang="less"></style>
  398. <style lang="less" scoped>
  399. @import '~@/styles/common/variable.less';
  400. .exam-detail-body {
  401. .exam-detail-info {
  402. width: 100%;
  403. .exam-detail-name {
  404. font-size: 20px;
  405. font-weight: bold;
  406. color: @mainColorBlack85;
  407. }
  408. .exam-detail-description,
  409. .exam-detail-type {
  410. font-size: 14px;
  411. color: @mainColorBlack;
  412. }
  413. .exam-detail-totalGrades {
  414. font-size: 16px;
  415. font-weight: bold;
  416. color: @mainColorBlack65;
  417. }
  418. .exam-detail-item {
  419. margin-top: @paddingMarginVal;
  420. }
  421. .exam-detail-title {
  422. font-size: 14px;
  423. color: @mainColorBlack85;
  424. }
  425. .exam-detail-txt {
  426. font-size: 14px;
  427. color: @mainColorBlack65;
  428. }
  429. .exam-status-green {
  430. color: #58e206;
  431. }
  432. .exam-status-yellow {
  433. color: #ff8d1a;
  434. }
  435. .exam-status-red {
  436. color: #d43030;
  437. }
  438. }
  439. }
  440. </style>