Browse Source

3.0合并tmd分支冲突部分:TchActivity

CrazyIter_Bin 4 years ago
parent
commit
b35eddea94

+ 4 - 4
TEAMModelOS.SDK/DI/AzureStorage/AzureStorageTableExtensions.cs

@@ -259,7 +259,7 @@ namespace TEAMModelOS.SDK.DI
 
 
         public static async Task<List<T>> DeleteAll<T>(this AzureStorageFactory azureStorage,  List<T> entitys) where T : TableEntity, new()
         public static async Task<List<T>> DeleteAll<T>(this AzureStorageFactory azureStorage,  List<T> entitys) where T : TableEntity, new()
         {
         {
-            if (entitys.IsEmpty())
+            if (!entitys.IsNotEmpty())
             {
             {
                 return null;
                 return null;
             }
             }
@@ -300,7 +300,7 @@ namespace TEAMModelOS.SDK.DI
 
 
         public static async Task<List<T>> SaveOrUpdateAll<T>(this AzureStorageFactory azureStorage, List<T> entitys) where T : TableEntity, new()
         public static async Task<List<T>> SaveOrUpdateAll<T>(this AzureStorageFactory azureStorage, List<T> entitys) where T : TableEntity, new()
         {
         {
-            if (entitys.IsEmpty())
+            if (!entitys.IsNotEmpty())
             {
             {
                 return null;
                 return null;
             }
             }
@@ -340,7 +340,7 @@ namespace TEAMModelOS.SDK.DI
         }
         }
         public static async Task<List<T>> UpdateAll<T>(this AzureStorageFactory azureStorageFactory, List<T> entitys) where T : TableEntity, new()
         public static async Task<List<T>> UpdateAll<T>(this AzureStorageFactory azureStorageFactory, List<T> entitys) where T : TableEntity, new()
         {
         {
-            if (entitys.IsEmpty())
+            if (!entitys.IsNotEmpty())
             {
             {
                 return null;
                 return null;
             }
             }
@@ -380,7 +380,7 @@ namespace TEAMModelOS.SDK.DI
         }
         }
         public static async Task<List<T>> SaveAll<T>(this AzureStorageFactory azureStorage, List<T> entitys) where T : TableEntity, new()
         public static async Task<List<T>> SaveAll<T>(this AzureStorageFactory azureStorage, List<T> entitys) where T : TableEntity, new()
         {
         {
-            if (entitys.IsEmpty())
+            if (!entitys.IsNotEmpty())
             {
             {
                 return null;
                 return null;
             }
             }

+ 1 - 16
TEAMModelOS.SDK/Helper/Common/CollectionHelper/CollectionHelper.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections;
 using System.Collections;
 using System.Collections.Generic;
 using System.Collections.Generic;
 
 
@@ -8,21 +8,6 @@ namespace TEAMModelOS.SDK.Helper.Common.CollectionHelper
 {
 {
     public static class CollectionHelper
     public static class CollectionHelper
     {
     {
-        /// <summary>
-        /// 判断集合是否为空
-        /// </summary>
-        /// <param name="collection"></param>
-        /// <returns></returns>
-        public static bool IsEmpty(this ICollection collection)
-        {
-            if (collection != null && collection.Count > 0)
-            {
-                return false;
-            }
-            else {
-                return true;
-            }
-        }
         /// <summary>
         /// <summary>
         /// 判断集合是否不为空
         /// 判断集合是否不为空
         /// </summary>
         /// </summary>

+ 10 - 0
TEAMModelOS/ClientApp/src/api/stuAccount.js

@@ -40,6 +40,16 @@ export default {
     format.students.push(...data)
     format.students.push(...data)
     return post('/student/student-manage', format)
     return post('/student/student-manage', format)
   },
   },
+  // 匯入
+  ImportStudent: function(schoolId, data) {
+    let format = {
+      grant_type: 'import',
+      schoolId: schoolId,
+      students: []
+    }
+    format.students.push(...data)
+    return post('/student/student-manage', format)
+  },
   updateStudent: function(data) {
   updateStudent: function(data) {
     return post('/api/Student/upsert', data)
     return post('/api/Student/upsert', data)
   },
   },

+ 1 - 1
TEAMModelOS/ClientApp/src/store/module/schoolBaseInfo.js

@@ -173,7 +173,7 @@ export default {
         addStudentsToState(context, data) {
         addStudentsToState(context, data) {
             context.commit('addStudents', data)
             context.commit('addStudents', data)
         },
         },
-        uptStudentsToState(context, data) {            
+        updStudentsToState(context, data) {            
             context.commit('uptStudents', data)
             context.commit('uptStudents', data)
         },
         },
         delStudentsToState(context, data) {            
         delStudentsToState(context, data) {            

+ 58 - 57
TEAMModelOS/ClientApp/src/view/student-account/AddStudent.vue

@@ -361,66 +361,67 @@
                 if (this.isFull) {
                 if (this.isFull) {
                     this.same = false
                     this.same = false
                     if (this.bizType == 2) {
                     if (this.bizType == 2) {
-                        this.isLoading = true
-                        var editInfo = this.editStudentInfo
-
+                        console.log(this.editStudentInfo, 'this.editStudentInfo')
+                        // this.isLoading = true
                         let stringify = JSON.stringify(this.editStudentInfo)
                         let stringify = JSON.stringify(this.editStudentInfo)
                         let parse = JSON.parse(stringify)
                         let parse = JSON.parse(stringify)
                         let apiData = []
                         let apiData = []
-                        if(parse.length == 1){
-                            parse.forEach(function(item){
-                                item.year = item.year ? item.year.toString() : ''
-                                item.no = item.no ? item.no.toString() : ''
-                            })                            
+console.log(parse, 'parse')
+                        // if(parse.length == 1){
+                        //     parse.forEach(function(item){
+                        //         item.year = item.year ? item.year.toString() : ''
+                        //         item.no = item.no ? item.no.toString() : ''
+                        //     })                            
 
 
-                            if(this.isRepeat(parse[0])){
-                                this.$Message.error('請檢查 帳號資訊 或 座號重複 了。')
-                                this.isLoading = false
-                            } else {
-                                apiData = parse
-                            }
-                        } else {
-                            let classId = parse[0].classId
-                            let temp = parse.map(function(item){
-                                return {
-                                    no : "",
-                                    id: item.id,
-                                    classId: classId,
-                                    name: item.name,
-                                    year: item.year ? item.year.toString() : ''
-                                }
-                            }) 
-                            apiData = temp
-                        }
-                        if(apiData.length > 0){                 
-                            // 新增 如果密碼沒被改變就拿掉此Key           
-                            apiData.forEach( (item) =>{
-                                if(item.pw == '******') {
-                                    delete item.pw
-                                }
-                            })
+                        //     if(this.isRepeat(parse[0])){
+                        //         this.$Message.error('請檢查 帳號資訊 或 座號重複 了。')
+                        //         this.isLoading = false
+                        //     } else {
+                        //         apiData = parse
+                        //     }
+                        // } else {
+                        //     let classId = parse[0].classId
+                        //     let temp = parse.map(function(item){
+                        //         return {
+                        //             no : "",
+                        //             id: item.id,
+                        //             classId: classId,
+                        //             name: item.name,
+                        //             year: item.year ? item.year.toString() : ''
+                        //         }
+                        //     })
+                        //     apiData = temp
+                        // }
 
 
-                            this.$api.stuAccount.saveAllStudent(this.schoolCode, apiData).then(
-                                (res) => {
-                                    if (res.error == null) {
-                                        this.show = false
-                                        this.$emit('saveStudentInfo', {
-                                            action: 2, // 批量修改数据
-                                            studentInfos: res.students
-                                        })
-                                        this.$refs.updateForm.resetFields()
-                                        this.uploadLoading = false
-                                    } else {
-                                        this.$Message.error('API error!')
-                                    }
-                                    this.isLoading = false
-                                },
-                                (err) => {
-                                    this.$Message.error('API error!')
-                                    this.isLoading = false
-                                }
-                            )
-                        }
+                        // if(apiData.length > 0){                 
+                        //     // 新增 如果密碼沒被改變就拿掉此Key           
+                        //     apiData.forEach( (item) =>{
+                        //         if(item.pw == '******') {
+                        //             delete item.pw
+                        //         }
+                        //     })
+
+                        //     this.$api.stuAccount.saveAllStudent(this.schoolCode, apiData).then(
+                        //         (res) => {
+                        //             if (!res.errorId) {
+                        //                 this.show = false
+                        //                 this.$emit('saveStudentInfo', {
+                        //                     action: 2, // 批量修改数据
+                        //                     studentInfos: res.students
+                        //                 })
+                        //                 this.$refs.updateForm.resetFields()
+                        //                 this.uploadLoading = false
+                        //             } else {
+                        //                 this.$Message.error('API error!')
+                        //             }
+                        //             this.isLoading = false
+                        //         },
+                        //         (err) => {
+                        //             this.$Message.error('API error!')
+                        //             this.isLoading = false
+                        //         }
+                        //     )
+                        // }
                     } else {
                     } else {
                         this.isLoading = true
                         this.isLoading = true
 
 
@@ -444,11 +445,11 @@
                         } else {
                         } else {
                             this.$api.stuAccount.saveStudent(this.schoolCode, apiData).then(
                             this.$api.stuAccount.saveStudent(this.schoolCode, apiData).then(
                                 (res) => {
                                 (res) => {
-                                    if (res.error == null) {
+                                    if (!res.errorId) {
                                         this.show = false
                                         this.show = false
                                         this.$emit('saveStudentInfo', {
                                         this.$emit('saveStudentInfo', {
                                             action: 1, // 新增学生
                                             action: 1, // 新增学生
-                                            studentInfos: res.students
+                                            studentInfos: res
                                         })
                                         })
                                         this.$refs.studentInfoForm.resetFields()
                                         this.$refs.studentInfoForm.resetFields()
                                     }
                                     }

+ 223 - 71
TEAMModelOS/ClientApp/src/view/student-account/ImportStudent.vue

@@ -25,6 +25,10 @@
                     <span class="table-info-label">{{$t('stuAccount.importInfo1')}}</span>
                     <span class="table-info-label">{{$t('stuAccount.importInfo1')}}</span>
                     <span class="table-info-num">{{totalNum}}</span>
                     <span class="table-info-num">{{totalNum}}</span>
                 </div>
                 </div>
+                <div class="table-info-item" v-if="excelFiledNum != 0">
+                    <span class="table-info-label">{{$t('Excel欄位有缺:')}}</span>
+                    <span class="table-info-num">{{ excelFiledNum }}</span>
+                </div>
                 <div class="table-info-item" v-if="repeatNum != 0">
                 <div class="table-info-item" v-if="repeatNum != 0">
                     <span class="table-info-label">{{$t('stuAccount.importInfo2')}}</span>
                     <span class="table-info-label">{{$t('stuAccount.importInfo2')}}</span>
                     <span class="table-info-num">{{repeatNum}}</span>
                     <span class="table-info-num">{{repeatNum}}</span>
@@ -59,10 +63,16 @@
                     <p>{{(row.pw == '' || row.pw == null)? '— —' : row.pw+''}}</p>
                     <p>{{(row.pw == '' || row.pw == null)? '— —' : row.pw+''}}</p>
                 </template>
                 </template>
                 <template slot-scope="{ row,index }" slot="status">
                 <template slot-scope="{ row,index }" slot="status">
+                    <!-- Excel 錯誤 -->
+                    <p :class="(excelValid.fieldIds.length == 0 || excelValid.fieldIds.indexOf(row.id) == -1) ? 'account-success-tips':'account-warning-tips'">{{(excelValid.fieldIds.length == 0 || excelValid.fieldIds.indexOf(row.id) == -1)?"":"警告:Excel 內欄未完整!" }}</p>
+                    <p :class="(excelValid.noReaptIds.length == 0 || excelValid.noReaptIds.indexOf(row.id) == -1) ? 'account-success-tips':'account-warning-tips'">{{(excelValid.noReaptIds.length == 0 || excelValid.noReaptIds.indexOf(row.id) == -1)?"":"警告:Excel 內的座位号重覆!" }}</p>
+                    <p :class="(excelValid.reaptIds.length == 0 || excelValid.reaptIds.indexOf(row.id) == -1) ? 'account-success-tips':'account-warning-tips'">{{(excelValid.reaptIds.length == 0 || excelValid.reaptIds.indexOf(row.id) == -1)?"":"警告:Excel 內账号重复!" }}</p>
+                    <p :class="row.seatRepeat? 'account-error-tips':''">{{row.seatRepeat ? "错误:座位号已在校內重复":"" }}</p>
+                    <!-- 
                     <p :class="(repeatAccounts.length == 0 || repeatAccounts.indexOf(row.id) == -1) ? 'account-success-tips':'account-error-tips'">{{(repeatAccounts.length == 0 || repeatAccounts.indexOf(row.id) == -1)?"":"错误:账号重复或已存在学校里!" }}</p>
                     <p :class="(repeatAccounts.length == 0 || repeatAccounts.indexOf(row.id) == -1) ? 'account-success-tips':'account-error-tips'">{{(repeatAccounts.length == 0 || repeatAccounts.indexOf(row.id) == -1)?"":"错误:账号重复或已存在学校里!" }}</p>
                     <p :class="(row.classId == '' || row.classId == null) ? 'account-warning-tips':''">{{(row.classId == '' || row.classId == null)?"警告 :未找到指定班级":"" }}</p>
                     <p :class="(row.classId == '' || row.classId == null) ? 'account-warning-tips':''">{{(row.classId == '' || row.classId == null)?"警告 :未找到指定班级":"" }}</p>
-                    <p :class="row.seatRepeat? 'account-error-tips':''">{{row.seatRepeat ? "错误:座位号重复或已存在於校內":"" }}</p>
-                    <p :class="(row.no == '' || row.no == null) ? 'account-warning-tips':''">{{(row.no == '' || row.no == null)?"警告 :沒有座號":"" }}</p>
+                    
+                    <p :class="(row.no == '' || row.no == null) ? 'account-warning-tips':''">{{(row.no == '' || row.no == null)?"警告 :沒有座號":"" }}</p> -->
 
 
                 </template>
                 </template>
             </Table>
             </Table>
@@ -92,9 +102,17 @@
         },
         },
         data() {
         data() {
             return {
             return {
+                // Excel 檢核
+                excelValid:{
+                    fieldIds: [],
+                    noReaptIds: [],
+                    reaptIds: []
+                },
                 totalNum: 0,
                 totalNum: 0,
                 seatRepeatNum: 0,
                 seatRepeatNum: 0,
                 repeatNum: 0,
                 repeatNum: 0,
+                excelFiledNum: 0,
+
                 existNum: 0,
                 existNum: 0,
                 repeatAccounts: [],
                 repeatAccounts: [],
                 noClassroomNum: 0,
                 noClassroomNum: 0,
@@ -125,7 +143,8 @@
                 students: 'schoolBaseInfo/getStudent', // 學生List
                 students: 'schoolBaseInfo/getStudent', // 學生List
             }),
             }),
             isError() {
             isError() {
-                return this.seatRepeatNum + this.repeatNum + this.existNum + this.noClassroomNum + this.noSeatNoNum
+                // return this.seatRepeatNum + this.repeatNum + this.existNum + this.noClassroomNum + this.noSeatNoNum
+                return this.repeatNum + this.seatRepeatNum + this.excelFiledNum
             },
             },
             show: {
             show: {
                 get() {
                 get() {
@@ -146,11 +165,16 @@
             },
             },
             rowClassName(row, index) {
             rowClassName(row, index) {
                 let className = ''
                 let className = ''
-                if (!(this.repeatAccounts.length == 0 || this.repeatAccounts.indexOf(row.id) == -1) || row.seatRepeat) {
-                    className = className + 'account-error-row-bg '
-                }
-                if (row.classId == '' || row.classId == null || row.no == '' || row.no == null) {
+
+                if( this.excelValid.fieldIds.indexOf(row.id) >= 0 || this.excelValid.noReaptIds.indexOf(row.id) >= 0 || this.excelValid.reaptIds.indexOf(row.id) >= 0){
                     className = className + 'account-warning-row-bg'
                     className = className + 'account-warning-row-bg'
+                } else {
+                    if (!(this.repeatAccounts.length == 0 || this.repeatAccounts.indexOf(row.id) == -1) || row.seatRepeat) {
+                        className = className + 'account-error-row-bg '
+                    }
+                    if (row.classId == '' || row.classId == null || row.no == '' || row.no == null) {
+                        className = className + 'account-warning-row-bg'
+                    }
                 }
                 }
                 return className
                 return className
             },
             },
@@ -241,77 +265,151 @@
                             return item
                             return item
                         })
                         })
 
 
-                        // 現在的學生List
-                        let studIDs = this.students.map(item => { return item.id })
+                        console.log(this.tableData, 'tableData')
 
 
-                        // 计算重复账号数量和重复账号,过滤重复账号
+                        // 給予Excel 總數
                         this.totalNum = this.tableData.length
                         this.totalNum = this.tableData.length
-                        // 取得Excel 全部的ID
-                        let accounts = this.tableData.map(item => { return item.id })
-                        // 合併
-                        let cocatIds = studIDs.concat(accounts);
-                        this.repeatAccounts = cocatIds.filter((item, index, self) => self.indexOf(item) != index)
-                        this.repeatAccounts = this.repeatAccounts.filter((item, index, self) => self.indexOf(item) === index)
 
 
-                        // 直接过滤重复账号
-                        // this.tableData = this.tableData.filter((item, index, self) => {
-                        //  if (accounts.indexOf(item.account) === index) {
-                        //    return 1;
-                        //  } else {
-                        //    return 0;
-                        //  }
-                        // });
-                        accounts = accounts.filter((item, index, self) => self.indexOf(item) === index)
-                        this.repeatNum = this.totalNum - accounts.length + this.repeatAccounts.length
+                        // 檢核現在的Excel 邏輯
+                        let excelFlag = this.validExcel(this.tableData)
 
 
-                        // 根据班级Code GroupBy,判断班级座位号是否重复
-                        let classStu = this.groupBy(this.tableData, 'classId')
+                        // Excel 檢核通過再和DATA比對
+                        if(excelFlag){
+                            // 先歸零
+                            this.errNumReset()
+                            // console.log(this.students, 'this.students')
+                            // console.log(this.tableData, 'this.tableData')
+                            let tempData = []
 
 
-                        for (let item of classStu) {
-                            let seatNoArr = item.map(item => { return item.no })
-                            for (let index in item) {
-                                let flag = seatNoArr.indexOf(item[index]['no'])
-                                if (flag != index) {
-                                    let tableIndex = this.getIndex(this.tableData, item[flag])
-                                    if (this.tableData[tableIndex].seatRepeat != true) {
-                                        this.seatRepeatNum++
-                                        this.tableData[tableIndex].seatRepeat = true
-                                    }
-                                    tableIndex = this.getIndex(this.tableData, item[index])
-                                    this.tableData[tableIndex].seatRepeat = true
-                                    this.seatRepeatNum++
-                                }
-                            }
-                        }
-                        // 筛选没有班级账号
-                        let noRoom = this.tableData.filter(item => { return (item.classId == '' || item.classId == null) })
-                        this.noClassroomNum = noRoom.length
+                            // 比較 students 取出已存在的教室內容
+                            this.tableData.forEach( (item) => {
+                                let stud = this.students.filter( (studInfo) => {
+                                    return (item.classId == studInfo.classNo)
+                                })
+                                console.log(stud)
+                                // let o = {}
+                                // if (stud.length > 0) {
+                                //     o.classId = stud.classNo
+                                //     o.id = stud.no
+                                //     o.name = stud.name
+                                //     o.no = stud.no
+                                // } else {
+                                //     o.classId = item.classId
+                                //     o.id = item.id
+                                //     o.name = item.name
+                                //     o.no = item.no
+                                // }
+                                // tempData.push(o)
+                            })
 
 
-                        // 筛选沒有座號
-                        let noSeatNo = this.tableData.filter(item => { return (item.no == '' || item.no == null) })
-                        this.noSeatNoNum = noSeatNo.length
+                            console.log(tempData, 'tempData')
 
 
-                        //整理TtableData
-                        this.tableData.map((item, index) => {
-                            if(item.pw == undefined || item.pw == null || item.pw == '') item.pw = item.id
-                            item['classroom'] = {}
-                            item.classroom.classId = item.classId
-                            item.classroom.className = item.className
-                            item.year = this.academicYear ? this.academicYear.toString() : ''
-                            item.no = item.no ? item.no.toString() : ''
-                            return item
-                        })
+                            // let errorID = []
+                            // tempData.forEach( (item, index, array) => {
+                            //     let a = array.filter( (i) => {
+                            //         return i.no == item.no
+                            //     })
+                            //     if (a.length > 0) {
+                            //         errorID.push(a)
+                            //     }              
+                            // })
+                            
+                            // console.log(errorID, 'errorID')
 
 
-                        // 檢查與現在的學生名單同教室裡是否有重複座號
-                        this.tableData.forEach( (item) => {
-                            let studdd = this.students.filter( (studInfo) => {
-                                return (item.classId == studInfo.classId && item.no == studInfo.no)
+                            // 修改與新增的學生檢核
+                            // this.tableData.forEach( (item, index, array) => {
+                                
+                            //     // 檢查座號是否與校內的衝突
+                            //     let studdd = this.students.some( (studInfo, index) => {
+                            //         return (item.classId == studInfo.classNo && item.no == studInfo.no)
+                            //     })
+                            //     if(studdd) {
+                            //         item.seatRepeat = true
+                            //         this.seatRepeatNum++
+                            //     }
+                            // })
+                            
+                            //整理TtableData
+                            this.tableData.map((item, index) => {
+                                if(item.pw == undefined || item.pw == null || item.pw == '') item.pw = item.id
+                                item['classroom'] = {}
+                                item.classroom.classId = item.classId
+                                item.classroom.className = item.className
+                                item.year = this.academicYear ? this.academicYear.toString() : ''
+                                item.no = item.no ? item.no.toString() : ''
+                                return item
                             })
                             })
-                            if(studdd.length > 0) {
-                                item.seatRepeat = true
-                                this.seatRepeatNum++
-                            }
-                        })
+                        }
+
+
+                        // // 计算重复账号数量和重复账号,过滤重复账号
+                        // this.totalNum = this.tableData.length
+                        // // 取得Excel 全部的ID
+                        // let accounts = this.tableData.map(item => { return item.id })
+                        // // 合併
+                        // let cocatIds = studIDs.concat(accounts);
+                        // this.repeatAccounts = cocatIds.filter((item, index, self) => self.indexOf(item) != index)
+                        // this.repeatAccounts = this.repeatAccounts.filter((item, index, self) => self.indexOf(item) === index)
+
+                        // // 直接过滤重复账号
+                        // // this.tableData = this.tableData.filter((item, index, self) => {
+                        // //  if (accounts.indexOf(item.account) === index) {
+                        // //    return 1;
+                        // //  } else {
+                        // //    return 0;
+                        // //  }
+                        // // });
+                        // accounts = accounts.filter((item, index, self) => self.indexOf(item) === index)
+                        // this.repeatNum = this.totalNum - accounts.length + this.repeatAccounts.length
+
+                        // // 根据班级Code GroupBy,判断班级座位号是否重复
+                        // let classStu = this.groupBy(this.tableData, 'classId')
+
+                        // for (let item of classStu) {
+                        //     let seatNoArr = item.map(item => { return item.no })
+                        //     for (let index in item) {
+                        //         let flag = seatNoArr.indexOf(item[index]['no'])
+                        //         if (flag != index) {
+                        //             let tableIndex = this.getIndex(this.tableData, item[flag])
+                        //             if (this.tableData[tableIndex].seatRepeat != true) {
+                        //                 this.seatRepeatNum++
+                        //                 this.tableData[tableIndex].seatRepeat = true
+                        //             }
+                        //             tableIndex = this.getIndex(this.tableData, item[index])
+                        //             this.tableData[tableIndex].seatRepeat = true
+                        //             this.seatRepeatNum++
+                        //         }
+                        //     }
+                        // }
+                        // // 筛选没有班级账号
+                        // let noRoom = this.tableData.filter(item => { return (item.classId == '' || item.classId == null) })
+                        // this.noClassroomNum = noRoom.length
+
+                        // // 筛选沒有座號
+                        // let noSeatNo = this.tableData.filter(item => { return (item.no == '' || item.no == null) })
+                        // this.noSeatNoNum = noSeatNo.length
+
+                        // //整理TtableData
+                        // this.tableData.map((item, index) => {
+                        //     if(item.pw == undefined || item.pw == null || item.pw == '') item.pw = item.id
+                        //     item['classroom'] = {}
+                        //     item.classroom.classId = item.classId
+                        //     item.classroom.className = item.className
+                        //     item.year = this.academicYear ? this.academicYear.toString() : ''
+                        //     item.no = item.no ? item.no.toString() : ''
+                        //     return item
+                        // })
+
+                        // // 檢查與現在的學生名單同教室裡是否有重複座號
+                        // this.tableData.forEach( (item) => {
+                        //     let studdd = this.students.filter( (studInfo) => {
+                        //         return (item.classId == studInfo.classId && item.no == studInfo.no)
+                        //     })
+                        //     if(studdd.length > 0) {
+                        //         item.seatRepeat = true
+                        //         this.seatRepeatNum++
+                        //     }
+                        // })
                         
                         
                         this.$Message.info(this.$t('stuAccount.importTips11'))
                         this.$Message.info(this.$t('stuAccount.importTips11'))
                         this.tableLoading = false
                         this.tableLoading = false
@@ -369,8 +467,12 @@
             saveFileData() {
             saveFileData() {
                 if (this.isError == 0) {
                 if (this.isError == 0) {
                     this.uploadLoading = true
                     this.uploadLoading = true
-
-                    this.$api.stuAccount.saveStudent(this.schoolCode, this.tableData).then(
+                    //整理TtableData
+                    let temp = this.tableData.map((item) => {
+                        item.classNo = item.classId
+                        return item
+                    })
+                    this.$api.stuAccount.ImportStudent(this.schoolCode, temp).then(
                         (res) => {
                         (res) => {
                             if (res.error == null) {
                             if (res.error == null) {
                                 this.$emit('importStudentInfo', res.students)
                                 this.$emit('importStudentInfo', res.students)
@@ -445,6 +547,56 @@
                         slot: 'status'
                         slot: 'status'
                     }
                     }
                 ]
                 ]
+            },
+            validExcel(data){
+                let _this = this
+                var excelData = data
+                let validFalg = false
+
+                // 先歸零
+                this.errNumReset()
+
+                excelData.forEach( (item, index, array) => {
+                    // 座號、ID、教室ID、教室名稱必填
+                    if(item.no == '' || item.no == null || item.id == '' || item.id == null || item.classId == '' || item.classId == null || item.className == '' || item.className == null) {
+                        _this.excelValid.fieldIds.push(item.id)
+                        _this.excelFiledNum++
+                    }
+
+                    // 座號重複檢核
+                    let repNo = array.filter( (i) => {
+                        return i.id != item.id && i.classId != undefined && i.classId != null && i.classId != '' && i.classId == item.classId && i.no == item.no 
+                    })
+                    if(repNo.length > 0){
+                        for( let no of repNo) {
+                            _this.excelValid.noReaptIds.push(no.id)
+                            _this.seatRepeatNum ++
+                            validFalg = true
+                        }
+                    }
+
+                    // ID 重複
+                    let repID = array.filter( (i, key) => {
+                        return i.id == item.id && index != key
+                    })
+                    if(repID.length > 0){
+                        for( let id of repID) {
+                            _this.excelValid.reaptIds.push(id.id)
+                            _this.repeatNum ++
+                            validFalg = true
+                        }
+                    }
+                })
+
+                if( (_this.excelValid.noReaptIds.length + _this.excelValid.fieldIds.length + _this.excelValid.reaptIds.length) == 0){
+                    validFalg = true
+                }
+                return validFalg
+            },
+            errNumReset(){
+                this.repeatNum = 0 // 帳號重複
+                this.seatRepeatNum = 0 // 座號重複
+                this.excelFiledNum = 0 // Excel 欄位空白檢核
             }
             }
         },
         },
         created() {
         created() {

+ 22 - 15
TEAMModelOS/ClientApp/src/view/student-account/Index.vue

@@ -35,10 +35,10 @@
                         <span>{{ $t('stuAccount.menuAuth') }}</span>
                         <span>{{ $t('stuAccount.menuAuth') }}</span>
                     </li>
                     </li>
                     <!--授權管理開關-->
                     <!--授權管理開關-->
-                    <li @click="importStudent()">
+                    <!-- <li @click="importStudent()">
                         <Icon type="md-arrow-round-up" color="white" size="18" />
                         <Icon type="md-arrow-round-up" color="white" size="18" />
                         <span>{{ $t('stuAccount.importStu') }}</span>
                         <span>{{ $t('stuAccount.importStu') }}</span>
-                    </li>
+                    </li> -->
                     <li @click="addStudent()">
                     <li @click="addStudent()">
                         <Icon type="md-add" color="white" size="18" />
                         <Icon type="md-add" color="white" size="18" />
                         <span>{{ $t('stuAccount.addStu') }}</span>
                         <span>{{ $t('stuAccount.addStu') }}</span>
@@ -47,10 +47,10 @@
                         <Icon type="md-trash" :color="selections.length > 0 ? 'white' : '#606060'" size="18" />
                         <Icon type="md-trash" :color="selections.length > 0 ? 'white' : '#606060'" size="18" />
                         <span>{{ $t('stuAccount.delStu') }}</span>
                         <span>{{ $t('stuAccount.delStu') }}</span>
                     </li>
                     </li>
-                    <li @click="editStudent()" :class="selections.length > 0 ? '' : 'sc-disable-cursor'">
+                    <!-- <li @click="editStudent()" :class="selections.length > 0 ? '' : 'sc-disable-cursor'">
                         <Icon type="md-create" :color="selections.length > 0 ? 'white' : '#606060'" size="18" />
                         <Icon type="md-create" :color="selections.length > 0 ? 'white' : '#606060'" size="18" />
                         <span>{{ $t('stuAccount.editInfo') }}</span>
                         <span>{{ $t('stuAccount.editInfo') }}</span>
-                    </li>
+                    </li> -->
                     <li @click="resetPW(-1)" :class="selections.length > 0 ? '' : 'sc-disable-cursor'">
                     <li @click="resetPW(-1)" :class="selections.length > 0 ? '' : 'sc-disable-cursor'">
                         <Icon custom="iconfont icon-reset" :color="selections.length > 0 ? 'white' : '#606060'" size="18" />
                         <Icon custom="iconfont icon-reset" :color="selections.length > 0 ? 'white' : '#606060'" size="18" />
                         <span>重置密码</span>
                         <span>重置密码</span>
@@ -67,9 +67,7 @@
                     <template slot-scope="{ row }" slot="status">
                     <template slot-scope="{ row }" slot="status">
                         <Icon custom="iconfont icon-auth-key"
                         <Icon custom="iconfont icon-auth-key"
                               size="25"
                               size="25"
-                              :style="{
-                color: aclassOneInfoNum != undefined && (aclassOneInfoNum.staIds.includes(row.id) == true || aclassOneInfoNum.dyncIds.includes(row.id)) == true ? '#00f492' : '#565656'
-              }" />
+                              :style="{color: aclassOneInfoNum != undefined && (aclassOneInfoNum.staIds.includes(row.id) == true || aclassOneInfoNum.dyncIds.includes(row.id)) == true ? '#00f492' : '#565656'}" />
                     </template>
                     </template>
                     <template slot-scope="{ row, index }" slot="header">
                     <template slot-scope="{ row, index }" slot="header">
                         <!--<span class="name-header" :style="{background:bgColor[index % 12]}">{{getFirstChart(row.name)}}</span>-->
                         <!--<span class="name-header" :style="{background:bgColor[index % 12]}">{{getFirstChart(row.name)}}</span>-->
@@ -89,7 +87,7 @@
                     </template>
                     </template>
                     <template slot-scope="{ row }" slot="action" v-if="authorizationStatus == false">
                     <template slot-scope="{ row }" slot="action" v-if="authorizationStatus == false">
                         <div class="item-tools" v-if="$access.can('admin.*|student-upd')">
                         <div class="item-tools" v-if="$access.can('admin.*|student-upd')">
-                            <Icon type="md-create" size="18" color="white" @click="editStudent(row)" title="修改" />
+                            <!-- <Icon type="md-create" size="18" color="white" @click="editStudent(row)" title="修改" /> -->
                             <Icon custom="iconfont icon-reset" size="18" color="white" @click="resetPW(row)" title=" 重置密码" />
                             <Icon custom="iconfont icon-reset" size="18" color="white" @click="resetPW(row)" title=" 重置密码" />
                             <Icon type="md-trash" size="18" color="white" @click="delStudent(row)" title="删除" />
                             <Icon type="md-trash" size="18" color="white" @click="delStudent(row)" title="删除" />
                         </div>
                         </div>
@@ -183,6 +181,7 @@ export default {
                         let ids = []
                         let ids = []
                         row.pw = row.id
                         row.pw = row.id
                         row.year = row.year.toString()
                         row.year = row.year.toString()
+                        delete row.no
                         ids.push(row)
                         ids.push(row)
                         this.tableLoading = true
                         this.tableLoading = true
                         this.$api.stuAccount.saveAllStudent(this.$store.state.user.schoolCode, ids).then(
                         this.$api.stuAccount.saveAllStudent(this.$store.state.user.schoolCode, ids).then(
@@ -208,6 +207,7 @@ export default {
                             let apiData = this.selections.map( (item) =>{
                             let apiData = this.selections.map( (item) =>{
                                 let d = item
                                 let d = item
                                 d.pw = d.id
                                 d.pw = d.id
+                                delete d.no                                
                                 return d
                                 return d
                             })
                             })
 
 
@@ -273,14 +273,21 @@ export default {
             this.selectRow = row
             this.selectRow = row
         },
         },
         closeAddStudent(data) {
         closeAddStudent(data) {
+            let newStudents = []
             // 給一個 PW 讓AddStudent.vue 的Watch 可以動作
             // 給一個 PW 讓AddStudent.vue 的Watch 可以動作
-            let newStudents = data.studentInfos.map(function(item) {
-                let temp = item
-                temp.pw = '******'
-                temp.year = parseInt(temp.year)
-                return temp
-            })
-            let storePath = data.action == 1 ? 'schoolBaseInfo/addStudentsToState' : 'schoolBaseInfo/uptStudentsToState'
+            if (data.action == 1) { // 新增
+                data.studentInfos.pw = '******'
+                data.studentInfos.year = parseInt(data.studentInfos.year)
+                newStudents.push(data.studentInfos)
+            } else if (data.action == 2) {  // 修改
+                newStudents = data.studentInfos.map(function(item) {
+                    let temp = item
+                    temp.pw = '******'
+                    temp.year = parseInt(temp.year)
+                    return temp
+                })
+            }
+            let storePath = data.action == 1 ? 'schoolBaseInfo/addStudentsToState' : 'schoolBaseInfo/updStudentsToState'
             this.$store.dispatch(storePath, newStudents)
             this.$store.dispatch(storePath, newStudents)
             this.addStudentStatus = false
             this.addStudentStatus = false
             this.filterData()
             this.filterData()

+ 1 - 1
TEAMModelOS/Controllers/Client/HiTeachController.cs

@@ -823,7 +823,7 @@ namespace TEAMModelOS.Controllers.Client
             //Case 2 取得班級固定成員
             //Case 2 取得班級固定成員
             if(grant_type.GetString() == "school" && students.Count == 0 && !string.IsNullOrWhiteSpace(classId) && string.IsNullOrWhiteSpace(stulist))
             if(grant_type.GetString() == "school" && students.Count == 0 && !string.IsNullOrWhiteSpace(classId) && string.IsNullOrWhiteSpace(stulist))
             {
             {
-                var query = $"SELECT c.id, c.name, c.no, c.schoolId FROM c WHERE c.classId = '{classId}'";
+                var query = $"SELECT c.id, c.name, c.no, c.schoolId, c.groupId, c.groupName FROM c WHERE c.classId = '{classId}'";
                 await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school_code}") }))
                 await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school_code}") }))
                 {
                 {
                     using var jsonst = await JsonDocument.ParseAsync(item.ContentStream);
                     using var jsonst = await JsonDocument.ParseAsync(item.ContentStream);

File diff suppressed because it is too large
+ 1329 - 747
TEAMModelOS/Controllers/School/StudentController.cs