wkyy 1 year ago
parent
commit
dbd26d2540
1 changed files with 69 additions and 45 deletions
  1. 69 45
      pages/teacher/callNames/classCall.vue

+ 69 - 45
pages/teacher/callNames/classCall.vue

@@ -48,9 +48,8 @@
 				</view>
 			</view>
 			
-			
 			<view class="details">
-				<view class="item"  v-for="(item,index) in rollCallList" :key="index">
+				<view class="item" v-for="(item,index) in rollCallList" :key="index">
 					<view class="picture">
 						<u-avatar class="avatar" mode="square"
 							:src="item.headPhoto != null ? item.headPhoto : '../../assets/img/head.png'" size="112">
@@ -76,11 +75,10 @@
 								<view class="num" v-if="item.courseAmountList != null">{{item.courseAmountList[0]}}</view>
 							</view>
 							<view class="leaved">
-								<!-- <view>已请假</view>
-								<view class="num"></view> -->
+								
 							</view>
 						</view>
-
+				
 					</view>
 					<view class="state" @click="showStudent(item)">
 						<view class="text" v-if="item.rollCallResult == '1'">到课</view>
@@ -94,21 +92,12 @@
 						</view>
 					</view>
 				</view>
-				
-				
 			</view>
-			<!-- <u-cell-group>
-				<u-cell-item title="班级名称" :value="classList.className" :arrow="false"></u-cell-item>
-				<u-cell-item title="上课时间" :value="scheduleSheet.courseDate+' '+scheduleSheet.coursePeriods" :arrow="false"></u-cell-item>
-				<u-cell-item title="上课教室" :value="classRoom.name" :arrow="false"></u-cell-item>
-				<u-cell-item class="teacher" title="任课老师" :value="employee.employeeName"
-					@click="gotoUrl('pages/teacher/myCourse/teacherHomepage?id='+employee.employeeId)"></u-cell-item>
-				<u-cell-item title="学员总数" :value="studentList.length+'人'" :arrow="false"></u-cell-item>
-				<u-cell-item title="点名结果批量设置" :value="resultName" @click="show = true"></u-cell-item>
-			</u-cell-group> -->
 		</view>
+		
 		<u-picker mode="selector" v-model="show" :default-selector="[0]" :range="selectorObj" range-key="cateName"
 			@confirm="confirm"></u-picker>
+			
 		<!-- 底部 -->
 		<view class="bottom">
 			<view class="sign-result">
@@ -117,7 +106,7 @@
 				</view>
 				<view class="result">
 					<view class="itemClass leave" @click="qbStudent">
-						全部<text>{{dkNum+qjNum}}</text>
+						全部<text>{{studentList.length + stopStudentList.length}}</text>
 					</view>
 					<view class="itemClass arrive" @click="dkStudent">
 						到课<text>{{dkNum}}</text>
@@ -156,6 +145,10 @@
 				</view>
 			</view>
 		</view>
+		
+		<view>
+			<u-toast ref="uToast" />
+		</view>
 	</view>
 </template>
 
@@ -166,7 +159,8 @@
 		data() {
 			return {
 				isCancel: false,
-				resultName: '到课',
+				resultName: '请选择',
+				resultId: '',
 				studentId: '',
 				studentResult: '',
 				classList: {},
@@ -261,13 +255,31 @@
 				})
 				callNamesApi.rollCallSignIn(this.sheetId, this.rollCallListAll).then((response) => {
 					uni.hideLoading();
+					
+					this.rollCallListAll = [];
+					this.resultName = '请选择';
 					this.isCancel = true;
+					
+					if(response.message != '') {
+						this.$refs.uToast.show({
+							title: response.message+'课程为0或已经停课,不能点名!',
+							type: 'warning ',
+							position: 'top',
+							duration: 5000
+						})
+					}
 					this.getRollCallDetail();
 				}).catch(error => {
-					uni.showToast({
-						title: error,
-						icon: "none"
-					})
+					this.rollCallListAll = [];
+					if(error != null) {
+						this.$refs.uToast.show({
+							title: error,
+							type: 'warning ',
+							position: 'top',
+							duration: 5000
+						})
+					}
+					this.getRollCallDetail();
 				})
 			},
 			getRollCallDetail() {
@@ -285,7 +297,13 @@
 					this.employee = response.data.employee;
 					this.scheduleSheet = response.data.scheduleSheet;
 					this.studentList = response.data.studentList;
+					for (var c = 0; c < this.studentList.length; c++) {
+						var key = "checked";
+						var value = false;
+						this.studentList[c][key] = value;
+					}
 					this.rollCallList = this.studentList;
+					
 					this.stopStudentList = response.data.stopStudentList;
 					
 					for (var n = 0; n < this.stopStudentList.length; n++) {
@@ -321,31 +339,29 @@
 			},
 			save() {
 				if(this.current == 0) {
-					for (var i = 0; i < this.rollCallList.length; i++) {
-						if(this.rollCallList[i].rollCallResult == null && !this.isCancel) {
-							this.rollCallList[i].rollCallResult = '1';
+					if(this.resultName != '请选择') {
+						for (var i = 0; i < this.rollCallList.length; i++) {
+							if(this.rollCallList[i].rollCallResult == null && !this.isCancel) {
+								this.rollCallList[i].rollCallResult = this.resultId;
+							}
 						}
+						
+						// console.log(this.rollCallList)
+						
+						this.rollCallListAll = this.rollCallList.concat(this.stopStudentList);
 					}
-					// console.log(this.rollCallList)
-					
-					this.rollCallListAll = this.rollCallList.concat(this.stopStudentList);
 				}
-				// if(this.current == 1) {
-				// 	for (var i = 0; i < this.studentList.length; i++) {
-				// 		if(this.studentList[i].rollCallResult == null) {
-				// 			this.studentList[i].rollCallResult = '1';
-				// 		}
-				// 	}
-				// 	this.rollCallListAll = this.rollCallList.concat(this.studentList, this.stopStudentList)
-				// } 
 				if(this.current == 1) {
-					for (var i = 0; i < this.studentList.length; i++) {
-						if(this.studentList[i].rollCallResult == null && !this.isCancel) {
-							this.studentList[i].rollCallResult = '1';
+					if(this.resultName != '请选择') {
+						for (var i = 0; i < this.studentList.length; i++) {
+							if(this.studentList[i].rollCallResult == null && !this.isCancel) {
+								this.studentList[i].rollCallResult = this.resultId;
+							}
 						}
+						this.rollCallListAll = this.rollCallList.concat(this.studentList);
 					}
-					this.rollCallListAll = this.rollCallList.concat(this.studentList);
-				} 
+				}
+
 				this.getRollCallSignIn();
 			},
 			showStudent(item) {
@@ -355,16 +371,24 @@
 			confirm(obj) {
 				if (!this.studentId) {
 					this.resultName = this.selectorObj[obj[0]].cateName;
+					this.resultId = this.selectorObj[obj[0]].id;
 					for (var i = 0; i < this.rollCallList.length; i++) {
 						this.rollCallList[i].rollCallResult = this.selectorObj[obj[0]].id;
 					}
 					console.log(this.rollCallList)
 				} else {
-					for (var i = 0; i < this.rollCallList.length; i++) {
-						if (this.studentId == this.rollCallList[i].studentId) {
-							this.rollCallList[i].rollCallResult = this.selectorObj[obj[0]].id;
+					for (var m = 0; m < this.rollCallListAll.length; m++) {
+						if (this.studentId == this.rollCallListAll[m].studentId) {
+							this.rollCallListAll.splice(this.rollCallListAll.indexOf(this.rollCallListAll[m]), 1);
 						}
 					}
+					for (var n = 0; n < this.rollCallList.length; n++) {
+						if (this.studentId == this.rollCallList[n].studentId) {
+							this.rollCallList[n].rollCallResult = this.selectorObj[obj[0]].id;
+							this.rollCallListAll.push(this.rollCallList[n])
+						}
+					}
+					
 					console.log(this.rollCallList)
 					this.studentId = '';
 				}
@@ -493,7 +517,7 @@
 							margin-right: 24rpx;
 
 							.num {
-								width: 40rpx;
+								width: 50rpx;
 								height: 32rpx;
 								line-height: 32rpx;
 								border-radius: 4px;