osbert 4 years ago
parent
commit
b3c394abbb

+ 1 - 0
TEAMModelOS/ClientApp/src/locale/lang/zh-CN/schoolBaseInfo.js

@@ -123,6 +123,7 @@ export default {
   tab1:'基础信息',
   tab2:'学生名单',
   tab3:'位置设定',
+  tab4: '关联Hiteach',
   classAttr:'教室属性',
   relationHi:'关联Hiteach设备',
   hiFilter1:'显示所有版本的Hiteach',

+ 1 - 0
TEAMModelOS/ClientApp/src/locale/lang/zh-TW/schoolBaseInfo.js

@@ -125,6 +125,7 @@ export default {
   tab1: '基礎資訊',
   tab2: '學生名單',
   tab3: '位置設定',
+  tab4: '關聯Hiteach',
   classAttr: '教室内容',
   relationHi: '關聯Hiteach設備',
   hiFilter1: '顯示所有版本的Hiteach',

+ 1 - 1
TEAMModelOS/ClientApp/src/view/schoolmgmt/ClassroomSetting/ClassroomSetting.less

@@ -278,7 +278,7 @@
     }
 }
 .hiteach-code-wrap {
-    width: 65%;
+    width: 100%;
     height: 100%;
     position: relative;
     &-header {

+ 146 - 113
TEAMModelOS/ClientApp/src/view/schoolmgmt/ClassroomSetting/ClassroomSetting.vue

@@ -93,6 +93,9 @@
                 <span :class="currentTabIndex == 1 ? 'main-header-tab line-bottom line-bottom-active':'main-header-tab line-bottom'" @click="selectTab(1)">
                     {{$t('schoolBaseInfo.tab3')}}
                 </span>
+                <span :class="currentTabIndex == 3 ? 'main-header-tab line-bottom line-bottom-active':'main-header-tab line-bottom'" @click="selectTab(3)">
+                    {{$t('schoolBaseInfo.tab4')}}
+                </span>
                 <!-- 编辑教室 -->
                 <Button v-if="$access.can('admin.*|classroom-upd')" class="save-btn" :loading="isSaveLoading" :disabled="!updated" icon="ios-albums-outline" @click="saveClassroom()" v-show="currentTabIndex == 0">
                     {{$t('schoolBaseInfo.saveInfo')}}
@@ -146,20 +149,64 @@
                             </Form>
                         </vuescroll>
                     </div>
-                    <!--HiTeach序列号列表-->
+                </div>
+
+                <!--平面位置-->
+                <div class="school-plan-wrap" v-show="currentTabIndex == 1">
+                    <Upload action="" :on-success="uploadSchoolPlan" :before-upload="getFileData">
+                        <Button icon="ios-cloud-upload-outline">{{$t('schoolBaseInfo.uploadPlan')}}</Button>
+                    </Upload>
+                    <div class="school-plan-zoom">
+                        <span @click="defaultSize()">1:1</span>
+                        <Icon type="ios-add-circle-outline" color="white" size="24" @click="bigger()" />
+                        <Icon type="ios-remove-circle-outline" color="white" size="24" @click="smaller()" />
+                    </div>
+                    <div class="school-plan-box" id="school-plan-box">
+                        <canvas id="school-plan" style="cursor:move;" @mousedown="canvasMouseDown" @mousemove="canvasMouseMove" @mouseup="canvasMouseUp" @mouseout="canvasMouseOut">
+                            {{$t('schoolBaseInfo.suportCanvas')}}
+                        </canvas>
+                    </div>
+                </div>
+
+                <!--学生名单-->
+                <div id="sut-list-box" class="dark-iview-table" style="width:100%;height:100%;" v-show="currentTabIndex == 2">
+                    <vuescroll style="height:100%;" v-if="classroomListShow[curClassIndex] && classroomListShow[curClassIndex].openType == '1'">
+                        <Table :columns="studentColumn" :data="students" @on-selection-change="(selections)=>{delSelection = selections}" :height="tableHeight" class="system-classroom-table" :loading="stuLoading" no-data-text="暂无学生">
+                            <Loading slot="loading" bgColor="rgba(103, 103, 103, 0.27)"></Loading>
+                            <template slot-scope="{ row }" slot="picture">
+                                <PersonalPhoto :name="row.name" :picture="row.picture" />
+                            </template>
+                            <template slot-scope="{ row ,index}" slot="action">
+                                <div class="item-tools" v-if="$access.can('admin.*|student-upd')">
+                                    <Icon type="md-create" size="18" color="white" @click="editStudent(row)" :title="$t('schoolBaseInfo.editSeat')" />
+                                </div>
+                            </template>
+                            <!-- <template slot-scope="{ row, index }" slot="groupId">
+                                <span>{{row.groupId ? row.groupId : '- -'}}</span>
+                            </template>
+                            <template slot-scope="{ row, index }" slot="groupName">
+                                <span>{{row.groupName ? row.groupName : '未分组'}}</span>
+                            </template> -->
+                        </Table>
+                    </vuescroll>
+                    <h2 v-else style="text-align:center;color:#cccccc;width:100%;padding-top:80px;">{{$t('schoolBaseInfo.onClassStu')}}</h2>
+                </div>
+
+                <!-- 關聯 Hiteach -->
+                <div id="hiteach-link" style="height: 100%;" v-show="currentTabIndex == 3">
                     <div class="hiteach-code-wrap">
                         <Loading v-show="hiteachListLoading"></Loading>
                         <div class="hiteach-code-wrap-header">
-                            <p>
+                            <!-- <p>
                                 {{$t('schoolBaseInfo.relationHi')}}
-                            </p>
+                            </p> -->
                             <div class="class-list-filter">
                                 <div class="class-list-filter-box">
                                     <Dropdown class="sort-dropdown" trigger="click" placement="bottom-start" @on-click="function(e){ filterHiteachVer = e }">
-                                        <span style="cursor: pointer;color:white;">
-                                            {{ $t('schoolBaseInfo.hiFilter1') }}
-                                            <Icon type="ios-arrow-down"></Icon>
-                                        </span>
+                                        <span v-if="filterHiteachVer == 'ALL'" style="cursor: pointer;color:white;"> {{ $t('schoolBaseInfo.hiFilter1') }} <Icon type="ios-arrow-down"></Icon></span>
+                                        <span v-else-if="filterHiteachVer == 'J223IZ6M'" style="cursor: pointer;color:white;"> {{ $t('schoolBaseInfo.hiFilter2') }} <Icon type="ios-arrow-down"></Icon></span>
+                                        <span v-else-if="filterHiteachVer == 'J223IZAM'" style="cursor: pointer;color:white;"> {{ $t('schoolBaseInfo.hiFilter3') }} <Icon type="ios-arrow-down"></Icon></span>
+                                        <span v-else-if="filterHiteachVer == '3222C6D2'" style="cursor: pointer;color:white;"> {{ $t('schoolBaseInfo.hiFilter4') }} <Icon type="ios-arrow-down"></Icon></span>
                                         <DropdownMenu slot="list">
                                             <DropdownItem name="ALL">{{ $t('schoolBaseInfo.hiFilter1') }}</DropdownItem>
                                             <DropdownItem name="J223IZ6M">{{ $t('schoolBaseInfo.hiFilter2') }}</DropdownItem>
@@ -174,7 +221,7 @@
                             </div>
                         </div>
                         <div class="hiteach-code-wrap-list">
-                            <vuescroll>
+                            <vuescroll >
                                 <div class="hiteach-collapse" v-for="(item, index) in showHiteachData" :key="index">
                                     <div @click="openHiSub(index)" class="hiteach-collapse-main">
                                         <Icon class="arrowIcon" v-if="item.deviceMax > 1" :type="item.subOpen ? 'ios-arrow-up' : 'ios-arrow-down'" size="30" color="white" />
@@ -207,7 +254,8 @@
                                         <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 -->
-                                                <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>
+                                                <Button style="margin-right: 70px;" v-model="dbItem.hiteachLink" >{{ 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))">
                                                     <ul>
                                                         <li>
@@ -243,46 +291,6 @@
                     </div>
                 </div>
 
-                <!--平面位置-->
-                <div class="school-plan-wrap" v-show="currentTabIndex == 1">
-                    <Upload action="" :on-success="uploadSchoolPlan" :before-upload="getFileData">
-                        <Button icon="ios-cloud-upload-outline">{{$t('schoolBaseInfo.uploadPlan')}}</Button>
-                    </Upload>
-                    <div class="school-plan-zoom">
-                        <span @click="defaultSize()">1:1</span>
-                        <Icon type="ios-add-circle-outline" color="white" size="24" @click="bigger()" />
-                        <Icon type="ios-remove-circle-outline" color="white" size="24" @click="smaller()" />
-                    </div>
-                    <div class="school-plan-box" id="school-plan-box">
-                        <canvas id="school-plan" style="cursor:move;" @mousedown="canvasMouseDown" @mousemove="canvasMouseMove" @mouseup="canvasMouseUp" @mouseout="canvasMouseOut">
-                            {{$t('schoolBaseInfo.suportCanvas')}}
-                        </canvas>
-                    </div>
-                </div>
-
-                <!--学生名单-->
-                <div id="sut-list-box" class="dark-iview-table" style="width:100%;height:100%;" v-show="currentTabIndex == 2">
-                    <vuescroll style="height:100%;" v-if="classroomListShow[curClassIndex] && classroomListShow[curClassIndex].openType == '1'">
-                        <Table :columns="studentColumn" :data="students" @on-selection-change="(selections)=>{delSelection = selections}" :height="tableHeight" class="system-classroom-table" :loading="stuLoading" no-data-text="暂无学生">
-                            <Loading slot="loading" bgColor="rgba(103, 103, 103, 0.27)"></Loading>
-                            <template slot-scope="{ row }" slot="picture">
-                                <PersonalPhoto :name="row.name" :picture="row.picture" />
-                            </template>
-                            <template slot-scope="{ row ,index}" slot="action">
-                                <div class="item-tools" v-if="$access.can('admin.*|student-upd')">
-                                    <Icon type="md-create" size="18" color="white" @click="editStudent(row)" :title="$t('schoolBaseInfo.editSeat')" />
-                                </div>
-                            </template>
-                            <!-- <template slot-scope="{ row, index }" slot="groupId">
-                                <span>{{row.groupId ? row.groupId : '- -'}}</span>
-                            </template>
-                            <template slot-scope="{ row, index }" slot="groupName">
-                                <span>{{row.groupName ? row.groupName : '未分组'}}</span>
-                            </template> -->
-                        </Table>
-                    </vuescroll>
-                    <h2 v-else style="text-align:center;color:#cccccc;width:100%;padding-top:80px;">{{$t('schoolBaseInfo.onClassStu')}}</h2>
-                </div>
             </div>
         </div>
         <!-- 原来可以创建序号,如果现在调整序列号部分后不需要添加可以删除相关代码 -->
@@ -512,6 +520,35 @@ export default {
         showHiteachData: function () {
             let data = this.hiteachData
             let filterText = this.filterHiteachVer
+            let nowSeletedClassId = null
+            if(this.classroomListShow.length > 0){
+                nowSeletedClassId = this.classroomListShow[this.curClassIndex].id
+            }
+
+            if(nowSeletedClassId != null && this.isSmart(nowSeletedClassId)){
+                
+                data = data.filter(item => {
+                    return Array.isArray(item.deviceBound) && item.deviceBound.length > 0
+                })
+
+                data = data.filter(item => {
+                    return item.deviceBound.some(s => {
+                        return s.classId == nowSeletedClassId
+                    })
+                })
+            } else {
+                data = data.filter(item => {
+                    let flag = false
+                    if(Array.isArray(item.deviceBound) && item.deviceBound.length > 0){
+                        flag = item.deviceBound.some(s => {
+                            return s.classId == null || s.classId == ''
+                        })
+                    }
+                    return flag
+                })
+            }
+                    
+
             if (Array.isArray(data) && data.length > 0 && filterText != 'ALL') {
                 data = data.filter(item => {
                     return item.prodCode == filterText
@@ -956,61 +993,14 @@ export default {
                                     this.classroomListShow[this.curClassIndex].option = 'insert'
                                     this.$Message.error(res.v)
                                 } else {
-
-                                    // 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
-
-                                                            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(this.$t('schoolBaseInfo.bindingErr'))
-                                    }).finally(
-                                        () => {
-                                            this.isSaveLoading = false
-                                            this.isListLoading = false
-                                        }
-                                    )
+                                    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]);
+                                    }
                                 }
 
                             } else {
@@ -1020,16 +1010,14 @@ export default {
                         err => {
                             this.$Message.error('API error!')
                         }
+                    ).finally(
+                        () => {
+                            this.isSaveLoading = false
+                            this.isListLoading = false
+                        }
                     )
-                        .finally(
-                            () => {
-                                this.isSaveLoading = false
-                                this.isListLoading = false
-                            }
-                        )
                 }
             })
-
         },
         getClassroom() {
             this.isListLoading = true
@@ -1099,7 +1087,7 @@ export default {
                                 classId: this.classroomListShow[index].id,
                                 school_code: this.$store.state.userInfo.schoolCode
                             })
-                            this.unlinkHiteach(this.classroomListShow[index].id) // 刪掉指定的classId                                
+                            // this.unlinkHiteach(this.classroomListShow[index].id) // 刪掉指定的classId                                
                             this.$store.dispatch('user/delSchoolClasses', this.classroomListShow[index].id);
 
                             this.classroomList.splice(originIndex, 1)
@@ -1312,7 +1300,7 @@ export default {
             if (this.classroomList.length > 0) {
                 this.classroomList.forEach(item => {
                     item.style = "normal"
-                    if (linkedClassIds.indexOf(item.id)) {
+                    if (linkedClassIds.indexOf(item.id) >= 0) {
                         item.style = "smart"
                     }
                 })
@@ -1400,6 +1388,51 @@ export default {
             })
             this.hiteachData = orgHiData
             this.orgHiteachData = JSON.stringify(orgHiData)
+        },
+        linkHiteach: function(){
+            // 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
+
+                                    if (item.classId != null) {
+                                        dbItem.hiteachLink = true
+                                    } else {
+                                        dbItem.hiteachLink = false
+                                    }
+                                }
+                            })
+
+                            orgHiData[tempIndex] = temp
+                        }
+                    }, err => {
+                        this.$Message.error(this.$t('schoolBaseInfo.bindingErr'))
+                    }).finally(
+                        () => {
+
+                        }
+                    )
+
+                    // 新增加
+                    this.hiteachData = orgHiData
+                    this.orgHiteachData = JSON.stringify(orgHiData)
+                }
+            })
         }
     },
     mounted() {