|
@@ -212,9 +212,9 @@
|
|
|
<template v-if="item.deviceBound.length >0">
|
|
|
<div v-for="(dbItem, dbIndex) in item.deviceBound" :key="dbIndex" class="hiteach-collapse-sub gradient" :class="{'linked': dbItem.classId != '' && dbItem.classId != null && classroomListShow[curClassIndex].id != dbItem.classId}">
|
|
|
<!-- 被關聯 disabled -->
|
|
|
- <Button style="margin-right: 70px;" v-model="dbItem.hiteachLink" >{{ dbItem.hiteachLink ? '解除關聯' : '關聯' }}</Button>
|
|
|
+ <Button class="hiteach-collapse-sub-linkBtn" v-model="dbItem.hiteachLink" @click="confirmLink(dbItem.hiteachLink, item.id, dbItem.uuid, dbItem.uuid2, classroomListShow[curClassIndex].id)" >{{ dbItem.hiteachLink ? '解除關聯' : '關聯' }}</Button>
|
|
|
<!-- <Checkbox :id="'checkbox-' + (dbItem.uuid + dbItem.uuid2)" @on-change="whatUpdHiLink(dbItem, classroomListShow[curClassIndex].id, item.id)" style="margin-right: 70px;" v-model="dbItem.hiteachLink" :disabled="dbItem.classId != '' && dbItem.classId != null && classroomListShow[curClassIndex].id != dbItem.classId"></Checkbox> -->
|
|
|
- <div class="hiteach-collapse-sub-detail" @click="pushCheckbox(dbItem, (dbItem.classId && classroomListShow[curClassIndex].id != dbItem.classId))">
|
|
|
+ <div class="hiteach-collapse-sub-detail">
|
|
|
<ul>
|
|
|
<li>
|
|
|
<h3>{{ dbItem.pcname }}</h3>
|
|
@@ -535,24 +535,29 @@ export default {
|
|
|
|
|
|
if(nowSeletedClassId != null && this.isSmart(nowSeletedClassId)){
|
|
|
|
|
|
+ // 篩選有 deviceBound 且classID 和現在的教室相同的
|
|
|
data = data.filter(item => {
|
|
|
- return Array.isArray(item.deviceBound) && item.deviceBound.length > 0
|
|
|
+ return Array.isArray(item.deviceBound) && item.deviceBound.length > 0 && item.deviceBound.some(s => { return s.classId == nowSeletedClassId })
|
|
|
})
|
|
|
|
|
|
- data = data.filter(item => {
|
|
|
- return item.deviceBound.some(s => {
|
|
|
- return s.classId == nowSeletedClassId
|
|
|
+ // 整形 拿掉不相關的
|
|
|
+ data = data.map(item => {
|
|
|
+ let newD = item
|
|
|
+ newD.deviceBound = newD.deviceBound.filter( f => {
|
|
|
+ return f.classId != null && f.classId != ''
|
|
|
})
|
|
|
+ return newD
|
|
|
})
|
|
|
} else {
|
|
|
- data = data.filter(item => {
|
|
|
- let flag = false
|
|
|
+ // 整形 拿掉沒被關聯的
|
|
|
+ data = data.map(item => {
|
|
|
+ let newD = item
|
|
|
if(Array.isArray(item.deviceBound) && item.deviceBound.length > 0){
|
|
|
- flag = item.deviceBound.some(s => {
|
|
|
- return s.classId == null || s.classId == ''
|
|
|
+ newD.deviceBound = newD.deviceBound.filter( f => {
|
|
|
+ return f.classId == null || f.classId == ''
|
|
|
})
|
|
|
}
|
|
|
- return flag
|
|
|
+ return newD
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -1139,7 +1144,7 @@ export default {
|
|
|
classId: this.classroomListShow[index].id,
|
|
|
school_code: this.$store.state.userInfo.schoolCode
|
|
|
})
|
|
|
- // this.unlinkHiteach(this.classroomListShow[index].id) // 刪掉指定的classId
|
|
|
+ this.unlinkHiteachByClassId(this.classroomListShow[index].id) // 刪掉指定的classId
|
|
|
this.$store.dispatch('user/delSchoolClasses', this.classroomListShow[index].id);
|
|
|
this.classroomList.splice(originIndex, 1)
|
|
|
this.classroomListShow.splice(index, 1)
|
|
@@ -1160,7 +1165,7 @@ export default {
|
|
|
this.updateBefore = JSON.stringify(this.classroomListShow[this.curClassIndex])
|
|
|
}
|
|
|
this.classroomListShow.splice(index, 1)
|
|
|
- this.unlinkHiteach(this.classroomListShow[index].id)// 刪掉指定的classId
|
|
|
+ this.unlinkHiteachByClassId(this.classroomListShow[index].id)// 刪掉指定的classId
|
|
|
this.isListLoading = false
|
|
|
this.updated = false
|
|
|
this.updHiteachLink = []
|
|
@@ -1418,7 +1423,7 @@ export default {
|
|
|
)
|
|
|
}
|
|
|
},
|
|
|
- unlinkHiteach: function (classId) {
|
|
|
+ unlinkHiteachByClassId: function (classId) {
|
|
|
// 刪掉指定的classId
|
|
|
let orgHiData = JSON.parse(this.orgHiteachData)
|
|
|
orgHiData.forEach(item => {
|
|
@@ -1434,49 +1439,66 @@ export default {
|
|
|
this.hiteachData = orgHiData
|
|
|
this.orgHiteachData = JSON.stringify(orgHiData)
|
|
|
},
|
|
|
- linkHiteach: function(){
|
|
|
+ // 詢問視窗
|
|
|
+ confirmLink: function(linkFlag, pid, uuid, uuid2, classId){
|
|
|
+ let action = linkFlag ? 'unLink' : 'link';
|
|
|
+ if(action == 'unLink'){
|
|
|
+ this.$Modal.confirm({
|
|
|
+ title: this.$t('解除關聯'),
|
|
|
+ content: `${this.$t('請問您確定要解除關聯')}?`,
|
|
|
+ onOk: () => {
|
|
|
+ this.executeHiteachLink(action, pid, uuid, uuid2, classId)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.executeHiteachLink(action, pid, uuid, uuid2, classId)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ executeHiteachLink: function(action, pid, uuid, uuid2, classId){
|
|
|
// Hiteach 與教室綁定
|
|
|
+ this.hiteachListLoading = true
|
|
|
this.$api.schoolSetting.hiteachLink({
|
|
|
school_code: this.$store.state.userInfo.schoolCode,
|
|
|
- linkList: this.updHiteachLink
|
|
|
- }).then(hiteachLinkRes => {
|
|
|
-
|
|
|
- if (hiteachLinkRes.error == 0) {
|
|
|
+ // linkList: this.updHiteachLink
|
|
|
+ action: action,
|
|
|
+ pid: pid,
|
|
|
+ uuid: uuid,
|
|
|
+ uuid2: uuid2,
|
|
|
+ classId: classId
|
|
|
+ }).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
|
|
|
- }
|
|
|
- }, err => {
|
|
|
- this.$Message.error(this.$t('schoolBaseInfo.bindingErr'))
|
|
|
- }).finally(
|
|
|
- () => {
|
|
|
-
|
|
|
+ let tempIndex;
|
|
|
+ let temp = orgHiData.find((hiItem, hiIndex) => {
|
|
|
+ tempIndex = hiIndex
|
|
|
+ return hiItem.id == pid
|
|
|
+ })
|
|
|
+ temp.deviceBound.forEach((dbItem, dbIndex, dbArray) => {
|
|
|
+ if ((dbItem.uuid + dbItem.uuid2) == (uuid + uuid2)) {
|
|
|
+ if(action == 'link'){
|
|
|
+ dbItem.classId = classId
|
|
|
+ dbItem.hiteachLink = true
|
|
|
+ } else if(action == 'unLink'){
|
|
|
+ dbItem.classId = null
|
|
|
+ dbItem.hiteachLink = false
|
|
|
+ }
|
|
|
}
|
|
|
- )
|
|
|
+ })
|
|
|
|
|
|
+ orgHiData[tempIndex] = temp
|
|
|
+
|
|
|
// 新增加
|
|
|
this.hiteachData = orgHiData
|
|
|
this.orgHiteachData = JSON.stringify(orgHiData)
|
|
|
+ } else if (res.error == 1){
|
|
|
+ this.$Message.error(this.$t('無法關聯已被關聯的Hiteach'))
|
|
|
}
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ this.$Message.error(this.$t('參數錯誤'))
|
|
|
+ }).finally(()=>{
|
|
|
+ this.hiteachListLoading = false
|
|
|
})
|
|
|
}
|
|
|
},
|