SanHQin 1 سال پیش
والد
کامیت
e1e1eab447

+ 6 - 3
src/components/pages/test/add/components/course/courseDilog.vue

@@ -6,7 +6,7 @@
         </div>
         <span slot="footer" class="dialog-footer">
             <el-button @click="close()">关 闭</el-button>
-            <el-button @click="close()" type="primary">确 定</el-button>
+            <el-button @click="submit()" type="primary">确 定</el-button>
         </span>
     </el-dialog>
 </template>
@@ -60,11 +60,14 @@ export default {
                 this.courseArray.push(newValue)
 
             }
-            this.$emit("setCourse", this.courseArray)
         },
         close() {
             this.$emit("update:dialogVisibleCourse", false);
-        }
+        },
+				submit(){
+					this.$emit("setCourse", this.courseArray);
+					this.close()
+				}
     }
 };
 </script>

+ 2 - 2
src/components/pages/test/add/components/course/courseIndex.vue

@@ -194,11 +194,11 @@
                 <div class="kc_time">{{ item.time }}</div>
               </div> -->
               <div class="bottom_box">
-                <!-- <div>
+                <div>
                   <el-tooltip :content="item.title" popper-class="text_tooltip" placement="top" effect="dark">
                     <span>{{ item.title }}</span>
                   </el-tooltip>
-                </div> -->
+                </div>
                 <!-- v-if="item.isCourseType == 2 || groupA == 1" -->
                 <div class="kc_t">
                   <span>{{ item.uname }}</span>

+ 69 - 6
src/components/pages/test/add/components/course/index.vue

@@ -14,9 +14,16 @@
             </div>
             <div class="set_title" style="flex-direction: column;">
                 <div @click="openCourse" class="setting">设置课程选择范围</div>
-                <div>
-                    <div>cid</div>
-                    <div>cid</div>
+								<!-- {{courses}} -->
+                <div class="set_title_list">
+                    <div v-for="(item,index) in courses" class="set_title_list_item">
+											<!-- {{ `课程名称:${item.title}     创建人:${item.username}`}} -->
+											<div class="set_title_list_itemBtn el-icon-remove-outline" @click.stop="delCourse(item)"></div>
+											<div class="set_title_list_itemLabel">
+												<span>课程名称:{{ coursesList.find(i=>i.courseId==item).title }}</span>
+												<span>创建人:{{ coursesList.find(i=>i.courseId==item).username }}</span>
+											</div>
+										</div>
                 </div>
             </div>
         </div>
@@ -46,7 +53,8 @@ export default {
             ],
             checkJson: {},
             dialogVisibleCourse:false,
-            courses: []
+            courses: [],
+						coursesList:[],
         }
     },
     directives: {
@@ -70,7 +78,22 @@ export default {
                 this.$emit("setJson", newVal)
             },
             deep: true
-        }
+        },
+				courses(newValue){
+					let result = [];
+					newValue.forEach(async (item,index)=>{
+						let params = {
+							cid: item
+						}
+
+						let data = await this.ajax.get(this.$store.state.api + 'getCourseInfoTest',params);
+						console.log(data)
+						result.push(data.data[0][0]);
+						if(result.length-1==index){
+							this.coursesList = result;
+						}
+					})
+				}
     },
     methods: {
         depthCopy(s) {
@@ -97,7 +120,12 @@ export default {
             this.checkJson.courses = courses
             this.courses = courses
             this.$forceUpdate()
-        }
+        },
+				// 删除课程
+				delCourse(cid){
+					let index = this.courses.findIndex(i=>i==cid);
+					this.courses.splice(index,1)
+				}
     },
     mounted() {
         console.log(1);
@@ -225,4 +253,39 @@ export default {
     background-size: 100% 100%;
     margin-right: 5px;
 }
+
+.set_title_list_item{
+	display: flex;
+	align-items: center;
+	width: auto;
+	height: 40px;
+	margin-bottom: 20px;
+	border-radius: 10px;
+	padding: 0 20px
+}
+
+.set_title_list_item:hover{
+	background-color: #d4dde1;
+}
+
+.set_title_list_item:hover>.set_title_list_itemBtn{
+	opacity: 1;
+}
+
+.set_title_list_itemBtn{
+	font-size: 18px;
+	margin-right: 20px;
+	cursor: pointer;
+	opacity: 0;
+}
+
+.set_title_list_itemLabel{
+	display: flex;
+	align-items: center;
+}
+
+.set_title_list_itemLabel>span{
+	margin-right: 20px;
+}
+
 </style>

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

@@ -150,6 +150,9 @@ export default {
     },
     addCheck(topicType) {
       let type = 1;
+			if(this.manualJson.filter(i=>i.type==6).length>=1){
+				return this.$message.error("一个表单只能添加一个课程组件");
+			}
       if (this.manualJson.length > 0) {
         for (var i = 0; i < this.manualJson.length; i++) {
           if (this.manualJson[i].ttype == 2) {
@@ -159,6 +162,7 @@ export default {
           }
         }
       }
+
       if (this.checkC) {
         let _check = this.checkC.replace("x", "").split("-");
         let _json = this.manualJson[_check[0]];

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

@@ -118,6 +118,9 @@ export default {
         this.$message.error("请填写数字");
         this.number = "";
       }
+			if(this.topicType==6){
+				this.number = 1;
+			}
     },
     changeJson(json) {
       this.checkJson = json;
@@ -133,6 +136,9 @@ export default {
         return;
       }
       let type = 1;
+			if(this.checkJson.filter(i=>i.type==6).length>=1){
+				return this.$message.error("一个表单只能添加一个课程组件");
+			}
       if (this.checkJson.length > 0) {
         for (var i = 0; i < this.checkJson.length; i++) {
           if (this.checkJson[i].ttype == 2) {