examManagementDetail.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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. import { QUESTIONLISTRES } from '@/common/resData';
  103. export default {
  104. name: 'examManagementDetail',
  105. props: {},
  106. components: {},
  107. data() {
  108. return {
  109. tableHeight: 400, // 表格高度
  110. columns: [], // form表单的列参数
  111. pagination: {
  112. pageSize: 7,
  113. current: 1,
  114. total: 0,
  115. }, // 分页参数
  116. loading: false, // 是否展示加载动画
  117. examDetailData: {}, // 单场考试的详情信息
  118. examQuestionList: [], // 单场考试的试题列表
  119. };
  120. },
  121. created() {
  122. this.initDataFun(); //初始化数据
  123. },
  124. mounted() {
  125. this.initTableHeightFun(); // 初始化表单的高度
  126. },
  127. beforeDestroy() {},
  128. watch: {
  129. screenHeight() {
  130. this.initTableHeightFun(); // 初始化表单的高度
  131. },
  132. },
  133. computed: {
  134. // 是否选择了数据
  135. ...mapGetters(['screenHeight']),
  136. },
  137. methods: {
  138. // 初始化表单的高度
  139. initTableHeightFun() {
  140. this.tableHeight =
  141. this.$refs.tableBody.offsetHeight -
  142. (this.$refs.filterCard.offsetHeight + 48 * 3);
  143. },
  144. //初始化数据
  145. initDataFun() {
  146. if (!this.$route.query.id) {
  147. this.$message.error('页面异常,请重新进入');
  148. return;
  149. }
  150. this.loading = true;
  151. // 表单的列的配置参数
  152. this.columns = [
  153. {
  154. title: '题目编号',
  155. dataIndex: 'questionCode',
  156. key: 'questionCode',
  157. scopedSlots: { customRender: 'questionCode' },
  158. width: 200,
  159. },
  160. {
  161. title: '题目',
  162. dataIndex: 'questionDescription',
  163. key: 'questionDescription',
  164. },
  165. {
  166. title: '题目类别',
  167. dataIndex: 'questionType',
  168. key: 'questionType',
  169. scopedSlots: { customRender: 'questionType' },
  170. width: 150,
  171. },
  172. {
  173. title: '工种',
  174. dataIndex: 'engineeringWork',
  175. key: 'engineeringWork',
  176. scopedSlots: { customRender: 'engineeringWork' },
  177. width: 150,
  178. },
  179. {
  180. title: '分值',
  181. dataIndex: 'grade',
  182. key: 'grade',
  183. width: 150,
  184. },
  185. {
  186. title: '操作',
  187. dataIndex: 'action',
  188. key: 'action',
  189. scopedSlots: { customRender: 'action' },
  190. width: 150,
  191. },
  192. ];
  193. this.getExamDetailFun(); // 查询:考试详情
  194. },
  195. // 查询:考试详情
  196. getExamDetailFun() {
  197. let params = {
  198. id: this.$route.query.id,
  199. };
  200. console.log(params);
  201. // this.$_http
  202. // .get(this.$_API.INTERFACE_GET_EXAM_DETAIL, { params })
  203. // .then((res) => {
  204. // console.log(res);
  205. // this.tableData = res.data;
  206. // this.pagination.total = res.pagination.total;
  207. // })
  208. // .catch((err) => {
  209. // console.log(err);
  210. // })
  211. // .finally(() => {
  212. // this.loading = false;
  213. // });
  214. let resData = {
  215. id: 5,
  216. examCode: 'TradeCode 5',
  217. examName: '期末考试',
  218. startTime: '2021-06-20 12:00:00',
  219. examTimeMins: '201606',
  220. status: '未开始',
  221. description: '这里是考试描述',
  222. type: 'PuTongKaoShi',
  223. engineeringWork: 'QiaoSuiGong',
  224. };
  225. let tarTime = formatTimeHoursMinuteSecondsFun(resData.examTimeMins);
  226. resData.examLongTime =
  227. tarTime.hours + '时' + tarTime.minutes + '分' + tarTime.seconds + '秒';
  228. this.examDetailData = resData;
  229. this.getQusetionsListFun(resData.id); // 查询:题目列表数据
  230. },
  231. // 查询:题目列表数据
  232. getQusetionsListFun() {
  233. // 列表数据
  234. const resData = QUESTIONLISTRES.data;
  235. setTimeout(() => {
  236. resData.forEach((item) => {
  237. EXAM_QUESTION_TYPE.forEach((it) => {
  238. if (item.questionType === it.code) {
  239. item.questionTypeTxt = it.title;
  240. }
  241. });
  242. ENGINEERING_WORK_LIST.forEach((it) => {
  243. if (item.engineeringWork === it.code) {
  244. item.engineeringWorkTxt = it.title;
  245. }
  246. });
  247. });
  248. this.pagination.total = resData.length;
  249. this.examQuestionList = [...resData];
  250. this.loading = false;
  251. }, 1500);
  252. },
  253. // 查询:表格某页的数据
  254. handleTableChange(pagination) {
  255. this.loading = true;
  256. const pager = { ...this.pagination };
  257. pager.current = pagination.current;
  258. this.pagination = pager;
  259. this.loading = false;
  260. // let params = {
  261. // pagination: pagination,
  262. // questionType: this.checkedExamType,
  263. // engineeringWork: this.engineeringWorkChooseValue
  264. // };
  265. // this.$_http
  266. // .get(this.$_API.INTERFACE_GET_USER_ADMIN_USERS, { params })
  267. // .then((res) => {
  268. // console.log(res);
  269. // this.tableData = res.data;
  270. // this.pagination.total = res.pagination.total;
  271. // })
  272. // .catch((err) => {
  273. // console.log(err);
  274. // })
  275. // .finally(() => {
  276. // this.loading = false;
  277. // });
  278. },
  279. // 操作:详情
  280. toQuestionDetailFun(record) {
  281. console.log('查看某个试题的详情', record);
  282. },
  283. },
  284. };
  285. </script>
  286. <style lang="less"></style>
  287. <style lang="less" scoped>
  288. @import '~@/styles/common/variable.less';
  289. .exam-detail-body {
  290. .exam-detail-info {
  291. width: 100%;
  292. .exam-detail-name {
  293. font-size: 20px;
  294. font-weight: bold;
  295. color: @mainColorBlack85;
  296. }
  297. .exam-detail-description,
  298. .exam-detail-type {
  299. font-size: 14px;
  300. color: @mainColorBlack;
  301. }
  302. .exam-detail-totalGrades {
  303. font-size: 16px;
  304. font-weight: bold;
  305. color: @mainColorBlack65;
  306. }
  307. .exam-detail-item {
  308. margin-top: @paddingMarginVal;
  309. }
  310. .exam-detail-title {
  311. font-size: 14px;
  312. color: @mainColorBlack85;
  313. }
  314. .exam-detail-txt {
  315. font-size: 14px;
  316. color: @mainColorBlack65;
  317. }
  318. .exam-status-green {
  319. color: #58e206;
  320. }
  321. .exam-status-yellow {
  322. color: #ff8d1a;
  323. }
  324. .exam-status-red {
  325. color: #d43030;
  326. }
  327. }
  328. }
  329. </style>