Browse Source

Merge branch 'develop5.0-tmd' of http://106.12.23.251:10080/TEAMMODEL/TEAMModelOS into develop5.0-tmd

zhouj1203@hotmail.com 4 years ago
parent
commit
e0948bd523

+ 3 - 2
TEAMModelOS/ClientApp/src/common/UploadModal.vue

@@ -56,9 +56,10 @@
                         </Checkbox>
                         <Progress style="top:-10px;" v-if="item.status == 0" :percent="item.loadedBytes * 100 / item.size" status="active" stroke-color="#1CC0F3" :stroke-width="2" hide-info />
                     </div>
-                    <div class="upload-item-right">
+                    <!-- 暂时去掉删除功能 -->
+                    <!-- <div class="upload-item-right">
                         <Icon type="ios-close" class="delete-btn" color="red" size="30" style="float:right;" @click="deleteFile(index)" />
-                    </div>
+                    </div> -->
                 </div>
             </div>
         </div>

+ 1 - 1
TEAMModelOS/ClientApp/src/locale/lang/en-US/schoolBaseInfo.js

@@ -142,7 +142,7 @@ export default {
   noEnable: '此序号尚未启用',
   onClassStu: '专科教室没有固定学生名单!',
   classNoErr: '教室编码不能为空!',
-  classNoErr1: '教室编码只能由字母和数字组成!',
+  classNoErr1: '班级只能是数字!',
   classAttr1: '常规教室(有固定学生)',
   classAttr2: '专科教室(无固定学生)',
   nameWarning: '请输入教室名称',

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

@@ -164,7 +164,7 @@ export default {
   noEnable: '此序号尚未启用',
   onClassStu: '专科教室没有固定学生名单!',
   classNoErr: '教室编码不能为空!',
-  classNoErr1: '教室编码只能由字母和数字组成!',
+  classNoErr1: '班级只能是数字!',
   classAttr1: '常规教室(有固定学生)',
   classAttr2: '专科教室(无固定学生)',
   nameWarning: '请输入名称',

+ 2 - 2
TEAMModelOS/ClientApp/src/locale/lang/zh-CN/stuAccount.js

@@ -3,8 +3,8 @@ export default {
   seatNo: '座号',
   account: '账号资讯',
   stuName: '姓名',
-  classroomCode: '教室编码',
-  classroomName: '教室名称',
+  classroomCode: '班级',
+  classroomName: '班级名称',
   period: '学段',
   grade: '年级',
   authStatus: '授权状态',

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

@@ -137,7 +137,7 @@ export default {
   noEnable: '此序號尚未啟用',
   onClassStu: '專科教室沒有固定學生名單!',
   classNoErr: '教室編碼不能為空!',
-  classNoErr1: '教室編碼只能由字母和數位組成!',
+  classNoErr1: '教室編碼只能是數字!',
   classAttr1: '班級教室(有固定學生)',
   classAttr2: '專科教室(無固定學生)',
   nameWarning: '請輸入教室名稱',

+ 13 - 1
TEAMModelOS/ClientApp/src/view/student-account/ClassMgt.less

@@ -449,7 +449,11 @@
     border: 1px solid aqua;
     padding: 1px 3px;
     border-radius: 3px;
-    vertical-align:middle;
+    vertical-align: middle;
+    text-align: center;
+    display: inline-block;
+    line-height: 16px;
+    height: 18px;
 }
 .item-tools{
     display:none;
@@ -459,4 +463,12 @@
     display: inline-block;
     margin-left: 10px;
     cursor: pointer;
+}
+.grade-year-tips{
+    display: inline-block;
+    width: 100%;
+    position: relative;
+    vertical-align: middle;
+    line-height: normal;
+    color: white;
 }

+ 112 - 34
TEAMModelOS/ClientApp/src/view/student-account/ClassMgt.vue

@@ -14,15 +14,18 @@
                         <DropdownItem :name="item.id">{{ item.name }}</DropdownItem>
                     </DropdownMenu>
                 </Dropdown>
-                <!-- <Dropdown class="sort-dropdown" trigger="click" placement="bottom-start" @on-click="function(e){ filterYear = e }" @on-visible-change="filterByYear" style="margin-left:15px">
+                <Dropdown class="sort-dropdown" trigger="click" placement="bottom-start" @on-click="function(e){ filterYear = e }" @on-visible-change="filterByYear" style="margin-left:15px">
                     <span style="cursor: pointer;">
-                        <b class="title">{{ filterYear}}</b>
+                        <b class="title">{{ filterYearName}}</b>
                         <Icon type="ios-arrow-down" style="margin-left:8px;"></Icon>
                     </span>
+                    <DropdownMenu slot="list">
+                        <DropdownItem name="all">全部</DropdownItem>
+                    </DropdownMenu>
                     <DropdownMenu slot="list" v-for="(item,index) in years" :value="item.value" :key="index">
-                        <DropdownItem :name="item.label">{{ item.label }}</DropdownItem>
+                        <DropdownItem :name="item.value">{{ item.label }}</DropdownItem>
                     </DropdownMenu>
-                </Dropdown> -->
+                </Dropdown>
                 <div v-if="!isSearch" style="float:right;">
                     <Icon class="action-btn-icon" type="ios-search" @click="isSearch = true" />
                     <Icon v-if="$access.can('admin.*|classroom-upd')" class="action-btn-icon" type="md-trash" @click.stop="showConfirmDelete()" />
@@ -94,19 +97,34 @@
                                     <span slot="label" class="class-attr-wrap-label">名称</span>
                                     <Input @on-change="watchUpdate" :disabled="editStatus" v-model="classListShow[curClassIndex].name" clearable :placeholder="$t('schoolBaseInfo.classroomNameHolder')" />
                                 </FormItem>
-                                <FormItem prop="no" @click.native.stop class="requird-color">
-                                    <span slot="label" class="class-attr-wrap-label">编码</span>
-                                    <Input @on-change="watchUpdate" :disabled="editStatus" v-model="classListShow[curClassIndex].no" clearable :placeholder="$t('schoolBaseInfo.classroomCodeHolder')" />
-                                </FormItem>
+
                                 <FormItem prop="gradeId" :label="$t('schoolBaseInfo.setGrade')" @click.native.stop class="requird-color">
-                                    <span slot="label" class="class-attr-wrap-label">学级</span>
-                                    <!-- <Select @on-change="watchUpdate" :disabled="editStatus" v-model="classListShow[curClassIndex].gradeId" clearable>
-                                        <Option v-for="(item,index) in $jsFn.getPeriod($store.state.user.schoolProfile.school_base,classListShow[curClassIndex].periodId).grades" :value="item.id" :key="index">
-                                            {{ item.name }}
+                                    <span slot="label" class="class-attr-wrap-label">学级/年级</span>
+                                    <!-- 暂未入学班级 -->
+                                    <p v-if="classListShow[curClassIndex].year > maxYear" class="grade-year-tips">
+                                        未到入学时间
+                                    </p>
+                                    <!-- 在校班级 -->
+                                    <Select v-else-if="classListShow[curClassIndex].year <= maxYear && classListShow[curClassIndex].year > minYear" @on-change="watchUpdate" :disabled="editStatus" v-model="classListShow[curClassIndex].year" clearable>
+                                        <Option v-for="(item,index) in years" :value="item.value" :key="index">
+                                            {{ item.label }}
                                         </Option>
-                                    </Select> -->
-                                    <DatePicker v-model="yearDate" :options="options" type="year" placeholder="请设置学级" style="width: 100%" @on-change="getClassYear"></DatePicker>
+                                    </Select>
+                                    <!-- 毕业班级 -->
+                                    <p v-else-if="classListShow[curClassIndex].year <= minYear && classListShow[curClassIndex].year > 0" class="grade-year-tips">
+                                        已毕业
+                                    </p>
+                                    <!-- 未设置 -->
+                                    <p v-else class="grade-year-tips">
+                                        未设置
+                                    </p>
+                                    <!-- <DatePicker v-model="yearDate" :options="options" type="year" placeholder="请设置学级" style="width: 100%" @on-change="getClassYear"></DatePicker> -->
                                 </FormItem>
+                                <FormItem prop="no" @click.native.stop class="requird-color">
+                                    <span slot="label" class="class-attr-wrap-label">班级</span>
+                                    <Input @on-change="watchUpdate" :disabled="editStatus" v-model="classListShow[curClassIndex].no" clearable :placeholder="$t('schoolBaseInfo.classroomCodeHolder')" />
+                                </FormItem>
+
                                 <FormItem prop="teacher" :label="$t('schoolBaseInfo.headmaster')" @click.native.stop class="requird-color">
                                     <span slot="label" class="class-attr-wrap-label">{{$t('schoolBaseInfo.headmaster')}}</span>
                                     <Select @on-change="watchUpdate" :disabled="editStatus" v-model="classListShow[curClassIndex].teacher.id" clearable filterable>
@@ -182,7 +200,7 @@ export default {
             if (!value) {
                 return callback(new Error(this.$t('schoolBaseInfo.classNoErr')))
             }
-            let zg = /^[0-9a-zA-Z]+$/
+            let zg = /^[0-9]+$/
             if (zg.test(value)) {
                 callback()
             } else {
@@ -196,7 +214,7 @@ export default {
                 }
             },
             roomList: [],
-            filterYear: '',
+            filterYear: 'all',
             // years:[2021,2020,2019,2018,2017,2016,2015,2014],
             studentColumn: [
                 {
@@ -280,7 +298,7 @@ export default {
                 openType: [
                     { required: true, message: this.$t('schoolBaseInfo.typeWarning'), trigger: 'change' }
                 ],
-                gradeId: [
+                year: [
                     { required: true, message: this.$t('schoolBaseInfo.gradeWarning'), trigger: 'change' }
                 ]
             }
@@ -290,6 +308,20 @@ export default {
         ...mapGetters({
             periods: 'user/getPeriods', // 學制s
         }),
+        filterYearName() {
+            if (this.filterYear == 'all') {
+                return '全部'
+            } else {
+                let data = this.years.find(item => {
+                    return item.value == this.filterYear
+                })
+                if (data) {
+                    return data.label
+                } else {
+                    return ''
+                }
+            }
+        },
         filterPeriodName: function () {
             let data = this.periods
             let pId = this.filterPeriod
@@ -354,7 +386,7 @@ export default {
                             value: year--
                         }
                     })
-                    this.filterYear = res[0].label
+                    // this.filterYear = res[0].label
                     return res
                 } else {
                     return []
@@ -371,13 +403,58 @@ export default {
                 }
             },
             set: function (value) {
-                if (this.classListShow[this.curClassIndex] && !this.classListShow[this.curClassIndex].year){
+                if (this.classListShow[this.curClassIndex] && !this.classListShow[this.curClassIndex].year) {
                     this.classListShow[this.curClassIndex].year = undefined
                 }
                 // this.yearDate = value
-            },
-
-        }
+            }
+        },
+        //当前学段在校最大学级
+        maxYear() {
+            let date = new Date()
+            let curYear = date.getFullYear()
+            let month = date.getMonth() + 1
+            if (this.schoolBase && this.schoolBase.period.length && this.filterPeriod) {
+                let pData = this.schoolBase.period.find(item => {
+                    return item.id == this.filterPeriod
+                })
+                if (pData) {
+                    let start = pData.semesters.find(item => {
+                        return item.start == 1
+                    })
+                    // 根据入学月份确定当前年级和学级的关系
+                    if (start && month < start.month) {
+                        curYear--
+                    }
+                    return curYear
+                }
+            } else {
+                return curYear
+            }
+        },
+        //当前学段在校最小学级
+        minYear() {
+            let date = new Date()
+            let curYear = date.getFullYear()
+            let month = date.getMonth() + 1
+            if (this.schoolBase && this.schoolBase.period.length && this.filterPeriod) {
+                let pData = this.schoolBase.period.find(item => {
+                    return item.id == this.filterPeriod
+                })
+                if (pData) {
+                    let start = pData.semesters.find(item => {
+                        return item.start == 1
+                    })
+                    // 根据入学月份确定当前年级和学级的关系
+                    if (start && month < start.month) {
+                        curYear--
+                    }
+                    return curYear - pData.grades.length
+                }
+            } else {
+                return curYear
+            }
+        },
     },
     methods: {
         //根据班级学年计算年级
@@ -398,7 +475,7 @@ export default {
                         curYear--
                     }
                     let res = pData.grades[curYear - year]
-                    if(curYear - year >= pData.grades.length){
+                    if (curYear - year >= pData.grades.length) {
                         return '已毕业'
                     }
                     return res ? res.name : '未到入学时间'
@@ -411,7 +488,6 @@ export default {
         },
         // 设置班级学年
         getClassYear(value, date) {
-            console.log(value, date)
             this.classListShow[this.curClassIndex].year = parseInt(value)
             this.updated = true
         },
@@ -478,7 +554,6 @@ export default {
         //确认添加学生
         confirmAddStu() {
             if (this.selections.length > 0) {
-                console.log(this.selections)
                 let data = this._.cloneDeep(this.selections)
                 data.forEach(item => {
                     item.classId = this.classListShow[this.curClassIndex].id
@@ -553,19 +628,22 @@ export default {
             return data
         },
         // 学级/年级筛选
-        filterByYear() {
-            this.curClassIndex = 0
-            // if (this.filterYear) {
-            //     this.classListShow = this.classList.filter(item => item.year == this.filterYear || !item.year)
-            // } else {
-            //     this.classListShow = [...this.classList]
-            // }
-            // 排序
-            // this.classListShow = this.dataSort(this.classListShow)
+        filterByYear(status) {
+            if (!status) {
+                this.curClassIndex = 0
+                if (this.filterYear == 'all') {
+                    this.filterByPeriod()
+                } else {
+                    this.classListShow = this.classList.filter(item => (item.year == this.filterYear || !item.year) && item.periodId == this.filterPeriod)
+                }
+                // 排序
+                this.classListShow = this.dataSort(this.classListShow)
+            }
         },
         //学段筛选
         filterByPeriod() {
             this.curClassIndex = 0
+            this.filterYear = 'all'
             if (this.filterPeriod) {
                 this.classListShow = this.classList.filter(item => item.periodId == this.filterPeriod || !item.periodId)
             } else {

+ 445 - 410
TEAMModelOS/ClientApp/src/view/student-account/ImportStudent.vue

@@ -1,8 +1,8 @@
 <style lang="less" scoped>
-    @import './ImportStudent.less';
+@import "./ImportStudent.less";
 </style>
 <style lang="less">
-    @import './IImportStudent.less';
+@import "./IImportStudent.less";
 </style>
 <template>
     <div class="content">
@@ -48,8 +48,8 @@
                 <div class="table-info-item" v-if="gradeNum != 0">
                     <span class="table-info-label">{{$t('年級錯誤:')}}</span>
                     <span class="table-info-num">{{gradeNum}}</span>
-                </div>                
-            
+                </div>
+
                 <div class="table-info-item" v-if="existNum != 0">
                     <span class="table-info-label">{{$t('stuAccount.importInfo5')}}</span>
                     <span class="table-info-num">{{existNum}}</span>
@@ -66,8 +66,8 @@
                 <template slot-scope="{ row,index }" slot="pw">
                     <p>{{(row.pw == '' || row.pw == null)? '— —' : row.pw+''}}</p>
                 </template>
-                <template slot-scope="{ row }" slot="gradeIndex">
-                    <p>{{ getGradesName(row.gradeIndex) }}</p>
+                <template slot-scope="{ row }" slot="classYear">
+                    <p>{{ `${getGradeByYear(row.classYear)}(${row.classYear}级)` }}</p>
                 </template>
                 <template slot-scope="{ row,index }" slot="status">
                     <!-- Excel 錯誤 -->
@@ -75,7 +75,7 @@
                     <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="(excelValid.gradeIds.length == 0 || excelValid.gradeIds.indexOf(row.id) == -1) ? 'account-success-tips':'account-warning-tips'">{{(excelValid.gradeIds.length == 0 || excelValid.gradeIds.indexOf(row.id) == -1)?"":"警告:年級錯誤" }}</p>                    
+                    <p :class="(excelValid.gradeIds.length == 0 || excelValid.gradeIds.indexOf(row.id) == -1) ? 'account-success-tips':'account-warning-tips'">{{(excelValid.gradeIds.length == 0 || excelValid.gradeIds.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>
@@ -90,456 +90,491 @@
     </div>
 </template>
 <script>
-    import excel from '../../utils/excel'
-    import {  mapGetters } from 'vuex'
-    export default {
-        props: {
-            isShow: {
-                type: Boolean,
-                default: false
-            },
-            schoolCode: {
-                type: String,
-                default: ''
-            },
-            academicYear: {
-                type: Number,
-            },
-            period: {
-                type: String,
-            }
+import excel from '../../utils/excel'
+import { mapGetters } from 'vuex'
+export default {
+    props: {
+        isShow: {
+            type: Boolean,
+            default: false
         },
-        data() {
-            return {
-                // Excel 檢核
-                excelValid:{
-                    fieldIds: [],
-                    noReaptIds: [],
-                    reaptIds: [],
-                    gradeIds: []
-                },
-                totalNum: 0,
-                seatRepeatNum: 0,
-                repeatNum: 0,
-                excelFiledNum: 0,
-                gradeNum: 0,
-                existNum: 0,
-                repeatAccounts: [],
-                noClassroomNum: 0,
-                noSeatNoNum: 0,
-                uploadLoading: false,
-                progressPercent: 0,
-                showProgress: false,
-                showRemoveFile: false,
-                selectionData: [],
-                file: null,
-                tableData: [],
-                tableTitle: [],
-                tableLoading: false,
-                systemColumn: [
-                    'id',
-                    // 'pw',//密码默认同账号
-                    'name',
-                    'className',
-                    'classId',
-                    'no'
-                ]
-            }
+        schoolCode: {
+            type: String,
+            default: ''
         },
-        components: {
+        academicYear: {
+            type: Number,
         },
-        computed: {
-            ...mapGetters({
-                students: 'schoolBaseInfo/getStudent', // 學生List
-                grades: 'user/getGrades', // 年級
-                classes: 'user/getClasses', // 教室ID
-            }),
-            isError() {
-                return this.repeatNum + this.seatRepeatNum + this.excelFiledNum + this.gradeNum
+        period: {
+            type: String,
+        }
+    },
+    data() {
+        return {
+            // Excel 檢核
+            excelValid: {
+                fieldIds: [],
+                noReaptIds: [],
+                reaptIds: [],
+                gradeIds: []
             },
-            show: {
-                get() {
-                    return this.isShow
-                },
-                set(value) {
-                }
-            }
-        },
-        watch: {
+            totalNum: 0,
+            seatRepeatNum: 0,
+            repeatNum: 0,
+            excelFiledNum: 0,
+            gradeNum: 0,
+            existNum: 0,
+            repeatAccounts: [],
+            noClassroomNum: 0,
+            noSeatNoNum: 0,
+            uploadLoading: false,
+            progressPercent: 0,
+            showProgress: false,
+            showRemoveFile: false,
+            selectionData: [],
+            file: null,
+            tableData: [],
+            tableTitle: [],
+            tableLoading: false,
+            systemColumn: [
+                'id',
+                'pw',
+                'name',
+                'className',
+                'classId', //班级编号 1,2,3(只能是数字)
+                'no',
+                'stuYear',//学生学级
+                'classYear'//班级年级
+            ]
+        }
+    },
+    components: {
+    },
+    computed: {
+        ...mapGetters({
+            students: 'schoolBaseInfo/getStudent', // 學生List
+            grades: 'user/getGrades', // 年級
+            classes: 'user/getClasses', // 教室ID
+        }),
+        isError() {
+            return this.repeatNum + this.seatRepeatNum + this.excelFiledNum + this.gradeNum
         },
-        methods: {
-            getSelectInfo() {
-
+        show: {
+            get() {
+                return this.isShow
             },
-            cancelAll() {
+            set(value) {
+            }
+        }
+    },
+    watch: {
+    },
+    methods: {
+        getSelectInfo() {
 
-            },
-            getGradesName: function(val) {
-                let str = '不存在此年級'
-                if(this.grades){
-                    let p = this.period
-                    let data = this.grades.filter( (item)=>{
-                        return item.periodId == p
-                    })
-                    if(data.length > 0 && data[val-1]) {
-                        str = data[val-1].name
-                    }
-                }
-                return str
-            },
-            rowClassName(row, index) {
-                let className = ''
+        },
+        cancelAll() {
 
-                if( this.excelValid.fieldIds.indexOf(row.id) >= 0 || this.excelValid.noReaptIds.indexOf(row.id) >= 0 || this.excelValid.reaptIds.indexOf(row.id) >= 0  || this.excelValid.gradeIds.indexOf(row.id) >= 0){
-                    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 '
+        },
+        //根据班级学年计算年级
+        getGradeByYear(year) {
+            console.log(year)
+            if (year && this.schoolBase && this.schoolBase.period.length && this.period) {
+                let pData = this.schoolBase.period.find(item => {
+                    return item.id == this.period
+                })
+                if (pData) {
+                    let date = new Date()
+                    let curYear = date.getFullYear()
+                    let month = date.getMonth() + 1
+                    let start = pData.semesters.find(item => {
+                        return item.start == 1
+                    })
+                    // 根据入学月份确定当前年级和学级的关系
+                    if (start && month < start.month) {
+                        curYear--
                     }
-                    if (row.classId == '' || row.classId == null || row.no == '' || row.no == null) {
-                        className = className + 'account-warning-row-bg'
+                    let res = pData.grades[curYear - year]
+                    if (curYear - year >= pData.grades.length) {
+                        return '已毕业'
                     }
-                }
-                return className
-            },
-            cancelUploadFile() {
-                this.file = null
-            },
-            initUpload() {
-                this.file = null
-                this.showProgress = false
-                this.tableData = []
-            },
-            openUploadFile() {
-                this.initUpload()
-            },
-            handleRemove() {
-                this.initUpload()
-                this.$Message.info(this.$t('stuAccount.importTips4'))
-            },
-            handleBeforeUpload(file) {
-                const fileExt = file.name.split('.').pop().toLocaleLowerCase()
-                if (fileExt === 'xlsx' || fileExt === 'xls') {
-                    this.readFile(file)
-                    this.file = file
+                    return res ? res.name : '未入学'
                 } else {
-                    this.$Notice.warning({
-                        title: this.$t('stuAccount.importTips5'),
-                        desc: this.$t('stuAccount.importTips6') + file.name + this.$t('stuAccount.importTips7')
-                    })
+                    return '- -'
                 }
-                return false
-            },
-            // 读取文件
-            readFile(file) {
-                this.tableLoading = true
-                const reader = new FileReader()
-                reader.readAsArrayBuffer(file)
-                reader.onloadstart = e => {
-                    this.showProgress = true
-                }
-                reader.onprogress = e => {
-                    this.progressPercent = Math.round(e.loaded / e.total * 100)
+            } else {
+                return '- -'
+            }
+        },
+        rowClassName(row, index) {
+            let className = ''
+
+            if (this.excelValid.fieldIds.indexOf(row.id) >= 0 || this.excelValid.noReaptIds.indexOf(row.id) >= 0 || this.excelValid.reaptIds.indexOf(row.id) >= 0 || this.excelValid.gradeIds.indexOf(row.id) >= 0) {
+                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 '
                 }
-                reader.onerror = e => {
-                    this.$Message.error(this.$t('stuAccount.importTips8'))
+                if (row.classId == '' || row.classId == null || row.no == '' || row.no == null) {
+                    className = className + 'account-warning-row-bg'
                 }
-                reader.onload = e => {
-                    const data = e.target.result
-                    const { header, results } = excel.read(data, 'array')
-                    const tableColumn = header.map(item => { return { title: item, key: item } })
-                    const columns = tableColumn.map(item => {
-                        return item.key
-                    })
-                    const columnStr = columns.join('')
-                    let flag = true
-                    let column = ''
-                    console.log('汇入表头:',columns)
-                    for (let item of this.systemColumn) {
-                        let f = 0
-                        for (let i of columns) {
-                            if (i == item) {
-                                f = 1
-                                break
-                            }
-                        }
-                        if (f == 0) {
-                            column = item
-                            flag = false
+            }
+            return className
+        },
+        cancelUploadFile() {
+            this.file = null
+        },
+        initUpload() {
+            this.file = null
+            this.showProgress = false
+            this.tableData = []
+        },
+        openUploadFile() {
+            this.initUpload()
+        },
+        handleRemove() {
+            this.initUpload()
+            this.$Message.info(this.$t('stuAccount.importTips4'))
+        },
+        handleBeforeUpload(file) {
+            const fileExt = file.name.split('.').pop().toLocaleLowerCase()
+            if (fileExt === 'xlsx' || fileExt === 'xls') {
+                this.readFile(file)
+                this.file = file
+            } else {
+                this.$Notice.warning({
+                    title: this.$t('stuAccount.importTips5'),
+                    desc: this.$t('stuAccount.importTips6') + file.name + this.$t('stuAccount.importTips7')
+                })
+            }
+            return false
+        },
+        // 读取文件
+        readFile(file) {
+            this.tableLoading = true
+            const reader = new FileReader()
+            reader.readAsArrayBuffer(file)
+            reader.onloadstart = e => {
+                this.showProgress = true
+            }
+            reader.onprogress = e => {
+                this.progressPercent = Math.round(e.loaded / e.total * 100)
+            }
+            reader.onerror = e => {
+                this.$Message.error(this.$t('stuAccount.importTips8'))
+            }
+            reader.onload = e => {
+                const data = e.target.result
+                const { header, results } = excel.read(data, 'array')
+                const tableColumn = header.map(item => { return { title: item, key: item } })
+                const columns = tableColumn.map(item => {
+                    return item.key
+                })
+                const columnStr = columns.join('')
+                let flag = true
+                let column = ''
+                for (let item of this.systemColumn) {
+                    let f = 0
+                    for (let i of columns) {
+                        if (i == item) {
+                            f = 1
                             break
                         }
                     }
-                    if (flag) {
-                        // 处理表格导入数据类型
-                        this.tableData = results.filter(item => {
-                            // let arr = item.id.split('#') //账号id不用#
-                            // if (arr.length == 2) {
-                                for (let i of this.systemColumn) {
-                                    if (i != 'no') {
-                                        if (typeof item[i] === 'number') {
-                                            item[i] = item[i] + ''
-                                        }
-                                        //表格去掉pw栏位,密码默认同账号id
-                                        // if (item.pw == undefined) {
-                                        //     item.pw = arr[1]
-                                        // }
-                                        item.pw = item.id
-                                    }
+                    if (f == 0) {
+                        column = item
+                        flag = false
+                        break
+                    }
+                }
+                if (flag) {
+                    // 处理表格导入数据类型
+                    this.tableData = results.filter(item => {
+                        // let arr = item.id.split('#') //账号id不用#
+                        // if (arr.length == 2) {
+                        for (let i of this.systemColumn) {
+                            if (i != 'no') {
+                                if (typeof item[i] === 'number') {
+                                    item[i] = item[i] + ''
                                 }
-                            // } else {
-                            //     item._disabled = true
-                            // }
-                            return item
-                        })
+                                //表格保留pw栏位,如果没有设置则密码默认同账号id
+                                // if (item.pw == undefined) {
+                                //     item.pw = arr[1]
+                                // }
+                                item.pw = item.pw || item.id
+                                // item.pw = item.id
+                            }
+                        }
+                        // } else {
+                        //     item._disabled = true
+                        // }
+                        return item
+                    })
 
-                        // 給予Excel 總數
-                        this.totalNum = this.tableData.length
+                    // 給予Excel 總數
+                    this.totalNum = this.tableData.length
 
-                        // 檢核現在的Excel 邏輯
-                        let excelFlag = this.validExcel(this.tableData)
+                    // 檢核現在的Excel 邏輯
+                    let excelFlag = this.validExcel(this.tableData)
 
-                        // Excel 檢核通過再和DATA比對
-                        if(excelFlag){
-                            // 先歸零
-                            this.errNumReset()
+                    // Excel 檢核通過再和DATA比對
+                    if (excelFlag) {
+                        // 先歸零
+                        this.errNumReset()
 
-                            // 比較 students 取出已存在的教室內容
-                            // 取出Excel重複的班級
-                            let classIds = []
-                            this.tableData.forEach( (item) => {
-                                if (classIds.indexOf(item.classId) < 0) { classIds.push(item.classId) }
+                        // 比較 students 取出已存在的教室內容
+                        // 取出Excel重複的班級
+                        let classIds = []
+                        this.tableData.forEach((item) => {
+                            if (classIds.indexOf(item.classId) < 0) { classIds.push(item.classId) }
+                        })
+                        // 先篩選出會被修改的學生
+                        let updStuds = []
+                        classIds.forEach((id) => {
+                            let stud = this.students.filter((studInfo) => {
+                                return (id == studInfo.classNo)
                             })
-                            // 先篩選出會被修改的學生
-                            let updStuds = []
-                            classIds.forEach( (id) => {
-                                let stud = this.students.filter( (studInfo) => {
-                                    return (id == studInfo.classNo)
-                                })
 
-                                updStuds.push(...stud)
+                            updStuds.push(...stud)
+                        })
+
+                        // 修改與新增的學生檢核
+                        this.tableData.forEach((item, index, array) => {
+                            // 檢查座號是否與校內的衝突
+                            // 先抓教室座號是否與原教室座號重複
+                            let repStud = updStuds.filter((studInfo) => {
+                                return (item.classId == studInfo.classNo && item.no == studInfo.no)
                             })
 
-                            // 修改與新增的學生檢核
-                            this.tableData.forEach( (item, index, array) => {
-                                // 檢查座號是否與校內的衝突
-                                // 先抓教室座號是否與原教室座號重複
-                                let repStud = updStuds.filter( (studInfo) => {
-                                    return (item.classId == studInfo.classNo && item.no == studInfo.no)
+                            if (repStud.length > 0) {
+                                let isExistTable = array.some((a) => {
+                                    return a.classId == repStud[0].classNo && a.id == repStud[0].id
                                 })
 
-                                if(repStud.length > 0) {
-                                    let isExistTable = array.some( (a) => {
-                                        return a.classId == repStud[0].classNo && a.id == repStud[0].id
-                                    })
-                                    
-                                    if (!isExistTable) {
-                                        item.seatRepeat = true
-                                        this.seatRepeatNum++
-                                    }
+                                if (!isExistTable) {
+                                    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() : ''
-                                item.periodId = this.period
-                                return item
-                            })
-                        }
-                        
-                        this.$Message.info(this.$t('stuAccount.importTips11'))
-                        this.tableLoading = false
-                    } else {
-                        this.$Message.error({
-                            content: this.$t('stuAccount.importTips9') + column + this.$t('stuAccount.importTips10'),
-                            duration: 4
+                            }
+                        })
+
+                        //整理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() : ''//通过表格汇入,不用从UI上面设置
+                            item.year = item.stuYear
+                            item.no = item.no ? item.no.toString() : ''
+                            item.periodId = this.period
+                            return item
                         })
-                        this.tableLoading = false
                     }
-                    this.showRemoveFile = true
-                }
-            },
-            saveFileData() {
-                if (this.isError == 0) {
-                    this.uploadLoading = true
-                    //整理TtableData
-                    let temp = this.tableData.map((item) => {
-                        item.classNo = item.classId
-                        delete item.classId
-                        delete item._disabled
-                        delete item.schoolCode
-                        delete item.classroom
-                        return item
-                    })
-                    this.$api.stuAccount.ImportStudent(this.schoolCode, temp).then(
-                        (res) => {
-                            if (res.error == null) {
-                                this.$emit('importStudentInfo', res.students)
-                                this.$Message.info(this.$t('匯入成功'))
-                                this.initData()
-                                this.uploadLoading = false
-                            } else {
-                                this.$Message.error('API error!')
-                            }
-                        },
-                        (err) => {
 
-                        }
-                    )
+                    this.$Message.info(this.$t('stuAccount.importTips11'))
+                    this.tableLoading = false
                 } else {
-                    this.$Message.error(this.$t('stuAccount.importTips12'))
+                    this.$Message.error({
+                        content: this.$t('stuAccount.importTips9') + column + this.$t('stuAccount.importTips10'),
+                        duration: 4
+                    })
+                    this.tableLoading = false
                 }
-            },
-            cancel() {
-                this.initData()
-                this.$emit('importStudentInfo', {
-                    data: []
+                this.showRemoveFile = true
+            }
+        },
+        saveFileData() {
+            if (this.isError == 0) {
+                this.uploadLoading = true
+                //整理TtableData
+                let temp = this.tableData.map((item) => {
+                    item.classNo = item.classId
+                    delete item.classId
+                    delete item._disabled
+                    delete item.schoolCode
+                    delete item.classroom
+                    return item
                 })
-            },
-            initData() {
-                this.totalNum = 0
-                this.repeatNum = 0
-                this.existNum = 0
-                this.seatRepeatNum = 0
-                this.repeatAccounts = []
-                this.noClassroomNum = 0
-                this.noSeatNoNum = 0
-                this.uploadLoading = false
-                this.progressPercent = 0
-                this.showProgress = false
-                this.showRemoveFile = false
-                this.file = null
-                this.tableData = []
-                this.tableTitle = [
-                    {
-                        type: 'selection',
-                        width: 80,
-                        align: 'center'
-                    },
-                    {
-                        title: this.$t('stuAccount.seatNo'),
-                        key: 'no',
-                        width: 80
-                    },
-                    {
-                        title: this.$t('stuAccount.account'),
-                        key: 'id'
-                    },
-                    {
-                        title: this.$t('stuAccount.password'),
-                        slot: 'pw'
-                    },
-                    {
-                        title: this.$t('stuAccount.stuName'),
-                        key: 'name'
-                    },
-                    // {
-                    //     title: '年級',
-                    //     slot: 'gradeIndex'
-                    // },
-                    {
-                        title: this.$t('stuAccount.classroomName'),
-                        key: 'className'
-                    },
-                    {
-                        title: this.$t('stuAccount.classroomCode'),
-                        key: 'classId'
-                    },
-                    {
-                        title: this.$t('stuAccount.abnormalStatus'),
-                        slot: 'status'
+                this.$Message.warning('API待调整')
+                // this.$api.stuAccount.ImportStudent(this.schoolCode, temp).then(
+                //     (res) => {
+                //         if (res.error == null) {
+                //             this.$emit('importStudentInfo', res.students)
+                //             this.$Message.info(this.$t('匯入成功'))
+                //             this.initData()
+                //             this.uploadLoading = false
+                //         } else {
+                //             this.$Message.error('API error!')
+                //         }
+                //     },
+                //     (err) => {
+
+                //     }
+                // )
+            } else {
+                this.$Message.error(this.$t('stuAccount.importTips12'))
+            }
+        },
+        cancel() {
+            this.initData()
+            this.$emit('importStudentInfo', {
+                data: []
+            })
+        },
+        initData() {
+            this.totalNum = 0
+            this.repeatNum = 0
+            this.existNum = 0
+            this.seatRepeatNum = 0
+            this.repeatAccounts = []
+            this.noClassroomNum = 0
+            this.noSeatNoNum = 0
+            this.uploadLoading = false
+            this.progressPercent = 0
+            this.showProgress = false
+            this.showRemoveFile = false
+            this.file = null
+            this.tableData = []
+            this.tableTitle = [
+                {
+                    type: 'selection',
+                    width: 80,
+                    align: 'center'
+                },
+                {
+                    title: this.$t('stuAccount.seatNo'),
+                    key: 'no',
+                    width: 80
+                },
+                {
+                    title: this.$t('stuAccount.account'),
+                    key: 'id'
+                },
+                {
+                    title: this.$t('stuAccount.password'),
+                    slot: 'pw'
+                },
+                {
+                    title: this.$t('stuAccount.stuName'),
+                    key: 'name'
+                },
+                {
+                    title: '学级',
+                    key: 'stuYear'
+                },
+                {
+                    title: this.$t('stuAccount.classroomName'),
+                    key: 'className'
+                },
+                {
+                    title: '年级',
+                    slot: 'classYear'
+                },
+                {
+                    title: this.$t('stuAccount.classroomCode'),
+                    key: 'classId'
+                },
+                
+                {
+                    title: this.$t('stuAccount.abnormalStatus'),
+                    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 || item.gradeIndex == '' || item.gradeIndex == null) {
+                if (!item.no || !item.id || !item.classId || !item.className) {
+                    _this.excelValid.fieldIds.push(item.id)
+                    _this.excelFiledNum++
+                } else {
+                    // 座號重複檢核
+                    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++
+                        }
                     }
-                ]
-            },
-            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 || item.gradeIndex == '' || item.gradeIndex == null) {
-                    if(!item.no || !item.id || !item.classId || !item.className) {
-                        _this.excelValid.fieldIds.push(item.id)
-                        _this.excelFiledNum++
-                    } else {
-                        // 座號重複檢核
-                        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++
-                            }
+
+                    // 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++
                         }
+                    }
 
-                        // ID 重複
-                        let repID = array.filter( (i, key) => {
-                            return i.id == item.id && index != key
+                    // 年級與教室的組合必須一致
+                    let classInfo = _this.classes.filter((i) => {
+                        return item.classId == i.no
+                    })
+                    if (classInfo.length > 0) {
+                        let gradeID = ''
+                        let data = _this.grades.filter((i) => {
+                            return i.periodId == _this.period
                         })
-                        if(repID.length > 0){
-                            for( let id of repID) {
-                                _this.excelValid.reaptIds.push(id.id)
-                                _this.repeatNum++
-                            }
+                        if (data.length > 0 && data[item.gradeIndex - 1]) {
+                            gradeID = data[item.gradeIndex - 1].id
                         }
-
-                        // 年級與教室的組合必須一致
-                        let classInfo = _this.classes.filter( (i) => {
-                            return item.classId == i.no
+                        // //不用设置年级,通过学级自动计算年级
+                        // if(gradeID != classInfo[0].gradeId){
+                        //     _this.excelValid.gradeIds.push(item.id)
+                        //     _this.gradeNum++
+                        // }
+                    } else {
+                        let data = array.filter((i) => {
+                            return i.classId == item.classId && i.gradeIndex != item.gradeIndex
                         })
-                        if(classInfo.length > 0){
-                            let gradeID = ''
-                            let data = _this.grades.filter( (i)=>{
-                                return i.periodId == _this.period
-                            })
-                            if(data.length > 0 && data[item.gradeIndex-1]) {
-                                gradeID = data[item.gradeIndex-1].id
-                            }
-                            // //不用设置年级,通过学级自动计算年级
-                            // if(gradeID != classInfo[0].gradeId){
-                            //     _this.excelValid.gradeIds.push(item.id)
-                            //     _this.gradeNum++
-                            // }
-                        } else {
-                            let data = array.filter( (i) => {
-                                return i.classId == item.classId && i.gradeIndex != item.gradeIndex
-                            })
 
-                            if(data.length > 0){
-                                _this.excelValid.gradeIds.push(item.id)
-                                _this.gradeNum++
-                            }
+                        if (data.length > 0) {
+                            _this.excelValid.gradeIds.push(item.id)
+                            _this.gradeNum++
                         }
                     }
-                })
-
-                if( (_this.excelValid.noReaptIds.length + _this.excelValid.fieldIds.length + _this.excelValid.reaptIds.length + _this.excelValid.gradeIds.length) == 0){
-                    validFalg = true
                 }
-                return validFalg
-            },
-            errNumReset(){
-                this.repeatNum = 0 // 帳號重複
-                this.seatRepeatNum = 0 // 座號重複
-                this.excelFiledNum = 0 // Excel 欄位空白檢核
-                this.gradeNum = 0 // 年級錯誤
+            })
+
+            if ((_this.excelValid.noReaptIds.length + _this.excelValid.fieldIds.length + _this.excelValid.reaptIds.length + _this.excelValid.gradeIds.length) == 0) {
+                validFalg = true
             }
+            return validFalg
         },
-        created() {
-            this.initData()
-        },
-        mounted() {
-        },
-        watch: {
-            
+        errNumReset() {
+            this.repeatNum = 0 // 帳號重複
+            this.seatRepeatNum = 0 // 座號重複
+            this.excelFiledNum = 0 // Excel 欄位空白檢核
+            this.gradeNum = 0 // 年級錯誤
         }
+    },
+    created() {
+        this.initData()
+        //直接读取登录成功拿到得学校基础信息
+        this.$store.dispatch('user/getSchoolProfile').then(
+            res => {
+                this.schoolBase = res.school_base
+            },
+            err => {
+                this.$Message.warning(this.$t('cusMgt.noSchool'))
+            }
+        )
+    },
+    mounted() {
+    },
+    watch: {
+
     }
+}
 </script>

+ 19 - 12
TEAMModelOS/ClientApp/src/view/student-account/Index.vue

@@ -131,14 +131,16 @@
             <div slot="header">
                 <span class="import-model-title">{{ $t('stuAccount.importTitle') }}</span>
                 <div style="display: flex;justify-items: center;">
-                    <div class="importPeriod">
+                    <!-- <div class="importPeriod">
                         <span class="label">目前學段:</span>
                         <span class="name">{{ getPeriodName }}</span>
-                    </div>
-                    <div class="importAcademicYear">
+                    </div> -->
+                    <BasePdSelect @pd-change="(data)=>{searchPeriod = data }"></BasePdSelect>
+                    <!-- 由excel汇入 -->
+                    <!-- <div class="importAcademicYear">
                         <span class="label">學年度:</span>
                         <InputNumber v-model="academicYear" :editable="false"></InputNumber>
-                    </div>
+                    </div> -->
                 </div>
             </div>
             <import-student v-if="importStudentStatus" :period="searchPeriod" :schoolCode="$store.state.user.schoolCode" :isShow="importStudentStatus" @importStudentInfo="closeImportStudent" :academicYear="academicYear"></import-student>
@@ -672,6 +674,7 @@ export default {
         /**根据学段、年级、班级搜索 */
         filterData: function () {
             let data = this.students
+            // 优先判断班级筛选条件
             // 筛选没有关联班级的学生
             if (this.searchClassroom == 'noclass') {
                 if (this.searchClassroom) {
@@ -681,11 +684,21 @@ export default {
                     })
                 }
 
+                this.tableFilterData = data
+                this.pointNum = this.basicCount
+                this.tableShowData = data.slice(0, this.basicCount)
+                return
+            } else if (this.searchClassroom) {
+                let id = this.searchClassroom
+                data = data.filter(function (item) {
+                    return item.classId == id
+                })
                 this.tableFilterData = data
                 this.pointNum = this.basicCount
                 this.tableShowData = data.slice(0, this.basicCount)
                 return
             }
+            
 
             // 帳號資訊搜尋
             if (this.searchText) {
@@ -711,13 +724,7 @@ export default {
                 })
             }
 
-            // 教室篩選
-            if (this.searchClassroom) {
-                let id = this.searchClassroom
-                data = data.filter(function (item) {
-                    return item.classId == id
-                })
-            }
+
 
             this.tableFilterData = data
             this.pointNum = this.basicCount
@@ -748,7 +755,7 @@ export default {
                     }
                     this.academicYear = curYear
                 }
-                
+
             }
         )
         this.initData()