PaperPreview.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <div class="preview_container">
  3. <el-card>
  4. <div class="paper_header">
  5. <div class="paper_title">{{ paperName }}</div>
  6. <div class="operation">
  7. <div class="shoucan">
  8. <div v-if="collectFlag" class="fx-row ai-center" @click="cancelCollect()">
  9. <img src="@/assets/images/icon_shoucang_s.png" alt=""/>
  10. <span class="sc_text">已收藏</span>
  11. </div>
  12. <div v-else @click="Collect()" class="fx-row ai-center">
  13. <img src="@/assets/images/icon_shoucang_n.png" alt=""/>
  14. <span class="sc_text">收藏</span>
  15. </div>
  16. <span class="btn" @click="paperDownLoad(paperId)">下载试卷</span>
  17. </div>
  18. </div>
  19. </div>
  20. <!-- 题目 -->
  21. <div class="paper_questions" id="question_list">
  22. <div class="que_item" v-for="(item, index) in opticList" :key="item.id">
  23. <div class="que_content" style="display: flex">
  24. <div>{{ index + 1 }}.</div>
  25. <span v-html="item.title"></span>
  26. </div>
  27. <div class="option-list">
  28. <span v-html="'A&nbsp'+item.optionA" v-if="item.optionA != ''"></span>
  29. <span v-html="'B&nbsp'+item.optionB" v-if="item.optionB != ''"></span>
  30. <span v-html="'C&nbsp'+item.optionC" v-if="item.optionC != ''"></span>
  31. <span v-html="'D&nbsp'+item.optionD" v-if="item.optionD != ''"></span>
  32. </div>
  33. <div class="subQueBox" v-if="item.issub == 1 && item.subquestions != null">
  34. <div class="subQueItem" v-for="(item,index) in item.subquestions" :key="index" v-html="item.title">
  35. </div>
  36. </div>
  37. <div class="que_footer">
  38. <div class="spans">
  39. <span class="id">ID: {{ item.id }}</span>
  40. <span>题型: {{ item.qtpye }}</span>
  41. <span>难度: 一般</span>
  42. </div>
  43. <div class="operation">
  44. <div class="shoucan">
  45. <div v-show="item.collect" @click="toCancelCollectQue(item)" style="display: flex;align-items: center;">
  46. <img src="@/assets/images/icon_shoucang_s.png" alt=""/>
  47. <span>已收藏</span>
  48. </div>
  49. <div v-show="!item.collect" @click="toCollectQue(item)" style="display: flex;align-items: center;">
  50. <img src="@/assets/images/icon_shoucang_n.png" alt=""/>
  51. <span>收藏</span>
  52. </div>
  53. </div>
  54. <div class="jiucuo mr20" @click="$refs.correct.open(item.id)">
  55. <img src="@/assets/images/icon_jiucuo.png" alt=""/>
  56. <span>纠错</span>
  57. </div>
  58. <div class="detail" @click="handleParseVisible(item)">
  59. <img src="@/assets/images/icon_chakan.png" alt=""/>
  60. <span>查看详情>></span>
  61. </div>
  62. </div>
  63. </div>
  64. <!-- NOTE: 改v-if否则全部公式渲染太费时间 -->
  65. <div :id="`question_parse_${item.id}`" v-if="item.updateTime" class="info">
  66. <div v-html="'【解答】'+item.answer2" class="mb20"></div>
  67. <div v-html="'【解析】'+item.parse"></div>
  68. </div>
  69. </div>
  70. </div>
  71. </el-card>
  72. <correct-question ref="correct"></correct-question>
  73. </div>
  74. </template>
  75. <script>
  76. import {
  77. downloadRealPaper,
  78. isCollected,
  79. papersCancelCollect,
  80. papersCollect,
  81. preview,
  82. queCancelCollect,
  83. queCollect
  84. } from '@/api/webApi/webQue.js'
  85. import { mapGetters } from 'vuex'
  86. import correctQuestion from '../../components/MxPaper/plus/correct-question-dialog.vue'
  87. export default {
  88. components: { correctQuestion },
  89. data() {
  90. return {
  91. collectFlag: false,
  92. paperId: 0,
  93. paperName: '',
  94. opticList: []
  95. }
  96. },
  97. computed: {
  98. ...mapGetters(['period'])
  99. },
  100. created() {
  101. this.paperId = this.$route.query.paperId
  102. this.paperName = this.$route.query.paperName
  103. isCollected({ paperId: this.paperId }).then((res) => {
  104. console.log(res)
  105. this.collectFlag = res.data
  106. })
  107. this.getOptics()
  108. },
  109. methods: {
  110. getOptics() {
  111. preview({ paperId: this.paperId }).then((res) => {
  112. this.opticList = res.data
  113. setTimeout(_ => this.mxGlobal.MathQueue('question_list'))
  114. })
  115. },
  116. async handleParseVisible(item) {
  117. item.updateTime = !item.updateTime
  118. const parseEl = `question_parse_${item.id}`
  119. this.$nextTick(_ => this.mxGlobal.MathQueue(parseEl))
  120. },
  121. toCollectQue(item) {
  122. queCollect({ questionId: item.id }).then((res) => {
  123. item.collect = !item.collect
  124. this.msgSuccess('收藏成功')
  125. console.log(res)
  126. })
  127. },
  128. toCancelCollectQue(item) {
  129. queCancelCollect({ questionId: item.id }).then((res) => {
  130. item.collect = !item.collect
  131. this.msgSuccess('取消收藏成功')
  132. console.log(res)
  133. })
  134. },
  135. cancelCollect() {
  136. papersCancelCollect({ paperId: this.paperId }).then((res) => {
  137. this.collectFlag = false
  138. this.msgSuccess('取消收藏成功')
  139. })
  140. },
  141. Collect() {
  142. papersCollect({ paperId: this.paperId }).then((res) => {
  143. this.collectFlag = true
  144. this.msgSuccess('收藏成功')
  145. })
  146. },
  147. paperDownLoad(paperId) {
  148. downloadRealPaper(paperId, this.period)
  149. }
  150. }
  151. }
  152. </script>
  153. <style scoped>
  154. .preview_container {
  155. padding: 20px;
  156. }
  157. .paper_header {
  158. overflow: hidden;
  159. margin-bottom: 33px;
  160. }
  161. .paper_title {
  162. height: 25px;
  163. font-size: 18px;
  164. font-family: PingFangSC-Medium, PingFang SC;
  165. font-weight: 500;
  166. color: #292929;
  167. line-height: 25px;
  168. float: left;
  169. }
  170. .operation {
  171. float: right;
  172. }
  173. .shoucan {
  174. display: flex;
  175. align-items: center;
  176. margin-right: 53px;
  177. font-size: 14px;
  178. font-family: PingFangSC-Regular, PingFang SC;
  179. font-weight: 400;
  180. }
  181. .shoucan img {
  182. margin-right: 6px;
  183. cursor: pointer;
  184. }
  185. .shoucan .sc_text {
  186. color: #9f9f9f;
  187. line-height: 20px;
  188. cursor: pointer;
  189. margin-right: 28px;
  190. }
  191. .shoucan .btn {
  192. padding: 6px 20px;
  193. cursor: pointer;
  194. background: #47c6a2;
  195. color: white;
  196. border-radius: 4px;
  197. }
  198. .que_item {
  199. border-radius: 1px;
  200. border: 1px solid #dedede;
  201. margin-bottom: 8px;
  202. }
  203. .que_content {
  204. padding: 12px 24px 0 33px;
  205. font-size: 14px;
  206. font-family: PingFangSC-Medium, PingFang SC;
  207. font-weight: 500;
  208. color: #4c4c4c;
  209. line-height: 27px;
  210. margin-bottom: 10px;
  211. }
  212. .options {
  213. padding-left: 36px;
  214. font-size: 14px;
  215. font-family: PingFangSC-Regular, PingFang SC;
  216. font-weight: 400;
  217. color: #4c4c4c;
  218. line-height: 27px;
  219. border-bottom: 1px solid #dedede;
  220. }
  221. .options .option {
  222. margin-bottom: 10px;
  223. }
  224. .que_footer {
  225. border-top: 1px solid #dedede;
  226. padding-left: 33px;
  227. overflow: hidden;
  228. padding-bottom: 23px;
  229. padding-top: 21px;
  230. }
  231. .que_footer .spans {
  232. float: left;
  233. font-size: 12px;
  234. font-family: PingFangSC-Regular, PingFang SC;
  235. font-weight: 400;
  236. color: #979797;
  237. line-height: 20px;
  238. }
  239. .que_footer .spans > span {
  240. margin-right: 20px;
  241. }
  242. .operation {
  243. display: flex;
  244. align-items: center;
  245. font-size: 14px;
  246. font-family: PingFangSC-Regular, PingFang SC;
  247. font-weight: 400;
  248. color: #47c6a2;
  249. line-height: 20px;
  250. }
  251. .operation > div {
  252. display: flex;
  253. align-items: center;
  254. cursor: pointer;
  255. }
  256. .operation .shoucan {
  257. margin-right: 46px;
  258. }
  259. .operation .detail span {
  260. border-radius: 1px;
  261. border-bottom: 1px solid #47c6a2;
  262. }
  263. .operation .detail {
  264. margin-right: 32px;
  265. }
  266. .operation > div > img {
  267. margin-right: 10px;
  268. }
  269. .operation .addQue {
  270. padding: 7px;
  271. border-radius: 4px;
  272. border: 1px solid #979797;
  273. margin-right: 24px;
  274. }
  275. .info {
  276. padding: 12px 40px;
  277. }
  278. .option-list {
  279. display: flex;
  280. flex-direction: column;
  281. margin-bottom: 40px;
  282. font-size: 14px;
  283. }
  284. .option-list span {
  285. padding: 5px 40px;
  286. clear: both;
  287. }
  288. .subQueBox {
  289. padding: 5px 40px;
  290. }
  291. .subQueBox .subQueItem {
  292. margin-bottom: 10px;
  293. font-size: 14px;
  294. }
  295. </style>