<style lang="scss" scoped>
	.container{
		background:#F6F6F6;
		padding:14px 0;
		min-height:100%;
		&>.u-button{
			margin:38px auto 0px;
			width:80%;
		}
	}
</style>
<template>
	<view class="container">
		<u-form class="card inline" :model="formData" ref="form" :rules="rules" labelWidth="auto">
			<d-form
				v-for="(v,k) in fields"
				:key="k"
				v-bind="v"
				:required="!!rules[k]"
				:field="k"
				@selectDate="selectDate"/>
		</u-form>
		<u-button shape="circle" color="#10C176">保存</u-button>
	</view>
</template>
<script>
import dForm from '@/components/form.vue'
	export default{
		components:{dForm},
		data(){
			return{
				fields:{
					name:{label:"基地名称"},
					code:{label:"地块编号"},
					massifName:{label:"地块名称"},
					area:{label:"地块面积(亩)"},
					sjArea:{label:"实际面积"},
					imgs:{label:"地块图片",type:"upImg"},
					date:{label:"使用日期",type:"dateRange",value:[]},
					jw:{label:"经/纬度"},
					adder:{label:"详细地址",type:"textarea"},
				},
				formData:{
					name:"",
					date:[],
				},
				rules:{
					date:{required:true, message:"日期必填！", trigger:"blue"}
				},
			}
		},
		methods:{
			selectDate(e){
				console.log(e,'-----e---------')
				switch(e.type){
					case "start":this.fields.date.value[0]=e.value;break;
					case 'end':this.fields.date.value[1]=e.value;break;
				}
			}
		},
	}
</script>