Commit f3d1c4cebd62666118ef0777a88e3eb020a2c9a8
1 parent
7f592639
feat: 查看解析
Showing
2 changed files
with
102 additions
and
1 deletions
src/views/basic/askTestQuestion/components/analysisDialog.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <el-dialog | ||
| 3 | + :visible.sync="visible" | ||
| 4 | + width="50%" | ||
| 5 | + :before-close="handleClose" | ||
| 6 | + :modal-append-to-body="false" | ||
| 7 | + > | ||
| 8 | + <div class="test-box" v-if="analysisUrl"> | ||
| 9 | + <iframe | ||
| 10 | + :src="analysisUrl" | ||
| 11 | + ref="iframe" | ||
| 12 | + @load="onIFrameLoad()" | ||
| 13 | + style="width: 100%; border: none; /* 启用点击穿透 */" | ||
| 14 | + ></iframe> | ||
| 15 | + </div> | ||
| 16 | + | ||
| 17 | + <span slot="title" class="title"> 题目解析 </span> | ||
| 18 | + </el-dialog> | ||
| 19 | +</template> | ||
| 20 | + <script> | ||
| 21 | +export default { | ||
| 22 | + name: "analysisDialog", | ||
| 23 | + props: { | ||
| 24 | + visible: { | ||
| 25 | + type: Boolean, | ||
| 26 | + default() { | ||
| 27 | + return false; | ||
| 28 | + }, | ||
| 29 | + }, | ||
| 30 | + analysisUrl: { | ||
| 31 | + // 科目 | ||
| 32 | + type: String, | ||
| 33 | + default() { | ||
| 34 | + return null; | ||
| 35 | + }, | ||
| 36 | + }, | ||
| 37 | + }, | ||
| 38 | + data() { | ||
| 39 | + return {}; | ||
| 40 | + }, | ||
| 41 | + | ||
| 42 | + watch: { | ||
| 43 | + visible(val) { | ||
| 44 | + if (val) { | ||
| 45 | + console.log(val); | ||
| 46 | + } else { | ||
| 47 | + this.handleClose(); | ||
| 48 | + } | ||
| 49 | + }, | ||
| 50 | + }, | ||
| 51 | + methods: { | ||
| 52 | + /** 按钮 - 取消 */ | ||
| 53 | + handleClose() { | ||
| 54 | + this.$emit("update:visible", false); | ||
| 55 | + }, | ||
| 56 | + | ||
| 57 | + onIFrameLoad() { | ||
| 58 | + const iframeRef = this.$refs.iframe; // 获取对应的 iframe | ||
| 59 | + const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; | ||
| 60 | + const body = iframeRef.contentWindow.document.body; | ||
| 61 | + body.style.overflowX = "hidden"; // 不允许出现横向滚动条 | ||
| 62 | + const height = body.scrollHeight; // 获取内容的高度 | ||
| 63 | + iframeRef.style.height = `${height + 20}px`; // 设置 iframe 的高度 | ||
| 64 | + // 获取第一个P标签 | ||
| 65 | + const firstP = doc.getElementsByTagName("p")[0]; | ||
| 66 | + // 或者修改第一个 < p > 标签的内容; | ||
| 67 | + if (firstP) { | ||
| 68 | + let a = this.processString(firstP.innerHTML); | ||
| 69 | + firstP.innerHTML = a; | ||
| 70 | + } | ||
| 71 | + }, | ||
| 72 | + }, | ||
| 73 | +}; | ||
| 74 | +</script> | ||
| 75 | + <style lang="scss" scoped> | ||
| 76 | +.title { | ||
| 77 | + font-weight: 600; | ||
| 78 | +} | ||
| 79 | +.test-box { | ||
| 80 | + width: 100%; | ||
| 81 | + box-sizing: border-box; | ||
| 82 | + padding: 20px; | ||
| 83 | +} | ||
| 84 | +</style> | ||
| 0 | \ No newline at end of file | 85 | \ No newline at end of file |
src/views/basic/askTestQuestion/wrongQuestion.vue
| @@ -168,7 +168,10 @@ | @@ -168,7 +168,10 @@ | ||
| 168 | <!-- <div class="topic-info" v-html="item.modifiedHtml"></div> --> | 168 | <!-- <div class="topic-info" v-html="item.modifiedHtml"></div> --> |
| 169 | <div class="topic-bottom"> | 169 | <div class="topic-bottom"> |
| 170 | <div> | 170 | <div> |
| 171 | - <span v-if="item.answerScreenshot" class="knowledge size" | 171 | + <span |
| 172 | + v-if="item.answerScreenshot" | ||
| 173 | + class="knowledge size" | ||
| 174 | + @click="handleAnalysis(item.answerScreenshot)" | ||
| 172 | ><i class="el-icon-key"></i>查看解析</span | 175 | ><i class="el-icon-key"></i>查看解析</span |
| 173 | > | 176 | > |
| 174 | <span class="color size">知识点:</span> | 177 | <span class="color size">知识点:</span> |
| @@ -242,15 +245,21 @@ | @@ -242,15 +245,21 @@ | ||
| 242 | :gradeId="formData.grade" | 245 | :gradeId="formData.grade" |
| 243 | @setQuestions="setQuestions" | 246 | @setQuestions="setQuestions" |
| 244 | /> | 247 | /> |
| 248 | + <analysisDialog | ||
| 249 | + :visible.sync="analysisVisible" | ||
| 250 | + :analysisUrl="analysisUrl" | ||
| 251 | + /> | ||
| 245 | </div> | 252 | </div> |
| 246 | </template> | 253 | </template> |
| 247 | 254 | ||
| 248 | <script> | 255 | <script> |
| 249 | import { setDateRules } from "@/utils"; | 256 | import { setDateRules } from "@/utils"; |
| 250 | import wrongQuestionDialog from "./components/wrongQuestionDialog.vue"; | 257 | import wrongQuestionDialog from "./components/wrongQuestionDialog.vue"; |
| 258 | +import analysisDialog from "./components/analysisDialog.vue"; | ||
| 251 | export default { | 259 | export default { |
| 252 | components: { | 260 | components: { |
| 253 | wrongQuestionDialog, | 261 | wrongQuestionDialog, |
| 262 | + analysisDialog, | ||
| 254 | }, | 263 | }, |
| 255 | data() { | 264 | data() { |
| 256 | return { | 265 | return { |
| @@ -259,6 +268,8 @@ export default { | @@ -259,6 +268,8 @@ export default { | ||
| 259 | maxValue: 100, // 最大值 | 268 | maxValue: 100, // 最大值 |
| 260 | visible: false, // 购物车弹框控制 | 269 | visible: false, // 购物车弹框控制 |
| 261 | queryLoading: false, //loading | 270 | queryLoading: false, //loading |
| 271 | + analysisUrl: null, // 解析url | ||
| 272 | + analysisVisible: false, // 解析弹框 | ||
| 262 | // 分页 | 273 | // 分页 |
| 263 | listPage: { | 274 | listPage: { |
| 264 | page: 1, | 275 | page: 1, |
| @@ -597,6 +608,12 @@ export default { | @@ -597,6 +608,12 @@ export default { | ||
| 597 | setQuestions() { | 608 | setQuestions() { |
| 598 | this.questions = JSON.parse(localStorage.getItem("testlist")) || []; | 609 | this.questions = JSON.parse(localStorage.getItem("testlist")) || []; |
| 599 | }, | 610 | }, |
| 611 | + | ||
| 612 | + // 查看解析 | ||
| 613 | + handleAnalysis(url) { | ||
| 614 | + this.analysisUrl = url; | ||
| 615 | + this.analysisVisible = true; | ||
| 616 | + }, | ||
| 600 | }, | 617 | }, |
| 601 | }; | 618 | }; |
| 602 | </script> | 619 | </script> |