<template>
	<view style="padding-left: 24rpx;padding-right: 24rpx;padding-bottom: 16rpx;">
		<u-form :model="form" label-position="top" :label-style="labelStyle" ref="uForm" :rules="rules"
			:errorType="errorType">
			<u-form-item label="检查事项" v-if="form.item_">
				<view>
				<view>
					{{form.item_.cate_name}}
				</view>
				<view>{{form.item_.sortnum}}.{{form.item_.name}}</view>
				</view>
			</u-form-item>
			<u-form-item label="取证要求" v-if="form.item_">
				<span>{{form.item_.require}}</span>
			</u-form-item>
			<u-form-item label="检查结果" prop="result">
				<span v-if="form.result">{{form.result}}</span>
			</u-form-item>
			<u-form-item label="检查说明">
				<span v-if="form.note">{{form.note}}</span>
			</u-form-item>
			<u-form-item label="拍照取证">
				<u-image
				@click="imgListPreview(index)"
				width="260rpx" height="260rpx" :src="item" v-for="(item, index) in fileList" v-bind:key="index" style="margin: 2rpx;"></u-image>
			</u-form-item>
				
		</u-form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {

				},
				fileList: [],
				resultList: ['未发现', '发现', '不适用'],
				labelStyle: {
					"color": "gray",
				},
				errorType: ['message'],
				rules: {
					result: [{
						required: true,
						message: '请选择结果',
						// 可以单个或者同时写两个触发验证方式 
						trigger: ['change', 'blur'],
					}],
				}
			}
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		onLoad(options) {
			this.getRecord(options.id)
		},
		methods: {
			getHeader() {
				this.header = {
					Authorization: "Bearer " + this.vuex_token
				}
			},
			getRecord(id) {
				this.$u.api.getInspectRecord(id).then(res => {
					this.form = res.data
					let fileList = []
					for (var i = 0; i < res.data.imgs_.length; i++) {
						fileList.push(res.data.imgs_[i].file + '?token='+ this.vuex_token)
					}
					this.fileList = fileList
				})
			},
			 //预览图片
			            imgListPreview(index){
			                uni.previewImage({
			                    current: index,
			                    urls: this.fileList
			                })
			            }

		}
	}
</script>

<style>

</style>
