Browse Source

Merge branch 'develop3.0-tmd' into develop3.0

JAELYS 4 years ago
parent
commit
af8ab776cc

+ 124 - 126
TEAMModelFunction/MonitorCosmosDB.cs

@@ -6,9 +6,7 @@ using System.Threading.Tasks;
 using Azure.Cosmos;
 using Microsoft.Azure.Documents;
 using Microsoft.Azure.WebJobs;
-using Microsoft.Azure.WebJobs.Host;
 using Microsoft.Extensions.Logging;
-using TEAMModelOS.Models.CommonInfo;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 
@@ -16,14 +14,14 @@ namespace TEAMModelFunction
 {
     public class MonitorCosmosDB
     {
+        private readonly IHttpClientFactory _clientFactory;
         private readonly AzureCosmosFactory _azureCosmos;
-        private readonly DingDing _dingDing;
 
-        public MonitorCosmosDB( IHttpClientFactory clientFactory,AzureCosmosFactory azureCosmos,DingDing dingDing)
+        public MonitorCosmosDB(IHttpClientFactory clientFactory, AzureCosmosFactory azureCosmos)
         {
+            _clientFactory = clientFactory;
             _azureCosmos = azureCosmos;
-            _dingDing = dingDing;
-    }
+        }
 
         [FunctionName("School")]
         public async Task School([CosmosDBTrigger(
@@ -32,156 +30,156 @@ namespace TEAMModelFunction
             ConnectionStringSetting = "CosmosConnection",
             LeaseCollectionName = "leases")]IReadOnlyList<Document> input, ILogger log)
         {
-            try {
-                var client = _azureCosmos.GetCosmosClient();
-                List<ExamInfo> exams = new List<ExamInfo>();
-                string pk = input[0].GetPropertyValue<string>("pk");
-                if (!string.IsNullOrEmpty(pk) && pk.Equals("Exam", StringComparison.OrdinalIgnoreCase))
+            if (input != null && input.Count > 0)
+            {
+                log.LogInformation("Documents modified " + input.Count);
+                log.LogInformation("First document Id " + input[0].Id);
+            }
+            //input[0]
+            var client = _azureCosmos.GetCosmosClient();
+            List<ExamInfo> exams = new List<ExamInfo>();
+            string pk = input[0].GetPropertyValue<string>("pk");
+            if (!string.IsNullOrEmpty(pk) && pk.Equals("Exam"))
+            {
+                string code = input[0].GetPropertyValue<string>("code");
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id = '{input[0].Id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"{code}") }))
                 {
-                    string code = input[0].GetPropertyValue<string>("code");
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id = '{input[0].Id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"{code}") }))
+                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                        if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                         {
-                            foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
-                            {
 
-                                exams.Add(obj.ToObject<ExamInfo>());
-                            }
+                            exams.Add(obj.ToObject<ExamInfo>());
                         }
                     }
-                    for (int i = 0; i < exams.Count; i++)
+                }
+                for (int i = 0; i < exams.Count; i++)
+                {
+                    List<ExamClassResult> examClassResults = new List<ExamClassResult>();
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId = '{exams[i].id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"{code}") }))
                     {
-                        List<ExamClassResult> examClassResults = new List<ExamClassResult>();
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId = '{exams[i].id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"{code}") }))
+                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                        if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                         {
-                            using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                            if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                            foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                             {
-                                foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
-                                {
-                                    examClassResults.Add(obj.ToObject<ExamClassResult>());
-                                }
+                                examClassResults.Add(obj.ToObject<ExamClassResult>());
                             }
                         }
-                        /*if (exams[i].startTime.CompareTo(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()) < 0 
-                            && exams[i].endTime.CompareTo(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()) > 0 )
-                        {*/
-                        if (examClassResults.Count < 0)
+                    }
+                    /*if (exams[i].startTime.CompareTo(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()) < 0 
+                        && exams[i].endTime.CompareTo(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()) > 0 )
+                    {*/
+                    if (examClassResults.Count < 0)
+                    {
+                        if (exams[i].progress.Equals("going"))
                         {
-                            if (exams[i].progress.Equals("going", StringComparison.OrdinalIgnoreCase))
-                            {
 
-                                //await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exams[i], exams[i].id.ToString(), new Azure.Cosmos.PartitionKey($"{exams[i].code}"));
-                                for (int j = 0; j < exams[i].subjects.Count; j++)
+                            //await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exams[i], exams[i].id.ToString(), new Azure.Cosmos.PartitionKey($"{exams[i].code}"));
+                            for (int j = 0; j < exams[i].subjects.Count; j++)
+                            {
+                                for (int k = 0; k < exams[i].targetClassIds.Count; k++)
                                 {
-                                    for (int k = 0; k < exams[i].targetClassIds.Count; k++)
+                                    ExamClassResult result = new ExamClassResult();
+                                    result.code = "ExamClassResult-" + exams[i].school;
+                                    result.examId = exams[i].id;
+                                    result.id = Guid.NewGuid().ToString();
+                                    result.subjectId = exams[i].subjects[j].id;
+                                    result.year = exams[i].year;
+                                    result.ttl = -1;
+                                    result.scope = exams[i].scope;
+                                    result.pk = typeof(ExamClassResult).Name;
+                                    result.info.id = exams[i].targetClassIds[k];
+                                    var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(exams[i].targetClassIds[k], new Azure.Cosmos.PartitionKey($"Class-{exams[i].school}"));
+                                    if (sresponse.Status == 200)
                                     {
-                                        ExamClassResult result = new ExamClassResult();
-                                        result.code = "ExamClassResult-" + exams[i].school;
-                                        result.examId = exams[i].id;
-                                        result.id = Guid.NewGuid().ToString();
-                                        result.subjectId = exams[i].subjects[j].id;
-                                        result.year = exams[i].year;
-                                        result.ttl = -1;
-                                        result.scope = exams[i].scope;
-                                        result.pk = typeof(ExamClassResult).Name;
-                                        result.info.id = exams[i].targetClassIds[k];
-                                        var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(exams[i].targetClassIds[k], new Azure.Cosmos.PartitionKey($"Class-{exams[i].school}"));
-                                        if (sresponse.Status == 200)
+                                        using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
+                                        Classroom classroom = json.ToObject<Classroom>();
+                                        result.info.name = classroom.name;
+                                        List<List<string>> ans = new List<List<string>>();
+                                        List<double> ansPoint = new List<double>();
+                                        foreach (double p in exams[i].papers[j].point)
                                         {
-                                            using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
-                                            Classroom classroom = json.ToObject<Classroom>();
-                                            result.info.name = classroom.name;
-                                            List<List<string>> ans = new List<List<string>>();
-                                            List<double> ansPoint = new List<double>();
-                                            foreach (double p in exams[i].papers[j].point)
-                                            {
-                                                ans.Add(new List<string>());
-                                                ansPoint.Add(0);
-                                            }
-                                            foreach (StudentSimple stu in classroom.students)
-                                            {
-                                                result.studentIds.Add(stu.id);
-                                                result.studentAnswers.Add(ans);
-                                                result.studentScores.Add(ansPoint);
-                                            }
+                                            ans.Add(new List<string>());
+                                            ansPoint.Add(0);
+                                        }
+                                        foreach (StudentSimple stu in classroom.students)
+                                        {
+                                            result.studentIds.Add(stu.id);
+                                            result.studentAnswers.Add(ans);
+                                            result.studentScores.Add(ansPoint);
                                         }
-                                        result.progress = exams[i].progress;
-                                        result.school = exams[i].school;
-                                        await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(result, new Azure.Cosmos.PartitionKey($"{result.code}"));
-
                                     }
+                                    result.progress = exams[i].progress;
+                                    result.school = exams[i].school;
+                                    await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(result, new Azure.Cosmos.PartitionKey($"{result.code}"));
+
                                 }
                             }
                         }
-                        if (exams[i].progress.Equals("finish", StringComparison.OrdinalIgnoreCase))
+                    }
+                    if (exams[i].progress.Equals("finish"))
+                    {
+                        for (int j = 0; j < exams[i].subjects.Count; j++)
                         {
-                            for (int j = 0; j < exams[i].subjects.Count; j++)
-                            {
-                                ExamResult result = new ExamResult();
-                                result.ttl = -1;
-                                result.pk = typeof(ExamResult).Name;
-                                result.code = "ExamResult-" + exams[i].school;
-                                result.school = exams[i].school;
-                                result.id = Guid.NewGuid().ToString();
-                                result.examId = exams[i].id;
-                                result.subjectId = exams[i].subjects[j].id;
-                                result.year = exams[i].year;
-                                result.paper = exams[i].papers[j];
-                                result.point = exams[i].papers[j].point;
-                                result.scope = exams[i].scope;
-                                result.name = exams[i].name;
-                                //result.time
+                            ExamResult result = new ExamResult();
+                            result.ttl = -1;
+                            result.pk = typeof(ExamResult).Name;
+                            result.code = "ExamResult-" + exams[i].school;
+                            result.school = exams[i].school;
+                            result.id = Guid.NewGuid().ToString();
+                            result.examId = exams[i].id;
+                            result.subjectId = exams[i].subjects[j].id;
+                            result.year = exams[i].year;
+                            result.paper = exams[i].papers[j];
+                            result.point = exams[i].papers[j].point;
+                            result.scope = exams[i].scope;
+                            result.name = exams[i].name;
+                            //result.time
 
-                                //人数总和
-                                int Count = 0;
-                                int m = 0;
-                                List<ClassRange> classRanges = new List<ClassRange>();
-                                foreach (ExamClassResult classResult in examClassResults)
+                            //人数总和
+                            int Count = 0;
+                            int m = 0;
+                            List<ClassRange> classRanges = new List<ClassRange>();
+                            foreach (ExamClassResult classResult in examClassResults)
+                            {
+                                //处理班级信息
+                                ClassRange range = new ClassRange();
+                                range.id = classResult.info.id;
+                                range.name = classResult.info.name;
+                                List<int> ran = new List<int>();
+                                int stuCount = classResult.studentIds.Count;
+                                Count += stuCount;
+                                if (m == 0)
                                 {
-                                    //处理班级信息
-                                    ClassRange range = new ClassRange();
-                                    range.id = classResult.info.id;
-                                    range.name = classResult.info.name;
-                                    List<int> ran = new List<int>();
-                                    int stuCount = classResult.studentIds.Count;
-                                    Count += stuCount;
-                                    if (m == 0)
-                                    {
-                                        ran.Add(0);
-                                        ran.Add(stuCount - 1);
-                                    }
-                                    else
-                                    {
-                                        ran.Add(Count - stuCount);
-                                        ran.Add(Count - 1);
-                                    }
-                                    m++;
-                                    range.range = ran;
-                                    classRanges.Add(range);
-                                    //处理学生ID
-                                    foreach (string id in classResult.studentIds)
-                                    {
-                                        result.studentIds.Add(id);
-                                    }
-                                    foreach (List<double> scores in classResult.studentScores)
-                                    {
-                                        result.studentScores.Add(scores);
-                                    }
+                                    ran.Add(0);
+                                    ran.Add(stuCount - 1);
+                                }
+                                else
+                                {
+                                    ran.Add(Count - stuCount);
+                                    ran.Add(Count - 1);
+                                }
+                                m++;
+                                range.range = ran;
+                                classRanges.Add(range);
+                                //处理学生ID
+                                foreach (string id in classResult.studentIds)
+                                {
+                                    result.studentIds.Add(id);
+                                }
+                                foreach (List<double> scores in classResult.studentScores)
+                                {
+                                    result.studentScores.Add(scores);
                                 }
-                                result.classes = classRanges;
-                                await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Common").CreateItemAsync(result, new Azure.Cosmos.PartitionKey($"ExamResult-{result.school}"));
                             }
+                            result.classes = classRanges;
+                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Common").CreateItemAsync(result, new Azure.Cosmos.PartitionKey($"ExamResult-{result.school}"));
                         }
                     }
                 }
-            } catch (Exception e) {
-                await _dingDing.SendBotMsg($"CosmosDB_common,School()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
-                return;
             }
-                     
         }
     }
 }

+ 3 - 6
TEAMModelFunction/ServiceBusTopic.cs

@@ -45,8 +45,7 @@ namespace TEAMModelFunction
                     await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"{code}"));
                 }
             } catch (Exception ex) {
-                await _dingDing.SendBotMsg($"ServiceBus,ExamBus()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
-                return;
+                await _dingDing.SendBotMsg($"ServiceBusㄛExamBus()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);               
             }
                               
         }
@@ -79,8 +78,7 @@ namespace TEAMModelFunction
                     }
                 }
             } catch (Exception ex){
-                await _dingDing.SendBotMsg($"ServiceBus,VoteBus()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
-                return;
+                await _dingDing.SendBotMsg($"ServiceBusㄛVoteBus()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);               
             }
                          
         }
@@ -108,8 +106,7 @@ namespace TEAMModelFunction
                 }
             }
             catch (Exception ex){
-                await _dingDing.SendBotMsg($"ServiceBus,VoteBus()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
-                return;
+                await _dingDing.SendBotMsg($"ServiceBusㄛVoteBus()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);                
             }                       
         }
     }

+ 6 - 0
TEAMModelOS/ClientApp/src/common/BaseSelectSchool.vue

@@ -126,6 +126,12 @@
 		font-family: '微軟正黑體', 'Heiti TC' !important;
 
 		.ivu-dropdown {
+			
+			.ivu-select-dropdown{
+				width: max-content;
+				width: -webkit-max-content;
+				left: -35%;
+			}
 
 			.ivu-dropdown-item:hover {
 				background: #83d7ff;

+ 1 - 1
TEAMModelOS/ClientApp/src/components/learnactivity/BaseVoteForm.vue

@@ -512,7 +512,7 @@
                         this.editInfo = null
                     }
                 },
-                deep: true,
+                // deep: true,
 				// immediate:true
             }
         }

+ 27 - 12
TEAMModelOS/ClientApp/src/components/questionnaire/BaseAddItem.vue

@@ -10,18 +10,21 @@
 				<span @click="addOption" class="btn-add-option" v-show="curType !== 'judge'">添加选项</span>
 			</p>
 			<div class="option-editors" id="optionEditors">
-				<div v-for="(item,index) in options" :key="index">
-					<div class="option-editor-wrap" v-show="(curType !== 'judge') || (curType === 'judge' && item < 2)">
-						<!-- 选项序号 -->
-						<div class="option-order">
-							<span>{{ index + 1 }}</span>
-							<span class="btn-delete" @click="deleteOption(index)" v-show="curType !== 'judge'">
-								<Icon type="md-trash" size="24" color="#fff" /></span>
+				<div v-if="options.length">
+					<div v-for="(item,index) in options" :key="index">
+						<div class="option-editor-wrap" v-show="(curType !== 'judge') || (curType === 'judge' && item < 2)">
+							<!-- 选项序号 -->
+							<div class="option-order">
+								<span>{{ index + 1 }}</span>
+								<span class="btn-delete" @click="deleteOption(index)" v-show="curType !== 'judge'">
+									<Icon type="md-trash" size="24" color="#fff" /></span>
+							</div>
+							<!-- 选项编辑器 -->
+							<div :ref="'singleOption' + item " style="text-align:left" class="option-editor" @click="optionClick(item)"></div>
 						</div>
-						<!-- 选项编辑器 -->
-						<div :ref="'singleOption' + item " style="text-align:left" class="option-editor" @click="optionClick(item)"></div>
 					</div>
 				</div>
+				
 			</div>
 		</div>
 
@@ -33,7 +36,7 @@
 		props: ['type','editItem'],
 		data() {
 			return {
-				options: [0,1,2,3],
+				options: [],
 				trueIndex: 0,
 				curType: '',
 				editInfo: {},
@@ -55,7 +58,11 @@
 		},
 		methods: {
 			initEditors() {
-				this.optionEditors = []
+				console.log(this.optionEditors.length)
+				// this.optionEditors = []
+				console.log('进了initEditors')
+				console.log(this.options)
+				console.log(this.optionsContent)
 				// Editor默认配置
 				if (this.options.length > 0) {
 					this.$nextTick(() => {
@@ -157,6 +164,8 @@
 			// 置空内容
 			resetContent(){
 				this.options = [0,1,2,3]
+				this.optionsContent = []
+				this.stemContent = []
 				this.stemEditor.txt.clear()
 				this.optionEditors.forEach(i => {
 					i.txt.clear()
@@ -184,14 +193,20 @@
 			}
 			stemEditor.create()
 			this.stemEditor = stemEditor
-			this.initEditors()
+			this.$nextTick(() => {
+			    this.initEditors()
+			})
 		},
 		watch: {
 			type: {
 				handler(newValue) {
 					if (!newValue) return
 					this.curType = newValue
+					this.options = newValue === 'judge' ? [0,1] : [0,1,2,3]
 					this.optionsContent = []
+					this.$nextTick(() => {
+					    this.initEditors()
+					})
 				}
 			},
 			editItem: {

+ 213 - 0
TEAMModelOS/ClientApp/src/components/questionnaire/BaseAddSingle.vue

@@ -0,0 +1,213 @@
+<template>
+	<div>
+		<div class="exersices-box">
+			<p class="title">题干</p>
+			<!-- 题干富文本 -->
+			<div ref="singleEditor" style="text-align:left"></div>
+			<!-- 选项富文本 -->
+			<p class="title">
+				<span>选项</span>
+				<span @click="addOption" class="btn-add-option" v-show="curType !== 'judge'">添加选项</span>
+			</p>
+			<div class="option-editors" id="optionEditors">
+				<div v-for="(item,index) in options" :key="index" :class="'editor-wrap-'+item" style="margin-top:10px;display:flex">
+				    <span class="fl-center option-editor-wrap">{{String.fromCharCode(64 + parseInt(index+1))}}</span>
+				    <div :ref="'singleOption'+item" style="text-align:left" class="option-editor" @click="optionClick(item)"></div>
+				</div>
+			</div>
+			
+			
+		</div>
+
+	</div>
+</template>
+<script>
+	import E from '@/utils/wangEditor.js'
+	export default {
+		props: ['type','editItem'],
+		data() {
+			return {
+				options: [0,1,2,3],
+				trueIndex: 0,
+				curType: '',
+				editInfo: {},
+				stemEditor: null,
+				stemContent: '',
+				optionsContent: [],
+				optionEditors:[],
+				existEditors:[],
+				defaultConfig: {
+					uploadImgServer: '/api/file/uploadWangEditor', // 图片上传地址
+					showLinkImg: false, // 是否展示网络图片链接上传
+					uploadFileName: 'files', // 上传图片后台获取的文件名
+					menus: this.$tools.wangEditorMenu
+				}
+			}
+		},
+		created() {
+			
+		},
+		methods: {
+			initEditors() {
+			    // Editor默认配置
+			    if (this.options.length > 0) {
+			        this.options.forEach((item, i) => {
+			            let that = this
+			            let editor = new E(that.$refs['singleOption' + i][0])
+			            editor.customConfig = this.defaultConfig
+						editor.customConfig.uploadVideoDisable = true,
+						// editor.customConfig.zIndex = 100
+			
+			            // 选项编辑器失焦隐藏工具栏
+			            editor.customConfig.onblur = function () {
+			                let allToolbars = document.getElementsByClassName('option-editor')
+			                for (let i = 0; i < allToolbars.length; i++) {
+			                    if (allToolbars[i].children.length) {
+			                        allToolbars[i].children[0].style.visibility = 'hidden'
+			                    }
+			                }
+			            }
+						
+						editor.customConfig.onVideoWarning = (text) => {
+							this.$Message.warning(text)
+						},
+			
+			            // 选项编辑器内容发生变化时
+			            editor.customConfig.onchange = (html) => {
+			                let key = String.fromCharCode(64 + parseInt(i + 1))
+			                let codeArr = this.optionsContent.map(item => item.code)
+			                // 如果已经编辑过则 修改选项内容
+			                if (codeArr.indexOf(key) !== -1) {
+			                    this.optionsContent[codeArr.indexOf(key)].value = html
+			                } else { // 否则创建新选项
+			                    let option = {
+			                        code: key,
+			                        value: html
+			                    }
+			                    this.optionsContent.push(option)
+			                }
+			            }
+			            editor.create()
+			
+			            // 如果是编辑状态 则将选项内容回显
+			            if (this.editItem && Object.keys(this.editItem).length > 0) {
+			            	editor.txt.html(this.editItem.option[i].value)
+			            }
+			        })
+			    }
+			},
+			// 添加选项
+			addOption() {
+				let that = this
+				let newIndex = parseInt(this.options[this.options.length - 1]) + 1
+				let optionsLength = this.options.length
+				if (optionsLength < 9) {
+					this.options.push(newIndex)
+					this.$nextTick(() => {
+						let editor = new E(that.$refs['singleOption' + newIndex][0])
+						editor.customConfig = this.defaultConfig
+
+						editor.customConfig.onchange = (html) => {
+							let key = String.fromCharCode(64 + parseInt(newIndex + 1))
+							let codeArr = this.optionsContent.map((item,index) => String.fromCharCode(64 + parseInt(index + 1)))
+							// 如果已经编辑过则 修改选项内容
+							if (codeArr.indexOf(key) !== -1) {
+								this.optionsContent[codeArr.indexOf(key)].value = html
+							} else { // 否则创建新选项
+								let option = {
+									code: key,
+									value: html
+								}
+								this.optionsContent.push(option)
+							}
+							console.log(this.optionsContent)
+						}
+						editor.create()
+					})
+				} else {
+					this.$Message.warning('最多只有9个选项!')
+				}
+			},
+			// 删除选项
+			deleteOption(index) {
+				console.log(index)
+				if (this.options.length > 2) {
+					this.options.splice(index, 1)
+					this.optionsContent.splice(index, 1)
+				} else {
+					this.$Message.warning('至少保留两个选项!')
+				}
+			},
+			// 模拟选项聚焦事件
+			optionClick(index) {
+				let allToolbars = document.getElementsByClassName('option-editor')
+				let that = this
+				for (let i = 0; i < allToolbars.length; i++) {
+					allToolbars[i].children[0].style.visibility = 'hidden'
+				}
+				setTimeout(function() {
+					let currentToolBar = that.$refs['singleOption' + index][0].children[0]
+					currentToolBar.style.visibility = 'visible'
+				}, 100)
+			},
+			// 置空内容
+			resetContent(){
+				this.options = [0,1,2,3]
+				this.stemEditor.txt.clear()
+				this.optionEditors.forEach(i => {
+					i.txt.clear()
+				})
+				
+			},
+			
+			// 渲染编辑试题的内容
+			doRender(item){
+				let newValue = JSON.parse(JSON.stringify(item))
+				this.stemEditor.txt.html(newValue.question)
+				this.stemContent = newValue.question
+				this.optionsContent = newValue.option
+				this.options = newValue.option.map((item, index) => index)
+				this.$nextTick(() => {
+				    this.initEditors()
+				})
+			}
+		},
+		mounted() {
+			let stemEditor = new E(this.$refs.singleEditor)
+			stemEditor.customConfig = this.defaultConfig
+			stemEditor.customConfig.onchange = (html) => {
+				this.stemContent = html
+			}
+			stemEditor.create()
+			this.stemEditor = stemEditor
+			// this.$nextTick(() => {
+			//     this.initEditors()
+			// })
+		},
+		watch: {
+			type: {
+				handler(newValue) {
+					if (!newValue) return
+					this.curType = newValue
+					this.options = [0,1,2,3]
+					this.optionsContent = []
+					this.$nextTick(() => {
+					    this.initEditors()
+					})
+				}
+			},
+			editItem: {
+				handler(newValue) {
+					if (!newValue) return
+					this.doRender(newValue)
+				},
+				
+			}
+
+		}
+	}
+</script>
+
+<style lang="less">
+	@import "./BaseAddItem.less";
+</style>

+ 2 - 1
TEAMModelOS/ClientApp/src/components/questionnaire/BaseQuestionnaire.vue

@@ -145,6 +145,7 @@
 				let addItem = this.$refs.addItem
 				console.log('新增Ref的内容')
 				console.log(addItem)
+				console.log(addItem.optionsContent.map(i => i.value))
 				// 判断获取到的新题是否规范
 				if ( this.getSimpleText(addItem.stemContent) && (addItem.options.length === this.curType === 'judge' ? 2 : addItem.optionsContent.length) && this.checkOptionNull(addItem.optionsContent)){
 					let newItem = {
@@ -194,7 +195,7 @@
 			/* 编辑单个题目 */
 			onItemEdit(item, index) {
 				if(this.editIndex === index){
-					this.$refs.addItem.doRender(item)
+					// this.$refs.addItem.doRender(item)
 				}else{
 					this.curItem = item
 					this.editIndex = index

+ 3 - 0
TEAMModelOS/ClientApp/src/view/evaluation/types/BaseMultiple.vue

@@ -63,6 +63,9 @@
                             }
                         }
                     }
+					editor.customConfig.onVideoWarning = (text) => {
+						this.$Message.warning(text)
+					},
                     editor.customConfig.onchange = (html) => {
                         let key = String.fromCharCode(64 + parseInt(i + 1))
                         let codeArr = this.optionsContent.map(item => item.code)