<template>
	<view class="container">
		<view class="example">
			<uni-forms ref="form" :model="firm" labelWidth="80px">
				<uni-forms-item label="监测图斑" name="dkbh">
					{{obj.dkbh}}
				</uni-forms-item>
				<uni-forms-item label="监测面积" name="dkmj">
					{{obj.dkmj}}
				</uni-forms-item>
				<uni-forms-item v-if="firm.confirmState == '1' " label="退回原因" name="confirmType">
					<uni-data-select v-model="firm.confirmType" :localdata="options"></uni-data-select>
				</uni-forms-item>
				<uni-easyinput v-if="firm.confirmState == '1' " v-model=" firm.confirmNotse" type="textarea"
					placeholder="请输入其他原因" />
			</uni-forms>
			<button type="primary" @click="submit">提交</button>
		</view>
	</view>
</template>

<script>
	import {
		confirm,
	} from "@/api/dkjbxx.js";


	export default {
		data() {
			return {
				tytitle: '',
				obj: {},
				firm: {
					"id": "",
					"confirmState": "",
					"confirmType": "",
					"confirmNotse": "",
					"auditflowStep": "WYQR"
				},
				options: [{
					text: '图斑位置无法到达',
					value: "0"
				}, {
					text: '任务期间处于离岗',
					value: "1"
				}, {
					text: '其它',
					value: "2"
				}],

			}
		},

		onLoad(option) {
			this.tytitle = option.confirmState == '1' ? '退回' : '确认'
			uni.setNavigationBarTitle({
				title: `${this.tytitle}图斑外业任务` // 这里的标题可以是变量或者计算结果
			});

			this.obj = uni.$globalData || {}
			this.firm.id = this.obj.id
			this.firm.confirmState = option.confirmState
			console.log(this.obj)
		},
		onReady() {
			// this.$refs.form.setRules(this.rules)
		},
		methods: {

			submit(ref) {
				this.$refs.form.validate().then(res => {
					confirm(this.firm).then(response => {
						this.$modal.msgSuccess("修改成功")
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ffffff;
	}

	.example {
		padding: 15px;
		background-color: #fff;
	}

	.segmented-control {
		margin-bottom: 15px;
	}

	.button-group {
		margin-top: 15px;
		display: flex;
		justify-content: space-around;
	}

	.form-item {
		display: flex;
		align-items: center;
		flex: 1;
	}

	.button {
		display: flex;
		align-items: center;
		height: 35px;
		line-height: 35px;
		margin-left: 10px;
	}
</style>