ソースを参照

Merge branch 'develop3.0-tmd' of http://106.12.23.251:10080/TEAMMODEL/TEAMModelOS into develop3.0-tmd

liqk 4 年 前
コミット
5ec0f8091b

+ 4 - 3
TEAMModelOS/ClientApp/src/components/student-web/EventView/EventContentTypeTemplate/PaperTest.vue

@@ -78,7 +78,7 @@
                         <div class="que-item" v-if="getQue(queNo).type != 'compose' && getQue(queNo).parent == undefined">
                             <span>{{ queNo +1 }}.</span>
                             <!--题目渲染-->
-                            <div v-html="getQue(queNo).question"></div>
+                            <div id="answer-box" v-html="getQue(queNo).question"></div>
                         </div>
                         <!--综合题-->
                         <div v-if="getQue(queNo).type == 'compose' || getQue(queNo).parent != undefined">
@@ -98,7 +98,7 @@
                                 <div class="que-content">
                                     <span style="width:40px">{{ getQue(queNo).paperIndex}}:</span>
                                     <!--题目渲染-->
-                                    <div class="que-items" v-html="getQue(queNo).question"></div>
+                                    <div class="que-items" id="answer-box" v-html="getQue(queNo).question"></div>
                                 </div>
                             </div>
                         </div>
@@ -171,7 +171,7 @@
                         <Icon type="ios-arrow-back" />上一题
                     </button>
                     <button @click="nextQ()"
-                           v-show="queNo != (examInfo.length-1)"
+                            v-show="queNo != (examInfo.length-1)"
                             :class="{ hintClick:queNo != (examInfo.length-1) && checkers[queNo] != ''}">
                         下一题
                         <Icon type="ios-arrow-forward" />
@@ -189,6 +189,7 @@
             <img @click.stop="imgPreview.show = true" :src="imgPreview.img" />
         </div>
     </div>
+
 </template>
 
 <script>

+ 51 - 14
TEAMModelOS/ClientApp/src/components/student-web/EventView/EventContentTypeTemplate/composePaper.vue

@@ -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

+ 2 - 27
TEAMModelOS/ClientApp/src/utils/editorTools.js

@@ -62,29 +62,6 @@ export default {
 		]
 	},
 	
-	/* 初始化自定义富文本简版配置项 */
-	initStuSimpleEditor(editor) {
-		editor.config.uploadImgMaxSize = 2 * 1024 * 1024 // 2M
-		editor.config.uploadImgShowBase64 = true;
-		editor.config.uploadImgMaxLength = 5 // 一次最多上传 5 个图片
-		editor.config.showLinkImg = false
-		editor.config.showFullScreen = false
-		// 配置菜单栏,删减菜单,调整顺序
-		editor.config.menus = [
-			'bold',
-			'italic',
-			'underline',
-			'indent',
-			'link',
-			'list',
-			'quote',
-			'image',
-			'table',
-			'splitLine',
-			'connector'
-		]
-	},
-
 	/* 添加自定义本地视频上传功能 */
 	addVideoUpload(vm, editor) {
 		this.addFormula(vm,editor)
@@ -392,8 +369,6 @@ export default {
 		editor.config.menus = editor.config.menus.concat(canvasDraw);
 	},
 
-	
-	
 	/* 添加公式编辑器功能 */
 	addFormula(vm,editor){
 		// 获取必要的变量,这些在下文中都会用到
@@ -432,7 +407,7 @@ export default {
 		editor.config.menus = editor.config.menus.concat(videoUpload);
 	},
 	
-	/* 添加公式编辑器功能 */
+	/* 添加学生端画板自定义功能 */
 	addStuBgBtn(vm,editor){
 		// 获取必要的变量,这些在下文中都会用到
 		const {
@@ -463,7 +438,7 @@ export default {
 		
 		// 将菜单加入到 editor.config.menus 中
 		// 也可以通过配置 menus 调整菜单的顺序,参考【配置菜单】部分的文档
-		editor.config.menus = editor.config.menus.concat(videoUpload);
+		//editor.config.menus = editor.config.menus.concat(videoUpload);
 	},
 	
 	/* 移除上传的音视频富文本src中的HOST */

+ 4 - 1
TEAMModelOS/ClientApp/src/view/evaluation/components/BaseCreateChild.vue

@@ -196,6 +196,9 @@
 			
 			onSelectPoints(){
 				if(this.hasSchool){
+					console.log(this.schoolInfo)
+					console.log(this.curPeriodIndex)
+					console.log(this.curSubjectIndex)
 					this.selectPointsModal = true
 				}else{
 					this.$Message.warning('您当前未加入学校,无法选择知识点!')
@@ -475,7 +478,7 @@
 
 				this.childList = editItem.children || [];
 				let schoolInfo = await this.$store.dispatch('user/getSchoolProfile');
-				this.schoolInfo = schoolInfo;
+				this.schoolInfo = schoolInfo.school_base;
 
 				this.stemContent = editItem.question;
 				this.relateFileList = editItem.repairResource || [];

+ 1 - 1
TEAMModelOS/ClientApp/src/view/evaluation/components/BaseEditExercise.vue

@@ -660,7 +660,7 @@
 
 			// 提取富文本内容中的文本
 			getSimpleText(html) {
-				var r = /<[^>]*>|/g;
+				var r = /<(?!img|video|audio).*?>/g;
 				return html.replace(r, "");
 			},
 			// 排除对象空属性

+ 2 - 2
TEAMModelOS/Controllers/Core/CoreController.cs

@@ -80,12 +80,12 @@ namespace TEAMModelOS.Controllers.Core
                     }
                     else
                     {
-                        respons.Add(new { base64 = obase64, blob = "" }); //異常的圖片,原Base64返回
+                        respons.Add(new { base64 = item.base64, blob = "" }); //異常的圖片,原Base64返回
                     }
                 }
                 else
                 {
-                    respons.Add(new { base64 = obase64, blob = "" }); //不符合的圖片,原Base64返回
+                    respons.Add(new { base64 = item.base64, blob = "" }); //不符合的圖片,原Base64返回
                 }
             }
             return Ok(respons);