<style lang="scss">
	.container{
		min-height:100%;
		background:#f6f6f6;
		padding:30rpx 0;

		&.agr{
			padding:30rpx;
			background:#fff;
		}
		&>.agrInfo{
			margin-top:0;
			.data{
				display:flex;
				align-items: center;
				margin-bottom:16rpx;
				text{
					&:first-child{
						flex-shrink: 0;
						color:#fff;
						background:#10C176;
						border-radius: 6rpx;
						min-width:80rpx;
						height:40rpx;
						line-height: 40rpx;
						text-align: center;
						font-size:20rpx;
						margin-right:16rpx;
					}
					&:nth-child(3){
						background:#10C176;
						border-radius: 50%;
						width:36rpx;
						height:36rpx;
						text-align: center;
						line-height: 36rpx;
						color:#fff;
						margin-left:auto;
					}
				}
			}
		}
		.u-form{
			&.card{
				margin:30rpx 30rpx 0;
			}
			&>.addAgr{
				color:#10C176;
				background:rgba(16, 193, 119, 0.1);
				border-radius: 24rpx;
				height:100rpx;
				display:flex;
				align-items: center;
				justify-content: space-between;
				padding:30rpx;
				margin-bottom:28rpx;
			}
		}
	}
</style>
<template>
	<view class="container" :class="{agr:!isAgr}">
		<d-navbar text="农资入库" isBack style="--bg:#10C176;--c:#fff;">
			<button slot="right" class="cu-btn round" @click="submit">提交</button>
		</d-navbar>

		<view class="agrInfo card" v-if="isAgr">
			<view class="data"> <text>化肥</text><text class="over">中量元素水溶肥</text><text class="plant-jiantou_zuoyouqiehuan"/> </view>
			<view style="color:#707070;font-size:20rpx;">云南云天化股份有限公司</view>
		</view>

		<u-form class="inline" :class="{card:isAgr}" errorType="toast" :model="formData" ref="form" :rules="rules" labelWidth="auto">
			<view class="addAgr">添加农资<text class="plant-batch-add"/></view>
			<template v-for="(v,k) in fields">
				<d-form
					v-if="!v.agr ||v.agr&&isAgr"
					:key="k"
					v-bind="v"
					:field="k"
					:required="!!rules[k]"
					:value="formData[k]"/>
			</template>
		</u-form>
	</view>
</template>
<script>
	export default{
		data(){
			return{
				fields:{
					scpect:{label:"规格", type:"select", columns:[[]],value:[],agr:true},
					num:{label:"入库数量", type:"number",suffix:"袋", tip:"共计：40kg",agr:true},
					type:{label:"入库类型"},
					date:{label:"入库时间"},
					imgs:{label:"单据、凭证图片",type:"upImg",value:''},
					remarks:{label:"备注",type:"textarea"},
				},
				formData:{
					type:"",
					date:"",
					imgs:[],
					remarks:"",
				},
				rules:{
					type:{required:true},
					date:{required:true},
					imgs:{required:true},
				},
				isAgr: false,
			}
		},
		onLoad(){},
		methods:{
			submit(){},
		},
	}
</script>