SanHQin 1 år sedan
förälder
incheckning
89b79b1399

+ 18 - 0
src/components/pages/test/add/edit/edit/index.vue

@@ -153,6 +153,24 @@ export default {
 			// if(this.manualJson.filter(i=>i.type==6).length>=1){
 			// 	return this.$message.error("一个表单只能添加一个课程组件");
 			// }
+			function checkType(obj){
+				if(obj.filter(i=>i.array).length>0){
+					let bol = false;
+					obj.forEach(i=>{
+						console.log(i.array)
+						if(bol)return;
+						bol = checkType(i.array);
+					})
+					return bol;
+				}else if(obj.filter(i=>i.type==6).length>=1){
+					return true;
+				}else{
+					return false;
+				}
+			}
+			if(topicType == 6 && checkType(this.manualJson)){
+				return this.$message.error("一个表单只能添加一个课程组件");
+			}
       if (this.manualJson.length > 0) {
         for (var i = 0; i < this.manualJson.length; i++) {
           if (this.manualJson[i].ttype == 2) {

+ 18 - 0
src/components/pages/test/add/setInfo/manualCreated.vue

@@ -139,6 +139,24 @@ export default {
 			// if(this.checkJson.filter(i=>i.type==6).length>=1){
 			// 	return this.$message.error("一个表单只能添加一个课程组件");
 			// }
+			function checkType(obj){
+				if(obj.filter(i=>i.array).length>0){
+					let bol = false;
+					obj.forEach(i=>{
+						console.log(i.array)
+						if(bol)return;
+						bol = checkType(i.array);
+					})
+					return bol;
+				}else if(obj.filter(i=>i.type==6).length>=1){
+					return true;
+				}else{
+					return false;
+				}
+			}
+			if(this.topicType == 6 && checkType(this.checkJson)){
+				return this.$message.error("一个表单只能添加一个课程组件");
+			}
       if (this.checkJson.length > 0) {
         for (var i = 0; i < this.checkJson.length; i++) {
           if (this.checkJson[i].ttype == 2) {