浏览代码

CF99 介接ies5 名單: 抓ies5名單前,先同步舊有CCRoster

Louise lin 1 周之前
父节点
当前提交
97574745f5

+ 1 - 1
HiTeachCC/ClientApp/src/components/EditMemberList.vue

@@ -194,7 +194,7 @@ export default {
         }
         tempMemberList.push(tempStudent)
       })
-      console.log(this.$parent.currentMemberList,"183")
+     
       this.$parent.memberList = Object.keys(this.$parent.currentMemberList).length == 0 ? [] : tempMemberList;
       this.$parent.verifyMode = Object.keys(this.$parent.currentMemberList).length == 0 ? "Dynamic" : "Fixed";
       this.currentEditStudent = {};

+ 1 - 0
HiTeachCC/ClientApp/src/store/index.js

@@ -198,6 +198,7 @@ export default new Vuex.Store({
       }
     ],
     tempGptActionList:[{ value: i18n.t('gptBox["總結大意"]') }, { value: i18n.t('gptBox["整理同義字"]') },{value:""},{value:""},{value:""},{value:""},{value:""},{value:""},{value:""},{value:""}],
+    tempIsSyncOldCCRoster:false,
     startTime: 0,
     elapsedTime: 0,
     timeLineEvents: [],

+ 3 - 1
HiTeachCC/ClientApp/src/store/module/preferences.js

@@ -28,6 +28,7 @@ export default {
             ],
             memberListIDs:[],
             gptActionList: [{ value: i18n.t('gptBox["總結大意"]') }, { value: i18n.t('gptBox["整理同義字"]') }, {value:""},{value:""},{value:""},{value:""},{value:""},{value:""},{value:""},{value:""}],
+            isSyncOldCCRoster:false
         }
     },
     getters: {
@@ -37,7 +38,8 @@ export default {
         return state.pref.pens.find(item => item.type === type)
        },
        getPREFMemberList:state=>state.pref.memberListIDs, // 取得自訂名單,
-       getGptActionList:state => state.pref.gptActionList
+       getGptActionList:state => state.pref.gptActionList,
+       getIsSyncOldCCRoster:state=>state.pref.isSyncOldCCRoster
     },
     mutations: {
         [KEEPSTORAGE](state, data) {

+ 49 - 3
HiTeachCC/ClientApp/src/views/Board.vue

@@ -6874,6 +6874,7 @@ export default {
         IRSBlockSize: this.$store.state.tempIRSBlockSize, // IRS Block 大小
         pens: this.$store.state.tempPenstate,
         gptActionList:this.$store.state.tempGptActionList,
+        isSyncOldCCRoster:this.$store.state.tempIsSyncOldCCRoster
       };
       this.$Spin.show(); // 畫面loading表現你可以自己調整
       await this.$store.dispatch("preferences/updProfilePREF", data).then(() => {
@@ -7049,7 +7050,7 @@ export default {
       else if (isPureAccount && this.classInfo.isIES5) type = 2;
       else if (!isPureAccount && this.classInfo.isIES5) type = 3;
       console.log(type,'AuthType',this.$store.state.loginType)
-      return 3;
+      return type;
     },
     isAuthOpenAIAccount(){
       return this.getFunc("aigpt")?.active
@@ -7512,6 +7513,7 @@ export default {
     console.log(this.getPREFMemberList,"getPREFMemberList")
     console.log(this.classInfo, "classInfo");
     console.log(this.blobConnect);
+    console.log(this.getIsSyncOldCCRoster,"getIsSyncOldCCRoster")
 
     if(!!this.getGptActionList){
       this.$store.state.tempGptActionList=this.getGptActionList
@@ -7532,8 +7534,50 @@ export default {
     
      //帶入自訂名單偏好設定20250523 先註解
     // this.customMemberlist=this.getPREFMemberList?this.getPREFMemberList.length!=0?await this.$refs.editMemberList.fetchCCroster():[]:[]
-    const fetchCCroster=await this.$refs.editMemberList.fetchCCroster()
-    console.log(fetchCCroster,"fetchCCroster")
+   
+    if (!this.getIsSyncOldCCRoster) {
+      const fetchCCrosterData = await this.$refs.editMemberList.fetchCCroster() || []
+      // console.log(fetchCCrosterData, "fetchCCrosterData")
+      if (!fetchCCrosterData || !Array.isArray(fetchCCrosterData) || fetchCCrosterData.length === 0) {
+        this.$store.state.tempIsSyncOldCCRoster = true;
+        this.updProfilePREF()
+      } else {
+        // 使用 Promise.all 確保所有 API 呼叫都完成
+        try {
+          const apiPromises = fetchCCrosterData.map((item) => {
+            return this.$api.ies5Api.createIES5StudentList({
+              courseName: "HiTeach",
+              groupListName: item.listName,
+              limitCount: 200,
+              courseId: "",
+              groupId: "",
+              member: item.list.map((item2) => {
+                return {
+                  seatID: item2.seatID,
+                  memberID: item2.memberID,
+                  memberName: item2.memberName,
+                  id: "",
+                  code: null,
+                  type: 3,
+                  nickname: item2.memberName,
+                  no: item2.seatID,
+                  irs: item2.seatID,
+                }
+              }),
+            })
+          });
+
+          // 等待所有 API 呼叫完成
+          await Promise.all(apiPromises);
+          console.log('所有名單同步完成');
+          this.$store.state.tempIsSyncOldCCRoster = true;
+          this.updProfilePREF()
+        } catch (error) {
+          console.error('名單同步過程中發生錯誤:', error);
+        }
+      }
+    }
+    
     const res=await this.$api.ies5Api.getIES5TeacherInfo()
     
     if (res.courses && Array.isArray(res.courses)) {
@@ -7548,6 +7592,7 @@ export default {
         }
       });
     }
+    
 
 
     this.getStorageSize("session");
@@ -7942,6 +7987,7 @@ export default {
       getPREFPenState: "preferences/getPenState", // 取得預設畫筆設定檔
       getGptActionList:'preferences/getGptActionList',
       getPREFMemberList:"preferences/getPREFMemberList", // 取得自訂名單
+      getIsSyncOldCCRoster:"preferences/getIsSyncOldCCRoster", // 取得自訂名單
       classInfo: "classInfo/getInfo", // 取得課堂設定
       callLogout: "mqtt/getCallLogout", // 取得mqtt是否呼叫登出
       mqttDeviceId: "mqtt/getDeviceId", // 取得mqtt 裝置ID