<template>
	<view class="fullHeight">
		<headers :showBack="true">
			<view class="headerName">
				{{pageTitle}}
			</view>
		</headers>
		<view class="formBox">
			<form @submit="formSubmit">
				<view class="uni-form-item">
					<view class="uni-form-label">
						<text class="star">*</text>测区名称
					</view>
					<view class="uni-form-input">
						<input class="uni-input" placeholder-class="cl" name="areaName" :value="form.areaName"
							placeholder="请输入" />
					</view>
				</view>
				<view class="uni-form-item">
					<view class="uni-form-label">
						<text class="star">*</text>选择规范
					</view>
					<view class="uni-form-input">
						<picker @change="bindPickerChange" :value="standardTypeIndex" :range="standardTypeList"
							range-key="typeName">
							<view class="uni-input uni-select cl" v-if="standardTypeIndex==null">
								请选择 <image class="icon-down" src="/static/icon-down-black.png" mode=""></image>
							</view>
							<view class="uni-input uni-select" v-else>{{standardTypeList[standardTypeIndex]}}
								<image class="icon-down" src="/static/icon-down-black.png" mode=""></image>
							</view>
						</picker>
					</view>
				</view>
				<view class="uni-form-item">
					<view class="uni-form-label">
						<text class="star">*</text>选择规则
					</view>
					<view class="uni-form-input">
						<picker @change="bindPickerChange2" :value="ruleIndex" :range="ruleList"
							range-key="floorName">
							<view class="uni-input uni-select cl" v-if="ruleIndex==null">
								请选择 <image class="icon-down" src="/static/icon-down-black.png" mode=""></image>
							</view>
							<view class="uni-input uni-select" v-else>{{ruleList[ruleIndex]}}
								<image class="icon-down" src="/static/icon-down-black.png" mode=""></image>
							</view>
						</picker>
					</view>
				</view>
				<button form-type="submit" type="primary" class="btn submitBtn big">保存</button>
			</form>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageTitle: '添加任务',
				leaderIndex: null,
				standardTypeIndex: null,
				ruleIndex: null,
				selectList: [{
						name: 'C15'
					}, {
						name: 'C20'
					}, {
						name: 'C25'
					}, {
						name: 'C30'
					}, {
						name: 'C35'
					},
					{
						name: 'C40'
					}, {
						name: 'C45'
					}, {
						name: 'C50'
					}, {
						name: 'C55'
					}, {
						name: 'C60'
					}
				],
				selectArr: [],
				standardTypeList: ["激光测距", "靠尺规范", "回弹测试", "角度"],
				ruleList: ["一级","二级","三级"],
				leaderList: ["董事长","项目经理"],
				form: {
					areaName: '',
					standardType: "",
					ruleType: ""
				},
				personList: [],
				projectDetail: {},
				isAdd: true
			}
		},
		onLoad(options) {},
		onShow() {

		},
		methods: {
			bindPickerChange: function(e) {
				this.standardTypeIndex = e.target.value
				this.form.standardType = e.target.value
			},
			bindPickerChange2: function(e) {
				this.ruleIndex = e.target.value
				this.form.ruleType = e.target.value
			},
			formSubmit(e) {
				var that = this
				console.log(e)
				var params = e.detail.value
				params.projectSn = this.projectDetail.projectSn
				if (params.concreteTab == '') {
					uni.showToast({
						title: '请输入混泥土标号',
						icon: 'none'
					})
					return false;
				}
				if (this.standardTypeIndex == null) {
					uni.showToast({
						title: '请选择楼栋',
						icon: 'none'
					})
					return false;
				}
				if (this.ruleIndex == null) {
					uni.showToast({
						title: '请选择楼层',
						icon: 'none'
					})
					return false;
				}


				params.buildId = this.standardTypeList[this.standardTypeIndex].id
				params.floorId = this.ruleList[this.ruleIndex].floorId
				params.pourTime = this.form.pourTime
				params.designStrength = this.selectArr.join(',')


				var url = 'xmgl/electronPourOrder/edit'
				if (this.isAdd) {
					url = 'xmgl/electronPourOrder/add'

				} else {
					params.id = this.form.id
				}
				this.sendRequest({
					url: url,
					data: params,
					method: "POST",
					success(res) {
						uni.showToast({
							title: '保存成功！'
						})
						uni.navigateBack({

						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
</style>