bluebirds 4 years ago
parent
commit
436ef3083e

+ 4 - 0
pagesClass/extraLessonsForm.vue

@@ -82,6 +82,10 @@
 								}
 							})
 						}, 'POST').then(res => {
+							uni.setStorage({
+								key: 'extraLessonsUserList',
+								data: []
+							})
 							this.$refs.uTips.show({
 								title: '提交成功',
 								type: 'success',

+ 43 - 4
pagesClass/extraLessonsStudentList.vue

@@ -3,8 +3,8 @@
 		<view class="filter-box">
 			<u-search placeholder="请输入关键字" v-model="filterText" @search="setFilterText" @custom="setFilterText"></u-search>
 		</view>
-		<scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
-		 :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
+		<scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" 
+		 :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white"
 		 @refresherrestore="onRestore">
 			<u-checkbox-group :active-color="mainColor" shape="circle" size="56" icon-size="36">
 				<u-card :head-border-bottom="false" :foot-border-top="false" padding="0px" margin="0" borderRadius="0" v-for="(item, index) in tableList"
@@ -14,7 +14,7 @@
 							<u-avatar :src="item.url" size="100"></u-avatar>
 						</view>
 						<view class="card-info-text">{{item.name}}</view>
-						<u-checkbox v-model="item.checked" @click.native.stop=""></u-checkbox>
+						<u-checkbox v-model="item.checked" @click.native="changeStatus(item)"></u-checkbox>
 					</view>
 				</u-card>
 			</u-checkbox-group>
@@ -47,6 +47,7 @@
 				isOver: false,
 				pageIndex: 1,
 				tableList: [],
+				checkedList: uni.getStorageSync('extraLessonsUserList').length ? uni.getStorageSync('extraLessonsUserList') : []
 			}
 		},
 		onLoad() {
@@ -89,6 +90,13 @@
 					res.data.row.forEach(site => site.checked = false)
 					this.tableList = this.tableList.concat(res.data.row)
 					this.isOver = res.data.row.length != 10
+					this.tableList.forEach(
+						item=>{
+							if(this.checkedList.filter(checkedItem=>checkedItem.id==item.id).length!=0){
+								item.checked = true
+							}
+						}
+					)
 				}).catch(error => {
 					this.triggered = false
 					this.$refs.uTips.show({
@@ -100,12 +108,43 @@
 			//  变更状态
 			changeStatus(item) {
 				item.checked = !item.checked
+				if(item.checked){
+					if(this.checkedList.filter(checkedItem=>checkedItem.id==item.id).length==0){
+						this.checkedList.push(
+							{
+								id: item.id,
+								name: item.name,
+								url: item.url,
+								hasHead: item.hasUrl,
+								checked: false,
+							}
+						)
+					}
+				}else{
+					this.checkedList = this.checkedList.filter(checkedItem=>checkedItem.id!=item.id)
+				}
 			},
 			//  选择学员
 			selectStudent() {
+				const data = this.tableList.filter(site => site.checked).map(site => {
+					return {
+						id: site.id,
+						name: site.name,
+						url: site.url,
+						hasHead: site.hasUrl,
+						checked: false,
+					}
+				})
+				data.forEach(
+					item=>{
+						if(this.checkedList.filter(checkedItem=>checkedItem.id==item.id).length==0){
+							this.checkedList.push(item)
+						}
+					}
+				)
 				uni.setStorage({
 					key: 'extraLessonsUserList',
-					data: this.tableList.filter(site => site.checked)
+					data: this.checkedList
 				})
 				uni.navigateBack()
 			}

+ 10 - 2
pagesClass/signForm.vue

@@ -25,7 +25,7 @@
 		</u-card>
 		<view class="handle-fix-box">
 			<u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="submitForm()">
-				{{status == 1 ? '签到确认' : '今日已签到'}}
+				{{status == 0 ? '签到确认' : '今日已签到'}}
 				 <!-- :disabled="status != 0" -->
 			</u-button>
 		</view>
@@ -77,7 +77,15 @@
 					id: this.classId
 				}, 'POST').then(res => {
 					res.data.forEach(site => site.checked = false)
-					this.studentList = res.data.concat(uni.getStorageSync('signUserList').length ? uni.getStorageSync('signUserList') : [])
+					this.studentList = res.data
+					const checkedList = uni.getStorageSync('signUserList').length ? uni.getStorageSync('signUserList') : []
+					checkedList.forEach(
+						checkedItem => {
+							if(this.studentList.filter(item=>checkedItem.id==item.id).length==0){
+								this.studentList.push(checkedItem)
+							}
+						}
+					)
 				}).catch(error => {
 					this.$refs.uTips.show({
 						title: error.message,

+ 46 - 13
pagesClass/signStudentList.vue

@@ -3,8 +3,8 @@
 		<view class="filter-box">
 			<u-search placeholder="请输入关键字" v-model="filterText" @search="setFilterText" @custom="setFilterText"></u-search>
 		</view>
-		<scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
-		 :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
+		<scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore"
+		 :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white"
 		 @refresherrestore="onRestore">
 			<u-checkbox-group :active-color="mainColor" shape="circle" size="56" icon-size="36">
 				<u-card :head-border-bottom="false" :foot-border-top="false" padding="0px" margin="0" borderRadius="0" v-for="(item, index) in tableList"
@@ -14,7 +14,7 @@
 							<u-avatar :src="item.url" size="100"></u-avatar>
 						</view>
 						<view class="card-info-text">{{item.name}}</view>
-						<u-checkbox v-model="item.checked" @click.native.stop=""></u-checkbox>
+						<u-checkbox v-model="item.checked" @click.native="changeStatus(item)"></u-checkbox>
 					</view>
 				</u-card>
 			</u-checkbox-group>
@@ -47,15 +47,18 @@
 				isOver: false,
 				pageIndex: 1,
 				tableList: [],
+				checkedList: uni.getStorageSync('signUserList').length ? uni.getStorageSync('signUserList') : []
 			}
 		},
 		onLoad() {
 			this.getTableList()
 		},
-		onReady() {},
+		onReady() {
+		},
 		methods: {
 			//  设置过滤字段
 			setFilterText(value) {
+				this.onRestore()
 				this.onRefresh()
 			},
 			//  下拉刷新
@@ -89,6 +92,13 @@
 					res.data.row.forEach(site => site.checked = false)
 					this.tableList = this.tableList.concat(res.data.row)
 					this.isOver = res.data.row.length != 10
+					this.tableList.forEach(
+						item=>{
+							if(this.checkedList.filter(checkedItem=>checkedItem.id==item.id).length!=0){
+								item.checked = true
+							}
+						}
+					)
 				}).catch(error => {
 					this.triggered = false
 					this.$refs.uTips.show({
@@ -100,20 +110,43 @@
 			//  变更状态
 			changeStatus(item) {
 				item.checked = !item.checked
+				if(item.checked){
+					if(this.checkedList.filter(checkedItem=>checkedItem.id==item.id).length==0){
+						this.checkedList.push(
+							{
+								id: item.id,
+								name: item.name,
+								url: item.url,
+								hasHead: item.hasUrl,
+								checked: false,
+							}
+						)
+					}
+				}else{
+					this.checkedList = this.checkedList.filter(checkedItem=>checkedItem.id!=item.id)
+				}
 			},
 			//  选择学员
 			selectStudent() {
+				const data = this.tableList.filter(site => site.checked).map(site => {
+					return {
+						id: site.id,
+						name: site.name,
+						url: site.url,
+						hasHead: site.hasUrl,
+						checked: false,
+					}
+				})
+				data.forEach(
+					item=>{
+						if(this.checkedList.filter(checkedItem=>checkedItem.id==item.id).length==0){
+							this.checkedList.push(item)
+						}
+					}
+				)
 				uni.setStorage({
 					key: 'signUserList',
-					data: this.tableList.filter(site => site.checked).map(site => {
-						return {
-							id: site.id,
-							name: site.name,
-							url: site.url,
-							hasUrl: site.hasUrl,
-							checked: false,
-						}
-					})
+					data: this.checkedList
 				})
 				uni.navigateBack()
 			}