|
@@ -142,10 +142,10 @@
|
|
<span style="color:white;">{{ gradeName }}</span>
|
|
<span style="color:white;">{{ gradeName }}</span>
|
|
</FormItem>
|
|
</FormItem>
|
|
</div>
|
|
</div>
|
|
- <div style="display:flex;justify-content: space-between;">
|
|
|
|
|
|
+ <div style="display:flex;justify-content: space-between;" v-if="editStudentInfo.length == 1">
|
|
<!-- 學年度 -->
|
|
<!-- 學年度 -->
|
|
<FormItem :label="$t('stuAccount.academicYear')" prop="year" style="width:45%">
|
|
<FormItem :label="$t('stuAccount.academicYear')" prop="year" style="width:45%">
|
|
- <InputNumber v-model="editStudentInfo[0].year" :editable="false"></InputNumber>
|
|
|
|
|
|
+ <Input v-model="editStudentInfo[0].year" disabled></Input>
|
|
</FormItem>
|
|
</FormItem>
|
|
</div>
|
|
</div>
|
|
</Form>
|
|
</Form>
|
|
@@ -296,44 +296,7 @@
|
|
} else {
|
|
} else {
|
|
this.gradeName = res.name
|
|
this.gradeName = res.name
|
|
}
|
|
}
|
|
- })
|
|
|
|
- if (this.bizType == 1) {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- getCurrentClassroom(index) {
|
|
|
|
- //bizType:1 新增
|
|
|
|
- if (this.bizType == 1) {
|
|
|
|
- // this.studentInfo.classroomName = this.classroomList[index].classroomName
|
|
|
|
- // this.studentInfo.periodCode = this.classroomList[index].periodCode;
|
|
|
|
- // this.studentInfo.gradeCode = this.classroomList[index].gradeCode;
|
|
|
|
- // this.studentInfo.classId = this.classroomList[index].classId;
|
|
|
|
- // let currentInfo = this.$JSONPath.query(this.$store.state.schoolBaseInfo.schoolBaseInfo, "$..period[?(@.periodCode=='" + this.classroomList[index].periodCode + "')]")
|
|
|
|
-
|
|
|
|
- // if (currentInfo.length > 0) {
|
|
|
|
- // this.studentInfo.periodName = currentInfo[0].periodName
|
|
|
|
- // this.studentInfo.gradeName = this.$JSONPath.query(currentInfo, "$..grades[?(@.gradeCode=='" + this.classroomList[index].gradeCode + "')]")[0].gradeName
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- // let currentInfo = this.$JSONPath.query(this.$store.state.schoolBaseInfo.schoolBaseInfo, "$..period[?(@.periodCode=='" + this.classroomList[index].periodCode + "')]")
|
|
|
|
- // let periodName = '数据错误'
|
|
|
|
- // let gradeName = '数据错误'
|
|
|
|
- // if (currentInfo.length > 0) {
|
|
|
|
- // periodName = currentInfo[0].periodName
|
|
|
|
- // gradeName = this.$JSONPath.query(currentInfo, "$..grades[?(@.gradeCode=='" + this.classroomList[index].gradeCode + "')]")[0].gradeName
|
|
|
|
- // }
|
|
|
|
- // for (let i = 0; i < this.editStudentInfo.length; i++) {
|
|
|
|
- // this.editStudentInfo[i].periodCode = this.classroomList[index].periodCode
|
|
|
|
- // this.editStudentInfo[i].gradeCode = this.classroomList[index].gradeCode
|
|
|
|
- // this.editStudentInfo[i].classId = this.classroomList[index].classId
|
|
|
|
- // this.$set(this.editStudentInfo[i],'periodName',periodName)
|
|
|
|
- // this.$set(this.editStudentInfo[i],'gradeName',gradeName)
|
|
|
|
- // }
|
|
|
|
- }
|
|
|
|
|
|
+ })
|
|
},
|
|
},
|
|
getClassroom() {
|
|
getClassroom() {
|
|
this.classroomList = this.$store.state.schoolBaseInfo.classroomList
|
|
this.classroomList = this.$store.state.schoolBaseInfo.classroomList
|
|
@@ -355,35 +318,58 @@
|
|
this.same = false
|
|
this.same = false
|
|
if (this.bizType == 2) {
|
|
if (this.bizType == 2) {
|
|
this.isLoading = true
|
|
this.isLoading = true
|
|
- let editInfo = this.editStudentInfo.map(function(item){
|
|
|
|
- let itemTemp = item
|
|
|
|
- if(itemTemp.pw == '******') {
|
|
|
|
- delete itemTemp.pw
|
|
|
|
- }
|
|
|
|
- return itemTemp
|
|
|
|
- })
|
|
|
|
|
|
+ var editInfo = this.editStudentInfo
|
|
|
|
|
|
- this.$api.stuAccount.saveAllStudent(this.schoolCode, this.editStudentInfo).then(
|
|
|
|
- (res) => {
|
|
|
|
- if (res.error == null) {
|
|
|
|
- this.show = false
|
|
|
|
- this.$emit('saveStudentInfo', {
|
|
|
|
- action: 2, // 批量修改数据
|
|
|
|
- studentInfo: this.editStudentInfo
|
|
|
|
- })
|
|
|
|
- this.$refs.updateForm.resetFields()
|
|
|
|
- // this.initData();
|
|
|
|
- this.uploadLoading = false
|
|
|
|
- } else {
|
|
|
|
- this.$Message.error('API error!')
|
|
|
|
- }
|
|
|
|
- this.isLoading = false
|
|
|
|
- },
|
|
|
|
- (err) => {
|
|
|
|
- this.$Message.error('API error!')
|
|
|
|
|
|
+ let stringify = JSON.stringify(this.editStudentInfo)
|
|
|
|
+ let parse = JSON.parse(stringify)
|
|
|
|
+ let apiData = []
|
|
|
|
+ if(parse.length == 1){
|
|
|
|
+ parse.forEach(function(item){
|
|
|
|
+ item.year = item.year ? item.year.toString() : ''
|
|
|
|
+ item.no = item.no ? item.no.toString() : ''
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ if(this.isRepeat(parse[0])){
|
|
|
|
+ this.$Message.error('請檢查 帳號資訊 或 座號重複 了。')
|
|
this.isLoading = false
|
|
this.isLoading = false
|
|
|
|
+ } else {
|
|
|
|
+ apiData = parse
|
|
}
|
|
}
|
|
- )
|
|
|
|
|
|
+ } else {
|
|
|
|
+ let classId = parse[0].classId
|
|
|
|
+ let temp = parse.map(function(item){
|
|
|
|
+ return {
|
|
|
|
+ no : "",
|
|
|
|
+ id: item.id,
|
|
|
|
+ classId: classId,
|
|
|
|
+ name: item.name,
|
|
|
|
+ year: item.year ? item.year.toString() : ''
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ apiData = temp
|
|
|
|
+ }
|
|
|
|
+ if(apiData.length > 0){
|
|
|
|
+ this.$api.stuAccount.saveAllStudent(this.schoolCode, apiData).then(
|
|
|
|
+ (res) => {
|
|
|
|
+ if (res.error == null) {
|
|
|
|
+ this.show = false
|
|
|
|
+ this.$emit('saveStudentInfo', {
|
|
|
|
+ action: 2, // 批量修改数据
|
|
|
|
+ studentInfos: res.students
|
|
|
|
+ })
|
|
|
|
+ this.$refs.updateForm.resetFields()
|
|
|
|
+ this.uploadLoading = false
|
|
|
|
+ } else {
|
|
|
|
+ this.$Message.error('API error!')
|
|
|
|
+ }
|
|
|
|
+ this.isLoading = false
|
|
|
|
+ },
|
|
|
|
+ (err) => {
|
|
|
|
+ this.$Message.error('API error!')
|
|
|
|
+ this.isLoading = false
|
|
|
|
+ }
|
|
|
|
+ )
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
this.isLoading = true
|
|
this.isLoading = true
|
|
|
|
|
|
@@ -398,14 +384,10 @@
|
|
// "className":this.studentInfo.classroomName ? this.studentInfo.classroomName : ''
|
|
// "className":this.studentInfo.classroomName ? this.studentInfo.classroomName : ''
|
|
}
|
|
}
|
|
|
|
|
|
- let isRepeat= this.students.some(function(item){
|
|
|
|
- return (item.id === apiData.id || (apiData.classId !='' && apiData.classId === item.classId && apiData.no === item.no))
|
|
|
|
- })
|
|
|
|
- if(isRepeat){
|
|
|
|
|
|
+ if(this.isRepeat(apiData)){
|
|
this.$Message.error('請檢查 帳號資訊 或 座號重複 了。')
|
|
this.$Message.error('請檢查 帳號資訊 或 座號重複 了。')
|
|
this.isLoading = false
|
|
this.isLoading = false
|
|
} else {
|
|
} else {
|
|
-
|
|
|
|
this.$api.stuAccount.saveStudent(this.schoolCode, apiData).then(
|
|
this.$api.stuAccount.saveStudent(this.schoolCode, apiData).then(
|
|
(res) => {
|
|
(res) => {
|
|
if (res.error == null) {
|
|
if (res.error == null) {
|
|
@@ -433,6 +415,22 @@
|
|
this.$router.push({
|
|
this.$router.push({
|
|
path: '/school/classroom'
|
|
path: '/school/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
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|