11wqe1 1 bulan lalu
induk
melakukan
bdfb923191
1 mengubah file dengan 316 tambahan dan 48 penghapusan
  1. 316 48
      src/components/components/choseWorksDetailDialog.vue

+ 316 - 48
src/components/components/choseWorksDetailDialog.vue

@@ -879,6 +879,7 @@
                   </div>
 
                 </div>
+                
               </div>
             </div>
             <div class="s_b_m_b_item" v-if="showType === 1 && dialogTypeList[1].showType.includes(toolType)">
@@ -1135,6 +1136,53 @@
         </div>
       </div>
     </el-dialog>
+    <el-dialog
+      title="分组设置"
+      :visible.sync="dialogVisibleGroup2"
+      :append-to-body="true"
+      width="650px"
+      :before-close="handleClose"
+      class="dialog_diy"
+    >
+      <div class="groupBox">
+        <div v-if="groupJson2.group" class="groupContent">
+          <div class="groupTitle">请设置小组数量及名称</div>
+          <div
+            v-for="(item, index) in groupJson2.group"
+            :key="index"
+            class="groupName"
+          >
+            <span class="groupn">第{{ index + 1 }}组名称:</span>
+            <el-input
+              v-model="item.name"
+              placeholder="请输入名称..."
+              style="width: 250px"
+            ></el-input>
+            <!-- <div class="groupBtn">
+              <el-button type="primary" size="small" @click="addGroup(index)">
+                添加</el-button>
+              <el-button type="primary" size="small" @click="deleteGroup(index)"
+                v-if="groupJson2.group && groupJson2.group.length > 1">删除</el-button>
+            </div> -->
+          </div>
+        </div>
+        <div class="groupContent">
+          <div class="groupTitle">请设置每组人数</div>
+          <!-- <el-input v-model="groupJson.number" placeholder="2-10人以内"
+            style="width: 150px; margin: 10px 10px 0 0"></el-input> -->
+          <el-input
+            v-model="groupJson2.number"
+            style="width: 150px"
+            placeholder="请输入2-10的数字"
+            @change="numberPan"
+          ></el-input>
+        </div>
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="dialogVisibleGroup2 = false">取 消</el-button>
+        <el-button type="primary" @click="updateGroupJson">确定</el-button>
+      </span>
+    </el-dialog>
     <studentWorkPreviewDialog ref="studentWorkPreviewDialogRef" @close="studentPreviewClose"/>
   </div>
 </template>
@@ -1209,10 +1257,12 @@ export default {
   },
   data() {
     return {
+      chapInfoListData2:[],
       radioS:[], //提交作业数组容器
       questionsData:'', //提交作业字符串容器
       isShowList:[], //排序判断的显示容器
       islock:true,
+      tcid: this.$route.query.tcid,
       AIUrl:'',
       show: false,
       showType: 0,
@@ -1223,6 +1273,8 @@ export default {
       groupJson:[], //学生分组
       groupStudentUid:[], //学生分组
       groupStudent:[], //学生分组
+      groupJson2:{}, 
+      dialogVisibleGroup2:false,
       userId: this.$route.query.userid,
       courseId:this.$route.query.courseId,
       id: this.$route.query.courseId,
@@ -1505,6 +1557,41 @@ export default {
     }
   },
   watch: {
+    chapInfoListData:{
+      handler(newl){
+        
+        if (!this.show && this.toolType != 49) return
+        if (JSON.stringify(newl) != JSON.stringify(this.chapInfoListData2)) {
+          this.chapInfoListData2 = newl
+          
+          let _tempData = newl[this.courseType].chapterInfo[0]
+            .taskJson[this.taskCount].toolChoose[this.toolIndex];
+
+          this.testData = _tempData ? _tempData : null;
+
+          this.testJson = this.testData.testJson
+            ? this.testData.testJson.testJson
+            : null;
+
+
+            
+          this.groupJson = this.testData.groupJson;
+          this.islock = this.groupJson.islock == 1 ? true : false;
+          this.selectGroup()
+        }
+        
+      },
+      deep: true
+    },
+    groupStudentUid2:{
+      handler(newl){
+        if (!this.show) return
+
+        console.log('777');
+        
+      },
+      deep: true
+    },
     worksStudentData: {
       handler(newValue) {
 
@@ -1561,6 +1648,8 @@ export default {
     // 监视是否开启学生查看所有作业
     sIsOpen:{
       handler(newl,oldl){
+        if (!this.show) return
+
           let yym = JSON.parse(
             JSON.stringify(this.worksStudentData[this.toolIndex])
           );
@@ -1579,6 +1668,8 @@ export default {
     },
     noWorksSData: {
       handler(newValue) {
+        if (!this.show) return
+
         if (
           this.show &&
           this.toolIndex !== null &&
@@ -1595,6 +1686,44 @@ export default {
     }
   },
   methods: {
+    // 设置分组
+    updateGroupJson(){
+      for (var i = 0; i < this.groupStudentUid[this.toolIndex].length; i++) {
+        if (
+          this.groupStudentUid[this.toolIndex][i].length >
+          this.groupJson2.number
+        ) {
+          this.$message.error("已经有小组比你设置的人数多,请重新设置");
+          return;
+        }
+      }
+      this.groupJson = JSON.parse(JSON.stringify(this.groupJson2));
+      
+      this.chapInfoListData2[this.courseType].chapterInfo[0].taskJson[
+        this.taskCount
+      ].toolChoose[this.toolIndex].groupJson = this.groupJson;
+
+      
+      let params = [
+        {
+          cid: this.id,
+          chapters: JSON.stringify(this.chapInfoListData2),
+          uid: this.userId,
+          unitIndex: this.courseType,
+        },
+      ];
+      this.ajax
+        .post(this.$store.state.api + "updateWorkNew4", params)
+        .then((res) => {
+          this.$message.success("设置成功");
+          this.$emit('getCourseDetail',2)
+          this.$forceUpdate();
+        })
+        .catch((err) => {
+          this.$message.error("网络不佳");
+          console.error(err);
+        });
+    },
     // 提交英语写作作业
     addEnglishWork() {
       let myAnList ={}
@@ -1633,19 +1762,43 @@ export default {
           console.error(err);
         });
     },
-    lockChair(){
-      let a =  this.islock ? true : false
-
-      this.islock = JSON.parse(JSON.stringify(a))
-      console.log('this.islock',this.islock);
-
-    },
     updateGroup(){
-      console.log('testData estJson',this.testData);
-      console.log('groupStudent',this.groupStudent);
-
-      console.log('分组设置');
+      this.groupJson2 = JSON.parse(JSON.stringify(this.groupJson));
+      this.dialogVisibleGroup2 = true;
+    },
 
+    lockChair(){
+     
+     
+      this.groupJson2 = JSON.parse(JSON.stringify(this.groupJson));
+      this.groupJson2.islock = this.groupJson2.islock == 1 ? 2 : 1;
+      this.groupJson = JSON.parse(JSON.stringify(this.groupJson2));
+      this.islock = this.groupJson.islock == 1 ? true : false;
+
+      this.chapInfoListData2[this.courseType].chapterInfo[0].taskJson[
+        this.taskCount
+      ].toolChoose[this.toolIndex].groupJson = this.groupJson;
+
+      
+      let params = [
+        {
+          cid: this.id,
+          chapters: JSON.stringify(this.chapInfoListData2),
+          uid: this.userId,
+          unitIndex: this.courseType,
+        },
+      ];
+      this.ajax
+        .post(this.$store.state.api + "updateWorkNew4", params)
+        .then((res) => {
+          this.$message.success("设置成功");
+          this.$emit('getCourseDetail',2)
+          this.$forceUpdate();
+        })
+        .catch((err) => {
+          this.$message.error("网络不佳");
+          console.error(err);
+        });
     },
 
     // 加入分组前检查人员是否已经满了
@@ -1660,41 +1813,67 @@ export default {
         this.ajax
           .get(this.$store.state.api + "selectSWorks", params)
           .then((res) => {
-            var workS = res.data[3];
-            // 每组人数
-            let GroupSize = this.groupJson.number
 
-            // 当前组人数
-            let nowSize = 0
+            let groupStudent = []
+            let groupStudentUid = []
 
-            console.log('groupJson',this.groupJson);
+            let a = this.chapInfoListData[this.courseType].chapterInfo[0]
+            .taskJson[this.taskCount].toolChoose
+            var f = res.data[3];
 
-            console.log('workS',workS);
-
-            let classID = [];
-            if (this.classid != '') {
-              classID = this.classid.split(',')
+            if (this.tType == 2) {
+              this.tcid = this.classid
             }
-            console.log('classID',classID);
-
-            workS.forEach(e=>{
-              if (index == e.group) {
-                if (!e.classid || classID.length == 0) {
-                  let classID2 = e.classid.split(',')
-                  const result = this.hasOverlap(classID,classID2);
-                  if (result) {
-                    nowSize++
+
+
+            for (var i = 0; i < a.length; i++) {
+            
+              groupStudent[i] = [];
+              groupStudentUid[i] = [];
+
+
+              if (a[i].tool[0] == 49) {
+                for (var gA = 0; gA < a[i].groupJson.group.length; gA++) {
+                  groupStudent[i][gA] = [];
+                  groupStudentUid[i][gA] = [];
+
+                  for (var g = 0; g < f.length; g++) {
+                    if (
+                      f[g].ttype == 2 &&
+                      this.tcid &&
+                      this.arrayToArray( (f[g].classid ? f[g].classid.split(",") : []), this.tcid.split(","))
+                      .length == 0
+                    ) {
+                      continue;
+                    }
+                    
+
+                    let _classId = this.arrayToArray(
+                        this.courseDetail.juri ? this.courseDetail.juri.split(",") : [],
+                        this.classid ? this.classid.split(",") : []
+                      )
+
+                      // console.log(' this.tcid', this.tcid);
+
+                    if (gA == f[g].group && f[g].tool == i 
+                      && (this.arrayToArray((f[g].classid ? f[g].classid.split(",") : []),this.tcid.split(",")).length !== 0 
+                      || this.arrayToArray((f[g].classid ? f[g].classid.split(",") : []), _classId).length !== 0 
+                      || (!this.tcid && this.tType == '1') || (this.courseDetail.juri === '') || f[g].ttype == 1)
+                    ){
+                      groupStudent[i][gA].push(f[g]);
+                      groupStudentUid[i][gA].push(f[g].userid);
+                    }
                   }
-                }else{
-                  nowSize++
                 }
+                this.$forceUpdate();
               }
-            })
-
-            console.log("nowSize",nowSize);
-
-
+            }
+            this.groupStudent = groupStudent
+            this.groupStudentUid = groupStudentUid
 
+            if (index != null) {
+              this.joinGroup(index)
+            }
 
           })
           .catch((err) => {
@@ -1702,6 +1881,22 @@ export default {
           });
 
 
+    },
+    // 判断是否在班级内
+    arrayToArray(arrayo, arrayt) {
+      let array1 = arrayo;
+      let array2 = arrayt;
+
+      let commonElements = [];
+
+      for (let i = 0; i < array1.length; i++) {
+        for (let j = 0; j < array2.length; j++) {
+          if (array1[i] === array2[j]) {
+            commonElements.push(array1[i]);
+          }
+        }
+      }
+      return commonElements;
     },
     // 学生分组判断与学生一个班级的学生
     hasOverlap(arr1, arr2) {
@@ -1740,7 +1935,7 @@ export default {
         .post(this.$store.state.api + "joinGroup", params)
         .then((res) => {
           this.$message.success("加入成功");
-          this.$emit("getCourseDetail",2)
+          this.selectGroup()
         })
         .catch((err) => {
           this.$message.error("网络不佳");
@@ -1750,7 +1945,6 @@ export default {
 
     // 退出分组
     exitGroup(id) {
-      return
       if (this.groupJson.islock == 2) {
         this.$message.error("位置已被锁定,无法退出");
         return;
@@ -1765,7 +1959,7 @@ export default {
         .post(this.$store.state.api + "exitGroup", params)
         .then((res) => {
           this.$message.success("退出成功");
-          this.$emit.getCourseDetail(2);
+          this.selectGroup()
         })
         .catch((err) => {
           this.$message.error("网络不佳");
@@ -2181,7 +2375,9 @@ export default {
         );
           let _tempData = this.chapInfoListData[this.courseType].chapterInfo[0]
             .taskJson[this.taskCount].toolChoose[this.toolIndex];
+
           this.testData = _tempData ? _tempData : null;
+
           this.testJson = this.testData.testJson
             ? this.testData.testJson.testJson
             : null;
@@ -2240,7 +2436,7 @@ export default {
                 this.radioS.push('')
               }
             })
-          }else if (this.toolType == 69) {
+          }else if (this.toolType == 69) { //英语写作
             console.log('this.testJsonCopy',this.testJsonCopy);
 
             // if (this.testJsonCopy.length) {
@@ -2273,13 +2469,11 @@ export default {
           }else if (this.toolType == 49) {
             this.groupStudent=this.groupStudent2
             this.groupStudentUid=this.groupStudentUid2
+            // this.timerId = setInterval(() => {
+            //   this.selectGroup()
+            // }, 5000);
 
-            // console.log('this.groupStudent',this.groupStudent);
-            // console.log('groupStudentUid',this.groupStudentUid);
-
-            // console.log('this.testData',this.testData);
-
-
+            
             this.groupJson = this.testData.groupJson;
             this.islock = this.groupJson.islock == 1 ? true : false;
           }
@@ -2287,6 +2481,8 @@ export default {
     },
     close() {
       this.show = false;
+      // 清除定时器
+      // clearInterval(this.timerId);
       this.init();
 			this.$emit("changeSplitScreenBehavior",{code:99})
     },
@@ -2304,6 +2500,8 @@ export default {
       this.toolIndex = null;
       this.testData = null;
 			this.toolType = null;
+      this.groupJson2 = {}
+      this.chapInfoListData2= [];
       this.foldList = {
         noSubmit: false,
         worksPreview: false
@@ -3694,4 +3892,74 @@ ol {
   align-items: center;
   justify-content: center;
 }
+.dialog_diy >>> .el-dialog {
+  margin-top: 10vh !important;
+}
+.dialog_diy >>> .el-dialog__header,
+.dialog_diy1 >>> .el-dialog__header {
+  background: #454545 !important;
+  padding: 15px 20px;
+}
+
+.dialog_diy >>> .el-dialog__title,
+.dialog_diy1 >>> .el-dialog__title {
+  color: #fff;
+}
+
+.dialog_diy >>> .el-dialog__headerbtn,
+.dialog_diy1 >>> .el-dialog__headerbtn {
+  top: 19px;
+}
+
+.dialog_diy >>> .el-dialog__headerbtn .el-dialog__close,
+.dialog_diy1 >>> .el-dialog__headerbtn .el-dialog__close {
+  color: #fff;
+}
+
+.dialog_diy >>> .el-dialog__headerbtn .el-dialog__close:hover,
+.dialog_diy1 >>> .el-dialog__headerbtn .el-dialog__close:hover {
+  color: #fff;
+}
+
+.dialog_diy1 >>> .el-dialog__body {
+  padding: 0;
+}
+
+.dialog_diy >>> .el-dialog__body,
+.dialog_diy >>> .el-dialog__footer,
+.dialog_diy1 >>> .el-dialog__footer {
+  background: #fafafa;
+}
+.groupContent + .groupContent {
+  margin-top: 30px;
+}
+.groupContent >>> .el-input-number.is-without-controls .el-input__inner {
+  text-align: left;
+}
+.groupName {
+  display: flex;
+  align-items: center;
+}
+
+.groupn {
+  font-size: 15px;
+  margin-right: 10px;
+}
+
+.groupName + .groupName {
+  margin-top: 15px;
+}
+
+.groupBtn {
+  margin-left: 10px;
+}
+
+.groupContent >>> .el-input-number.is-without-controls .el-input__inner {
+  text-align: left;
+}
+.groupTitle {
+  font-size: 24px;
+  color: rgb(80, 80, 80);
+  margin-bottom: 20px;
+}
 </style>