|
@@ -144,9 +144,6 @@
|
|
|
</Option>
|
|
|
</Select>
|
|
|
</FormItem>
|
|
|
- <FormItem>
|
|
|
- <!-- <Button @click="testSave()">TEST</Button> -->
|
|
|
- </FormItem>
|
|
|
</Form>
|
|
|
</vuescroll>
|
|
|
</div>
|
|
@@ -546,7 +543,7 @@
|
|
|
computed: {
|
|
|
...mapGetters({
|
|
|
periods: 'user/getPeriods', // 學制s
|
|
|
- aprules: 'schoolBaseInfo/getAprules',
|
|
|
+ aprules: 'schoolBaseInfo/getAprules',
|
|
|
}),
|
|
|
filterPeriodName: function(){
|
|
|
let data = this.periods
|
|
@@ -1008,17 +1005,60 @@
|
|
|
this.$Message.error(res.v)
|
|
|
} else {
|
|
|
|
|
|
- // 修改Hiteach
|
|
|
-
|
|
|
+ // Hiteach 與教室綁定
|
|
|
+ this.$api.schoolSetting.hiteachLink({
|
|
|
+ school_code: this.$store.state.userInfo.schoolCode,
|
|
|
+ linkList: this.updHiteachLink
|
|
|
+ }).then( hiteachLinkRes =>{
|
|
|
+
|
|
|
+ if(hiteachLinkRes.error == 0){
|
|
|
+ let orgHiData = JSON.parse(this.orgHiteachData)
|
|
|
|
|
|
+ this.updHiteachLink.forEach(item => {
|
|
|
+ let tempIndex;
|
|
|
+ let temp = orgHiData.find( (hiItem, hiIndex) => {
|
|
|
+ tempIndex = hiIndex
|
|
|
+ return hiItem.id == item.id
|
|
|
+ })
|
|
|
+ if(temp.deviceBound != null && Array.isArray(temp.deviceBound) && temp.deviceBound.length > 0){
|
|
|
+ temp.deviceBound.forEach( (dbItem, dbIndex, dbArray) => {
|
|
|
+ if( (dbItem.uuid + dbItem.uuid2) == (item.uuid + item.uuid2)){
|
|
|
+ dbItem.classId = item.classId
|
|
|
|
|
|
- this.$Message.success(this.$t('schoolBaseInfo.csTips3'))
|
|
|
- this.updated = false
|
|
|
- this.updHiteachLink = []
|
|
|
- if (option == 'insert') {
|
|
|
- this.classroomListShow[this.curClassIndex].code = 'Class-'+ this.classroomListShow[this.curClassIndex].code
|
|
|
- this.classroomList.unshift(this.classroomListShow[this.curClassIndex])
|
|
|
- }
|
|
|
+ if(item.classId != null){
|
|
|
+ dbItem.hiteachLink = true
|
|
|
+ } else {
|
|
|
+ dbItem.hiteachLink = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ orgHiData[tempIndex] = temp
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // 原本API 內容
|
|
|
+ this.$Message.success(this.$t('schoolBaseInfo.csTips3'))
|
|
|
+ this.updated = false
|
|
|
+ this.updHiteachLink = []
|
|
|
+ if (option == 'insert') {
|
|
|
+ this.classroomListShow[this.curClassIndex].code = 'Class-'+ this.classroomListShow[this.curClassIndex].code
|
|
|
+ this.classroomList.unshift(this.classroomListShow[this.curClassIndex])
|
|
|
+ this.$store.dispatch('user/addSchoolClasses', this.classroomListShow[this.curClassIndex]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 新增加
|
|
|
+ this.hiteachData = orgHiData
|
|
|
+ this.orgHiteachData = JSON.stringify(orgHiData)
|
|
|
+ }
|
|
|
+ },err => {
|
|
|
+ this.$Message.error('Hiteach 綁定失敗!')
|
|
|
+ }).finally(
|
|
|
+ () => {
|
|
|
+ this.isSaveLoading = false
|
|
|
+ this.isListLoading = false
|
|
|
+ }
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
} else {
|
|
@@ -1028,7 +1068,8 @@
|
|
|
err => {
|
|
|
this.$Message.error('API error!')
|
|
|
}
|
|
|
- ).finally(
|
|
|
+ )
|
|
|
+ .finally(
|
|
|
() => {
|
|
|
this.isSaveLoading = false
|
|
|
this.isListLoading = false
|
|
@@ -1080,7 +1121,6 @@
|
|
|
this.$Message.warning('您暂无次操作权限!')
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
delClassroom(index) {
|
|
|
this.isListLoading = true
|
|
|
if (this.classroomListShow[index].option !== 'insert') {
|
|
@@ -1102,21 +1142,13 @@
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
- // 刪掉指定的classId
|
|
|
- let orgHiData = JSON.parse(this.orgHiteachData)
|
|
|
- orgHiData.forEach( item => {
|
|
|
- if(Array.isArray(item.deviceBound) && item.deviceBound.length > 0){
|
|
|
- item.deviceBound.forEach(db => {
|
|
|
- if(db.classId == this.classroomListShow[index].id) {
|
|
|
- db.classId = null
|
|
|
- db.hiteachLink = false
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+
|
|
|
+ this.$api.schoolSetting.hiteachUnlinkByClassId({
|
|
|
+ classId: this.classroomListShow[index].id,
|
|
|
+ school_code: this.$store.state.userInfo.schoolCode
|
|
|
})
|
|
|
-
|
|
|
- this.hiteachData = orgHiData
|
|
|
- this.orgHiteachData = JSON.stringify(orgHiData)
|
|
|
+ this.unlinkHiteach(this.classroomListShow[index].id) // 刪掉指定的classId
|
|
|
+ this.$store.dispatch('user/delSchoolClasses', this.classroomListShow[index].id);
|
|
|
|
|
|
this.classroomList.splice(originIndex, 1)
|
|
|
this.classroomListShow.splice(index, 1)
|
|
@@ -1138,11 +1170,11 @@
|
|
|
this.updateBefore = JSON.stringify(this.classroomListShow[this.curClassIndex])
|
|
|
}
|
|
|
this.classroomListShow.splice(index, 1)
|
|
|
+ this.unlinkHiteach(this.classroomListShow[index].id)// 刪掉指定的classId
|
|
|
this.isListLoading = false
|
|
|
this.updated = false
|
|
|
this.updHiteachLink = []
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
uploadSchoolPlan(res, file) {
|
|
|
this.$Message.success(this.$t('schoolBaseInfo.csTips5'))
|
|
@@ -1399,49 +1431,23 @@
|
|
|
deviceId: item.deviceId
|
|
|
}
|
|
|
)
|
|
|
- }
|
|
|
+ }
|
|
|
},
|
|
|
- testSave(){
|
|
|
- // 給API
|
|
|
- this.isListLoading = true
|
|
|
- this.$api.schoolSetting.hiteachLink({
|
|
|
- school_code: this.$store.state.userInfo.schoolCode,
|
|
|
- linkList: this.updHiteachLink
|
|
|
- }).then( res=>{
|
|
|
-
|
|
|
- if(res.error == 0){
|
|
|
- let orgHiData = JSON.parse(this.orgHiteachData)
|
|
|
-
|
|
|
- this.updHiteachLink.forEach(item => {
|
|
|
- let tempIndex;
|
|
|
- let temp = orgHiData.find( (hiItem, hiIndex) => {
|
|
|
- tempIndex = hiIndex
|
|
|
- return hiItem.id == item.id
|
|
|
- })
|
|
|
- if(temp.deviceBound != null && Array.isArray(temp.deviceBound) && temp.deviceBound.length > 0){
|
|
|
- temp.deviceBound.forEach( (dbItem, dbIndex, dbArray) => {
|
|
|
- if( (dbItem.uuid + dbItem.uuid2) == (item.uuid + item.uuid2)){
|
|
|
- dbItem.classId = item.classId
|
|
|
-
|
|
|
- if(item.classId != null){
|
|
|
- dbItem.hiteachLink = true
|
|
|
- } else {
|
|
|
- dbItem.hiteachLink = false
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- orgHiData[tempIndex] = temp
|
|
|
+ unlinkHiteach: function(classId){
|
|
|
+ // 刪掉指定的classId
|
|
|
+ let orgHiData = JSON.parse(this.orgHiteachData)
|
|
|
+ orgHiData.forEach( item => {
|
|
|
+ if(Array.isArray(item.deviceBound) && item.deviceBound.length > 0){
|
|
|
+ item.deviceBound.forEach(db => {
|
|
|
+ if(db.classId == classId) {
|
|
|
+ db.classId = null
|
|
|
+ db.hiteachLink = false
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
- this.hiteachData = orgHiData
|
|
|
- this.orgHiteachData = JSON.stringify(orgHiData)
|
|
|
- this.updHiteachLink = []
|
|
|
- this.updated = false
|
|
|
- this.isListLoading = false
|
|
|
}
|
|
|
})
|
|
|
+ this.hiteachData = orgHiData
|
|
|
+ this.orgHiteachData = JSON.stringify(orgHiData)
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|