<template>
	<view class="page">
		<view class="form">
			<view class="itembox">
				<view class="item">
					<view class="left">
						单位名称
					</view>
					<view class="right">
						{{list.companyName||""}}
					</view>
				</view>
				<view class="item">
					<view class="left">
						单位管理人
					</view>
					<view class="right">
						{{list.directorName||""}}
					</view>
				</view>
				<view class="item">
					<view class="left">
						联系方式
					</view>
					<view class="right">
						{{list.directorPhone||""}}
					</view>
				</view>
				<view class="item">
					<view class="left">
						单位地址
					</view>
					<view class="right">
						{{list.address||""}}
					</view>
				</view>
				<view class="item">
					<view class="left">
						建筑结构
					</view>
					<view class="right">
						{{datas.basicInfo.structure}}
					</view>
				</view>
				<view class="item">
					<view class="left">
						建筑高度
					</view>
					<view class="right">
						{{datas.basicInfo.height}}
					</view>
				</view>
				<view class="item">
					<view class="left">
						建筑层数
					</view>
					<view class="right">
						{{datas.basicInfo.layer}}
					</view>
				</view>
			</view>
			<view class="itembox">
				<view class="item">
					<view class="left">
						控制室位置
					</view>
					<view class="right_inp">
						<input type="text" placeholder="输入多个请用“，”隔开" v-model="datas.facilities.controlPosition">
					</view>
				</view>
				<view class="item">
					<view class="left">
						安全重点部位
					</view>
					<view class="right_inp">
						<input type="text" placeholder="输入安全重点部位" v-model="datas.KeyParts[0].useNature">
					</view>
				</view>
				<view class="item">
					<view class="left">
						单位性质
					</view>
					<view class="right_inp">
						<picker :range="danwei"  @change="danweif($event)">
							<view>{{datas.basicInfo.nature||"请选择"}}</view>
						</picker>
					</view>
				</view>
				<view class="item">
					<view class="left">
						消防设施及器材
					</view>
					<view class="right_inp">
						<input type="text" placeholder="(个)" v-model="datas.facilities.fireFightingFacilities">
					</view>
				</view>
				<!-- <view class="item">
					<view class="left">
						单位主要消防设施
					</view>
					<view class="right_inp">
						<input type="text" placeholder="输入多个请用“，”隔开">
					</view>
				</view> -->
			</view>
		</view>
		<view class="button">
			<button>确定</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:"",
				list:{},
				danwei:["一般单位",'重点单位'],
				datas: {
				    basicInfo: {
				      name: "",
				      addr: "",
				      phone: "",
				      total: "",
				      height: "",
				      layer: "",
				      structure: "",
				      coveredArea: "",
				      builtUpArea: "",
				      nature: "",
				      east: "",
				      south: "",
				      west: "",
				      north: "",
				      routeAndTime: "",
				      positionCoordinates: { x: 0, y: 0 }
				    },
				    facilities: {
				      controlPosition: "",
				      poolNumbe: "",
				      poolPosition: "",
				      poolCapacity: "",
				      supplyMode: "",
				      waterSources: "",
				      waterSourcesPosition: "",
				      system: {
				        alarm: false,
				        spray: false,
				        broadcast: false,
				        smoke: false,
				      },
				      hydrantsNumber: "",
				      hydrantsPosition: "",
				      pumpNumber: "",
				      pumpRange: "",
				      pumpFlow: "",
				      pumpAdapter: "",
				      SprayPumpNumber: "",
				      SprayPumpRange: "",
				      SprayPumpFlow: "",
				      SprayPumpAdapter: "",
				      elevator: "",
				      stairs: "",
				      Export: "",
				      indoorHydrant: "",
				      standardIndoorHydrant: "",
					  fireFightingFacilities:""
				    },
				    KeyParts: [
				      {
				        keyparts: "",
				        keypartsposition: "",
				        buildingstructure: "",
				        useNature: "",
				        danger: ""
				      },
				      {
				        keyparts: "",
				        keypartsposition: "",
				        buildingstructure: "",
				        useNature: "",
				        danger: ""
				      }
				    ],
					datasIndex:0,
				    tips: ""
				  }
			}
		},
		onLoad(e) {
			this.id=e.id
			this.getCompanies()
		},
		onReady() {


		},
		methods: {
			getCompanies(){
				this.$request.get("/api/Companies/"+this.id,{},(data,res)=>{
					console.log(res);
					this.list=res
					if(this.list.data){
						this.datas=JSON.parse(this.list.data)
						if(this.datas.basicInfo.nature=="重点单位"){
							this.datasIndex=1
						}
					}
				})
			},
			danweif(e){
				console.log(e);
				this.datas.basicInfo.nature=this.danwei[e.detail.value]
			}
		}

	}
</script>

<style lang="scss">
	
	.button{
		margin-top: 40rpx;
		button {
			width: 200rpx;
			// height: 140rpx;
			// background: linear-gradient(180deg, #317AFF 0%, #0052E6 100%);
			color: #fff;
			background: #317AFF;
			border-radius: 20rpx;
		}
	}
	.form{
		
		.itembox{
			margin-top: 20rpx;
			background: #fff;
			.item{
				display: flex;
				height: 100rpx;
				border-top: 2rpx solid #E4E7EC;
				box-sizing: border-box;
				margin: 0 20rpx;
				font-size: 32rpx;
				.left{
					color: #8D8C8F;
					line-height: 100rpx;
				}
				.right{
					flex: 1;
					color: #100F19;
					text-align: right;
					line-height: 100rpx;
					
				}
				.right_inp{
					flex: 1;
					color: #100F19;
					text-align: right;
					margin-top: 26rpx;
				}
				
			}
			.item:nth-child(1){
				display: flex;
				height: 100rpx;
				
				box-sizing: border-box;
				margin: 0 20rpx;
				font-size: 32rpx;
			}
		}
		
		
	}
</style>
