<template>
	<view>
		<view class="mtop"><image src="../../static/lx.jpg" mode="widthFix"></image></view>
		<view class="cn">
			<view class="info">
				<view class="form_group hr">
					<view class="lable">散客预约人数</view>
					<input type="text" placeholder="请输入散客预约人数" v-model="item.scatteredAppointment" />
				</view>
				<view class="form_group hr">
					<view class="lable">散客接待人数</view>
					<input type="number" placeholder="请输入散客接待人数" v-model="item.scatteredReception" />
				</view>
				<view class="form_group hr">
					<view class="lable">团客预约人数</view>
					<input type="number" placeholder="请输入团客预约人数" v-model="item.groupAppointment" />
				</view>
				<view class="form_group hr">
					<view class="lable">团客接待人数</view>
					<input type="number" placeholder="请输入团客接待人数" v-model="item.groupReception" />
				</view>
				<view class="form_group hr">
					<view class="lable">销售金额</view>
					<input type="number" placeholder="请输入销售金额" v-model="item.salesAmount" />
				</view>
			</view>
			<button class="btn" @click="up()">上报数据</button>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			item: {}
		};
	},
	methods: {
		up() {
			let rule = [
				{ name: 'scatteredAppointment', checkType: 'notnull', errorMsg: '请输入散客预约人数' },
				{ name: 'scatteredReception', checkType: 'notnull', errorMsg: '请输入散客接待人数' },
				{ name: 'groupAppointment', checkType: 'notnull', errorMsg: '请输入团客预约人数' },
				{ name: 'groupReception', checkType: 'notnull', errorMsg: '请输入团客接待人数' },
				{ name: 'salesAmount', checkType: 'notnull', errorMsg: '请输入销售金额' }
			];
			if (!this.$verify.check(this.item, rule)) {
				uni.showModal({ content: this.$verify.error, showCancel: false });
				return;
			}
			this.$http.request({
				method: 'POST',
				url: this.$http.urls.pushRecord,
				data: this.item,
				success: res => {
					uni.showToast({ title: '上报成功' });
					setTimeout(() => {
						uni.navigateBack();
					}, 700);
				}
			});
		}
	}
};
</script>

<style lang="scss">
.mtop {
	text-align: center;
	image {
		width: 80%;
	}
}
.cn {
	padding: 15px;
	.info {
		background-color: white;
		border-radius: 5px;
		margin-top: 10px;
		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
	}
	.btn {
		margin-top: 25px;
	}
}
</style>
