Procházet zdrojové kódy

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

XW před 4 roky
rodič
revize
5fdc91bc5d

+ 8 - 5
TEAMModelOS/ClientApp/src/locale/lang/en-US/stuAccount.js

@@ -37,8 +37,8 @@ export default {
   delOk:'删除成功',
   isBottom:'已经到底了',
   edit:'修改',
-  adminClass:'行政班管理',
-  teachClass:'教學班管理',
+  adminClass:'行政班',
+  teachClass:'教學班',
   stuMgt:'學生管理',
 
   // AddStudent.vue
@@ -51,9 +51,9 @@ export default {
   stuNameHolder: '请输入学生名称',
   stuSeatNo: '座位号',
   stuSeatNoHolder: '请设置座位号',
-  classroomInfo: '教室信息',
-  classroomInfoHolder: '请选择教室',
-  newClassroom: '建立新教室',
+  classroomInfo: '班級',
+  classroomInfoHolder: '请选择班級',
+  newClassroom: '建立新班級',
   periodInfo: '学制',
   gradeInfo: '年级',
   submitAccount: '建立账号',
@@ -62,6 +62,9 @@ export default {
   chooseNum: '总计:',
   numUnit: '条',
   academicYear: '学年度',
+  noMatch:'暫無匹配數據',
+  stuIdErr:'學生賬號不能為空',
+  stuIdErr1:'學生賬號只能包含數字',
 
   // ImportStudent.vue
   importTitle: '导入学生名单',

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

@@ -37,8 +37,8 @@ export default {
   delOk:'删除成功',
   isBottom:'已经到底了',
   edit:'修改',
-  adminClass:'行政班管理',
-  teachClass:'教学班管理',
+  adminClass:'行政班',
+  teachClass:'教学班',
   stuMgt:'学生管理',
 
   // AddStudent.vue
@@ -51,9 +51,9 @@ export default {
   stuNameHolder: '请输入学生名称',
   stuSeatNo: '座位号',
   stuSeatNoHolder: '请设置座位号',
-  classroomInfo: '教室信息',
-  classroomInfoHolder: '请选择教室',
-  newClassroom: '建立新教室',
+  classroomInfo: '班级',
+  classroomInfoHolder: '请选择班级',
+  newClassroom: '建立新班级',
   periodInfo: '学段',
   gradeInfo: '年级',
   submitAccount: '建立账号',
@@ -61,7 +61,10 @@ export default {
   chooseInfo: '选取项目',
   chooseNum: '总计:',
   numUnit: '条',
-  academicYear: '学年度',
+  academicYear: '学级',
+  noMatch:'暂无匹配数据',
+  stuIdErr:'学生账号不能为空',
+  stuIdErr1:'学生账号只能包含数字',
 
   // ImportStudent.vue
   importTitle: '导入学生名单',

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

@@ -131,7 +131,7 @@ export default {
             sendInvite:'发送邀请',
             backHome: '重新检索'
         },
-        content: '<span>请输入<span class="point">教师账号</span>、<span class="point">电话</span>或<span class="point">电子信箱</span >等资讯进行搜寻</span>',
+        content: '<span>请输入<span class="point">手机号</span>、<span class="point">醍摩豆Id</span>或<span class="point">电子信箱</span >等资讯进行搜寻</span>',
         skyBox:{
             text1: '本次搜寻结果',
             text2: '档案资料数',

+ 9 - 6
TEAMModelOS/ClientApp/src/locale/lang/zh-TW/stuAccount.js

@@ -37,8 +37,8 @@ export default {
   delOk: '刪除成功',
   isBottom: '已經到底了',
   edit:'修改',
-  adminClass:'行政班管理',
-  teachClass:'教學班管理',
+  adminClass:'行政班',
+  teachClass:'教學班',
   stuMgt:'學生管理',
 
   //AddStudent.vue
@@ -51,9 +51,9 @@ export default {
   stuNameHolder: '請輸入學生名稱',
   stuSeatNo: '座位號',
   stuSeatNoHolder: '請設定座位號',
-  classroomInfo: '教室資訊',
-  classroomInfoHolder: '請選擇教室',
-  newClassroom: '建立新教室',
+  classroomInfo: '班級',
+  classroomInfoHolder: '請選擇班級',
+  newClassroom: '建立新班級',
   periodInfo: '學制資訊',
   gradeInfo: '年級',
   submitAccount: '建立帳號',
@@ -61,7 +61,10 @@ export default {
   chooseInfo: '選取項目',
   chooseNum: '總計:',
   numUnit: '條',
-  academicYear: '學年度',
+  academicYear: '學級',
+  noMatch:'暫無匹配數據',
+  stuIdErr:'學生賬號不能為空',
+  stuIdErr1:'學生賬號只能包含數字',
 
   //ImportStudent.vue
   importTitle: '匯入學生名單',

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

@@ -129,7 +129,7 @@ export default {
             sendInvite:'發送邀請',
             backHome: '重新檢索'
         },
-        content: '<span>請輸入<span class="point">教師帳號</span>、<span class="point">電話</span>或<span class="point">電子信箱</span>等資訊進行搜尋</span>',
+        content: '<span>請輸入<span class="point">手機號</span>、<span class="point">醍摩豆Id</span>或<span class="point">電子信箱</span>等資訊進行搜尋</span>',
         skyBox:{
             text1: '本次搜尋結果',
             text2: '檔案資料數',

+ 3 - 1
TEAMModelOS/ClientApp/src/store/module/user.js

@@ -155,8 +155,10 @@ export default {
         },
         getRooms: state => {
             return state.schoolProfile.school_rooms
+        },
+        getSchoolBase: state => {
+            return state.schoolProfile.school_base
         }
-
     },
     mutations: {
         setSchoolUserList(state, data) {

+ 33 - 2
TEAMModelOS/ClientApp/src/utils/js-fn.js

@@ -249,7 +249,7 @@ function findChartIndex(str, cha, num) {
 }
 
 /**
- * 根据班级学年年级名称
+ * 根据学年获取年级名称
  * @param data 学校基础数据 schoolProfile.school_base
  * @param curPd 当前学段id
  * @param year 学年
@@ -283,6 +283,36 @@ function getGradeNameByYear(data, curPd, year) {
         return '- -'
     }
 }
+/**
+ * 根据班级学年年级名称
+ * @param data 学校基础数据 schoolProfile.school_base
+ * @param curPd 当前学段id
+ * @param grade 年级index
+ */
+function getYearByGrade(data, curPd, grade) {
+    let date = new Date()
+    let curYear = date.getFullYear()
+    let month = date.getMonth() + 1
+    if (grade > -1 && data && data.period && curPd) {
+        let pData = data.period.find(item => {
+            return item.id == curPd
+        })
+        if (pData) {
+            let start = pData.semesters.find(item => {
+                return item.start == 1
+            })
+            // 根据入学月份确定当前年级和学级的关系
+            if (start && month < start.month) {
+                curYear--
+            }
+            return curYear - grade
+        } else {
+            return curYear
+        }
+    } else {
+        return curYear
+    }
+}
 
 export default {
     groupBy,
@@ -302,5 +332,6 @@ export default {
     formatBytes,
     uuid,
     findChartIndex,
-    getGradeNameByYear
+    getGradeNameByYear,
+    getYearByGrade
 }

+ 25 - 19
TEAMModelOS/ClientApp/src/view/joinclass/JoinClass.vue

@@ -10,22 +10,25 @@
                 </Divider> -->
             </p>
             <p class="course-name">{{cusName}}</p>
-            <p class="info-item">
-                <span class="info-lable">
-                    教师:
-                </span>
-                <span class="info-value">
-                    {{tName}}
-                </span>
-            </p>
-            <p class="info-item">
-                <span class="info-lable">
-                    名单:
-                </span>
-                <span class="info-value">
-                    {{listName}}
-                </span>
-            </p>
+            <div style="width:fit-content;margin: auto;">
+                <p class="info-item">
+                    <span class="info-lable">
+                        教师:
+                    </span>
+                    <span class="info-value">
+                        {{tName}}
+                    </span>
+                </p>
+                <p class="info-item">
+                    <span class="info-lable">
+                        名单:
+                    </span>
+                    <span class="info-value">
+                        {{listName}}
+                    </span>
+                </p>
+            </div>
+
             <div class="join-btn" @click="joinList()">
                 立即加入
             </div>
@@ -74,7 +77,8 @@ export default {
     background-image: url("../../assets/image/bak_light.jpg");
 }
 .join-btn {
-    width: fit-content;
+    // width: fit-content;
+    width: 100%;
     margin: auto;
     margin-top: 60px;
     text-align: center;
@@ -86,7 +90,7 @@ export default {
     letter-spacing: 2px;
     font-weight: 400;
     user-select: none;
-    &:hover{
+    &:hover {
         background: rgba(25, 190, 107, 0.5);
         color: white;
     }
@@ -98,11 +102,13 @@ export default {
     font-family: cursive;
 }
 .join-main-box {
-    width: 100%;
+    max-width: 90%;
+    width: fit-content;
     text-align: center;
     .info-item {
         margin-top: 20px;
         font-size: 15px;
+        width: fit-content;
     }
     .info-lable {
         color: #a5a5a5;

+ 23 - 4
TEAMModelOS/ClientApp/src/view/newcourse/MyCourse.vue

@@ -28,7 +28,7 @@
                         <div v-for="(item,index) in courseListShow" :key="index" @click="selectCourse(index)" :class="index === curCusIndex ? 'course-list-item block-bg block-bg-active':'course-list-item block-bg'">
                             <p class="course-name">
                                 {{item.name}}
-                                <Icon type="ios-information-circle-outline" @click="toggleCusInfo" :title="$t('cusMgt.cusInfo')" />
+                                <!-- <Icon type="ios-information-circle-outline" @click="toggleCusInfo" :title="$t('cusMgt.cusInfo')" /> -->
                             </p>
                             <p class="course-code">
                                 <Icon type="md-pricetags" />
@@ -318,7 +318,7 @@
             <StudentList @getSelectInfo="(selction)=>{selections = selction}"></StudentList>
         </Modal>
         <div class="qr-code-wrap" v-show="showQrStatus" @click="showQrStatus = false">
-            <div id="qrcode" :class="showQrStatus ? 'animated fadeIn':'animated fadeOut'" ref="qrcode" style="padding:20px;background-color:white;width:320px;margin:auto;">
+            <div @click.stop id="qrcode" :class="showQrStatus ? 'animated fadeIn':'animated fadeOut'" ref="qrcode" style="padding:20px;background-color:white;width:320px;margin:auto;">
                 <span class="qr-code-text">扫码加入名单</span>
             </div>
         </div>
@@ -1000,8 +1000,27 @@ export default {
 
             //这里需要根据站点动态拼接域名
             let addr = this.$store.state.config.srvAdr
-            let host = ''
-            let url = `http://teammodelos-test.chinacloudsites.cn/joinclass?tId=${tId}&listName=${listName}&tName=${tName}&listId=${listId}&cusName=${cusName}`
+            let type = this.$store.state.config.srvAdrType
+            let host
+            //国际站
+            if (addr == 'Global') {
+                if (type == 'product') {
+                    // 正式站
+                    host = this.$store.state.config[addr].domainUrl[0].url
+                } else {
+                    // 测试站
+                    host = this.$store.state.config[addr].domainUrl[1].url
+                }
+            }
+            // 大陆站
+            else {
+                if (type == 'product') {
+                    host = this.$store.state.config.China.domainUrl[0].url
+                } else {
+                    host = this.$store.state.config.China.domainUrl[1].url
+                }
+            }
+            let url = `${host}/joinclass?tId=${tId}&listName=${listName}&tName=${tName}&listId=${listId}&cusName=${cusName}`
             console.log(url)
             this.createQRCode(url)
         },

+ 418 - 400
TEAMModelOS/ClientApp/src/view/student-account/AddStudent.vue

@@ -1,69 +1,69 @@
 <style lang="less" scoped>
-    @import './AddStudent.less';
+@import "./AddStudent.less";
 </style>
 <style lang="less">
-    .add-student .ivu-input, .add-student .ivu-input-number {
-        background: none;
-        border: none;
-        border-bottom: 1px solid #505050;
-        border-radius: 0px;
-        color: white;
-        font-size: 16px;
-    }
+.add-student .ivu-input,
+.add-student .ivu-input-number {
+    background: none;
+    border: none;
+    border-bottom: 1px solid #505050;
+    border-radius: 0px;
+    color: white;
+    font-size: 16px;
+}
 
-    .add-student .ivu-input-number{
-        width: 100%;
-    }
+.add-student .ivu-input-number {
+    width: 100%;
+}
 
-    .add-student .ivu-modal-footer {
-        border: none;
-    }
-    .add-student .ivu-form-item-label {
-        color: #929292;
-    }
+.add-student .ivu-modal-footer {
+    border: none;
+}
+.add-student .ivu-form-item-label {
+    color: #929292;
+}
 
-    .add-student .ivu-form-item-required .ivu-form-item-label:before {
-        color: #6DE2C4;
-    }
+.add-student .ivu-form-item-required .ivu-form-item-label:before {
+    color: #6de2c4;
+}
 
-    .add-student .ivu-form-item-error .ivu-input:focus {
-        border: none;
-    }
-
-    .add-student .ivu-input-group-prepend {
-        border: none;
-        background: none;
-        color: white;
-        font-size: 14px;
-    }
+.add-student .ivu-form-item-error .ivu-input:focus {
+    border: none;
+}
 
-    .add-student .ivu-checkbox-wrapper {
-        float: right;
-        color: #929292;
-    }
+.add-student .ivu-input-group-prepend {
+    border: none;
+    background: none;
+    color: white;
+    font-size: 14px;
+}
 
-    .add-student .ivu-checkbox-inner {
-        background: none;
-        border-color: #6DE2C4;
-    }
+.add-student .ivu-checkbox-wrapper {
+    float: right;
+    color: #929292;
+}
 
-    .add-student .ivu-checkbox-checked .ivu-checkbox-inner:after {
-        border-color: #6DE2C4;
-    }
+.add-student .ivu-checkbox-inner {
+    background: none;
+    border-color: #6de2c4;
+}
 
-    .account-form .ivu-select-selection {
-        border-color: #505050;
-    }
+.add-student .ivu-checkbox-checked .ivu-checkbox-inner:after {
+    border-color: #6de2c4;
+}
 
-        .account-form .ivu-select-selection:hover {
-            border-color: #57a3f3;
-        }
+.account-form .ivu-select-selection {
+    border-color: #505050;
+}
 
-    .account-form .ivu-select-input {
-        color: white;
-        font-size: 16px;
-    }
+.account-form .ivu-select-selection:hover {
+    border-color: #57a3f3;
+}
 
+.account-form .ivu-select-input {
+    color: white;
+    font-size: 16px;
+}
 </style>
 <template>
 
@@ -73,13 +73,12 @@
             <!-- ID -->
             <FormItem :label="$t('stuAccount.accountInfo')" prop="id">
                 <Input v-model="studentInfo.id" :placeholder="$t('stuAccount.accountHolder')" @on-change="setPassword(same)">
-                <!-- <span slot="prepend">{{schoolCode}}#</span> 前方 -->
                 </Input>
-                <input type="text" style="position:fixed;z-index:-10000;width:0;border:none"/>
+                <input type="text" style="position:fixed;z-index:-10000;width:0;border:none" />
             </FormItem>
             <!-- 密碼 -->
             <FormItem :label="$t('stuAccount.passwordInfo')" prop="pw">
-                <input type="password" style="position:fixed;z-index:-10000;width:0;border:none"/>
+                <input type="password" style="position:fixed;z-index:-10000;width:0;border:none" />
                 <Input v-model="studentInfo.pw" type="password" password :placeholder="$t('stuAccount.passwordHolder')"></Input>
                 <Checkbox v-model="same" @on-change="setPassword">{{$t('stuAccount.isSame')}}</Checkbox>
             </FormItem>
@@ -91,7 +90,7 @@
             <div style="display:flex;justify-content: space-between;">
                 <!-- 學制 -->
                 <FormItem :label="$t('stuAccount.periodInfo')" style="width:45%">
-                    <Select v-model="searchPeriod" style="width: 100%;" :placeholder="$t('stuAccount.periodHolder')" clearable >
+                    <Select v-model="searchPeriod" style="width: 100%;" :placeholder="$t('stuAccount.periodHolder')" clearable>
                         <Option v-for="(item, index) in periods" :value="item.id" :key="index">{{ item.name }}</Option>
                     </Select>
                 </FormItem>
@@ -104,8 +103,8 @@
             </div>
             <!-- 教室資訊 -- 班级 -->
             <FormItem :label="$t('stuAccount.classroomInfo')" prop="classId">
-                <Select filterable style="width:100%" :placeholder="$t('stuAccount.classroomInfoHolder')" v-model="studentInfo.classId" clearable>
-                    <Option v-for="(item,index) in filterClasses" :value="item.id" :key="index" @click.native="setCurrentClassDetail(item)">{{ item.name }}</Option>
+                <Select filterable style="width:100%" :placeholder="$t('stuAccount.classroomInfoHolder')" v-model="studentInfo.classId" clearable :not-found-text="searchGrade ? '暂无匹配数据' : $t('stuAccount.sltPdFirst')">
+                    <Option v-for="(item,index) in filterClasses" :value="item.id" :key="index">{{ item.name }}</Option>
                 </Select>
                 <span style="float:right;color:#6DE2C4;cursor:pointer;text-decoration:underline;font-size:12px;" @click="createClassroom">{{$t('stuAccount.newClassroom')}}</span>
             </FormItem>
@@ -114,16 +113,17 @@
                 <FormItem :label="$t('stuAccount.stuSeatNo')" prop="no" style="width:45%">
                     <InputNumber v-model="studentInfo.no" :min="1" :placeholder="$t('stuAccount.stuSeatNoHolder')"></InputNumber>
                 </FormItem>
-                <!-- 學級 -->
-                <FormItem :label="$t('stuAccount.gradeInfo')" prop="gradeCode" style="width:45%">
-                    <span style="color:white;">{{ gradeName }}</span>
-                </FormItem>
-            </div>
-            <div style="display:flex;justify-content: space-between;">
                 <!-- 學年度 -->
                 <FormItem :label="$t('stuAccount.academicYear')" prop="year" style="width:45%">
                     <InputNumber v-model="studentInfo.year" :editable="false"></InputNumber>
                 </FormItem>
+                <!-- 學級 -->
+                <!-- <FormItem :label="$t('stuAccount.gradeInfo')" prop="gradeCode" style="width:45%">
+                    <span style="color:white;">{{ gradeName }}</span>
+                </FormItem> -->
+            </div>
+            <div style="display:flex;justify-content: space-between;">
+
             </div>
         </Form>
 
@@ -155,9 +155,9 @@
                 <FormItem :label="$t('stuAccount.stuSeatNo')" prop="no" style="width:45%">
                     <Input type="number" number v-model="editStudentInfo[0].no" :min="1" :placeholder="$t('stuAccount.stuSeatNoHolder')"></Input>
                 </FormItem>
-                <FormItem :label="$t('stuAccount.gradeInfo')" prop="gradeCode" style="width:45%">
+                <!-- <FormItem :label="$t('stuAccount.gradeInfo')" prop="gradeCode" style="width:45%">
                     <span style="color:white;">{{ gradeName }}</span>
-                </FormItem>
+                </FormItem> -->
             </div>
             <div style="display:flex;justify-content: space-between;" v-if="editStudentInfo.length == 1">
                 <!-- 學年度 -->
@@ -171,350 +171,384 @@
     </div>
 </template>
 <script>
-    import fn from '@/utils/js-fn.js'
-    import { mapGetters } from 'vuex'
+import fn from '@/utils/js-fn.js'
+import { mapGetters } from 'vuex'
 // import { delete } from 'vuedraggable'
 
-    export default {
-        props: {
-            isShow: {
-                type: Boolean,
-                default: false
-            },
-            schoolCode: {
-                type: String,
-                default: ''
+export default {
+    props: {
+        isShow: {
+            type: Boolean,
+            default: false
+        },
+        schoolCode: {
+            type: String,
+            default: ''
+        },
+        editStudentInfo: {
+            type: Array,
+            default: () => {
+                return [
+                    {
+                        classId: ''
+                    }
+                ]
+            }
+        },
+        bizType: {
+            type: Number,
+            default: 0 //1新增 2编辑
+        }
+    },
+    data() {
+        // 验证只能是数字
+        const validateId = (rule, value, callback) => {
+            if (!value) {
+                return callback(new Error(this.$t('stuAccount.stuIdErr')))
+            }
+            let zg = /^[0-9]+$/
+            if (zg.test(value)) {
+                callback()
+            } else {
+                callback(new Error(this.$t('stuAccount.stuIdErr1')))
+            }
+        }
+        const validateSeatNo = (rule, value, callback) => {
+            let flag = (value == null || typeof value == 'undefined' || value === '')
+            if (flag && (this.studentInfo.classId != null && typeof this.studentInfo.classId != 'undefined' && this.studentInfo.classId !== '')) {
+                callback(new Error('学生座位号不能为空'));
+            } else {
+                callback();
+            }
+        };
+        const validateclassId = (rule, value, callback) => {
+            if (value === '' && (this.studentInfo.no != null && typeof this.studentInfo.no != 'undefined' && this.studentInfo.no !== '')) {
+                callback(new Error('班级资讯不能为空'));
+            } else {
+                callback()
+            }
+        };
+        const validatePw = (rule, value, callback) => {
+            if (this.bizType == 1 && value === '') {
+                callback(new Error('密码不能为空'));
+            } else {
+                callback()
+            }
+        };
+        return {
+            fn,
+            isLoading: false,
+            test: true,
+            showError: false,
+            isFull: false,
+            classroomList: [],
+            same: '',
+            list: [],
+            studentInfo: {
+                name: '',
+                id: '',
+                no: null,
+                classId: '',
+                className: '',
+                // periodCode:'',
+                // gradeCode:'',
+                pw: '',
+                year: new Date().getFullYear()
             },
-            editStudentInfo: {
-                type: Array,
-                default: () => {
-                    return [
-                        {
-                            classId: ''
-                        }
-                    ]
-                }
+            // gradeName: '',
+            ruleValidate: {
+                id: [
+                    { validator: validateId, required: true, trigger: 'change' }
+                ],
+                pw: [
+                    // { required: true, message: '密码不能为空', trigger: 'blur' }
+                    { validator: validatePw, trigger: 'blur' }
+                ],
+                name: [
+                    { required: true, message: '学生姓名不能为空', trigger: 'blur' }
+                ],
+                no: [
+                    { validator: validateSeatNo, type: 'number', trigger: 'blur' }
+                ],
+                classId: [
+                    { validator: validateclassId, trigger: 'blur' },
+                ]
             },
-            bizType: {
-                type: Number,
-                default: 0 //1新增 2编辑
+            modal_loading: false,
+            searchPeriod: '',
+            searchGrade: ''
+        }
+    },
+    computed: {
+        ...mapGetters({
+            periods: 'user/getPeriods', // 學制s
+            grades: 'user/getGrades', // 年級
+            classes: 'user/getClasses', // 教室ID,
+            students: 'schoolBaseInfo/getStudent', // 學生List
+            schoolBase: 'user/getSchoolBase', // 学校基础设置
+        }),
+        filterGrades: function () {
+            var data = this.grades
+            console.log(this.schoolBase)
+            if (this.searchPeriod) {
+                let periodId = this.searchPeriod
+                data = data.filter(function (item) {
+                    return item.periodId == periodId
+                })
+                return data
+            } else {
+                return []
             }
         },
-        data() {
-            const validateSeatNo = (rule, value, callback) => {
-                let flag = (value == null || typeof value == 'undefined' || value === '')
-                if (flag && (this.studentInfo.classId != null && typeof this.studentInfo.classId != 'undefined' && this.studentInfo.classId !=='')) {
-                    callback(new Error('学生座位号不能为空'));                    
-                } else {
-                    callback();
-                }
-            };
-            const validateclassId = (rule, value, callback) => {
-                if (value === '' &&  (this.studentInfo.no != null && typeof this.studentInfo.no != 'undefined' && this.studentInfo.no !=='')) {
-                    callback(new Error('班级资讯不能为空'));
-                } else {
-                    callback()
-                }
-            };
-            const validatePw = (rule, value, callback) => {
-                if(this.bizType == 1 && value === ''){
-                    callback(new Error('密码不能为空'));
-                } else {
-                    callback()
-                }
-            };            
-            return {
-                fn,
-                isLoading: false,
-                test: true,
-                showError: false,
-                isFull: false,
-                classroomList: [],
-                same: '',
-                list: [],
-                studentInfo: {
-                    name: '',
-                    id: '',
-                    no: null,
-                    classId:'',
-                    className:'',
-                    // periodCode:'',
-                    // gradeCode:'',
-                    pw: '',
-                    year: new Date().getFullYear()
-                },
-                gradeName:'',
-                ruleValidate: {
-                    id: [
-                        { required: true, message: '账号不能为空', trigger: 'blur' }
-                    ],
-                    pw: [
-                        // { required: true, message: '密码不能为空', trigger: 'blur' }
-                        { validator: validatePw, trigger: 'blur' }
-                    ],
-                    name: [
-                        { required: true, message: '学生姓名不能为空', trigger: 'blur' }
-                    ],
-                    no: [
-                        { validator: validateSeatNo, type: 'number', trigger: 'blur' }
-                    ],
-                    classId: [
-                        { validator: validateclassId, trigger: 'blur' },
-                    ]
-                },
-                modal_loading: false,
-                searchPeriod: '',
-                searchGrade: ''
+        filterClasses() {
+            var data = this.classes
+            if (this.searchGrade > -1) {
+                let year = this.$jsFn.getYearByGrade(this.schoolBase, this.searchPeriod, this.searchGrade)
+                console.log(year)
+                data = data.filter((item)=>{
+                    return item.year == year && item.periodId == this.searchPeriod
+                })
+                console.log('班级', data)
+                return data
+            } else {
+                return []
             }
         },
-        computed: {
-            ...mapGetters({
-                periods: 'user/getPeriods', // 學制s
-                grades: 'user/getGrades', // 年級
-                classes: 'user/getClasses', // 教室ID,
-                students: 'schoolBaseInfo/getStudent', // 學生List
-            }),
-            filterGrades: function() {
-                var data = this.grades
-                if (this.searchPeriod) {
-                    let periodId = this.searchPeriod
-                    data = data.filter(function(item) {
-                        return item.periodId == periodId
-                    })
-                    return data
-                } else {
-                    return []
-                }
+        show: {
+            get() {
+                // if (this.bizType == 2 && this.isShow == true) {
+                //  if (this.editStudentInfo.length == 1) {
+                //    let arr = this.editStudentInfo[0].id.split("#");
+                //    if (arr.length > 1) {
+                //      this.editStudentInfo[0].id = arr[1];
+                //    } else {
+                //      alert("学生账号格式错误!");
+                //    }
+                //  }
+                // }
+                return this.isShow
             },
-            filterClasses: function() {
-                var data = this.classes
-                if (this.searchGrade) {
-                    let gradeId = this.searchGrade
-                    data = data.filter(function(item) {
-                        return item.gradeId == gradeId && item.openType == '1'
-                    })
-                    return data
-                } else {
-                    return []
-                }
-            },
-            show: {
-                get() {
-                    // if (this.bizType == 2 && this.isShow == true) {
-                    //  if (this.editStudentInfo.length == 1) {
-                    //    let arr = this.editStudentInfo[0].id.split("#");
-                    //    if (arr.length > 1) {
-                    //      this.editStudentInfo[0].id = arr[1];
-                    //    } else {
-                    //      alert("学生账号格式错误!");
-                    //    }
-                    //  }
-                    // }
-                    return this.isShow
-                },
-                set(value) {
-                }
+            set(value) {
             }
+        }
+    },
+    methods: {
+
+        cancel() {
+            this.same = false
+            this.$parent.addStudentStatus = false
+            this.$emit('saveStudentInfo', {
+                action: 0
+            })
         },
-        methods: {
-            
-            cancel() {
-                this.same = false
-                this.$parent.addStudentStatus = false
-                this.$emit('saveStudentInfo', {
-                    action: 0
+        setPassword(data) {
+            //bizType 编辑
+            if (this.bizType == 2) {
+                this.$set(this.editStudentInfo[0], 'pw', data ? this.editStudentInfo[0].id : '')
+            } else {
+                this.studentInfo.pw = data ? this.studentInfo.id : ''
+            }
+        },
+        // setCurrentClassDetail(item) {
+        //     this.$store.dispatch('user/getGradeById', item.gradeId).then(res => {
+        //         if (res.length == 0) {
+        //             this.gradeName = '暫無資訊'
+        //         } else {
+        //             this.gradeName = res.name
+        //         }
+        //     })
+        // },
+        getClassroom() {
+            this.classroomList = this.$store.state.schoolBaseInfo.classroomList
+            if (this.classroomList.length == 0) {
+                this.$api.schoolSetting.findClassInfo({
+                    SchoolCode: this.schoolCode
+                }).then(res => {
+                    if (res.error == null) {
+                        if (res.result.data.length > 0) {
+                            this.classroomList = res.result.data
+                        }
+                    }
                 })
-            },
-            setPassword(data) {
-                //bizType 编辑
+            }
+        },
+        confirm() {
+            this.showError = true
+            if (this.isFull) {
+                this.same = false
+                // 编辑信息
                 if (this.bizType == 2) {
-                    this.$set(this.editStudentInfo[0], 'pw', data ? this.editStudentInfo[0].id : '')
-                } else {
-                    this.studentInfo.pw = data ? this.studentInfo.id : ''
-                }
-            },
-            setCurrentClassDetail(item){
-                this.$store.dispatch('user/getGradeById', item.gradeId).then(res=>{
-                    if(res.length == 0){
-                        this.gradeName = '暫無資訊'
-                    } else {
-                        this.gradeName = res.name
-                    }
-                })   
-            },
-            getClassroom() {
-                this.classroomList = this.$store.state.schoolBaseInfo.classroomList
-                if (this.classroomList.length == 0) {
-                    this.$api.schoolSetting.findClassInfo({
-                        SchoolCode: this.schoolCode
-                    }).then(res => {
-                        if (res.error == null) {
-                            if (res.result.data.length > 0) {
-                                this.classroomList = res.result.data
-                            }
-                        }
-                    })
-                }
-            },
-            confirm() {
-                this.showError = true
-                if (this.isFull) {
-                    this.same = false
-                    if (this.bizType == 2) {
-
-                        this.isLoading = true
-                        let stringify = JSON.stringify( this.editStudentInfo)
-                        let parse = JSON.parse(stringify)
-                        let apiData = []
-                        if(parse.length == 1){
-                            let temp = parse.map(function(item){
-                                let data = {
-                                    id: item.id,
-                                    year: item.year ? item.year.toString() : '',
-                                    no: item.no ? item.no.toString() : '',
-                                    name: item.name,
-                                    classId: item.classId ? item.classId : ''
-                                }
-                                if(data.classId == '') data.no = ''
-                                return data
-                            })
-                            if(this.isRepeat(temp[0])){
-                                this.$Message.error('請檢查 帳號資訊 或 座號重複 了。')
-                                this.isLoading = false
-                            } else {
-                                apiData = temp
+                    this.isLoading = true
+                    let stringify = JSON.stringify(this.editStudentInfo)
+                    let parse = JSON.parse(stringify)
+                    let apiData = []
+                    if (parse.length == 1) {
+                        let temp = parse.map(function (item) {
+                            let data = {
+                                id: item.id,
+                                year: item.year ? item.year.toString() : '',
+                                no: item.no ? item.no.toString() : '',
+                                name: item.name,
+                                classId: item.classId ? item.classId : ''
                             }
+                            if (data.classId == '') data.no = ''
+                            return data
+                        })
+                        if (this.isRepeat(temp[0])) {
+                            this.$Message.error('請檢查 帳號資訊 或 座號重複 了。')
+                            this.isLoading = false
                         } 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
-                                }
-                            })
+                    } 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
+                            }
+                        })
 
-                            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.$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
                                 }
-                            )
-                        }
-                    } else {
-                        this.isLoading = true
-
-                        let apiData = 
+                                this.isLoading = false
+                            },
+                            (err) => {
+                                this.$Message.error('API error!')
+                                this.isLoading = false
+                            }
+                        )
+                    }
+                } 
+                // 新增学生
+                else {
+                    this.isLoading = true
+                    let apiData =
                         [
                             {
-                            "id": this.studentInfo.id,
-                            "no": this.studentInfo.no ? this.studentInfo.no.toString() : '',
-                            "name": this.studentInfo.name,
-                            "year": this.studentInfo.year ? this.studentInfo.year.toString() : '',
-                            "pw": this.studentInfo.pw,
-                            "classId": this.studentInfo.classId,
-                            // Excel 匯入才需要給classname
-                            // "className":this.studentInfo.classroomName ? this.studentInfo.classroomName : ''
+                                "id": this.studentInfo.id,
+                                "no": this.studentInfo.no ? this.studentInfo.no.toString() : '',
+                                "name": this.studentInfo.name,
+                                "year": this.studentInfo.year,
+                                "pw": this.studentInfo.pw,
+                                "classId": this.studentInfo.classId,
+                                // Excel 匯入才需要給classname
+                                // "className":this.studentInfo.classroomName ? this.studentInfo.classroomName : ''
                             }
                         ]
-                        if(this.isRepeat(apiData[0])){
-                            this.$Message.error('請檢查 帳號資訊 或 座號重複 了。')
-                            this.isLoading = false
-                        } else {
-                            this.$api.stuAccount.saveStudent(this.schoolCode, apiData).then(
-                                (res) => {
-                                    if (!res.errorId) {
-                                        this.show = false
-                                        res.gradeId = this.searchGrade
-                                        res.periodId = this.searchPeriod
-                                        this.$emit('saveStudentInfo', {
-                                            action: 1, // 新增学生
-                                            studentInfos: res
-                                        })
-                                        this.$refs.studentInfoForm.resetFields()
-                                    }
-                                    this.isLoading = false
-                                },
-                                (err) => {
-                                    this.$Message.error('API error!')
-                                    this.isLoading = false
+                    if (this.isRepeat(apiData[0])) {
+                        this.$Message.error('請檢查 帳號資訊 或 座號重複 了。')
+                        this.isLoading = false
+                    } else {
+                        this.$api.stuAccount.saveStudent(this.schoolCode, apiData).then(
+                            (res) => {
+                                if (!res.errorId) {
+                                    this.show = false
+                                    res.gradeId = this.searchGrade
+                                    res.periodId = this.searchPeriod
+                                    this.$emit('saveStudentInfo', {
+                                        action: 1, // 新增学生
+                                        studentInfos: res
+                                    })
+                                    this.$refs.studentInfoForm.resetFields()
                                 }
-                            )
-                        }
+                                this.isLoading = false
+                            },
+                            (err) => {
+                                this.$Message.error('API error!')
+                                this.isLoading = false
+                            }
+                        )
                     }
-                } else {
-                    this.$Message.error('请完善信息!')
                 }
-            },
-            createClassroom() {
-                this.$router.push({
-                    path: '/home/classroom'
-                })
-            },
-            isRepeat(data){
-                if(this.bizType == 1){
-                    return this.students.some(function(item){
-                        return (item.id === data.id || (data.classId !='' && data.classId === item.classId && data.no === item.no))
-                    })
-                } else if(this.bizType == 2){
-                    let temp = this.students.filter(function(item){
-                        return (data.classId !='' && data.classId === item.classId && data.no === item.no)
-                    })
-                    if(temp.length > 0){
-                        return !(temp[0].id == data.id)
-                    } else {
-                        return false
-                    }
-                }                
+            } else {
+                this.$Message.error('请完善信息!')
             }
         },
-        created() {
-            // this.getClassroom()
+        createClassroom() {
+            // this.$router.push({
+            //     path: '/home/classroom'
+            // })
+            this.$emit('createClass')
         },
-        mounted() {
-            if (this.bizType == 2 && this.isShow == true) {
-                if (this.editStudentInfo.length == 1) {
-                    this.setCurrentClassDetail(this.editStudentInfo[0])
-                    // let arr = this.editStudentInfo[0].id.split('#')
-                    // if (arr.length > 1) {
-                    //     this.editStudentInfo[0].id = arr[1]
-                    // } else {
-                    //     alert('学生账号格式错误!')
-                    // }
+        isRepeat(data) {
+            if (this.bizType == 1) {
+                return this.students.some(function (item) {
+                    return (item.id === data.id || (data.classId != '' && data.classId === item.classId && data.no === item.no))
+                })
+            } else if (this.bizType == 2) {
+                let temp = this.students.filter(function (item) {
+                    return (data.classId != '' && data.classId === item.classId && data.no === item.no)
+                })
+                if (temp.length > 0) {
+                    return !(temp[0].id == data.id)
+                } else {
+                    return false
                 }
             }
+        }
+    },
+    created() {
+        // this.getClassroom()
+    },
+    mounted() {
+        if (this.bizType == 2 && this.isShow == true) {
+            if (this.editStudentInfo.length == 1) {
+                // this.setCurrentClassDetail(this.editStudentInfo[0])
+                // let arr = this.editStudentInfo[0].id.split('#')
+                // if (arr.length > 1) {
+                //     this.editStudentInfo[0].id = arr[1]
+                // } else {
+                //     alert('学生账号格式错误!')
+                // }
+            }
+        }
+    },
+    watch: {
+        studentInfo: {
+            handler(newValue, oldValue) {
+                if (this.bizType == 1) {
+                    this.showError = false
+                    this.$refs.studentInfoForm.validate((valid) => {
+                        if (valid) {
+                            this.isFull = true
+                        } else {
+                            this.isFull = false
+                        }
+                    })
+                }
+            },
+            deep: true
         },
-        watch: {
-            studentInfo: {
-                handler(newValue, oldValue) {
-                    if (this.bizType == 1) {
-                        this.showError = false
-                        this.$refs.studentInfoForm.validate((valid) => {
+        editStudentInfo: {
+            handler(newValue, oldValue) {
+                this.$nextTick(() => {
+                    this.showError = false
+                    if (this.bizType == 2) {
+                        this.$refs.updateForm.validate((valid) => {
                             if (valid) {
                                 this.isFull = true
                             } else {
@@ -522,32 +556,16 @@
                             }
                         })
                     }
-                },
-                deep: true
+                })
             },
-            editStudentInfo: {
-                handler(newValue, oldValue) {
-                    this.$nextTick(() => {
-                        this.showError = false
-                        if (this.bizType == 2) {
-                            this.$refs.updateForm.validate((valid) => {
-                                if (valid) {
-                                    this.isFull = true
-                                } else {
-                                    this.isFull = false
-                                }
-                            })
-                        }
-                    })
-                },
-                deep: true,
-                immediate: true
-            }
+            deep: true,
+            immediate: true
         }
     }
+}
 </script>
 <style>
-    .account-form .ivu-btn {
-        border:none;
-    }
+.account-form .ivu-btn {
+    border: none;
+}
 </style>

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

@@ -193,7 +193,7 @@ export default {
         PersonalPhoto, StudentList
     },
     data() {
-        // 验证只能是字母和数字
+        // 验证只能是数字
         const validateCode = (rule, value, callback) => {
             if (!value) {
                 return callback(new Error(this.$t('schoolBaseInfo.classNoErr')))

+ 6 - 2
TEAMModelOS/ClientApp/src/view/student-account/Index.vue

@@ -93,7 +93,7 @@
                             <span>{{ row.no }}</span>
                         </template>
                         <template slot-scope="{ row }" slot="gradeName">
-                            <span>{{ $jsFn.getGradeNameByYear(schoolBase, searchPeriod, row.year) }}</span>
+                            <span>{{ $jsFn.getGradeNameByYear(schoolBase, searchPeriod, row.classYear) }}</span>
                         </template>
                         <template slot-scope="{ row }" slot="action" v-if="authorizationStatus == false">
                             <div class="item-tools" v-if="$access.can('admin.*|student-upd')">
@@ -117,7 +117,7 @@
             <MgtStuList></MgtStuList>
         </div>
         <Modal v-model="addStudentStatus" width="520" class-name="add-student dark-iview-modal" :mask-closable="false">
-            <add-student v-if="addStudentStatus" :schoolCode="$store.state.user.schoolCode" :isShow="addStudentStatus" :editStudentInfo="editStudentInfo" @saveStudentInfo="closeAddStudent" :bizType="bizType"></add-student>
+            <add-student v-if="addStudentStatus" :schoolCode="$store.state.user.schoolCode" :isShow="addStudentStatus" :editStudentInfo="editStudentInfo" @saveStudentInfo="closeAddStudent" :bizType="bizType" @createClass="createClass"></add-student>
             <div slot="footer"></div>
         </Modal>
         <Modal v-model="importStudentStatus" width="70%" class="import-student" :mask-closable="false">
@@ -198,6 +198,10 @@ export default {
         }
     },
     methods: {
+        createClass(){
+            this.addStudentStatus = false
+            this.tab = 'class'
+        },
         /**
          * 重置密碼
          * @param row

+ 11 - 3
TEAMModelOS/Controllers/School/StudentController.cs

@@ -888,7 +888,7 @@ namespace TEAMModelOS.Controllers
                 foreach (var classStud in dicClassStuds)
                 {
                     string classId = null, classNo = null, className = null, gradeId = null, periodId = null;
-                   
+                    int classYear = -1; 
                     if (classInfos.ContainsKey(classStud.Key))
                     {
                         classId = classInfos[classStud.Key].GetProperty("id").GetString();
@@ -896,6 +896,11 @@ namespace TEAMModelOS.Controllers
                         className = classInfos[classStud.Key].GetProperty("name").GetString();
                         //gradeId = classInfos[classStud.Key].GetProperty("gradeId").GetString();
                         periodId = classInfos[classStud.Key].GetProperty("periodId").GetString();
+                        if (classInfos[classStud.Key].TryGetProperty("year", out JsonElement year)) {
+                            if (year.ValueKind.Equals(JsonValueKind.Number)) {
+                                classYear = classInfos[classStud.Key].GetProperty("year").GetInt32();
+                            }
+                        }
                     }
 
                     var tmp = classStud.Value.Select(o =>
@@ -910,7 +915,9 @@ namespace TEAMModelOS.Controllers
                                          classNo,
                                          className,
                                          gradeId,
-                                         periodId
+                                         periodId,
+                                         classYear
+
                                      });
                     ret.AddRange(tmp);
                 }
@@ -928,7 +935,8 @@ namespace TEAMModelOS.Controllers
                         classNo = (string)null,
                         className = (string)null,
                         gradeId = (string)null,
-                        periodId = (string)null
+                        periodId = (string)null,
+                        classYear = -1
                     }));
 
                 return ret;