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

		.cu-navbar{
			.action>button{
				background:rgba(255, 255, 255, 0.1);
				width:96rpx;
				height:48rpx;
				line-height: 48rpx;
				text-align: center;
				font-size:32rpx;
				padding:0;
				color:#fff;
			}
		}
	}
</style>
<template>
	<view class="container">
		<cu-navbar text="采收信息" style="--bg:#10C176;--c:#fff;" isBack>
			<button slot="right" class="cu-btn round" @click="submit">提交</button>
		</cu-navbar>

		<u-form class="card inline" :model="formData" :rules="rules" ref="form" labelWidth="auto">
			<d-form
				v-for="(v,k) in fields"
				:key="k"
				v-bind="v"
				:field="k"
				:required="!!rules[k]"
				:value="/^select$/.test(v.type)?fields[k].value:formData[k]"/>
		</u-form>
	</view>
</template>
<script>
import request from '@/common/request'
export default {
	data(){
		return{
			fields:{
				harvestNum:{label:"采收数量",suffix:'kg'},
				harvestBatch:{label:"收获批次号",btnText:"生成", btnFun:()=>this.formData.harvestBatch=`CS${new Date().format('yyyyMMdd')}${new Date().getTime()}`},
				principal:{label:"负责人",type:"select"},
				harvestTime:{label:"采收时间",type:"calendar"},
				status:{label:"采收状态",type:"select",columns:[[{label:"本次采收完后续还会采收",value:"1"},{label:"已全部采收完",value:"2"}]],value:[null]},
			},
			formData:{
				harvestNum:"",
				harvestBatch:"",
				principal:"",
				harvestTime:"",
				status:"",
				plantSchedulId:"",//种植计划id
				plotId:"",
			},
			rules:{
				harvestNum: {required:true, message:"必填！", trigger:"blur"},
				harvestBatch:{required:true, message:"必填！", trigger:"blur"},
				principal:{required:true, message:"必填！", trigger:"blur"},
				harvestTime:{required:true, message:"必填！", trigger:"blur"},
				status:{required:true, message:"必填！", trigger:"blur"},
				plantSchedulId:{required:true, message:"必填！", trigger:"blur"},
			}
		}
	},
	onLoad(options){
		this.formData.plantSchedulId=options.plantId
		this.formData.plotId=options.plotId
	},
	methods:{
		submit(){},
	},
}
</script>