<template>
	<view class=" uni-container" v-if="formData.id">
		<view class="example container" :style="'height: ' + (screenHeight - wheight - 75) + 'px'">
			<!-- 自定义表单校验 1-->
			<u--form ref="customForm" :model="formData" labelPosition="top" labelWidth="150" labelAlign="left">
				<u-form-item label="检测项目" prop="detinspect" :required="true">
					<u-input v-model="formData.detinspect" disabled placeholder="请输入检测项目" />
				</u-form-item>
				<u-form-item label="预计检测时间" prop="detdate">
					<uni-datetime-picker v-model="formData.detdate" type="datetime"
						closeOnClickOverlay disabled></uni-datetime-picker>
				</u-form-item>
				<u-form-item label="检测维保结果" prop="detresult" >
					<u-input v-model="formData.detresult" disabled placeholder="请输入检测维保结果" />
				</u-form-item>
				<u-form-item label="所属单位"  prop="orgId" :required="true">
						<u-input v-model="formData.orgId" disabled placeholder="" />
				</u-form-item>
				<u-form-item label="附件">
					<view class="buju">
						<text v-if="formData.att == '' || formData.att == null">无</text>
						<!-- #ifdef MP-WEIXIN -->
						<text v-else style="color:#00a3f4;cursor: pointer;"
							@click.native="down(formData.att)">点击预览文件</text>
						<!-- #endif -->
						<!-- #ifdef H5 -->
						<a v-else style="color:#00a3f4;cursor: pointer;" @click="down(formData.att)">点击预览文件</a>
						<!-- #endif -->
					</view>
				</u-form-item>
			</u--form>
		</view>
		<uni-row class="heigthButton">
			<u-button @click="gotoEditDetection(formData)" shape="circle" size="large" color="#4cb2b6" style="width: 60%;"
				text="修改信息"></u-button>
		</uni-row>
	</view>
</template>
<script>
	var that = null;
	import {
		downSee
	} from '@/utils/common'
	export default {
		data() {
			return {
				formData: {
					orgName: ''
				},
				formData: {
					orgName: ''
				},
				screenHeight: this.$screenHeight,
				wheight: '',
			};
		},
		mounted() {
			uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
				this.wheight = data.height
			}).exec()
		},
		onLoad: function(option) {
			that = this
			var data = option.id;


			// 接收来自上个页面传递的参数
			const eventChannel = this.getOpenerEventChannel();
			eventChannel.on('acceptDataFromOpenerPage', function(val) {
				that.formData = val;
				console.log('val+++++++++++++++++++', that.formData);
			});
			this.formData.orgName = option.orgName
			console.log("option: ", that.formData);
		},

		methods: {
			// 下载附件
			down(attId) {
				console.log(attId, 'sdf');
				downSee(attId)
			},
			// 传递当前页面数据到 ‘修改信息’
			gotoEditDetection(val) {
				// console.log('val',val);
				uni.navigateTo({
					url: '/pagesA/fire/fpd_detection/edit_detection/edit_detection?id=' + val.id,
					events: {
						// 为指定事件添加一个监听器，获取被打开页面传送到当前页面的数据
						acceptDataFromOpenedPage: function(val) {
							this.formData = val;
						}
					},
					success: function(res) {
						// 通过eventChannel向被打开页面传送数据
						res.eventChannel.emit('acceptDataFromOpenedPage', val);
					}
				});
			}
		}
	};
</script>
<style lang="scss" scoped>
	page {
		background-color: #F5F7F9;
	}

	.container {
		position: relative;
		// height: 220vh;
		background-color: rgb(245, 247, 249);
		overflow: auto;

		.buju {
			margin: 40rpx;
		}
	}

	.cont {}

	.weiwan {
		color: #d51a52;
		background: rgba(213, 26, 82, 0.2);
		padding: 5rpx 20rpx;
		border-radius: 2px;
		border: 1px solid #d51a52;
	}

	.yiwan {
		color: #4cb2b6;
		background: rgba(76, 178, 182, 0.2);
		padding: 5rpx 20rpx;
		border-radius: 2px;
		border: 1px solid #4cb2b6;
	}

	.miaoshu {
		margin-right: 20rpx;
		color: #274647;
		font-weight: 600;
	}
</style>