Browse Source

添加课程

lsc 2 years ago
parent
commit
3f88defe23

+ 143 - 13
src/components/pages/addCourse.vue

@@ -207,16 +207,19 @@
                         添加权限
                       </div>
                     </div>
-                    <!-- <div style="flex: 0.5 1 0%; margin: 0">
+                    <div
+                      style="flex: 0.5 1 0%; margin: 0"
+                      v-if="courseUserid != '' ? courseUserid == userid : true"
+                    >
                       <div class="bInfo_title">协同编辑</div>
                       <div
                         class="addPeople"
-                        @click="isNoFinsh"
+                        @click="dialogVisibleMember = true"
                         style="background: #6b92c9"
                       >
                         添加协同成员
                       </div>
-                    </div> -->
+                    </div>
                   </div>
                 </div>
               </div>
@@ -745,7 +748,7 @@
                               :class="
                                 itemTool.toolType == 0 ? 'isChooseActive' : ''
                               "
-                              @click="itemTool.toolType = 0"
+                              @click="itemTool.toolType = 0,$forceUpdate();"
                             >
                               展示类
                             </div>
@@ -753,7 +756,7 @@
                               :class="
                                 itemTool.toolType == 1 ? 'isChooseActive' : ''
                               "
-                              @click="itemTool.toolType = 1"
+                              @click="itemTool.toolType = 1,$forceUpdate();"
                             >
                               思维类
                             </div>
@@ -761,7 +764,7 @@
                               :class="
                                 itemTool.toolType == 2 ? 'isChooseActive' : ''
                               "
-                              @click="itemTool.toolType = 2"
+                              @click="itemTool.toolType = 2,$forceUpdate();"
                             >
                               评价类
                             </div>
@@ -769,7 +772,7 @@
                               :class="
                                 itemTool.toolType == 3 ? 'isChooseActive' : ''
                               "
-                              @click="itemTool.toolType = 3"
+                              @click="itemTool.toolType = 3,$forceUpdate();"
                             >
                               创作类
                             </div>
@@ -1354,9 +1357,9 @@
               <!-- <div>您的课程编号</div>
               <div class="number">{{ number }}</div> -->
               <div class="success_button">
-                <div class="look_course" @click="isNoFinsh">
+                <!-- <div class="look_course" @click="isNoFinsh">
                   邀请老师协同编辑
-                </div>
+                </div> -->
                 <div class="attend_others" @click="goCourse">预览课程</div>
               </div>
             </div>
@@ -1560,6 +1563,52 @@
         <el-button type="primary" @click="isAddClass">确定</el-button>
       </span>
     </el-dialog>
+    <el-dialog
+      title="添加协同成员"
+      :visible.sync="dialogVisibleMember"
+      :append-to-body="true"
+      width="25%"
+      height="80%"
+      :before-close="handleClose"
+      class="addNewPP customWidth"
+    >
+      <div class="people">
+        <div class="people_top">
+          <div class="people_nav">选择成员</div>
+          <div class="people_top_right">
+            <div class="people_search">
+              <el-input
+                placeholder="搜索成员"
+                v-model="searchTN"
+                @keyup.enter.native="getTeacher"
+              ></el-input>
+              <div class="search_img" @click="getTeacher">
+                <img src="../../assets/icon/search.png" alt />
+              </div>
+            </div>
+          </div>
+        </div>
+        <el-checkbox-group
+          v-model="checkboxList3"
+          class="people_name"
+          v-if="teacherJuri.length"
+        >
+          <el-checkbox
+            v-for="item in teacherJuri"
+            :key="item.userid"
+            :label="item.userid"
+            >{{
+              (item.name ? item.name : "暂无姓名") + " " + item.username
+            }}</el-checkbox
+          >
+        </el-checkbox-group>
+        <div style="text-align: center; margin-top: 10px" v-else>暂无数据</div>
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="dialogVisibleMember = false">取 消</el-button>
+        <el-button type="primary" @click="isAddPPTeacher">确定</el-button>
+      </span>
+    </el-dialog>
     <el-dialog
       title="创建问卷调查"
       :visible.sync="dialogVisible5"
@@ -1933,8 +1982,10 @@ export default {
       dialogVisible7: false,
       dialogVisible8: false,
       dialogVisibleClass: false,
+      dialogVisibleMember: false,
       publicTool: 0,
       searchPeople: "",
+      searchTN: "",
       userid: this.$route.query.userid,
       oid: this.$route.query.oid,
       cid: this.$route.query.cid != undefined ? this.$route.query.cid : "",
@@ -1990,8 +2041,10 @@ export default {
         },
       ],
       studentJuri: [],
+      teacherJuri: [],
       checkboxList: [],
       checkboxList2: [],
+      checkboxList3: [],
       number: "",
       tTitle: "",
       tdetail: "",
@@ -2012,6 +2065,8 @@ export default {
       cidType: 0,
       answerQ: "",
       grade: [],
+      courseUserid: "",
+      timer: null,
     };
   },
   computed: {
@@ -2628,6 +2683,28 @@ export default {
           console.error(err);
         });
     },
+    getTeacher() {
+      let params = {
+        oid: this.oid,
+        cu: "",
+        cn: this.searchTN,
+      };
+      this.ajax
+        .get(this.$store.state.api + "selectTeacherAdd", params)
+        .then((res) => {
+          let teacherJuri = res.data[0];
+          for (var i = 0; i < teacherJuri.length; i++) {
+            if (teacherJuri[i].userid == this.userid) {
+              teacherJuri.splice(i, 1);
+              break;
+            }
+          }
+          this.teacherJuri = teacherJuri;
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+    },
     searchStudent() {
       this.getStudent();
     },
@@ -2738,10 +2815,12 @@ export default {
           chapters: JSON.stringify(this.unitJson).replaceAll(/%/g, "%25"),
           template: this.cTemplate != "undefined" ? this.cTemplate : "",
           courseType: JSON.stringify(this.courseTypeId),
+          ateacher:
+            this.checkboxList3.length > 0 ? this.checkboxList3.join(",") : "",
         },
       ];
       this.ajax
-        .post(this.$store.state.api + "addWorkNew2", params)
+        .post(this.$store.state.api + "addWorkNew3", params)
         .then((res) => {
           this.$message({
             message: "新增成功",
@@ -2788,10 +2867,12 @@ export default {
           template: this.myWord != "undefined" ? this.myWord : [],
           uid: this.userid,
           courseType: JSON.stringify(this.courseTypeId),
+          ateacher:
+            this.checkboxList3.length > 0 ? this.checkboxList3.join(",") : "",
         },
       ];
       this.ajax
-        .post(this.$store.state.api + "updateWorkNew2", params)
+        .post(this.$store.state.api + "updateWorkNew3", params)
         .then((res) => {
           this.$message({
             message: "修改成功",
@@ -2863,6 +2944,9 @@ export default {
     isAddClass() {
       this.dialogVisibleClass = false;
     },
+    isAddPPTeacher() {
+      this.dialogVisibleMember = false;
+    },
     getTemplate() {
       this.ajax
         .get(this.$store.state.api + "getCourseTemplateT", "")
@@ -3347,17 +3431,28 @@ export default {
             //   res.data[0][0].course_student.length > 0
             //     ? JSON.parse(res.data[0][0].course_student)
             //     : [];
-            this.checkboxList2 =
-              res.data[0][0].juri ? res.data[0][0].juri.split(",") : [];
+            this.checkboxList2 = res.data[0][0].juri
+              ? res.data[0][0].juri.split(",")
+              : [];
+            this.checkboxList3 = res.data[0][0].course_teacher
+              ? res.data[0][0].course_teacher.split(",")
+              : [];
             this.isTeacherSee =
               res.data[0][0].is_teacher_look == 0 ? true : false;
             this.myWord = res.data[0][0].template;
             this.templateC.id = "123";
+            this.courseUserid = res.data[0][0].userid;
             this.nbOrder = res.data[0][0].ordernumber;
             for (var i = 0; i < res.data[1].length; i++) {
               this.courseTypeId.push(res.data[1][i].typeid);
             }
             console.log(this.courseTypeId);
+            // if (this.timer) clearInterval(this.timer);
+            if (this.timer) clearTimeout(this.timer);
+            this.timer = null;
+            // this.timer = setInterval(() => {
+            this.seleteCourseUpdate();
+            // }, 5000);
             this.$forceUpdate();
           })
           .catch((err) => {
@@ -3365,6 +3460,31 @@ export default {
           });
       }
     },
+    seleteCourseUpdate() {
+      let params = {
+        cid: this.cid,
+      };
+      this.ajax
+        .get(this.$store.state.api + "select_course_detail", params)
+        .then((res) => {
+          let unitJson = JSON.parse(res.data[0][0].chapters);
+          let _unitIndex = this.unitIndex;
+          for (let i = 0; i < unitJson.length; i++) {
+            if (i == _unitIndex) {
+              continue;
+            } else {
+              this.unitJson[i] = unitJson[i];
+            }
+          }
+          this.$forceUpdate();
+          this.timer = setTimeout(() => {
+            this.seleteCourseUpdate();
+          }, 5000);
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+    },
     getTypeName() {
       console.log(this.courseTypeId);
       this.$forceUpdate();
@@ -3416,8 +3536,18 @@ export default {
       this.$forceUpdate();
     },
   },
+  beforeDestroy() {
+    clearTimeout(this.timer);
+    this.timer = null;
+  },
+  beforeRouteLeave(to, from, next) {
+    clearTimeout(this.timer);
+    this.timer = null;
+    next();
+  },
   created() {
     this.getStudent();
+    this.getTeacher();
     this.getClass();
     this.getTemplate();
     this.selectType();

+ 2 - 2
src/components/pages/components/worksDetail2.vue

@@ -1073,7 +1073,7 @@ export default {
             this.sInfo.sName +
             "</h3>";
           var _img = "";
-          if (workJson.img > 0) {
+          if (workJson.img.length > 0) {
             for (var i = 0; i < workJson.img.length; i++) {
               _img += `<div style="margin-top:10px"><div>图片${
                 i + 1
@@ -1093,7 +1093,7 @@ export default {
                 var _div2 = document.createElement("div");
                 _div2.innerHTML = `<h5>第${j + 1}题:${
                   workJson.askInfo[i].askJson[j].askstitle
-                }  选择:${workJson.askInfo[i].radio[j]}</h5> `;
+                }  选择:${workJson.askInfo[i].radio[j]+1}</h5> `;
                 var _div3 = document.createElement("div");
                 for (
                   var z = 0;

+ 149 - 44
src/components/pages/course.vue

@@ -3,11 +3,15 @@
     <div class="pb_head top">
       <span>项目管理</span>
       <div class="student_button">
+        <el-button type="primary" class="bgColor" @click="openCourse"
+          >协同编辑</el-button
+        >
         <el-button
           type="primary"
           class="bgColor"
           @click="goTo('/course/addCourse?userid=' + userid + '&oid=' + oid)"
-        >添加项目</el-button>
+          >添加项目</el-button
+        >
       </div>
     </div>
     <div class="pb_content_body" style="height: 100%">
@@ -20,9 +24,17 @@
               <el-option value="1" label="他人课程"></el-option>
             </el-select>
           </div>
-          <div class="all_choose" v-for="(item, index) in CourseType[0]" :key="index">
+          <div
+            class="all_choose"
+            v-for="(item, index) in CourseType[0]"
+            :key="index"
+          >
             <span>{{ item.name }}</span>
-            <el-select v-model="courseTypeId[item.id]" placeholder="请选择" @change="getTypeName">
+            <el-select
+              v-model="courseTypeId[item.id]"
+              placeholder="请选择"
+              @change="getTypeName"
+            >
               <el-option label="全部" value="1">全部</el-option>
               <el-option
                 v-for="item1 in CourseTypeJson[item.id]"
@@ -37,8 +49,14 @@
 
         <div class="student_right">
           <div class="head_left">
-            <el-input v-model="courseName" class="student_input" placeholder="请输入课程名称"></el-input>
-            <el-button class="course_button" @click="searchCourse">查询</el-button>
+            <el-input
+              v-model="courseName"
+              class="student_input"
+              placeholder="请输入课程名称"
+            ></el-input>
+            <el-button class="course_button" @click="searchCourse"
+              >查询</el-button
+            >
           </div>
         </div>
       </div>
@@ -48,18 +66,20 @@
             <div class="tup">
               <img
                 :src="
-									item.cover != null && item.cover != ''
-										? JSON.parse(item.cover).length > 0
-											? JSON.parse(item.cover)[0].url
-											: mr
-										: mr
-								"
+                  item.cover != null && item.cover != ''
+                    ? JSON.parse(item.cover).length > 0
+                      ? JSON.parse(item.cover)[0].url
+                      : mr
+                    : mr
+                "
                 alt
               />
             </div>
             <div class="bottom_box">
               <div>{{ item.title }}</div>
-              <div class="kc_t" v-if="groupA == '1'">创建老师:{{ item.uname }}</div>
+              <div class="kc_t" v-if="groupA == '1'">
+                创建老师:{{ item.uname }}
+              </div>
               <div class="kc_time">{{ item.time }}</div>
             </div>
             <div class="three_bottom">
@@ -67,28 +87,32 @@
               <div
                 v-if="groupA == '0'"
                 @click="
-									goTo(
-										'/course/addCourse?cid=' +
-											item.courseId +
-											'&userid=' +
-											userid +
-											'&oid=' +
-											oid
-									)
-								"
-              >修改</div>
+                  goTo(
+                    '/course/addCourse?cid=' +
+                      item.courseId +
+                      '&userid=' +
+                      userid +
+                      '&oid=' +
+                      oid
+                  )
+                "
+              >
+                修改
+              </div>
               <div
                 @click="
-									goTo(
-										'/works?cid=' +
-											item.courseId +
-											'&userid=' +
-											userid +
-											'&oid=' +
-											oid
-									)
-								"
-              >报告</div>
+                  goTo(
+                    '/works?cid=' +
+                      item.courseId +
+                      '&userid=' +
+                      userid +
+                      '&oid=' +
+                      oid
+                  )
+                "
+              >
+                报告
+              </div>
               <div @click="deleteCourse(item.courseId)">删除</div>
             </div>
           </div>
@@ -120,13 +144,69 @@
     >
       <div>
         <div class="a_addBox">
-			<CourseProblem :problemCourse="problemCourse"></CourseProblem>
+          <CourseProblem :problemCourse="problemCourse"></CourseProblem>
         </div>
       </div>
       <span slot="footer" class="dialog-footer">
         <el-button @click="dialogVisible = false">关 闭</el-button>
       </span>
     </el-dialog>
+    <el-dialog
+      title="查看协同课程"
+      :visible.sync="dialogVisibleCourse"
+      :append-to-body="true"
+      width="850px"
+      :before-close="handleClose"
+      class="dialog_diy"
+    >
+      <div class="ct_box">
+        <div
+          class="out_box"
+          v-for="(item, index) in courseTeam"
+          :key="index"
+          style="margin-left: 15px"
+        >
+          <div class="tup">
+            <img
+              :src="
+                item.cover != null && item.cover != ''
+                  ? JSON.parse(item.cover).length > 0
+                    ? JSON.parse(item.cover)[0].url
+                    : mr
+                  : mr
+              "
+              alt
+            />
+          </div>
+          <div class="bottom_box">
+            <div>{{ item.title }}</div>
+            <div class="kc_t">创建老师:{{ item.uname }}</div>
+            <div class="kc_time">{{ item.time }}</div>
+          </div>
+          <div class="three_bottom">
+            <div @click="jump(item.courseId)">查看内容</div>
+            <div
+              @click="
+                goTo(
+                  '/course/addCourse?cid=' +
+                    item.courseId +
+                    '&userid=' +
+                    userid +
+                    '&oid=' +
+                    oid
+                )
+              "
+            >
+              编辑
+            </div>
+          </div>
+        </div>
+         <div class="course_empty" v-if="courseTeam.length == 0">暂无数据</div>
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="dialogVisibleCourse = false">关 闭</el-button>
+      </span>
+    </el-dialog>
   </div>
 </template>
 
@@ -135,7 +215,7 @@ import "../../common/aws-sdk-2.235.1.min";
 import EditorBar from "../../components/tools/wangEnduit";
 import CourseProblem from "./components/courseProblem";
 export default {
-  components: { EditorBar,CourseProblem },
+  components: { EditorBar, CourseProblem },
   data() {
     return {
       itemCount: 1,
@@ -149,6 +229,7 @@ export default {
       formLabelWidth: "100px",
       dialogVisible: false,
       dialogVisible1: false,
+      dialogVisibleCourse: false,
       dialogImageUrl: "",
       group: "",
       userid: this.$route.query.userid,
@@ -173,6 +254,7 @@ export default {
       courseTypeSon: [],
       isChoose: 0,
       problemCourse: null, //查看提问的课程
+      courseTeam: [],
     };
   },
   methods: {
@@ -248,13 +330,14 @@ export default {
     },
     //uuid生成
     guid() {
-      return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (
-        c
-      ) {
-        var r = (Math.random() * 16) | 0,
-          v = c == "x" ? r : (r & 0x3) | 0x8;
-        return v.toString(16);
-      });
+      return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
+        /[xy]/g,
+        function (c) {
+          var r = (Math.random() * 16) | 0,
+            v = c == "x" ? r : (r & 0x3) | 0x8;
+          return v.toString(16);
+        }
+      );
     },
     time() {
       if (!this.now) {
@@ -400,13 +483,31 @@ export default {
           console.error(err);
         });
     },
+    openCourse() {
+      this.dialogVisibleCourse = true;
+      this.getTeamCourse();
+    },
+    getTeamCourse() {
+      let params = {
+        uid: this.userid,
+        oid: this.oid,
+      };
+      this.ajax
+        .get(this.$store.state.api + "selectCourseTeam", params)
+        .then((res) => {
+          this.courseTeam = res.data[0];
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+    },
     search() {
       this.page = 1;
       this.getCourse();
     },
     checkProblem(res) {
       this.problemCourse = res;
-	  this.dialogVisible = true;
+      this.dialogVisible = true;
     },
   },
   created() {
@@ -745,6 +846,10 @@ export default {
   cursor: pointer;
   margin-left: 20px;
 }
-
-
+.ct_box {
+  height: 500px;
+  overflow: auto;
+  display: flex;
+  flex-wrap: wrap;
+}
 </style>