<template>
	<view class="content">
		<view class="card" v-for="(item, index) in list" :key="index">
			<view class="lf-color-black lf-font-bold">{{ item.title }}</view>
			<view class="lf-row-between lf-m-t-30">
				<view>订购数</view>
				<view class="lf-color-black">{{ item.orderNum }}</view>
			</view>
			<view class="lf-row-between lf-m-t-30">
				<view>实到数</view>
				<view class="lf-flex">
					<input class="input" placeholder="0" type="number" :value="item.realNum" @blur="inputBlur(index, 'realNum', $event)" />
					<text class="lf-color-black">斤</text>
				</view>
			</view>
			<view class="lf-row-between lf-m-t-30">
				<view>实收数</view>
				<view class="lf-flex">
					<input class="input" placeholder="0" type="number" :value="item.receiptsNum" @blur="inputBlur(index, 'receiptsNum', $event)" />
					<text class="lf-color-black">斤</text>
				</view>
			</view>
		</view>
		<button class="btn" @click="comfirm">确认收货</button>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				list: [{
					title: '大白菜 / 长叶子 / 斤',
					orderNum: '300斤',
					realNum: '',
					receiptsNum: ''
				},{
					title: '拌凉菜 / 好好次 / 斤',
					orderNum: '100斤',
					realNum: '',
					receiptsNum: ''
				},{
					title: '你是真的菜 / 菜鸡 / 斤',
					orderNum: '1000吨',
					realNum: '',
					receiptsNum: ''
				}]
			}
		},
		onLoad(){
			
		},
		methods: {
			inputBlur(current, key, event){
				console.log("inputBlur", current, key, event);
				this.list[current][key] = event.detail.value;
			},
			comfirm(){
				// 使用延迟器，以防input还没有赋值成功
				setTimeout(() => {
					console.log("comfirm", this.list);
					this.$msg('确认收货成功！');
				}, 100);
			}
		}
	}
</script>

<style>
	page{
		background-color: #F6F6F6;
		overflow-x: hidden;
	}
</style>
<style lang="scss" scoped="scoped">
	.content{
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		flex-direction: column;
	}
	.card{
		width: 686rpx;
		height: auto;
		background-color: #FFFFFF;
		border-radius: 20rpx;
		margin-top: 30rpx;
		font-size: 28rpx;
		box-sizing: border-box;
		padding: 30rpx;
		color: #777777;
		.input{
			width: 88rpx;
			border-bottom: 1rpx solid #e5e5e5;
			margin-right: 14rpx;
			text-align: center;
			color: #222222;
		}
	}
	.btn{
		width: 686rpx;
		background-color: #11D189;
		margin-top: 30rpx;
		margin-bottom: 30rpx;
		color: #FFFFFF;
	}
	/deep/.placeholder-class{
		color: #777777;
	}
</style>
