index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <div id="testPaperPreview">
  3. <el-dialog
  4. :visible.sync="diavos"
  5. width="1080px"
  6. :show-close="false"
  7. :close-on-click-modal="false"
  8. >
  9. <div slot="title" class="hearders">
  10. <div class="leftTitle">试卷预览</div>
  11. <div class="rightBoxs">
  12. <img src="@/assets/images/Close@2x.png" alt="" @click="clears" />
  13. </div>
  14. </div>
  15. <div>
  16. <table class="table_style" border>
  17. <tr>
  18. <td>当前总分</td>
  19. <td>及格分数</td>
  20. <td>答卷时长</td>
  21. <td>答卷次数</td>
  22. <td>做题类型</td>
  23. </tr>
  24. <tr>
  25. <td>{{ topData.getAllpocis }}</td>
  26. <td>{{ topData.passScore }}</td>
  27. <td>
  28. {{ topData.answerTime === 0 ? "无限时长" : topData.answerTime }}
  29. </td>
  30. <td>
  31. {{ topData.answerNum === 0 ? "无限次" : topData.answerNum }}
  32. </td>
  33. <td>
  34. {{
  35. topData.doType === 1
  36. ? "练习"
  37. : topData.doType === 2
  38. ? "考试"
  39. : ""
  40. }}
  41. </td>
  42. </tr>
  43. </table>
  44. <div class="bank_style">
  45. <div v-for="(item, index) in tableData" :key="index">
  46. <div class="header_style">
  47. <span>题目{{ index + 1 }}</span>
  48. <span>{{ getTypeName(item.type) }}</span>
  49. <span>分值:{{ item.score }}</span>
  50. <el-button
  51. size="mini"
  52. style="float: right"
  53. @click="changeDatas(item)"
  54. v-if="type === 2"
  55. >修改</el-button
  56. >
  57. <div style="clear: both"></div>
  58. </div>
  59. <div class="dis_flex">
  60. <span>题目内容:</span>
  61. <div>
  62. <div class="divPy" v-html="imgExiz(item.content)"></div>
  63. <div v-if="item.type === 4">
  64. <div
  65. style="background: #e0e0e0; padding: 10px"
  66. v-for="(its, inds) in JSON.parse(item.jsonStr)"
  67. :key="inds"
  68. >
  69. <div class="header_style">
  70. <span>题目{{ inds + 1 }}</span>
  71. <span>{{ getTypeName(its.type) }}</span>
  72. </div>
  73. <div class="dis_flex">
  74. <span>题目内容:</span>
  75. <div>
  76. <div class="divPy" v-html="imgExiz(its.content)"></div>
  77. </div>
  78. </div>
  79. <div
  80. class="dis_flex"
  81. v-if="its.type !== 4 && its.type !== 5 && its.type !== 3"
  82. >
  83. <span>选项内容:</span>
  84. <div>
  85. <ul>
  86. <li
  87. v-for="(itemsxs, indexsxs) in its.optionsList"
  88. :key="indexsxs"
  89. :style="
  90. indexsxs === its.optionsList.length - 1
  91. ? 'margin-bottom: 0px'
  92. : 'margin-bottom: 10px'
  93. "
  94. >
  95. {{ Gest(indexsxs + 1) }}:{{ itemsxs.content }}
  96. <div style="margin: 10px 0px">
  97. <el-image
  98. v-if="itemsxs.imgUrl"
  99. style="
  100. max-width: 100%;
  101. max-height: 100%;
  102. vertical-align: middle;
  103. "
  104. :src="
  105. $methodsTools.splitImgHost(itemsxs.imgUrl)
  106. "
  107. :preview-src-list="[
  108. $methodsTools.splitImgHost(itemsxs.imgUrl),
  109. ]"
  110. >
  111. </el-image>
  112. </div>
  113. </li>
  114. </ul>
  115. </div>
  116. </div>
  117. <div class="dis_flex" v-if="its.type !== 5">
  118. <span>正确答案:</span>
  119. <div>
  120. <span v-if="its.type === 3">
  121. {{ its.answerQuestion == 1 ? "正确" : "错误" }}
  122. </span>
  123. <span v-else>
  124. {{ getDictChanges(its.answerQuestion) }}
  125. </span>
  126. </div>
  127. </div>
  128. <div class="dis_flex">
  129. <span>答案解析:</span>
  130. <div>
  131. <div v-html="imgExiz(its.analysisContent)"></div>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. <div
  139. class="dis_flex"
  140. v-if="item.type !== 3 && item.type !== 4 && item.type !== 5"
  141. >
  142. <span>选项内容:</span>
  143. <div>
  144. <ul v-if="item.type !== 4">
  145. <li
  146. v-for="(items, indexs) in item.optionsList"
  147. :key="indexs"
  148. :style="
  149. indexs === item.optionsList.length - 1
  150. ? 'margin-bottom: 0px'
  151. : 'margin-bottom: 10px'
  152. "
  153. >
  154. {{ Gest(indexs + 1) }}:{{ items.content }}
  155. <div style="margin: 10px 0px">
  156. <el-image
  157. v-if="items.imgUrl"
  158. style="
  159. max-width: 100%;
  160. max-height: 100%;
  161. vertical-align: middle;
  162. "
  163. :src="$methodsTools.splitImgHost(items.imgUrl)"
  164. :preview-src-list="[
  165. $methodsTools.splitImgHost(items.imgUrl),
  166. ]"
  167. >
  168. </el-image>
  169. </div>
  170. </li>
  171. </ul>
  172. </div>
  173. </div>
  174. <div class="dis_flex" v-if="item.type !== 5 && item.type !== 4">
  175. <span>正确答案:</span>
  176. <div>
  177. <span v-if="item.type === 3">
  178. {{ item.answerQuestion == 1 ? "正确" : "错误" }}
  179. </span>
  180. <span v-else>
  181. {{ getDictChanges(item.answerQuestion) }}
  182. </span>
  183. </div>
  184. </div>
  185. <div class="dis_flex" v-if="item.type !== 4">
  186. <span>答案解析:</span>
  187. <div><div v-html="imgExiz(item.analysisContent)"></div></div>
  188. </div>
  189. </div>
  190. </div>
  191. </div>
  192. <span slot="footer" class="dialog-footer">
  193. <el-button @click="clears">确 认</el-button>
  194. </span>
  195. </el-dialog>
  196. </div>
  197. </template>
  198. <script>
  199. export default {
  200. data() {
  201. return {
  202. diavos: false,
  203. tableData: [], //题目内容
  204. topData: {}, //顶部表格数据
  205. type: "",
  206. };
  207. },
  208. computed: {
  209. /**
  210. * 题目类型转换名称
  211. */
  212. getTypeName: function () {
  213. return function (type) {
  214. let typeName = "";
  215. switch (type) {
  216. case 1:
  217. typeName = "单选题";
  218. break;
  219. case 2:
  220. typeName = "多选题";
  221. break;
  222. case 3:
  223. typeName = "判断题";
  224. break;
  225. case 4:
  226. typeName = "案例题";
  227. break;
  228. case 5:
  229. typeName = "简答题";
  230. break;
  231. default:
  232. break;
  233. }
  234. return typeName;
  235. };
  236. },
  237. imgExiz: function () {
  238. return function (vms) {
  239. if (!vms) {
  240. return vms;
  241. } else {
  242. var ast1 = vms.replace(/<p/gi, '<p style="margin:0px;"');
  243. var ast = ast1.replace(/<img/gi, '<img style="max-width:100%;"');
  244. return ast;
  245. }
  246. };
  247. },
  248. },
  249. methods: {
  250. /**
  251. * type = 1时Id获取数据row = ID, 2时直接获取数据row = 数据
  252. */
  253. openBox(type, row) {
  254. const ROWS = JSON.parse(JSON.stringify(row));
  255. this.type = type;
  256. if (type === 1) {
  257. //搜索Id处理数据
  258. this.$api.obtainbankexam(row).then((res) => {
  259. this.topData = {
  260. answerTime: res.data.answerTime,
  261. answerNum: res.data.answerNum,
  262. doType: res.data.doType,
  263. passScore: res.data.passScore,
  264. };
  265. this.$api.inquirebankexamquestionList({ examId: row }).then((res) => {
  266. res.data.map((item) => {
  267. item.optionsList = JSON.parse(item.jsonStr);
  268. });
  269. this.tableData = res.data;
  270. var num = 0;
  271. res.data.forEach((item) => {
  272. num += item.score;
  273. });
  274. this.topData.getAllpocis = num;
  275. this.diavos = true;
  276. });
  277. });
  278. }
  279. if (type === 2) {
  280. this.topData = ROWS.topData;
  281. this.tableData = ROWS.tableData;
  282. this.diavos = true;
  283. }
  284. },
  285. changeDatas(row) {
  286. this.$parent.addClick(row, 0, row.index, true);
  287. },
  288. clears() {
  289. this.diavos = false;
  290. },
  291. changeUploadStatus(data) {
  292. let index = this.tableData.findIndex((item) => {
  293. return item.index === data.index;
  294. });
  295. this.$set(this.tableData, index, data);
  296. console.log(data);
  297. },
  298. /**
  299. * 选项转换
  300. */
  301. Gest(ints) {
  302. var int = parseInt(ints);
  303. var ast = "";
  304. switch (int) {
  305. case 1:
  306. ast = "A";
  307. break;
  308. case 2:
  309. ast = "B";
  310. break;
  311. case 3:
  312. ast = "C";
  313. break;
  314. case 4:
  315. ast = "D";
  316. break;
  317. case 5:
  318. ast = "E";
  319. break;
  320. case 6:
  321. ast = "F";
  322. break;
  323. case 7:
  324. ast = "G";
  325. break;
  326. case 8:
  327. ast = "H";
  328. break;
  329. default:
  330. ast = "X";
  331. break;
  332. }
  333. return ast;
  334. },
  335. getDictChanges(dan) {
  336. var arst = [];
  337. var arrays;
  338. if (dan instanceof Object) {
  339. arrays = dan;
  340. } else {
  341. if (dan) {
  342. arrays = dan.toString().split(",");
  343. } else {
  344. return "";
  345. }
  346. }
  347. for (let i = 0; i < arrays.length; i++) {
  348. arst.push(this.Gest(arrays[i]));
  349. }
  350. return arst.join(",");
  351. },
  352. },
  353. };
  354. </script>
  355. <style lang="scss" scoped>
  356. .table_style {
  357. width: 100%;
  358. border-collapse: collapse;
  359. text-align: center;
  360. margin-bottom: 14px;
  361. tr {
  362. &:first-of-type {
  363. background-color: rgb(255, 255, 204);
  364. font-weight: bold;
  365. }
  366. td {
  367. padding: 6px;
  368. }
  369. }
  370. }
  371. .bank_style {
  372. max-height: 600px;
  373. overflow: auto;
  374. & > div {
  375. padding: 10px;
  376. background-color: #eee;
  377. margin-bottom: 11px;
  378. }
  379. & .header_style {
  380. border-bottom: 1px dotted #999;
  381. padding-bottom: 6px;
  382. & > span {
  383. margin-right: 10px;
  384. }
  385. }
  386. & .dis_flex {
  387. display: flex;
  388. margin-bottom: 6px;
  389. & > span {
  390. width: 90px;
  391. flex-shrink: 0;
  392. }
  393. & > div {
  394. flex: 1;
  395. ul {
  396. margin: 0;
  397. }
  398. }
  399. }
  400. }
  401. /deep/.el-button {
  402. border-radius: 8px;
  403. }
  404. /deep/.el-dialog {
  405. border-radius: 8px;
  406. .el-dialog__header {
  407. padding: 0;
  408. .hearders {
  409. height: 40px;
  410. display: flex;
  411. align-items: center;
  412. justify-content: space-between;
  413. padding: 0px 18px 0px 20px;
  414. border-bottom: 1px solid #e2e2e2;
  415. .leftTitle {
  416. font-size: 14px;
  417. font-weight: bold;
  418. color: #2f4378;
  419. }
  420. .rightBoxs {
  421. display: flex;
  422. align-items: center;
  423. img {
  424. width: 14px;
  425. height: 14px;
  426. margin-left: 13px;
  427. cursor: pointer;
  428. }
  429. }
  430. }
  431. }
  432. .el-dialog__footer {
  433. padding: 0;
  434. .dialog-footer {
  435. padding: 0px 40px;
  436. height: 70px;
  437. border-top: 1px solid #e2e2e2;
  438. display: flex;
  439. align-items: center;
  440. justify-content: flex-end;
  441. }
  442. }
  443. }
  444. .imgBox {
  445. width: 100%;
  446. // height: 210px;
  447. border: 1px solid #e2e2e2;
  448. border-radius: 8px;
  449. padding: 8px 8px 3px;
  450. display: flex;
  451. flex-direction: column;
  452. align-items: center;
  453. .imgLabel {
  454. flex: 1;
  455. width: 100%;
  456. border: 1px dotted #e2e2e2;
  457. color: #999;
  458. font-size: 14px;
  459. cursor: pointer;
  460. border-radius: 8px;
  461. .msPhoto {
  462. display: flex;
  463. justify-content: center;
  464. align-items: center;
  465. max-width: 100%;
  466. max-height: 270px;
  467. img {
  468. max-width: 100%;
  469. max-height: 270px;
  470. }
  471. }
  472. .imgbbx {
  473. display: flex;
  474. flex-direction: column;
  475. align-items: center;
  476. justify-content: center;
  477. width: 100%;
  478. height: 100%;
  479. i {
  480. font-weight: bold;
  481. margin: 14px 0;
  482. font-size: 24px;
  483. }
  484. }
  485. }
  486. p {
  487. margin: 5px 0px;
  488. }
  489. }
  490. </style>