ソースを参照

學生帳號 #251

1. 在API新增Catch 防止錯誤
2. 在登入帳密的Input 新增ID
3. 學生帳號
  a. 新增與校內帳號的篩選
osbert 4 年 前
コミット
b8ef0f1d9f

+ 3 - 1
TEAMModelOS/ClientApp/src/api/login.js

@@ -139,7 +139,9 @@ export default {
 				} else {
 					error = res
 				}
-			})
+			}).catch(err=>{
+                error = err
+            })
 
 			if(error == ''){
 				let auth = jwtDecode(result.auth_token)

+ 4 - 4
TEAMModelOS/ClientApp/src/view/login/Index.vue

@@ -98,10 +98,10 @@
         <div v-show="!qrloginFlag">
           <Form class="loginForm" ref="loginForm" :model="loginForm" :rules="loginRule" :show-message="false" @keydown.enter.native="loginSubmit('loginForm')">
             <FormItem class="formItem" prop="id" >
-              <Input v-model="loginForm.id" :placeholder="$t('login.placeholder.id')"/>
+              <Input element-id = "tmdID" v-model="loginForm.id" :placeholder="$t('login.placeholder.id')"/>
             </FormItem>
             <FormItem class="formItem"  prop="pass">
-              <Input  type="password" v-model="loginForm.pass" :placeholder="$t('login.placeholder.psw')" >
+              <Input element-id = "tmdpw" type="password" v-model="loginForm.pass" :placeholder="$t('login.placeholder.psw')" >
                 <Icon size="24" v-show="!loading && loginFormEnter" @click="loginSubmit('loginForm')" type="md-arrow-forward" slot="suffix" class="iconFrame" />
                 <div v-show="loading" class="demo-spin-col" slot="suffix">
                   <Spin>
@@ -187,10 +187,10 @@
           </Select>
         </FormItem>
         <FormItem class="formItem" prop="id" >
-          <Input v-model="studForm.id" :placeholder="$t('login.placeholder.schoolID')"/>
+          <Input element-id = "studId" v-model="studForm.id" :placeholder="$t('login.placeholder.schoolID')"/>
         </FormItem>
         <FormItem class="formItem"  prop="pass">
-          <Input  type="password" v-model="studForm.pass" :placeholder="$t('login.placeholder.schoolPsw')" >
+          <Input element-id = "studpw"  type="password" v-model="studForm.pass" :placeholder="$t('login.placeholder.schoolPsw')" >
             <!-- <Icon v-show="studFormEnter" @click="loginSubmit('studForm')" type="md-arrow-forward" slot="suffix" /> -->
             <Icon size="24" v-show="!loading && studFormEnter" @click="loginSubmit('studForm')" type="md-arrow-forward" slot="suffix" class="iconFrame" />
             <div v-show="loading" class="demo-spin-col" slot="suffix">

+ 32 - 14
TEAMModelOS/ClientApp/src/view/student-account/ImportStudent.vue

@@ -59,14 +59,14 @@
                     <p>{{(row.password == '' || row.password == null)? '— —' : row.password.value+''}}</p>
                 </template>
                 <template slot-scope="{ row,index }" slot="status">
-                    <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="(repeatAccounts.length == 0 || repeatAccounts.indexOf(row.studentId) == -1) ? 'account-success-tips':'account-error-tips'">{{(repeatAccounts.length == 0 || repeatAccounts.indexOf(row.studentId) == -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.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>
@@ -75,6 +75,7 @@
 </template>
 <script>
     import excel from '../../utils/excel'
+    import {  mapGetters } from 'vuex'
     export default {
         props: {
             isShow: {
@@ -97,6 +98,7 @@
                 existNum: 0,
                 repeatAccounts: [],
                 noClassroomNum: 0,
+                noSeatNoNum: 0,
                 uploadLoading: false,
                 progressPercent: 0,
                 showProgress: false,
@@ -120,8 +122,10 @@
         components: {
         },
         computed: {
+            ...mapGetters({
+                students: 'schoolBaseInfo/getStudent', // 學生List
+            }),
             isError() {
-                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: {
@@ -131,7 +135,6 @@
                 set(value) {
                 }
             }
-
         },
         watch: {
         },
@@ -238,11 +241,19 @@
                             }
                             return item
                         })
+
+                        // 現在的學生List
+                        let studIDs = this.students.map(item => { return item.id })
+
                         // 计算重复账号数量和重复账号,过滤重复账号
                         this.totalNum = this.tableData.length
+                        // 取得Excel 全部的ID
                         let accounts = this.tableData.map(item => { return item.studentId })
-                        this.repeatAccounts = accounts.filter((item, index, self) => self.indexOf(item) != index)
+                        // 合併
+                        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) {
@@ -253,8 +264,10 @@
                         // });
                         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, 'classroomCode')
+
                         for (let item of classStu) {
                             let seatNoArr = item.map(item => { return item.seatNo })
                             for (let index in item) {
@@ -275,10 +288,8 @@
                         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
@@ -292,6 +303,17 @@
                             return item
                         })
 
+                        // 檢查與現在的學生名單同教室裡是否有重複座號
+                        this.tableData.forEach( (item) => {
+                            let studdd = this.students.filter( (studInfo) => {
+                                return (item.classroomCode == studInfo.classId && item.seatNo == studInfo.no)
+                            })
+                            if(studdd.length > 0) {
+                                item.seatRepeat = true
+                                this.seatRepeatNum++
+                            }
+                        })
+                        
                         this.$Message.info(this.$t('stuAccount.importTips11'))
                         this.tableLoading = false
                     } else {
@@ -428,15 +450,11 @@
         },
         created() {
             this.initData()
-            console.log(this.academicYear, 'academicYear')
         },
         mounted() {
-
         },
         watch: {
-            academicYear: function(newVal, oldVal){
-                console.log(newVal)
-            }
+            
         }
     }
 </script>