瀏覽代碼

#251 調整批次上傳功能

新增座號篩選與API格式調整
osbert 4 年之前
父節點
當前提交
f815d7eebe

+ 6 - 0
TEAMModelOS/ClientApp/src/store/module/schoolBaseInfo.js

@@ -26,6 +26,9 @@ export default {
             state.classroomList = data
         },
         setStudents(state, data) {
+            state.students = data
+        },
+        addStudents(state, data) {
             state.students.push(...data)
         },
         uptStudents(state, data) {
@@ -158,6 +161,9 @@ export default {
         setStudentsToState(context, data) {
             context.commit('setStudents', data)
         },
+        addStudentsToState(context, data) {
+            context.commit('addStudents', data)
+        },
         uptStudentsToState(context, data) {            
             context.commit('uptStudents', data)
         },

+ 24 - 0
TEAMModelOS/ClientApp/src/view/student-account/IImportStudent.less

@@ -135,3 +135,27 @@
     border: none;
     padding: 0px;
 }
+.importAcademicYear{
+    z-index: 1;
+    position: absolute;
+    left: 24px;
+    top: 8px;
+    overflow: hidden;
+    cursor: pointer;
+    display: flex;
+    align-items: center;
+}
+.importAcademicYear .label{
+    color: #7d7d7d;
+    margin-right: 5px;
+    font-size: 16px;
+}
+.importAcademicYear .ivu-input-number{
+    border-color: #7d7d7d;
+}
+.importAcademicYear .ivu-input-number-input{
+    border: 1px solid #7d7d7d;
+    color: #7d7d7d;
+    font-size: 16px;
+    background-color: #383838;
+}

+ 6 - 2
TEAMModelOS/ClientApp/src/view/student-account/ImportStudent.less

@@ -46,14 +46,18 @@
     }
 
     & > &-item:nth-child(4) {
-        color: #1CCC9E;
+        color: #ed6565;
     }
 
     & > &-item:nth-child(5) {
-        color: #E1B551;
+        color: #1CCC9E;
     }
 
     & > &-item:nth-child(6) {
+        color: #E1B551;
+    }
+
+    & > &-item:nth-child(7) {
         color: #11fd03;
     }
     /*& > &-item:last-child {

+ 27 - 4
TEAMModelOS/ClientApp/src/view/student-account/ImportStudent.vue

@@ -37,7 +37,11 @@
                     <span class="table-info-label">{{$t('stuAccount.importInfo4')}}</span>
                     <span class="table-info-num">{{noClassroomNum}}</span>
                 </div>
-
+                <div class="table-info-item" v-if="noSeatNoNum != 0">
+                    <span class="table-info-label">{{$t('沒有座號:')}}</span>
+                    <span class="table-info-num">{{noSeatNoNum}}</span>
+                </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>
@@ -58,9 +62,11 @@
                     <p :class="(repeatAccounts.length == 0 || repeatAccounts.indexOf(row.account) == -1) ? 'account-success-tips':'account-error-tips'">{{(repeatAccounts.length == 0 || repeatAccounts.indexOf(row.account) == -1)?"":"错误:账号重复!" }}</p>
                     <p :class="(row.classroomCode == '' || row.classroomCode == null) ? 'account-warning-tips':''">{{(row.classroomCode == '' || row.classroomCode == null)?"警告 :未找到指定班级":"" }}</p>
                     <p :class="row.seatRepeat? 'account-error-tips':''">{{row.seatRepeat ? "错误:座位号重复":"" }}</p>
+                    <p :class="(row.seatNo == '' || row.seatNo == null) ? 'account-warning-tips':''">{{(row.seatNo == '' || row.seatNo == null)?"警告 :沒有座號":"" }}</p>
                 </template>
             </Table>
             <p style="margin-top:15px;">{{$t('stuAccount.passwordTips')}}</p>
+            {{'isError: ' + isError }}
             <Button class="confirm-btn" :class=" isError == 0 ?'confirm-btn-active':''  " :loading="uploadLoading" @click="saveFileData">
                 {{$t('stuAccount.submitList')}}
             </Button>
@@ -78,6 +84,9 @@
             schoolCode: {
                 type: String,
                 default: ''
+            },
+            academicYear: {
+                type: Number,
             }
         },
         data() {
@@ -112,7 +121,8 @@
         },
         computed: {
             isError() {
-                return this.seatRepeatNum + this.repeatNum + this.existNum + this.noClassroomNum
+                console.log(this.noSeatNoNum, 'this.seatRepeatNum + this.repeatNum + this.existNum + this.noClassroomNum + this.noSeatNoNum')
+                return this.seatRepeatNum + this.repeatNum + this.existNum + this.noClassroomNum + this.noSeatNoNum
             },
             show: {
                 get() {
@@ -137,7 +147,7 @@
                 if (!(this.repeatAccounts.length == 0 || this.repeatAccounts.indexOf(row.studentId) == -1) || row.seatRepeat) {
                     className = className + 'account-error-row-bg '
                 }
-                if (row.classroomCode == '' || row.classroomCode == null) {
+                if (row.classroomCode == '' || row.classroomCode == null || row.seatNo == '' || row.seatNo == null) {
                     className = className + 'account-warning-row-bg'
                 }
                 return className
@@ -264,6 +274,14 @@
                         // 筛选没有班级账号
                         let noRoom = this.tableData.filter(item => { return (item.classroomCode == '' || item.classroomCode == null) })
                         this.noClassroomNum = noRoom.length
+
+                        // 筛选沒有有座號
+                        let noSeatNo = this.tableData.filter(item => { return (item.seatNo == '' || item.seatNo == null) })
+                        console.log(noSeatNo, 'noSeatNo')
+                        console.log(noSeatNo.length)
+                        this.noSeatNoNum = noSeatNo.length
+
+                        //整理TtableData
                         this.tableData.map((item, index) => {
                             let val = item.password
                             item.password = {}
@@ -273,6 +291,7 @@
                             item.password['value'] = val
                             return item
                         })
+
                         this.$Message.info(this.$t('stuAccount.importTips11'))
                         this.tableLoading = false
                     } else {
@@ -362,6 +381,7 @@
                 this.seatRepeatNum = 0
                 this.repeatAccounts = []
                 this.noClassroomNum = 0
+                this.noSeatNoNum = 0
                 this.uploadLoading = false
                 this.progressPercent = 0
                 this.showProgress = false
@@ -408,12 +428,15 @@
         },
         created() {
             this.initData()
+            console.log(this.academicYear, 'academicYear')
         },
         mounted() {
 
         },
         watch: {
-
+            academicYear: function(newVal, oldVal){
+                console.log(newVal)
+            }
         }
     }
 </script>

+ 73 - 86
TEAMModelOS/ClientApp/src/view/student-account/Index.vue

@@ -47,7 +47,7 @@
                         <Icon type="md-create" :color="selections.length > 0 ? 'white':'#606060'" size="18" />
                         <span>{{ $t('stuAccount.editInfo') }}</span>
                     </li>
-                    <li @click="resetPW()" :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" />
                         <span>重置密码</span>
                     </li>
@@ -86,10 +86,7 @@
                     </template>
                 </Table>
             </Scroll>
-            <!-- <div class="page-box dark-iview-page">
-                <Page :total="totalNum" show-sizer :page-size="pageSize" show-total :current.sync="currentPage" @on-change="getPageData" @on-page-size-change="setPageSize"/>
-            </div>
-            <authorization :isShow="authorizationStatus" @closeAuth="closeAuth" :selected="selections"></authorization> -->
+            <authorization :isShow="authorizationStatus" @closeAuth="closeAuth" :selected="selections"></authorization> 
         </div>
 
         <Modal v-model="addStudentStatus" width="520" class-name="add-student dark-iview-modal" :mask-closable="false">
@@ -100,8 +97,12 @@
         <Modal v-model="importStudentStatus" width="70%" class="import-student" :mask-closable="false">
             <div slot="header">
                 <span class="import-model-title">{{$t('stuAccount.importTitle')}}</span>
+                <div class="importAcademicYear">
+                    <span class="label">學年度:</span>
+                    <InputNumber v-model="academicYear" :editable="false"></InputNumber>
+                </div>
             </div>
-            <import-student v-if="importStudentStatus" :schoolCode="$store.state.user.schoolCode" :isShow="importStudentStatus" @importStudentInfo="closeImportStudent"></import-student>
+            <import-student v-if="importStudentStatus" :schoolCode="$store.state.user.schoolCode" :isShow="importStudentStatus" @importStudentInfo="closeImportStudent" :academicYear="academicYear"></import-student>
             <div slot="footer"></div>
         </Modal>
     </div>
@@ -147,12 +148,68 @@
                 tableColumns: [],
                 queryToken:'',
                 basicCount: 99,
-                pointNum: 0
+                pointNum: 0,
+                academicYear: new Date().getFullYear()
             }
         },
         methods: {
-            resetPW() {
-
+            /**
+             * 重置密碼
+             * @param row
+             */
+            resetPW(row) {
+                //重置单个学生
+                if (row != -1) {
+                    this.$Modal.confirm({
+                        title: this.$t('重置密碼'),
+                        content: '<p>' + this.$t('確定要重置') + " <strong style='color:red;'>" + row.name + '</strong>的密碼</p>',
+                        onOk: () => {
+                            let ids = []
+                            ids.push(
+                                {
+                                    id: row.id,
+                                    pw: row.id
+                                }
+                            )
+                            this.tableLoading = true
+                            this.$api.stuAccount.saveAllStudent(this.$store.state.user.schoolCode , ids).then(
+                                (res) => {
+                                    this.$Message.success('重置成功!')                                    
+                                    this.tableLoading = false
+                                },
+                                (err) => {
+                                    this.$Message.error('API error!')
+                                    this.tableLoading = false
+                                }
+                            )
+                        }
+                    })
+                } else {
+                    //批量重置
+                    if (this.selections.length > 0) {
+                        this.$Modal.confirm({
+                            title: this.$t('重置密碼'),
+                            content: '<p>确认批量重置' + " <strong style='color:red;'>" + this.selections.length + '</strong>个学生密碼</p>',
+                            onOk: () => {
+                                this.tableLoading = true
+                                let ids = this.selections.map((item) => {
+                                    return {id: item.id, pw: item.id}
+                                })
+                                this.$api.stuAccount.saveAllStudent(this.$store.state.user.schoolCode, ids).then(
+                                    (res) => {
+                                        this.selections.length = 0
+                                        this.$Message.success('重置成功!')
+                                        this.tableLoading = false
+                                    },
+                                    (err) => {
+                                        this.$Message.error('API ERROR!')
+                                        this.tableLoading = false
+                                    }
+                                )
+                            }
+                        })
+                    }
+                }
             },
             getFirstChart(name) {
                 if (name) {
@@ -205,7 +262,7 @@
                     temp.year = parseInt(temp.year)
                     return temp
                 })
-                let storePath = (data.action == 1 ? 'schoolBaseInfo/setStudentsToState' : 'schoolBaseInfo/uptStudentsToState')
+                let storePath = (data.action == 1 ? 'schoolBaseInfo/addStudentsToState' : 'schoolBaseInfo/uptStudentsToState')
                 this.$store.dispatch(storePath, newStudents)
                 this.addStudentStatus = false
                 this.filterData()
@@ -256,7 +313,6 @@
             },
             /**
              * 删除学生
-             * @param index
              * @param row
              */
             delStudent(row) {
@@ -292,20 +348,16 @@
                             content: '<p>确认批量删除' + " <strong style='color:red;'>" + this.selections.length + '</strong>个学生</p>',
                             onOk: () => {
                                 this.tableLoading = true
-                                let delIds = this.selections.map((item, index) => {
+                                let delIds = this.selections.map((item) => {
                                     return {id: item.id}
                                 })
                                 this.$api.stuAccount.deleteStudent(this.$store.state.user.schoolCode, delIds).then(
                                     (res) => {
-                                        if (res.error == null) {
-                                            //分页查询后,直接重新访问API
-                                            this.selections.length = 0
-                                            this.$store.dispatch('schoolBaseInfo/delStudentsToState', res.ids)
-                                            this.filterData()
-                                            this.$Message.success('删除成功!')
-                                        } else {
-                                            this.$Message.error('API ERROR!')
-                                        }
+                                        //分页查询后,直接重新访问API
+                                        this.selections.length = 0
+                                        this.$store.dispatch('schoolBaseInfo/delStudentsToState', res.ids)
+                                        this.filterData()
+                                        this.$Message.success('删除成功!')
                                         this.tableLoading = false
                                     },
                                     (err) => {
@@ -318,22 +370,6 @@
                     }
                 }
             },
-            getSchoolData() {
-                this.$store.dispatch('schoolBaseInfo/getClassroom').then(
-                    (res) => {
-                        if (res.code == 2) {
-                            this.$Message.warning('数据为空!')
-                        } else {
-                            this.schoolData = this.$store.state.schoolBaseInfo.schoolBaseInfo
-                            this.classroomList = this.$store.state.schoolBaseInfo.classroomList
-                            this.findStudentInfo()
-                        }
-                    },
-                    (err) => {
-                        this.$Message.error('API error!')
-                    }
-                )
-            },
             initData() {
                 this.tableColumns = [
                     {
@@ -400,16 +436,6 @@
                     }
                 ]
             },
-            /**查询当前Page学生信息 */
-            findStudentInfo() {
-                // this.tableLoading = true
-                // let params = {
-                //     '@CURRPAGE': this.currentPage,
-                //     '@PAGESIZE': this.pageSize,
-                //     'code': this.$store.state.user.schoolCode,
-                // }
-                // this.baseFindStudent(params)
-            },
             /**基础查询数据 */
             baseFindStudent(params) {
                 this.$api.stuAccount.findStudent(this.$store.state.user.schoolCode).then(
@@ -423,41 +449,12 @@
                         })
                         this.$store.dispatch('schoolBaseInfo/setStudentsToState', newStudents)
                         this.filterData()
-
-                        // if (res.error == null) {
-                        //     this.tableData = res.result.data
-                        //     for (let index in this.tableData) {
-                        //         let currentClassroomlInfo = this.$JSONPath.query(this.$store.state.schoolBaseInfo.classroomList, "$..[?(@.classId=='" + this.tableData[index].classId + "')]")
-                        //         if (currentClassroomlInfo.length > 0) {
-                        //             let currentSchoolInfo = this.$JSONPath.query(this.$store.state.schoolBaseInfo.schoolBaseInfo, "$..period[?(@.periodCode=='" + currentClassroomlInfo[0].periodCode + "')]")
-                        //             if (currentSchoolInfo.length > 0) {
-                        //                 this.tableData[index].periodName = currentSchoolInfo[0].periodName
-                        //                 this.tableData[index].periodCode = currentSchoolInfo[0].periodCode
-                        //                 this.tableData[index].gradeName = this.$JSONPath.query(currentSchoolInfo, "$..grades[?(@.gradeCode=='" + currentClassroomlInfo[0].gradeCode + "')]")[0].gradeName
-                        //                 this.tableData[index].gradeCode = this.$JSONPath.query(currentSchoolInfo, "$..grades[?(@.gradeCode=='" + currentClassroomlInfo[0].gradeCode + "')]")[0].gradeCode
-                        //                 this.tableData[index].classroomName = currentClassroomlInfo[0].classroomName
-                        //             }
-                        //         }
-                        //     }
-                        //     [...this.tableShowData] = this.tableData
-                        //     this.tableLoading = false
-                        // } else {
-                        //     this.$Message.error('API error!')
-                        //     this.tableLoading = false
-                        // }
                     },
                     (err) => {
                         this.tableLoading = false
                     }
                 )
             },
-            /**查询学生总共人数 */
-            getResultCount(params) {
-                
-                // this.$api.newEvaluation.FindCount(params).then(res => {
-                //     this.totalNum = res.result.data[0]
-                // })
-            },
             /** 取得年級Name */
             getGradeName: function(periodId, gradeId){
                 if(periodId != null && gradeId != null){
@@ -535,15 +532,6 @@
         created() {
             this.initData()
             this.baseFindStudent()
-
-            // this.getSchoolData()
-            // let findCountParams = {
-            //     "collectionName": "Student",
-            //     "queryDict": {
-            //         'code': this.$store.state.user.schoolCode
-            //     }
-            // }
-            // this.getResultCount(findCountParams)
         },
         computed: {
             ...mapGetters({
@@ -574,7 +562,6 @@
             }
         },
         mounted() {
-
         }
     }
 </script>