|
@@ -1,9 +1,16 @@
|
|
|
<template>
|
|
|
<div class="content">
|
|
|
- <div id="textArea"> </div>
|
|
|
+ <div id="textArea"> </div>
|
|
|
+ <Modal v-model="markStatus" fullscreen title="作答" footer-hide>
|
|
|
+
|
|
|
+ <BaseMyCanvas v-if="markStatus" :bgImg="markBg" @onCloseModal="closeModal" isStudent="markStatus" @onSaveCanvas="saveMark"></BaseMyCanvas>
|
|
|
+ </Modal>
|
|
|
+ <iframe style=" height: 0.1px; border: none;" id="answerIframe" :srcdoc="itemInfo.question"></iframe>
|
|
|
+
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
+ import html2canvas from 'html2canvas';
|
|
|
import E from 'wangeditor'
|
|
|
export default {
|
|
|
components: {
|
|
@@ -36,7 +43,9 @@
|
|
|
tabName: 'exercise',
|
|
|
editorContent: "",
|
|
|
examInfo: [],
|
|
|
- editor: null
|
|
|
+ editor: null,
|
|
|
+ markStatus: false,
|
|
|
+ markBg:""
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -48,6 +57,22 @@
|
|
|
this.editor.txt.html(this.examInfo[0])
|
|
|
}
|
|
|
},
|
|
|
+ closeModal() {
|
|
|
+ this.markStatus = false
|
|
|
+ this.markBg = ""
|
|
|
+ },
|
|
|
+ saveMark(data) {
|
|
|
+ if (data) {
|
|
|
+ data.height = 400
|
|
|
+ data.width = 400
|
|
|
+ let img = document.createElement('img')
|
|
|
+ img.src = data.base64
|
|
|
+ console.log(img)
|
|
|
+ this.editor.txt.html(img.outerHTML)
|
|
|
+ this.markStatus = false
|
|
|
+ }
|
|
|
+ console.log(data)
|
|
|
+ },
|
|
|
initEditor() {
|
|
|
this.editorContent = ""
|
|
|
this.editor = new E("#textArea");
|
|
@@ -61,20 +86,16 @@
|
|
|
"image", // 插入图片
|
|
|
]
|
|
|
this.editor.config.zIndex = 1
|
|
|
- //this.editor.config.linkImgCallback = function (url) {
|
|
|
- // //console.log(url); // url 即插入图片的地址
|
|
|
- //};
|
|
|
- //this.editor.config.linkCheck = function (text, link) {
|
|
|
- // //console.log(text); // 插入的文字
|
|
|
- // //console.log(link); // 插入的链接
|
|
|
- // return true; // 返回 true 表示校验成功
|
|
|
- //};
|
|
|
this.editor.config.placeholder = '请输入作答结果'
|
|
|
this.editor.config.height = 300
|
|
|
this.editor.config.showLinkImg = false;
|
|
|
this.editor.config.uploadImgShowBase64 = true; // 使用 base64 保存图片不建议使用这种,我只是图个方便
|
|
|
- // editor.customConfig.uploadImgServer = '/upload' // 上传图片到服务器
|
|
|
- this.$editorTools.addCanvas(this, this.editor)
|
|
|
+ if (this.itemInfo.type == 'correct' || this.itemInfo.type == 'connector') {
|
|
|
+ this.editor.config.menus.push('connector')
|
|
|
+ this.$editorTools.addStuBgBtn(this, this.editor)
|
|
|
+ } else {
|
|
|
+ this.$editorTools.addCanvas(this, this.editor)
|
|
|
+ }
|
|
|
this.editor.create();
|
|
|
if (this.close) {
|
|
|
this.editor.disable()
|
|
@@ -83,15 +104,31 @@
|
|
|
if (this.examInfo.length > 0) {
|
|
|
this.editor.txt.html(this.examInfo[0])
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ markStuAnswer() {
|
|
|
+ let answerIframe = document.getElementById('answerIframe')
|
|
|
+ let markBody = answerIframe.contentWindow.document.body
|
|
|
+ answerIframe.contentWindow.document.body.style.width = 'fit-content'
|
|
|
+ answerIframe.contentWindow.document.body.style.minWidth = '600px'
|
|
|
+ answerIframe.contentWindow.document.body.style.backgroundColor = '#f5f5f5'
|
|
|
+ html2canvas(answerIframe.contentWindow.document.body).then(canvas => {
|
|
|
+ this.markStatus = true
|
|
|
+ this.markBg = canvas.toDataURL("image/png");
|
|
|
+ })
|
|
|
+ },
|
|
|
},
|
|
|
mounted() {
|
|
|
this.initEditor()
|
|
|
this.getInfo()
|
|
|
+ // 监听富文本画板功能
|
|
|
+ this.$EventBus.$off('onStuCanvas')
|
|
|
+ this.$EventBus.$on('onStuCanvas', editor => {
|
|
|
+ this.markBg = ""
|
|
|
+ this.markStuAnswer()
|
|
|
+ })
|
|
|
},
|
|
|
watch: {
|
|
|
index() {
|
|
|
- console.log('试题信息',this.textData)
|
|
|
this.getInfo()
|
|
|
deep: true
|
|
|
immediate:true
|