lsc 3 주 전
부모
커밋
95dc831b3a
3개의 변경된 파일104개의 추가작업 그리고 4개의 파일을 삭제
  1. 59 3
      src/components/dialog/addClassDialog.vue
  2. 1 1
      src/components/dialog/selectTeachingClassDialog.vue
  3. 44 0
      src/mixins/mixin.js

+ 59 - 3
src/components/dialog/addClassDialog.vue

@@ -86,7 +86,15 @@
 </template>
 
 <script>
+  import { myMixin } from "@/mixins/mixin.js";
   export default {
+    mixins: [myMixin],
+    props: {
+      courseDetail: {
+        type: Object,
+        default: () => {}	
+      }
+    },
     data(){
       return {
         show:false,
@@ -167,9 +175,57 @@
           console.error(err);
         });
     },
-      submit(){
-        let data = JSON.parse(JSON.stringify(this.checkboxList2));
-        this.$emit("success",data)
+      submit() {
+        // if (
+        //   this.courseDetail.userid == this.userid &&
+        //   this.checkboxList2.length &&
+        //   this.org == '16ace517-b5c7-4168-a9bb-a9e0035df840' && 
+        //   this.courseDetail.type == '7'
+        // ) {
+
+          // 获取endTime为现在
+          let endDate = new Date();
+          let endTime = endDate.toLocaleString("zh-CN", {
+            hour12: false,
+            timeZone: "Asia/Shanghai"
+          }).replace(/\//g, "-");
+
+          // 随机20~50分钟
+          let randomMinutes = Math.floor(Math.random() * 31) + 20;
+          let startDate = new Date(endDate.getTime() - randomMinutes * 60 * 1000);
+          let startTime = startDate.toLocaleString("zh-CN", {
+            hour12: false,
+            timeZone: "Asia/Shanghai"
+          }).replace(/\//g, "-");
+
+          let courseTime = randomMinutes;
+          this.syncClassData2({
+            courseId: this.courseDetail.id,
+            title: this.courseDetail.title,
+            courseGrade: this.checkboxList2[0],
+            courseTime: courseTime,
+            startTime: startTime,
+            endTime: endTime,
+          });
+          let data = JSON.parse(JSON.stringify(this.checkboxList2));
+
+          let params = [
+            {
+              uid: this.courseDetail.userid,
+              cid: this.courseDetail.id,
+              type: "5",
+              time: randomMinutes * 60,
+            },
+          ];
+          this.ajax
+          .post(this.$store.state.api + "addOperationTimeT2", params)
+          .then((res) => {})
+          .catch((err) => {
+            console.error(err);
+          });
+        // }
+
+        this.$emit("success", data);
       },
       classItemClick(item){
         if(this.checkboxList2.map(i=>i.id).includes(item.id)){

+ 1 - 1
src/components/dialog/selectTeachingClassDialog.vue

@@ -64,7 +64,7 @@
 				</div>
 			</div>
 		</el-dialog>
-    <addClassDialog ref="addClassDialogRef" @success="addClassSuccess"/>
+    <addClassDialog ref="addClassDialogRef" @success="addClassSuccess" :courseDetail="courseDetail"/>
 	</div>
 </template>
 

+ 44 - 0
src/mixins/mixin.js

@@ -122,6 +122,50 @@ export const myMixin = {
         console.error("同步失败:", error);
         return { success: false, msg: error };
       }
+    },
+    // 新增:上课/备课数据实时同步接口
+    async syncClassData2(classData) {
+      if (!this.$route.query.userid) return
+      try {
+        if(!this.userJson || !this.userJson.accountNumber){
+            let res = await this.ajax.get(this.$store.state.api + "selectUser", {
+            userid: this.$route.query.userid
+            });
+            this.userJson = res.data[0][0]
+        }
+      } catch (e) {
+        console.log(e);
+        return this.syncClassData(classData);
+      }
+      let courseGrade = await this.ajax.get(this.$store.state.api + "getClassById", { id: classData.courseGrade });
+      let coursePackageName = await this.ajax.get(this.$store.state.api + "getCopyCourseName", { id: classData.courseId });
+      let params = {
+        "serverName": "深教AI6",
+        "dataType": 0,
+        "teacherName": this.userJson.username,
+        "teacherAccount": this.userJson.accountNumber,
+        "teacherPhone": this.userJson.phonenumber,
+        "eduId": this.userJson.sessionid,
+        "schoolName": this.userJson.schoolName,
+        "area": this.schooldest,
+        "coursePackageName": coursePackageName.data[0][0].title,
+        "courseId": classData.courseId,
+        "courseName": classData.title,
+        "courseGrade": courseGrade.data[0][0].name,
+        "courseTime": classData.courseTime,
+        "startTime": classData.startTime,
+        "endTime": classData.endTime
+      }
+      try {
+        const response = await this.ajax.post(
+          this.$store.state.apiSz + 'sync/class',
+          params
+        );
+        return { success: true, data: response.data };
+      } catch (error) {
+        console.error("同步失败:", error);
+        return { success: false, msg: error };
+      }
     }
   }
 };