<template>
	<view>
		<view class="tab" style="height: 110px;">
			<u-tabs :list="tab" @click="click" :lineHeight="5"></u-tabs>
			<view style="display: flex;margin-top: 10px;z-index: 999;">
				<view class="searchDate" @click="show=!show">{{param.declTime}}</view>
				<!-- <u--input placeholder="选择日期" border="surround"   v-model="param.declTime" clearable readonly @click="show=!show"> -->
				</u--input>
				<view class="reset_btn" @click="cleanDate">重置</view>
			</view>
			<u-calendar :show="show" minDate="2024-08-15" :insert="false" title="选择日期" @confirm="confirm"></u-calendar>
		</view>
		<view class="goodsList">
			<view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
				<view class="title">{{ item.shopName }}
					<view v-if="item.hzsConfirmStatus==0">
						<view class="state">
							<text class="icon">&#xe830;</text>
							<text>未确认</text>
						</view>
					</view>
					<view v-else>
						<view class="state" v-if="item.finishStatus == 1">
							<text class="icon">&#xe830;</text>
							<text>已结算</text>
						</view>
						<view class="state" v-else>
							<text class="icon">&#xe830;</text>
							<text>未结算</text>
						</view>
					</view>
				</view>
				<view class="con">
					<view class="productName omit" style="font-size: 16px;">{{ item.goodsNames }}</view>
					<view class="desc omit">
						<text>
							{{ item.fieldName }}</text>
					</view>
					<view class="desc">
						<text>重量 {{ item.sumGrossWt }}</text>
						<text>| 车辆 {{ item.veNo }}</text>
						<text v-if="item.orderCount"> | 订单 {{ item.orderCount }}</text>
					</view>

					<view class="price"> ¥ {{ item.sumAmt }}</view>
				</view>
				<view class="clear"></view>
				<view class="op">
					<view class="date">申报时间 {{ item.declTime.substr(0,16) }}</view>
					<template>
						<view class="an detail_btn" @click.stop="detail(item)">边民订单</view>
					</template>
				</view>
			</view>
			<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
			<u-empty v-if="!loadMore && list.length == 0"></u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tab: [{
						name: '全部',
						finishStatus: '', //订单完成状态
						resaleStatus: '' //订单转售状态
					},
					{
						name: '未确认',
						finishStatus: 0,
						hzsConfirmStatus: 0
					},
					{
						name: '未结算',
						finishStatus: 0,
						hzsConfirmStatus: 1
					},
					{
						name: '已结算',
						finishStatus: 1,
						hzsConfirmStatus: 1

					},
				],
				show: false,
				param: {
					pageNo: 1,
					pageSize: 10,
					declTime: '选择日期',
					sortType: 25
				},
				list: [],
				loadMore: true,
				id: '',
				flag: '',
			};
		},
		onLoad() {
			this.getData()
		},
		onShow() {},
		methods: {
			cleanDate() {
				this.param.declTime = '选择日期';
				this.param.pageNo = 1;
				this.getData()
			},
			confirm(days) {
				this.param.declTime = days[0];
				this.show = false;
				this.getData()
			},
			getData() {
				let params = JSON.parse(JSON.stringify(this.param));
				if (params.declTime == '选择日期') {
					params.declTime = '';
				}
				this.http.request({
					url: '/level-one-server/app/HtTradeSettlement/getList',
					loading: 'false',
					data: params,
					success: res => {
						this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
						if (res.data.data) {
							this.list.push(...res.data.data);
						}
						if (this.param.pageNo == 1 && res.data.data && res.data.data.length == 0) {
							this.list = []
						}
					}
				});
			},
			// 点击tab切换
			click(e) {
				this.param.finishStatus = e.finishStatus;
				this.getData();
			},
			detail(item) {
				uni.navigateTo({
					url: '/pages/market/one/cooperative/peopleOrders?mainId=' + item.id + '&goodsName=' + item
						.goodsNames + '&veNo=' + item.veNo + '&declTime=' + item.declTime + '&sumGrossWt=' + item
						.sumGrossWt
				});
			},
		},
		//下拉刷新
		onPullDownRefresh() {
			this.param.pageNo = 1;
			this.param.declTime = '';
			setTimeout(() => {
				this.getData();
				uni.stopPullDownRefresh();
			}, 1000);
		},
		//上拉加载
		onReachBottom() {
			if (this.loadMore) {
				this.param.pageNo++;
				this.getData();
			}
		}
	};
</script>

<style lang="scss">
	page {
		background-color: $pg;
	}

	.state {
		margin-right: -70px;
	}

	.goodsList {
		.item {
			.con {
				width: 90%;

				.desc {
					uni-text {
						padding-right: 5px;
					}
				}
			}
		}
	}

	.tab {
		.searchDate {
			width: 60%;
			font-size: 15px;
			border-radius: 5px;
			padding: 10px;
			color: #545555;
			background-color: #f6f6f6;
			margin-left: 10px;
		}

		.reset_btn {
			line-height: 35px;
			padding: 0 15px;
			border: 1px solid #e2e2e2;
			border-radius: 8px;
			margin-left: 10px;
			background: #e2e2e2
		}
	}

	.detail_btn {
		border: 1px solid;
		padding: 4px 7px;
		border-radius: 6px;
		background: #2f64c3;
		color: #ffff;
	}
</style>