<template>
	<view class="content">
		<view class="top"></view>
		<view class="title">
			<view class="title-item flex">
				<view class="title-font">
					提交人：
				</view>
				<view class="title-font">
					全包员工
				</view>
			</view>
			<view class="xian">
			</view>
			<view class="title-item flex">
				<view class="title-font">
					当前检验阶段：
				</view>
				<view class="title-font">
					下料
				</view>
			</view>
		</view>
		<view v-for="(item,index) in list">
			<view class="main">
				<view class="main-top">
					<image class="main-icon" src="../../static/icon/order.png" mode=""></image>
					<view class="main-font">
						{{item.name}}
					</view>
				</view>
				<view class="main-bottom flex">
					<view class="num">
						合格/不合格：
					</view>
					<view class="main-input">
						合格
					</view>
				</view>
				<view class="xian"></view>
				<view class="main-bottom flex">
					<view class="num">
						总数量：
					</view>
					<view class="main-input red">
						363
					</view>
				</view>
				<view class="xian"></view>
				<view class="main-bottom flex">
					<view class="num">
						合格数量：
					</view>
					<view class="main-input">
						<input type="number" v-model="item.hnumber" placeholder="请填写合格数量">
					</view>
				</view>
				<view class="xian"></view>
				<view class="main-bottom flex">
					<view class="num">
						品质评级：
					</view>
					<view class="main-input">
						<picker :range="pjlist" @change="choosePj($event,item)">
							<view v-if="item.pj">{{item.pj}}</view>
							<view v-else>请选择评级</view>
						</picker>
					</view>
				</view>
			</view>
			<view class="main">
				<view class="main-top">
					<image class="main-icon" src="../../static/icon/order.png" mode=""></image>
					<view class="main-font">
						{{item.name}}
					</view>
				</view>
				<view class="main-bottom flex">
					<view class="num">
						合格/不合格：
					</view>
					<view class="main-input">
						不合格
					</view>
				</view>
				<view class="xian"></view>
				<view class="main-bottom flex">
					<view class="num">
						总数量：
					</view>
					<view class="main-input red">
						363
					</view>
				</view>
				<view class="xian"></view>
				<view class="main-bottom flex">
					<view class="num">
						不合格数量：
					</view>
					<view class="main-input">
						<input type="number" v-model="item.bnumber" placeholder="请填写不合格数量">
					</view>
				</view>
				<view class="xian"></view>
				<view class="main-bottom">
					<view class="num">
						图片：
					</view>
					<view class="banner-box">
						<view class="banner" v-for="(imgitem,imgindex) in item.images" :key="index">
							<view class="banner-main">
								<image :src="imgitem" mode=""></image>
							</view>
							<image class="cha" @click.stop="delImg(imgindex)" src="../../static/img/cha.png" mode="">
							</image>
						</view>
						<view class="banner" @click="imgsub(index)">
							<image src="../../static/img/addP.png" mode=""></image>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="btn">
			确认提交
		</view>
		<view class="" style="height: 80rpx;"></view>
	</view>
</template>

<script>
	import {
		upload
	} from '@/api/user.js'
	export default {
		data() {
			return {
				list: [{
					name: '规格1(黄色,37码）',
					hnumber: '',
					bnumber: '',
					pj: '',
					images: []
				}, {
					name: '规格2(黄色,37码）',
					hnumber: '',
					bnumber: '',
					pj: '',
					images: []
				}, {
					name: '规格3(黄色,37码）',
					hnumber: '',
					bnumber: '',
					pj: '',
					images: []
				}, {
					name: '规格4(黄色,37码）',
					hnumber: '',
					bnumber: '',
					pj: '',
					images: []
				}, {
					name: '规格5(黄色,37码）',
					hnumber: '',
					bnumber: '',
					pj: '',
					images: []
				}, {
					name: '规格6(黄色,37码）',
					hnumber: '',
					bnumber: '',
					pj: '',
					images: []
				}, {
					name: '规格7(黄色,37码）',
					hnumber: '',
					bnumber: '',
					pj: '',
					images: []
				}, {
					name: '规格8(黄色,37码）',
					hnumber: '',
					bnumber: '',
					pj: '',
					images: []
				}],
				type: 0,
				pjlist: ['优', '良', '及', '不及']
			};
		},
		onLoad(opt) {
			this.type = opt.type
		},
		onShow() {},
		onReachBottom() {},
		onReady() {},
		methods: {
			choosePj(e, opt) {
				console.log(e);
				opt.pj = this.pjlist[e.detail.value]
			},
			delImg(i) {
				uni.showModal({
					content: '确定删除这张吗',
					success: res => {
						if (res.confirm) {
							this.imageList.splice(i, 1);
						} else if (res.cancel) {}
					}
				});
			},
			imgsub(index) {
				let obj = this;
				console.log('上传头像');
				upload({
					filename: ''
				}).then(res => {
					console.log(res[0].url);
					obj.list[index].images.push(res[0].url)
				});
			},
		}
	};
</script>

<style lang="scss">
	page,
	.content {
		min-height: 100%;
		height: auto;
		background: #ffffff;
	}

	.top {
		width: 100%;
		height: 20rpx;
		background: #f8f8f8;
	}

	.xian {
		width: 100%;
		height: 2rpx;
		background: #EAECED;
	}

	.title {
		width: 700rpx;
		background: #FFFFFF;
		border: 2px solid #EAECED;
		box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
		border-radius: 20rpx;
		margin: 20rpx auto 0;
		padding: 0 24rpx;

		.title-item {
			padding: 24rpx 6rpx;

			.title-font {
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #323333;
			}
		}
	}

	.main {
		margin: 20rpx auto 0;
		padding: 0 20rpx;
		width: 700rpx;
		background: #FFFFFF;
		border: 2px solid #EAECED;
		box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
		border-radius: 20rpx;

		.main-top {
			display: flex;
			align-items: center;
			padding: 16rpx 0;
			border-bottom: 1px solid #EAECED;

			.main-icon {
				width: 32rpx;
				height: 37rpx;
			}

			.main-font {
				margin-left: 10rpx;
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
			}
		}

		.main-bottom {
			padding: 20rpx 0;

			.num {
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #666666;
			}

			.main-input {
				text-align: right;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
			}

			.red {
				color: #FF4C4C;
			}
		}
	}

	.btn {
		text-align: center;
		margin: 100rpx auto 0;
		width: 622rpx;
		height: 85rpx;
		background: #069CFA;
		border-radius: 15rpx;
		line-height: 85rpx;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #FFFFFF;
	}

	.banner-box {
		background: #ffffff;
		padding: 20rpx;
		display: flex;
		align-items: center;
		flex-wrap: wrap;

		image {
			width: 100%;
			height: 100%;
		}

		.banner {
			position: relative;
			width: 110rpx;
			height: 110rpx;
			margin-right: 10rpx;

			.banner-main {
				position: absolute;
				top: 0;
				left: 0;
				right: 0;
				width: 160rpx;
				height: 160rpx;
				border-radius: 20rpx;

				image {
					border-radius: 20rpx;
				}
			}

			.cha {
				position: absolute;
				top: 0;
				right: 0;
				width: 40rpx;
				height: 40rpx;
			}
		}
	}
</style>