examManagementDetail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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-row">
  8. <div class="exam-detail-name">{{ examDetailData.name }}</div>
  9. <!-- <a-button
  10. type="primary"
  11. :disabled="examDetailData.disabled"
  12. @click="handleEditExam"
  13. >编辑</a-button
  14. > -->
  15. </div>
  16. <div class="flex-between exam-detail-item">
  17. <div class="exam-detail-description">
  18. 考试描述:<span>{{ examDetailData.description }}</span>
  19. </div>
  20. <div class="exam-detail-type">
  21. 考试分类:<span>{{
  22. examDetailData.examCategory | formateExamTypeFun
  23. }}</span>
  24. </div>
  25. </div>
  26. <div class="flex-between exam-detail-item">
  27. <div>
  28. <span class="exam-detail-title">考试工种:</span>
  29. <span class="exam-detail-txt">{{
  30. examDetailData.engineerTypeTxt
  31. }}</span>
  32. </div>
  33. <div>
  34. <span class="exam-detail-title">考试时间:</span>
  35. <span class="exam-detail-txt">{{
  36. examDetailData.startTime | formatDate
  37. }}</span>
  38. </div>
  39. <div>
  40. <span class="exam-detail-title">考试时长:</span>
  41. <span class="exam-detail-txt">{{
  42. examDetailData.examLongTime
  43. }}</span>
  44. </div>
  45. <div>
  46. <span class="exam-detail-title">试题数量:</span>
  47. <span class="exam-detail-txt">{{ pagination.total }}</span>
  48. </div>
  49. <div>
  50. <span class="exam-detail-title">状态:</span>
  51. <span
  52. class="exam-detail-txt"
  53. :class="
  54. examDetailData.examStatusTxt === examStatusTypeTxt[0]
  55. ? 'exam-status-green'
  56. : examDetailData.examStatusTxt === examStatusTypeTxt[1]
  57. ? 'exam-status-yellow'
  58. : examDetailData.examStatusTxt === examStatusTypeTxt[2]
  59. ? 'exam-status-red'
  60. : ''
  61. "
  62. >{{ examDetailData.examStatusTxt }}</span
  63. >
  64. </div>
  65. </div>
  66. <div class="exam-detail-totalGrades exam-detail-item">
  67. 总分:{{ examDetailData.totalPoints }}
  68. </div>
  69. <div class="border-line"></div>
  70. </div>
  71. <!-- 表单 :scroll="{ y: tableHeight }"-->
  72. <a-table
  73. :columns="columns"
  74. :data-source="tableData"
  75. :row-key="(record) => record.id"
  76. :pagination="false"
  77. >
  78. <template slot="questionCategory" slot-scope="text, record">
  79. <span>{{
  80. record.questionCategory ? record.questionCategory.name : '不限'
  81. }}</span>
  82. </template>
  83. <template slot="rootQuestionCategory" slot-scope="text, record">
  84. <span>{{
  85. record.rootQuestionCategory
  86. ? record.rootQuestionCategory.name
  87. : '不限'
  88. }}</span>
  89. </template>
  90. <template slot="status" slot-scope="text">
  91. <span
  92. :class="
  93. text === examStatusTypeTxt[0]
  94. ? 'exam-status-green'
  95. : text === examStatusTypeTxt[1]
  96. ? 'exam-status-yellow'
  97. : text === examStatusTypeTxt[2]
  98. ? 'exam-status-red'
  99. : ''
  100. "
  101. >{{ text }}</span
  102. >
  103. </template>
  104. <template slot="action" slot-scope="text, record">
  105. <a @click="toQuestionDetailFun(record)">详情</a>
  106. </template>
  107. </a-table>
  108. <!-- 分页 -->
  109. <div class="a-pagination-display">
  110. <a-pagination
  111. v-model="pagination.current"
  112. :pageSize="pagination.pageSize"
  113. :total.sync="pagination.total"
  114. show-less-items
  115. show-quick-jumper
  116. @change="getQusetionsListFun"
  117. />
  118. </div>
  119. </a-spin>
  120. </div>
  121. <div class="company-info">
  122. <span>
  123. copyright © 浮游科技有限公司出品
  124. </span>
  125. </div>
  126. <QuestionDetailDialog
  127. :questionDetail.sync="questionDetail"
  128. :isVisible.sync="isVisible"
  129. />
  130. </div>
  131. </template>
  132. <script>
  133. import { mapGetters } from 'vuex';
  134. import {
  135. formatTimeHoursMinuteSecondsFun,
  136. formatePathParams,
  137. formateExamStatesFun,
  138. formateEngineeringWork,
  139. } from '@/filters';
  140. import {
  141. EXAM_QUESTION_TYPE,
  142. EXAM_STATUS_TYPE_TXT,
  143. EXAM_STATUS_TYPE,
  144. } from '@/common/Constant';
  145. export default {
  146. name: 'examManagementDetail',
  147. props: {},
  148. components: {},
  149. data() {
  150. return {
  151. // tableHeight: 400, // 表格高度
  152. columns: [], // form表单的列参数
  153. pagination: {
  154. pageSize: 7,
  155. current: 1,
  156. total: 0,
  157. }, // 分页参数
  158. loading: false, // 是否展示加载动画
  159. examDetailData: {}, // 单场考试的详情信息
  160. tableData: [], // 单场考试的试题列表
  161. engineeringWorkList: [], // 工种数据列表
  162. examStatusTypeTxt: EXAM_STATUS_TYPE_TXT, // 考试状态属性文字
  163. isVisible: false, // 是否显示详情浮窗
  164. questionDetail: {}, // 需要展示的试题详情
  165. };
  166. },
  167. created() {
  168. this.initDataFun(); //初始化数据
  169. },
  170. mounted() {
  171. // this.initTableHeightFun(); // 初始化表单的高度
  172. },
  173. beforeDestroy() {},
  174. watch: {
  175. // screenHeight() {
  176. // this.initTableHeightFun(); // 初始化表单的高度
  177. // },
  178. },
  179. computed: {
  180. ...mapGetters(['screenHeight', 'GET_ENGINEERING_WORK_LIST']),
  181. },
  182. methods: {
  183. // // 初始化表单的高度
  184. // initTableHeightFun() {
  185. // this.tableHeight =
  186. // this.$refs.tableBody.offsetHeight -
  187. // (this.$refs.filterCard.offsetHeight + 48 * 3 + 16);
  188. // },
  189. //初始化数据
  190. initDataFun() {
  191. if (!this.$route.query.id) {
  192. this.$message.error('页面异常,请重新进入当前页面');
  193. return;
  194. }
  195. // 工种类别
  196. this.engineeringWorkList = [
  197. { name: '不限', id: '' },
  198. ...this.GET_ENGINEERING_WORK_LIST,
  199. ];
  200. // 表单的列的配置参数
  201. this.columns = [
  202. // {
  203. // title: '试题编号',
  204. // dataIndex: 'id',
  205. // key: 'id',
  206. // scopedSlots: { customRender: 'id' },
  207. // width: 240,
  208. // },
  209. {
  210. title: '试题',
  211. dataIndex: 'content',
  212. key: 'content',
  213. },
  214. {
  215. title: '试题类别',
  216. dataIndex: 'questionTypeTxt',
  217. key: 'questionTypeTxt',
  218. scopedSlots: { customRender: 'questionTypeTxt' },
  219. width: 150,
  220. },
  221. {
  222. title: '试题父类',
  223. dataIndex: 'rootQuestionCategory',
  224. key: 'rootQuestionCategory',
  225. scopedSlots: { customRender: 'rootQuestionCategory' },
  226. width: 150,
  227. },
  228. {
  229. title: '试题子类',
  230. dataIndex: 'questionCategory',
  231. key: 'questionCategory',
  232. scopedSlots: { customRender: 'questionCategory' },
  233. width: 150,
  234. },
  235. {
  236. title: '工种',
  237. dataIndex: 'engineerTypeTxt',
  238. key: 'engineerTypeTxt',
  239. scopedSlots: { customRender: 'engineerTypeTxt' },
  240. width: 200,
  241. },
  242. {
  243. title: '分值',
  244. dataIndex: 'points',
  245. key: 'points',
  246. width: 100,
  247. },
  248. {
  249. title: '操作',
  250. dataIndex: 'action',
  251. key: 'action',
  252. scopedSlots: { customRender: 'action' },
  253. width: 100,
  254. },
  255. ];
  256. this.getExamDetailFun(); // 查询:考试详情
  257. },
  258. // 查询:考试详情
  259. getExamDetailFun() {
  260. let params = {
  261. examId: this.$route.query.id,
  262. };
  263. this.$_http
  264. .get(formatePathParams(this.$_API.INTERFACE_GET_EXAM_DETAIL, params))
  265. .then((res) => {
  266. let resData = res.data;
  267. // 考试时长
  268. let tarTime = formatTimeHoursMinuteSecondsFun(resData.duration);
  269. resData.examLongTime =
  270. tarTime.hours +
  271. '时' +
  272. tarTime.minutes +
  273. '分' +
  274. tarTime.seconds +
  275. '秒';
  276. // 工种
  277. if (resData.engineerTypes) {
  278. let findItem = formateEngineeringWork(
  279. this.engineeringWorkList,
  280. resData.engineerTypes[0]
  281. );
  282. resData.engineerTypeTxt = findItem.name;
  283. } else {
  284. resData.engineerTypeTxt = '不限';
  285. }
  286. let obj = formateExamStatesFun(resData.startTime, resData.deadline);
  287. resData.examStatus = obj.examStatus;
  288. resData.examStatusTxt = obj.examStatusTxt;
  289. resData.disabled =
  290. resData.examStatus !== EXAM_STATUS_TYPE.NOT_START ? true : false; // 未开始的才能编辑
  291. this.examDetailData = resData;
  292. this.loading = false;
  293. this.getQusetionsListFun(); // 查询:试题列表数据
  294. })
  295. .catch(() => {
  296. this.loading = false;
  297. });
  298. },
  299. // 查询:试题列表数据
  300. getQusetionsListFun() {
  301. if (!this.$route.query.id) {
  302. return;
  303. }
  304. this.loading = true;
  305. let paramsPath = {
  306. examId: this.$route.query.id,
  307. };
  308. let params = {
  309. page: this.pagination.current - 1,
  310. size: this.pagination.pageSize,
  311. };
  312. this.$_http
  313. .get(
  314. formatePathParams(
  315. this.$_API.INTERFACE_GET_EXAM_QUESTIONS_LIST,
  316. paramsPath
  317. ),
  318. { params }
  319. )
  320. .then((res) => {
  321. let resData = res.data.content;
  322. resData.forEach((item) => {
  323. // 试题类别
  324. EXAM_QUESTION_TYPE.forEach((it) => {
  325. if (item.type === it.code) {
  326. item.questionTypeTxt = it.name;
  327. }
  328. });
  329. // 工种
  330. if (item.engineerTypes) {
  331. let findItem = formateEngineeringWork(
  332. this.engineeringWorkList,
  333. item.engineerTypes[0]
  334. );
  335. item.engineerTypeTxt = findItem.name;
  336. } else {
  337. item.engineerTypeTxt = '不限';
  338. }
  339. });
  340. this.tableData = [...resData];
  341. this.pagination.total = res.data.totalElements; // 总条数
  342. this.loading = false;
  343. })
  344. .catch(() => {
  345. this.loading = false;
  346. });
  347. },
  348. // 操作:编辑
  349. handleEditExam() {
  350. if (!this.examDetailData || !this.examDetailData.id) {
  351. this.$message.error('数据异常,请重新进入当前页面');
  352. return;
  353. }
  354. this.$router.push({
  355. path: '/examManagement/manualVolumeFormation',
  356. query: {
  357. id: this.examDetailData.id,
  358. questionNum: this.pagination.total,
  359. },
  360. });
  361. },
  362. // 操作:详情
  363. toQuestionDetailFun(record) {
  364. console.log('查看某个试题的详情', record);
  365. this.questionDetail = record;
  366. this.isVisible = true;
  367. // if (!record || !record.id) {
  368. // this.$message.error('数据异常,请重新进入当前页面');
  369. // return;
  370. // }
  371. // switch (record.type) {
  372. // case EXAM_QUESTION_TYPE[0].code:
  373. // this.$router.push({
  374. // path: '/examQuestionManagement/create/singleChoice',
  375. // query: { id: record.id },
  376. // });
  377. // break;
  378. // case EXAM_QUESTION_TYPE[1].code:
  379. // this.$router.push({
  380. // path: '/examQuestionManagement/create/multipleChoice',
  381. // query: { id: record.id },
  382. // });
  383. // break;
  384. // case EXAM_QUESTION_TYPE[2].code:
  385. // this.$router.push({
  386. // path: '/examQuestionManagement/create/trueOrFalse',
  387. // query: { id: record.id },
  388. // });
  389. // break;
  390. // case EXAM_QUESTION_TYPE[3].code:
  391. // this.$router.push({
  392. // path: '/examQuestionManagement/create/gapFilling',
  393. // query: { id: record.id },
  394. // });
  395. // break;
  396. // default:
  397. // this.$message.error('试题数据异常,无法查看详');
  398. // break;
  399. // }
  400. },
  401. },
  402. };
  403. </script>
  404. <style lang="less"></style>
  405. <style lang="less" scoped>
  406. @import '~@/styles/common/variable.less';
  407. .exam-detail-body {
  408. .exam-detail-info {
  409. width: 100%;
  410. .exam-detail-name-row {
  411. display: flex;
  412. justify-content: space-between;
  413. .exam-detail-name {
  414. font-size: 20px;
  415. font-weight: bold;
  416. color: @mainColorBlack85;
  417. }
  418. }
  419. .exam-detail-description,
  420. .exam-detail-type {
  421. font-size: 14px;
  422. color: @mainColorBlack;
  423. }
  424. .exam-detail-totalGrades {
  425. font-size: 16px;
  426. font-weight: bold;
  427. color: @mainColorBlack65;
  428. }
  429. .exam-detail-item {
  430. margin-top: @paddingMarginVal;
  431. }
  432. .exam-detail-title {
  433. font-size: 14px;
  434. color: @mainColorBlack85;
  435. }
  436. .exam-detail-txt {
  437. font-size: 14px;
  438. color: @mainColorBlack65;
  439. }
  440. .exam-status-green {
  441. color: #58e206;
  442. }
  443. .exam-status-yellow {
  444. color: #ff8d1a;
  445. }
  446. .exam-status-red {
  447. color: #d43030;
  448. }
  449. }
  450. }
  451. </style>