From da9c872e36667467aed056c5a3e51d704cabd1b7 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Sat, 31 Jul 2021 09:08:52 +0800
Subject: [PATCH] 页面逻辑完善

---
 pages/report/initiate.vue |    2 
 pages/report/receive.vue  |  168 ++++++++++++++++----
 pages/report/send.vue     |  165 +++++++++++++++++---
 utils/func.js             |    2 
 pages/company/company.vue |  100 ++++++------
 store/actions.js          |    1 
 6 files changed, 324 insertions(+), 114 deletions(-)

diff --git a/pages/company/company.vue b/pages/company/company.vue
index ecc9407..58a6a3d 100644
--- a/pages/company/company.vue
+++ b/pages/company/company.vue
@@ -1,8 +1,9 @@
 <template>
 	<view class="container">
 
-		<u-search v-model='keyValue' placeholder='请输入公司名称' shape="round" class="u-search" input-align="center" height="70"
-			@search='searchValue' @custom='searchValue' @clear='clearValue' @change='changeValue'></u-search>
+		<u-search v-model='keyValue' placeholder='请输入公司名称' shape="round" class="u-search" input-align="center"
+			height="70" @search='searchValue' @custom='searchValue' @clear='clearValue' @change='changeValue'>
+		</u-search>
 
 		<view v-if="newsList.length > 0">
 			<view class="inTmain" v-for="(item,index) in newsList">
@@ -39,6 +40,7 @@
 				status: 'loadmore',
 				keyValue: '',
 				pagelist: 0,
+				flag: true
 			};
 		},
 		onLoad() {
@@ -46,33 +48,38 @@
 		},
 		onReachBottom() {
 			var that = this;
-			if (that.dataList.length - 1 == that.pagelist) {
+			
+			if (that.dataList.length - 1 == that.pagelist && this.status != 'nomore' && that.flag == true) {
+				that.newsList.push(that.dataList[that.pagelist]);
 				this.status = 'nomore';
+				that.flag = false;
 				return;
-			}
-			// 后续将改为与后端联动
-			this.status = 'loading';
-			setTimeout(() => {
-				for (var i = 0; i < 5; i++) {
-
-					if (that.pagelist <= that.dataList.length - 1) {
-
-						that.newsList.push(that.dataList[that.pagelist])
-
-						if (that.pagelist <= that.dataList.length - 2) {
-
-							that.pagelist += 1
-
-							if (that.dataList.length - 1 == that.pagelist) {
-								that.newsList.push(that.dataList[that.pagelist])
-							}
-
-						}
-
-					}
-
+			} else {
+				if (that.flag == false) {
+					this.status = 'nomore';
+					return
 				}
-			}, 2000);
+				// 后续将改为与后端联动
+				this.status = 'loading';
+				
+				setTimeout(() => {
+					var flag = true;
+					
+					for (var i = 0; i < 5; i++) {
+					
+						if (that.pagelist <= that.dataList.length - 2 && flag == true) {
+					
+							that.newsList.push(that.dataList[that.pagelist++])
+							
+							if (that.dataList.length - 1 == that.pagelist) flag == false
+					
+						} 
+						
+					}
+				}, 2000);
+				
+			}
+			
 		},
 		mounted() {
 			this.getCompany();
@@ -90,27 +97,25 @@
 						var resdata = res.data.data.records;
 						that.dataList = resdata;
 
+						var flag = true;
+
 						for (var i = 0; i < 5; i++) {
 
-							if (that.pagelist <= that.dataList.length - 1) {
+							if (that.pagelist <= that.dataList.length - 2) {
 
-								that.newsList.push(that.dataList[that.pagelist])
+								that.newsList.push(that.dataList[that.pagelist++]);
 
-								if (that.pagelist <= that.dataList.length - 2) {
-									that.pagelist += 1
+							} else {
 
-									if (that.dataList.length - 1 == that.pagelist) {
-										that.newsList.push(that.dataList[that.pagelist])
-									}
+								if (that.dataList.length - 1 == that.pagelist && flag == true) {
 
-								} else {
-
-									that.status = 'nomore';
-
+									that.newsList.push(that.dataList[that.pagelist]);
+									flag = false;
+									that.flag = false;
+									
 								}
 
 							}
-
 						}
 
 					}
@@ -142,12 +147,9 @@
 				for (var i = 0; i < this.pagelist; i++) {
 					this.newsList.push(this.dataList[i])
 				}
-
-				if (this.dataList.length - 1 == this.pagelist) {
-					this.newsList.push(this.dataList[this.pagelist])
-					this.status = 'nomore';
-				} else if (this.pagelist < this.dataList.length - 1) {
-					this.status = 'loadmore';
+				
+				if (this.flag == false) {
+					this.newsList.push(this.dataList[this.pagelist]);
 				}
 			},
 			changeValue(value) {
@@ -156,15 +158,12 @@
 					for (var i = 0; i < this.pagelist; i++) {
 						this.newsList.push(this.dataList[i])
 					}
-					if (this.dataList.length - 1 == this.pagelist) {
-						this.newsList.push(this.dataList[this.pagelist])
-						this.status = 'nomore';
-					} else if (this.pagelist < this.dataList.length - 1) {
-						this.status = 'loadmore';
+					
+					if (this.flag == false) {
+						this.newsList.push(this.dataList[this.pagelist]);
 					}
 				}
 			}
-
 		}
 	};
 </script>
@@ -202,3 +201,4 @@
 		color: #999;
 	}
 </style>
+
diff --git a/pages/report/initiate.vue b/pages/report/initiate.vue
index 4b3308d..a6824a4 100644
--- a/pages/report/initiate.vue
+++ b/pages/report/initiate.vue
@@ -73,7 +73,7 @@
 						label: '周报'
 					},
 					{
-						value: '2',
+						value: '3',
 						label: '月报'
 					}
 				],
diff --git a/pages/report/receive.vue b/pages/report/receive.vue
index a658d20..434db85 100644
--- a/pages/report/receive.vue
+++ b/pages/report/receive.vue
@@ -1,22 +1,31 @@
 <template>
 	<view class="container">
-		<u-search v-model="keyword" shape="round" class="u-search" input-align="center" height="70" :show-action="false"></u-search>
-		<view class="inTmain" v-for="(item,index) in dataList">
-			<u-card :title="item.deptName" @click="goDetail(item)">
-					<view class="" slot="body">
-						<view>
-							<view style="margin-bottom: 10px;" class="u-body-item-title u-line-1">汇报人:{{item.realName}}</view>
+
+		<u-search v-model='keyValue' placeholder='请输入公司名称' shape="round" class="u-search" input-align="center"
+			height="70" @search='searchValue' @custom='searchValue' @clear='clearValue' @change='changeValue'>
+		</u-search>
+
+		<view v-if="newsList.length > 0">
+			<view class="inTmain" v-for="(item,index) in newsList">
+				<u-card :title="item.deptName" @click="goDetail(item)">
+						<view class="" slot="body">
+							<view>
+								<view style="margin-bottom: 10px;" class="u-body-item-title u-line-1">汇报人:{{item.realName}}</view>
+							</view>
+							<view>
+								<view class="u-body-item-title u-line-1">汇报类型:{{item.type == 1 ? '日报' : item.type == 2 ? '周报' : '月报' }}</view>
+							</view>
 						</view>
-						<view>
-							<view class="u-body-item-title u-line-1">汇报类型:{{item.type == 1 ? '日报' : item.type == 2 ? '周报' : '月报' }}</view>
-						</view>
-					</view>
-					<view class="" slot="foot"></u-icon>汇报时间:{{item.reportTime}}</view>
-			</u-card>
+						<view class="" slot="foot"></u-icon>汇报时间:{{item.reportTime}}</view>
+				</u-card>
+			</view>
+			<u-loadmore class='msg' :status="status" />
 		</view>
-		<view class="msg" v-show="dataList.length == 0">
+
+		<view class="msg" v-else>
 			暂无数据
 		</view>
+
 	</view>
 </template>
 
@@ -24,31 +33,89 @@
 	export default {
 		data() {
 			return {
-				dataList:[],
-				keyword: ""
+				dataList: [],
+				newsList: [],
+				status: 'loadmore',
+				keyValue: '',
+				pagelist: 0,
+				flag: true
 			};
 		},
 		onLoad() {
-			
+
 		},
 		onReachBottom() {
+			var that = this;
+			
+			if (that.dataList.length - 1 == that.pagelist && this.status != 'nomore' && that.flag == true) {
+				that.newsList.push(that.dataList[that.pagelist]);
+				this.status = 'nomore';
+				that.flag = false;
+				return;
+			} else {
+				if (that.flag == false) {
+					this.status = 'nomore';
+					return
+				}
+				// 后续将改为与后端联动
+				this.status = 'loading';
+				
+				setTimeout(() => {
+					var flag = true;
+					
+					for (var i = 0; i < 5; i++) {
+					
+						if (that.pagelist <= that.dataList.length - 2 && flag == true) {
+					
+							that.newsList.push(that.dataList[that.pagelist++])
+							
+							if (that.dataList.length - 1 == that.pagelist) flag == false
+					
+						} 
+						
+					}
+				}, 2000);
+				
+			}
 			
 		},
 		mounted() {
 			this.getCompany();
 		},
 		methods: {
-			getCompany(){
+			getCompany() {
 				var that = this;
 				uni.request({
 					url: this.$store.state.piAPI + "/workReport/pageReply?deptId=" + this.$store.state.UserData.dept_id + '&userId=' + this.$store.state.puserID,
 					method:"get",
-					data:{
-						
+					data: {
+
 					},
-					success:(res)=> {
+					success: (res) => {
 						var resdata = res.data.data.records;
 						that.dataList = resdata;
+
+						var flag = true;
+
+						for (var i = 0; i < 5; i++) {
+
+							if (that.pagelist <= that.dataList.length - 2) {
+
+								that.newsList.push(that.dataList[that.pagelist++]);
+
+							} else {
+
+								if (that.dataList.length - 1 == that.pagelist && flag == true) {
+
+									that.newsList.push(that.dataList[that.pagelist]);
+									flag = false;
+									that.flag = false;
+									
+								}
+
+							}
+						}
+
 					}
 				});
 			},
@@ -56,24 +123,61 @@
 				uni.navigateTo({
 					url: './receiveDetail?detailData=' + JSON.stringify(item)
 				});
+			},
+			searchValue(value) {
+				var that = this;
+				var str = value.replace(/\s*/g, "");
+				if (str == '') {
+					return
+				} else {
+					that.newsList = [];
+					that.dataList.forEach(item => {
+						if (item.deptName.indexOf(str) != -1) {
+							that.newsList.push(item)
+						}
+					})
+					that.status = 'nomore';
+				}
+			},
+			clearValue() {
+				this.keyValue = ''
+				this.newsList = [];
+				for (var i = 0; i < this.pagelist; i++) {
+					this.newsList.push(this.dataList[i])
+				}
+				
+				if (this.flag == false) {
+					this.newsList.push(this.dataList[this.pagelist]);
+				}
+			},
+			changeValue(value) {
+				if (value == '') {
+					this.newsList = [];
+					for (var i = 0; i < this.pagelist; i++) {
+						this.newsList.push(this.dataList[i])
+					}
+					
+					if (this.flag == false) {
+						this.newsList.push(this.dataList[this.pagelist]);
+					}
+				}
 			}
-			
 		}
 	};
 </script>
 
 <style lang="scss">
-	.u-card-wrap { 
-			background-color: $u-bg-color;
-			padding: 1px;
-		}
-		
+	.u-card-wrap {
+		background-color: $u-bg-color;
+		padding: 1px;
+	}
+
 	.u-body-item {
 		font-size: 32rpx;
 		color: #333;
 		padding: 20rpx 10rpx;
 	}
-		
+
 	.u-body-item image {
 		width: 120rpx;
 		flex: 0 0 120rpx;
@@ -81,15 +185,13 @@
 		border-radius: 8rpx;
 		margin-left: 12rpx;
 	}
-	
+
 	.u-search {
 		padding: 20rpx 30rpx 0 30rpx;
 	}
-	
-	.inTmain{
-		
-	}
-	
+
+	.inTmain {}
+
 	.msg {
 		height: 72rpx;
 		line-height: 72rpx;
diff --git a/pages/report/send.vue b/pages/report/send.vue
index d2a0cd7..fbdf085 100644
--- a/pages/report/send.vue
+++ b/pages/report/send.vue
@@ -1,23 +1,34 @@
 <template>
 	<view class="container">
-		<u-search v-model="keyword" shape="round" class="u-search" input-align="center" height="70" :show-action="false"></u-search>
-		<view v-for="(item,index) in dataList">
-			<u-card :title="item.deptName" @click="goDetail(item)">
+
+		<u-search v-model='keyValue' placeholder='请输入公司名称' shape="round" class="u-search" input-align="center"
+			height="70" @search='searchValue' @custom='searchValue' @clear='clearValue' @change='changeValue'>
+		</u-search>
+
+		<view v-if="newsList.length > 0">
+			<view class="inTmain" v-for="(item,index) in newsList">
+				<u-card :title="item.deptName" @click="goDetail(item)">
 					<view class="" slot="body">
 						<view>
-							<view style="margin-bottom: 10px;" class="u-body-item-title u-line-1">汇报人:{{item.realName}}</view>
+							<view style="margin-bottom: 10px;" class="u-body-item-title u-line-1">汇报人:{{item.realName}}
+							</view>
 						</view>
 						<view>
-							<view class="u-body-item-title u-line-1">汇报类型:{{item.type == 1 ? '日报' : item.type == 2 ? '周报' : '月报' }}</view>
+							<view class="u-body-item-title u-line-1">
+								汇报类型:{{item.type == 1 ? '日报' : item.type == 2 ? '周报' : '月报' }}</view>
 						</view>
 					</view>
-					<view class="" slot="foot"></u-icon>汇报时间:{{item.reportTime}}</view>
-			</u-card>
+					<view class="" slot="foot">
+						</u-icon>汇报时间:{{item.reportTime}}</view>
+				</u-card>
+			</view>
+			<u-loadmore class='msg' :status="status" />
 		</view>
-		
-		<view class="msg" v-show="dataList.length == 0">
+
+		<view class="msg" v-else>
 			暂无数据
 		</view>
+
 	</view>
 </template>
 
@@ -25,56 +36,152 @@
 	export default {
 		data() {
 			return {
-				dataList:[],
-				keyword: ""
+				dataList: [],
+				newsList: [],
+				status: 'loadmore',
+				keyValue: '',
+				pagelist: 0,
+				flag: true
 			};
 		},
 		onLoad() {
-			
+
 		},
 		onReachBottom() {
+			var that = this;
+			
+			if (that.dataList.length - 1 == that.pagelist && this.status != 'nomore' && that.flag == true) {
+				that.newsList.push(that.dataList[that.pagelist]);
+				this.status = 'nomore';
+				that.flag = false;
+				return;
+			} else {
+				if (that.flag == false) {
+					this.status = 'nomore';
+					return
+				}
+				// 后续将改为与后端联动
+				this.status = 'loading';
+				
+				setTimeout(() => {
+					var flag = true;
+					
+					for (var i = 0; i < 5; i++) {
+					
+						if (that.pagelist <= that.dataList.length - 2 && flag == true) {
+					
+							that.newsList.push(that.dataList[that.pagelist++])
+							
+							if (that.dataList.length - 1 == that.pagelist) flag == false
+					
+						} 
+						
+					}
+				}, 2000);
+				
+			}
 			
 		},
 		mounted() {
 			this.getCompany();
 		},
 		methods: {
-			getCompany(){
+			getCompany() {
 				var that = this;
 				uni.request({
-					url: this.$store.state.piAPI + "/workReport/page?deptId=" + this.$store.state.UserData.dept_id + '&userId=' + this.$store.state.puserID,
-					method:"get",
-					data:{
-						
+					url: this.$store.state.piAPI + "/workReport/page?deptId=" + this.$store.state.UserData
+						.dept_id + '&userId=' + this.$store.state.puserID,
+					method: "get",
+					data: {
+
 					},
-					success:(res)=> {
+					success: (res) => {
 						var resdata = res.data.data.records;
 						that.dataList = resdata;
+
+						var flag = true;
+
+						for (var i = 0; i < 5; i++) {
+
+							if (that.pagelist <= that.dataList.length - 2) {
+
+								that.newsList.push(that.dataList[that.pagelist++]);
+
+							} else {
+
+								if (that.dataList.length - 1 == that.pagelist && flag == true) {
+
+									that.newsList.push(that.dataList[that.pagelist]);
+									flag = false;
+									that.flag = false;
+									
+								}
+
+							}
+						}
+
 					}
 				});
 			},
-			goDetail(item){
+			goDetail(item) {
 				uni.navigateTo({
 					url: './sendDetail?detailData=' + JSON.stringify(item)
 				});
+			},
+			searchValue(value) {
+				var that = this;
+				var str = value.replace(/\s*/g, "");
+				if (str == '') {
+					return
+				} else {
+					that.newsList = [];
+					that.dataList.forEach(item => {
+						if (item.deptName.indexOf(str) != -1) {
+							that.newsList.push(item)
+						}
+					})
+					that.status = 'nomore';
+				}
+			},
+			clearValue() {
+				this.keyValue = ''
+				this.newsList = [];
+				for (var i = 0; i < this.pagelist; i++) {
+					this.newsList.push(this.dataList[i])
+				}
+				
+				if (this.flag == false) {
+					this.newsList.push(this.dataList[this.pagelist]);
+				}
+			},
+			changeValue(value) {
+				if (value == '') {
+					this.newsList = [];
+					for (var i = 0; i < this.pagelist; i++) {
+						this.newsList.push(this.dataList[i])
+					}
+					
+					if (this.flag == false) {
+						this.newsList.push(this.dataList[this.pagelist]);
+					}
+				}
 			}
-			
 		}
 	};
 </script>
 
 <style lang="scss">
-	.u-card-wrap { 
-			background-color: $u-bg-color;
-			padding: 1px;
-		}
-		
+	.u-card-wrap {
+		background-color: $u-bg-color;
+		padding: 1px;
+	}
+
 	.u-body-item {
 		font-size: 32rpx;
 		color: #333;
 		padding: 20rpx 10rpx;
 	}
-		
+
 	.u-body-item image {
 		width: 120rpx;
 		flex: 0 0 120rpx;
@@ -82,11 +189,13 @@
 		border-radius: 8rpx;
 		margin-left: 12rpx;
 	}
-	
+
 	.u-search {
 		padding: 20rpx 30rpx 0 30rpx;
 	}
-	
+
+	.inTmain {}
+
 	.msg {
 		height: 72rpx;
 		line-height: 72rpx;
diff --git a/store/actions.js b/store/actions.js
index a73d00c..0b22b92 100644
--- a/store/actions.js
+++ b/store/actions.js
@@ -53,7 +53,6 @@
 						});
 						return;
 					}
-					console.log(res.data, 897998)
 					store.commit('getUserData', res.data)
 					// console.log(res.data,123542);
 					data.isit = true;
diff --git a/utils/func.js b/utils/func.js
index 9f1fd8b..c6c966e 100644
--- a/utils/func.js
+++ b/utils/func.js
@@ -6,10 +6,10 @@
 		vm.$u.vuex('userInfo', userInfo)
 		vm.$u.vuex('accessToken', userInfo.access_token)
 		vm.$u.vuex('isLogin', true)
-		vm.loging = false
 		uni.switchTab({
 			url: '/pages/home/home'
 		})
+		uni.hideNavigationBarLoading();
 	}
 
 	// 退出登录

--
Gitblit v1.9.3