<template>
	<view class="container">
		<uni-section title="基本信息" type="line">
			<view class="form">
				<uni-forms ref="baseForm" :modelValue="form" label-width="100">
					<uni-forms-item label="客户名称" name="name" required>
						<uni-combox :candidates="candidates" placeholder="请选择客户名称" v-model="form.name"></uni-combox>
					</uni-forms-item>
					<uni-forms-item label="省份">
						<uni-easyinput v-model="form.provience" disabled />
					</uni-forms-item>
					<uni-forms-item label="城市">
						<uni-easyinput v-model="form.city" disabled />
					</uni-forms-item>
					<uni-forms-item label="行业" required>
						<uni-data-picker placeholder="请选择班级" popup-title="请选择行业" :localdata="dataTree" v-model="form.industryId"
							@change="onchange">
						</uni-data-picker>
					</uni-forms-item>
					<uni-forms-item label="联系人姓名" name="contact" required>
						<uni-easyinput v-model="form.contact" placeholder="请输入联系人姓名" />
					</uni-forms-item>
					<uni-forms-item label="手机" name="contact">
						<uni-easyinput v-model="form.contact" placeholder="请输入手机" />
					</uni-forms-item>
					<uni-forms-item label="账号" name="contact" required>
						<uni-easyinput v-model="form.contact" placeholder="请以院校首字母+admin的格式来设置" />
					</uni-forms-item>
					<uni-forms-item label="职务" name="contact">
						<uni-easyinput v-model="form.contact" placeholder="请输入职务" />
					</uni-forms-item>
					<uni-forms-item label="邮箱" name="contact">
						<uni-easyinput v-model="form.contact" placeholder="请输入邮箱" />
					</uni-forms-item>
					<uni-forms-item label="产品到期时间">
						<uni-datetime-picker type="datetime" return-type="timestamp"
							v-model="form.datetimesingle" />
					</uni-forms-item>
					<uni-forms-item label="客户类型">
						<uni-easyinput v-model="form.city" disabled />
					</uni-forms-item>
				</uni-forms>
				<button type="primary" @click="submit('valiForm')">提交</button>
			</view>
		</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				candidates: ['北京', '南京', '东京', '武汉', '天津', '上海', '海口'],
				dataTree: [{
						text: "一年级",
						value: "1-0",
						children: [{
								text: "1.1班",
								value: "1-1"
							},
							{
								text: "1.2班",
								value: "1-2"
							}
						]
					},
					{
						text: "二年级",
						value: "2-0",
						children: [{
								text: "2.1班",
								value: "2-1"
							},
							{
								text: "2.2班",
								value: "2-2"
							}
						]
					},
					{
						text: "三年级",
						value: "3-0",
						disable: true
					}
				],
				form: {
					name: '',
					provience: '',
					city: '',
					industryId: '',
					age: '',
					introduction: '',
					sex: 2,
					hobby: [5],
					datetimesingle: 1627529992399
				},
				sexs: [{
					text: '男',
					value: 0
				}, {
					text: '女',
					value: 1
				}, {
					text: '保密',
					value: 2
				}],
			}
		},
		onLoad() {
			
		},
		methods: {
			onchange(e) {
				console.log('---------onchange:', e);
			},
			submit(ref) {
				this.$refs[ref].validate().then(res => {
					console.log('success', res);
					uni.showToast({
						title: `校验通过`
					})
				}).catch(err => {
					console.log('err', err);
				})
			},
		}
	}
</script>

<style scoped lang="scss">
.form {
	padding: 15px;
	background-color: #fff;
}
</style>
