<template>
	<view class="">
		<view class="card">
			<scroll-view  style="margin: 40rpx;">
				<u-form :label-style="labelStyle" label-width="150" :model="form" ref="uForm">
					<u-form-item label="小区名称"><u-input v-model="form.name" placeholder="暂无信息" disabled/></u-form-item>
					<u-form-item label="所属机构">
						<u-input  v-model="form.agencyName"  placeholder="暂无信息" disabled></u-input>
					</u-form-item>
					<u-form-item label="物业服务">
						<u-input  v-model="form.estatePidName"  placeholder="暂无信息" disabled></u-input>
					</u-form-item>
					<u-form-item label="楼栋总数">
						<u-input v-model="form.buildingNumber" placeholder="暂无信息" disabled ></u-input>
					</u-form-item>
					<u-form-item label="单元总数">
						<u-input v-model="form.totalUnitNumber"  placeholder="暂无信息" disabled></u-input>
					</u-form-item>
					<u-form-item label="楼层总数">
						<u-input v-model="form.floorNumber"  placeholder="暂无信息" disabled></u-input>
					</u-form-item>
					<u-form-item label="房间总数">
						<u-input v-model="form.totalRoomNumber"  placeholder="暂无信息" disabled></u-input>
					</u-form-item>
					<u-form-item label="详细地址">
						<u-input v-model="form.address"  placeholder="暂无信息" disabled></u-input>
					</u-form-item>
				</u-form>
			</scroll-view>
		</view>
		<view class="" style="height: 150rpx;"></view>
		<view class="footer-fixed">
			<u-grid :col="3">
				<u-grid-item @click="add">
					<u-icon name="plus-circle-fill" color='#19be6b' :size="50"></u-icon>
					<view class="grid-text">新增</view>
				</u-grid-item>
				<u-grid-item @click="edit">
					<u-icon name="edit-pen-fill" color="#2979ff" :size="50"></u-icon>
					<view class="grid-text">修改</view>
				</u-grid-item>
				<u-grid-item @click="deleteResidential">
					<u-icon name="trash-fill" color="#fa3534" :size="50"></u-icon>
					<view class="grid-text">删除</view>
				</u-grid-item>
			</u-grid>
		</view>
		<navigator url="../index/index" open-type="switchTab"  class="cuIcon cu-btn round" style="background-color: rgba(0,0,0,.2);color: #FFFFFF;position: fixed;right: 3%;bottom: 20%;width: 80rpx;height: 80rpx;">
			<text class="cuIcon-home" style="font-size: 40rpx;"></text>
		</navigator>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				labelStyle:{
					"fontWeight":"600"
				},
				form:{}
			}
		},
		onLoad(options) {
			// this.fetchDetail(options.id)
			console.log(options)
			this.form = JSON.parse(options.item)
		},
		methods: {
			//获取详情
			fetchDetail(id){
				this.$api.residential.page({id}).then(res=>{
					this.form=res.list[0]
				})
			},
			//新增
			add(){
				uni.navigateTo({
					url:"add"
				})
			},
			//修改
			edit(){
				uni.navigateTo({
					// url:"./add?id="+this.form.id
					url:"./add?item="+JSON.stringify(this.form)
				})
			},
			//删除
			deleteResidential(){
				let item =this.form
				this.$dialog.showModal('确定要删除此项吗?').then(res=>{
					this.$api.residential.del({id:this.form.id}).then(res=>{
						if (res.data) {
							this.$dialog.showModal('删除',false).then(res=>{
								uni.navigateBack({
									delta:1
								})
							})
						}
					})
				})
			}
			
		}
	}
</script>

<style lang="scss">
	.card{
		background-color: #FFFFFF;
		margin: 30rpx;
		border-radius: 20rpx;
	}
</style>
