<template>
	<div class="hui-detail">
		<div class="hui-detail-title">基础信息</div>
		<div class="hui-detail-content">
			<div class="hui-detail-item">
				<div class="hui-detail-label">项目名称</div>
				<div class="hui-detail-value">{{detail.name}}</div>
			</div>
			<div class="hui-detail-item">
				<div class="hui-detail-label">类型</div>
				<div class="hui-detail-value">{{$field.findTypeName('projectType',detail.type)}}</div>
			</div>
			<div class="hui-detail-item">
				<div class="hui-detail-label">项目类型</div>
				<div class="hui-detail-value">{{$field.findTypeName('projectTypes',detail.projectType)}}</div>
			</div>
			<div class="hui-detail-item">
				<div class="hui-detail-label">竣工时间</div>
				<div class="hui-detail-value">{{detail.completionTime}}</div>
			</div>
			<div class="hui-detail-item">
				<div class="hui-detail-label">建筑面积</div>
				<div class="hui-detail-value">{{detail.buildingArea}}</div>
			</div>
			<div class="hui-detail-item">
				<div class="hui-detail-label">项目区域</div>
				<div class="hui-detail-value">{{detail.address.join('-')}}</div>
			</div>
			<div class="hui-detail-item">
				<div class="hui-detail-label">具体地点</div>
				<div class="hui-detail-value">{{detail.specificLocation}}</div>
			</div>
			<div class="hui-detail-item">
				<div class="hui-detail-label">项目介绍</div>
				<div class="hui-detail-value">{{detail.comment}}</div>
			</div>
		</div>
		<div class="hui-detail-title" v-if="detail.supportingFacilities">配套设施</div>
		<div class="hui-detail-content hui-detail-image" v-if="detail.supportingFacilities">
			<div class="hui-tag hui-tag-info"
				v-for="item in $field.findTypeNameByList('supportingFacilities',detail.supportingFacilities)"
				:key="item.id" style="margin-right: 10px;">
				{{item.name}}
			</div>
		</div>
		<div class="hui-detail-title" v-if="detail.coordinates">地图位置</div>
		<div class="hui-detail-content hui-detail-image" v-if="detail.coordinates">
			<select-location ref="map" type="look" :coordinates="detail.coordinates">
			</select-location>
		</div>
		<div class="hui-detail-title">项目标签</div>
		<div class="hui-detail-content hui-detail-image">
			<tag ref="tag" type="look" :tagType="1" :tagActive="detail.tagIds ? detail.tagIds.split(',') : []">
			</tag>
		</div>
		<div class="hui-detail-title">项目图片</div>
		<div class="hui-detail-content hui-detail-image">
			<upload ref="upload" :list="detail.picture ? JSON.parse(detail.picture) : []" type="preview">
			</upload>
		</div>
	</div>
</template>

<script>
	import {
		getProjectDetailById
	} from '@/httpApi/space'
	import upload from '@/components/common/upload'
	import tag from '@/components/common/tag'
	import selectLocation from '@/components/work/common/selectLocation'
	export default {
		props: ['detailId'],
		data() {
			return {
				detail: {
					name: '', //项目名称
					address: [],
					comment: '',
					data: '',
					organizationId: '',
					picture: '',
					tagIds: ''
				}
			}
		},
		created() {
			if (this.detailId) this.init();
		},
		components: {
			upload,
			tag,
			selectLocation
		},
		methods: {
			init() {
				getProjectDetailById(this.detailId).then(res => {
					if (res.state) {
						let obj = res.data;
						let data = {};
						if (obj.data) data = JSON.parse(obj.data);
						obj.address = JSON.parse(obj.address);
						this.detail = Object.assign(obj, data);
					}
				})
			}
		},
	}
</script>
<style lang="scss">

</style>