Browse Source

改为日期区间查询(年月日)、增加空数据显示

htc 11 months ago
parent
commit
fa42f99175
1 changed files with 68 additions and 19 deletions
  1. 68 19
      pagesHouse/Verification/record.vue

+ 68 - 19
pagesHouse/Verification/record.vue

@@ -2,26 +2,41 @@
 	<view class="page" :style="{'min-height':(h)+'px','padding-top':mt+'px'}">
 		<c-nav-bar title="核销记录"></c-nav-bar>
 		<view class="top">
-			<view class="time" @click="show=true">
-				<u-icon name="calendar" :label="dateStr" labelPos="right" labelColor="#666" color="#666" space="7px"
-					size="25px"></u-icon>
-				<u-icon name="arrow-down" color="#999" size="20px" style="margin-left: 20rpx;"></u-icon>
+			<view style="display: flex;align-items: center;">
+				<view class="time" @click="show=true">
+					<u-icon name="calendar" :label="dateStr" labelPos="right" labelColor="#666" color="#666" space="3px"
+						size="25px"></u-icon>
+					<u-icon name="arrow-right" color="#999" size="32rpx" style="margin:2rpx 0 0 20rpx;"></u-icon>
+				</view>
+				<view style="margin: 0 14rpx 0 10rpx;font-size: 30rpx;color: #666;">至</view>
+				<view class="time" @click="show2=true">
+					<u-icon :label="dateStr2" labelPos="right" labelColor="#666" color="#666" space="3px"
+						size="25px"></u-icon>
+					<u-icon name="arrow-right" color="#999" size="32rpx"></u-icon>
+				</view>
 			</view>
 			<view class="right">共{{totalNum}}单 收入¥{{totalAmount}}</view>
 		</view>
 		<view class="list">
-			<view class="item" v-for="(item,index) in data" :key="index" @tap="toDetails(item)">
-				<image :src="item.goodsType==2?'../../static/bao.png':'../../static/pin.png'"></image>
-				<view class="mid">
-					<text>{{item.playDate}} {{item.playTime}}出发/{{item.goodsType==2?'包船':'拼船'}}/{{item.boatNo}}</text>
-					<text>{{item.num}}人 · 出游{{item.playLength}}小时</text>
-					<text>核销时间:{{item.updateDate}}</text>
+			<block v-if="data.length>0">
+				<view class="item" v-for="(item,index) in data" :key="index" @tap="toDetails(item)">
+					<image :src="item.goodsType==2?'../../static/bao.png':'../../static/pin.png'"></image>
+					<view class="mid">
+						<text>{{item.playDate}} {{item.playTime}}出发/{{item.goodsType==2?'包船':'拼船'}}/{{item.boatNo}}</text>
+						<text>{{item.num}}人 · 出游{{item.playLength}}小时</text>
+						<text>核销时间:{{item.updateDate}}</text>
+					</view>
+					<view class="price">¥{{item.realPrice}}</view>
 				</view>
-				<view class="price">¥{{item.realPrice}}</view>
-			</view>
+			</block>
+			<block v-else>
+				<NoData/>
+			</block>
 		</view>
 		<u-datetime-picker @confirm="confirmDate" @cancel="show=false" :show="show" v-model="value1"
-			visibleItemCount="6" mode="year-month"></u-datetime-picker>
+			visibleItemCount="6" mode="date"></u-datetime-picker>
+		<u-datetime-picker @confirm="confirmDate2" @cancel="show2=false" :show="show2" v-model="value2"
+			visibleItemCount="6" mode="date"></u-datetime-picker>
 	</view>
 </template>
 
@@ -29,12 +44,16 @@
 	export default {
 		data() {
 			return {
-				dateStr: new Date().Format('yyyy年-MM月'),
-				date: new Date().Format('yyyy-MM'),
+				dateStr: new Date().Format('yyyy-MM-dd'),
+				dateStr2: new Date().Format('yyyy-MM-dd'),
+				date: new Date().Format('yyyy-MM-dd'),
+				date2: new Date().Format('yyyy-MM-dd'),
 				show: false,
+				show2: false,
 				k: '',
 				data: [],
 				value1: Number(new Date()),
+				value2: Number(new Date()),
 				merchantId: uni.getStorageSync('merchantId'),
 				totalAmount: 0,
 				totalNum: 0
@@ -49,14 +68,15 @@
 					limit:50,
 					page:1,
 					merchantId: this.merchantId,
-					queryDate: this.date
+					// queryDate: this.date,
+					startDate: this.date,
+					endDate: this.date2
 				}).then(res => {
 					if (res.data.code == 0) {
 						this.totalAmount = res.data.data.totalAmount;
 						this.totalNum = res.data.data.totalNum;
 						this.data=res.data.data.pageData.list;
 					}
-					console.log(res)
 				})
 			},
 			confirmDate(e) {
@@ -68,12 +88,37 @@
 				const day = ('0' + date.getDate()).slice(-2);
 				// 格式化时间
 				let formattedTime = "";
-				formattedTime = `${year}-${month}`;
-				this.dateStr = `${year}年-${month}月`
+				formattedTime = `${year}-${month}-${day}`;
+				
+				if(Date.parse(formattedTime) - Date.parse(this.date2)>0){
+					return this.$showToast('开始日期不能大于结束日期');
+				}
+				
+				this.dateStr = `${year}-${month}-${day}`
 				this.date = formattedTime;
 				this.show = false;
 				this.getdata()
 			},
+			confirmDate2(e) {
+				// 创建一个Date对象并传入时间戳
+				const date = new Date(e.value);
+				// 使用Date对象的方法获取年、月、日、小时、分钟和秒
+				const year = date.getFullYear();
+				const month = ('0' + (date.getMonth() + 1)).slice(-2);
+				const day = ('0' + date.getDate()).slice(-2);
+				// 格式化时间
+				let formattedTime = "";
+				formattedTime = `${year}-${month}-${day}`;
+				
+				if(Date.parse(formattedTime) - Date.parse(this.date)<0){
+					return this.$showToast('结束日期不能小于开始日期');
+				}
+				
+				this.dateStr2 = `${year}-${month}-${day}`
+				this.date2 = formattedTime;
+				this.show2 = false;
+				this.getdata()
+			},
 			toDetails(item){
 				uni.navigateTo({
 					url:'/pagesHouse/Verification/recordDetails?orderCode='+item.orderCode
@@ -84,6 +129,10 @@
 </script>
 
 <style lang="less" scoped>
+	/deep/ .uicon-arrow-right{
+		margin-top: 4rpx !important;
+	}
+	
 	.page{
 		box-sizing: border-box;
 	}