<template>
	<view class="mould-page">
		<navigation title="所有订单"></navigation>
		<!-- 搜索框 -->
		<view class="white-card">
			<!-- 搜索框 -->
			<!-- <uni-search-bar :focus="true" ></uni-search-bar> -->
			<u-search placeholder="请输入订单名称,订单编号" v-model="form.taskName"
				@search="searchforfun" @custom="searchforfun" @clear="clearforfun">
			</u-search>
		</view>
		
		<view class="list-box" v-if="dataList.length>0">
			<view class="list-item" v-for="(item, index) in dataList" :key="index" @click="Jumpfun(item)">
				<view class="title-center" >
					{{item.orderName}}
				</view>
				<view class="bottom-text">
					<view class="item-text flex-box">
						<view class="item-text-left">订单编号：</view>
						<view class="item-text-right">{{item.orderNum}}</view>
					</view>
					<view class="item-text flex-box">
						<view class="item-text-left">订单数量：</view>
						<view class="item-text-right">{{item.number}}</view>
					</view>
					<view class="item-text flex-box">
						<view class="item-text-left">订单生产时间：</view>
						<view class="item-text-right">{{item.startTime}}</view>
					</view>
					
					<view class="positioning-type">
						{{item.status}}
						<!-- <text v-if="item.orderStatus == ite.dictValue" 
						v-for="ite of clientOrderTypeData" :key="ite.id">{{ite.dictLabel}}</text> -->
					</view>
				</view>
				
			</view>
		</view>
		
		<empty v-else text="暂无数据"></empty>
		
		<view v-if="total !== 0 && dataList.length != 0" style="height: 60rpx;">
			<u-loadmore :status="status" />
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 请求传递的参数
				form:{
					pageNum:1,
					pageSize:10,
				},
				// 列表数据
				dataList:[],
				total:0,
				status: 'loadmore',
				clientOrderTypeData:[],
			}
		},
		onLoad(e) {
			this.form.status = e.status
			// this.clientOrderTypefun()
		},
		onShow() {
			this.dataList = []
			this.orderListfun()
		},
		onReachBottom() {
			this.status = 'loading'
			if (this.dataList.length < this.total) {
				this.form.pageNum++
				this.orderListfun()
			} else {
				this.status = 'nomore'
			}
		},
		methods: {
			// 跳转方法
			Jumpfun(item){
				uni.navigateTo({
					url: '/subPackages/orderforGoods/details?id=' + item.id + '&url=' + encodeURIComponent(item.url)
				});
			},
			// 搜索事件
			searchforfun(){
				this.form.pageNum = 1
				this.dataList = []
				this.productOrderlistfun()
			},
			// 搜索清空
			clearforfun(){
				delete this.form.taskName
				this.form.pageNum = 1
				this.dataList = []
				this.productOrderlistfun()
			},
			// 获取字典数据
			clientOrderTypefun(){
				this.$api.clientOrderType().then(res=>{
					this.clientOrderTypeData = res.data
				})
			},
			// 获取列表接口
			orderListfun(){
				uni.showLoading({
					title: '加载中',
					mask: true
				});
				this.$api.orderList(this.form).then(res=>{
					this.dataList = this.dataList.concat(res.rows)
					this.total = res.total
					if (this.dataList.length == res.total) {
						this.status = 'nomore'
					}
					uni.hideLoading();
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.mould-page {
		.white-card {
			background-color: $uni-bg-color;
			padding: 20rpx;
		}
		.list-box {
			padding: 0 20rpx;
			color: $uni-text-color-list; 	// #666
			.list-item {
				background-color: $uni-bg-color; // #ffffff
				border-radius: 20rpx;
				margin-top: 28rpx;
				font-size: 28rpx;
				.title-center {
					text-align: center;
					border-bottom: 1rpx solid #bababa;
					padding: 15rpx 0;
				}
				.bottom-text {
					padding: 20rpx;
					position: relative;
					.item-text {
						margin: 5rpx 0;
					}
					.positioning-type {
						position: absolute;
						top: 20rpx;
						right: 30rpx;
					}
				}
				
			}
	
		}
		.flex-box {
			display: flex;
			align-items: center;
		}
	}
</style>
