<template>
	<view class="mould-page">
		<navigation title="产品质检"></navigation>
		<!-- 搜索框 -->
		<view class="white-card">
			<!-- 搜索框 -->
			<!-- <uni-search-bar v-model="form.orderNum" :focus="true" placeholder="请输入工单名称,工单编号" ></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.id)">
				<view class="item-text flex-box">
					<view>订单名称：</view>
					<view>{{item.taskName}}</view>
				</view>
				<view class="item-text flex-box">
					<view>工单编号：</view>
					<view>{{item.orderNum}}</view>
				</view>
				<view class="item-text flex-box">
					<view>工单数量：</view>
					<view>{{item.orderAmounts || 0}}</view>
				</view>
				<view class="item-text flex-box">
					<view>合格数量：</view>
					<view>{{item.orderFinishNum || 0}}</view>
				</view>
				<view class="item-text flex-box">
					<view>缺陷数量：</view>
					<view>{{Number(item.orderAmounts) - Number(item.orderFinishNum) || 0}}</view>
				</view>
				<!-- <view class="btn-box">
					<view class="btn-item" >
						<view>卸载</view>
					</view>
					<view class="btn-item" >
						<view>换模</view>
					</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:{
					current:1,
					size:10,
					orderStatus:1
				},
				// 列表数据
				dataList:[],
				total:0,
				status: 'loadmore',
			}
		},
		onShow() {
			this.dataList = []
			this.productOrderlistfun()
		},
		onReachBottom() {
			this.status = 'loading'
			if (this.dataList.length < this.total) {
				this.page.current++
				this.productOrderlistfun()
			} else {
				this.status = 'nomore'
			}
		},
		methods: {
			// 跳转方法
			Jumpfun(orderId){
				uni.navigateTo({
					url: '/subPackages/qualityinspection/details?orderId=' + orderId
					
				});
			},
			// 搜索事件
			searchforfun(){
				this.form.current = 1
				this.dataList = []
				this.productOrderlistfun()
			},
			// 搜索清空
			clearforfun(){
				delete this.form.taskName
				this.form.current = 1
				this.dataList = []
				this.productOrderlistfun()
			},
			// 获取列表接口
			productOrderlistfun(){
				uni.showLoading({
					title: '加载中',
					mask: true
				});
				this.$api.productOrderlist(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
				padding: 20rpx;
				border-radius: 20rpx;
				margin-top: 28rpx;
	
				.item-text {
					margin-top: 10rpx;
					font-size: 30rpx;
					padding: 10rpx 0;
					border-bottom: 1rpx solid rgba(0, 0, 0, .1);
					&:last-child {
						border: 0;
					}
				}
				.flex-box {
					display: flex;
					align-items: center;
					justify-content: space-between;
				}
			}
	
			.btn-box {
				display: flex;
				justify-content: flex-end;
				margin-top: 10rpx;
	
				.btn-item {
					width: 175rpx;
					height: 50rpx;
					line-height: 50rpx;
					text-align: center;
					border-radius: 24rpx;
					margin-left: 20rpx;
					border: 1px solid #43adfd;
					color: #43adfd;
				}
			}
		}
	}
</style>
