
<template>
    <div class="detail-popup">
        <popup ref="popupRef" :async="true" width="80%" @confirm="handleSubmit" @close="handleClose">
            <el-form ref="formRef" :model="formData">
                <el-descriptions :column="3" title="基本信息" border>
                    <el-descriptions-item label="户主姓名" label-align="left">
                        {{ formData.name }}
                    </el-descriptions-item>
                    <el-descriptions-item label="联系方式" label-align="left">
                        {{ formData.contact }}
                    </el-descriptions-item>
                    <el-descriptions-item label="家庭人数" label-align="left">
                        {{ formData.family_count }}
                    </el-descriptions-item>
                    <el-descriptions-item label="家庭地址" label-align="left">
                        {{ formData.address }}
                    </el-descriptions-item>
                </el-descriptions>
                <el-descriptions :column="3" title="房子出租" border v-if="formData.house_rent_info.area">
                    <el-descriptions-item label="面积" label-align="left">
                        {{ formData.house_rent_info.area }}
                    </el-descriptions-item>
                    <el-descriptions-item label="出租年限" label-align="left">
                        {{ formData.house_rent_info.ageLimit }}
                    </el-descriptions-item>
                    <el-descriptions-item label="出租要求" label-align="left">
                        {{ formData.house_rent_info.request }}
                    </el-descriptions-item>
                    <el-descriptions-item label="主题结构是否完成" label-align="left">
                        {{ formData.house_rent_info.isFinish }}
                    </el-descriptions-item>
                    <el-descriptions-item label="是否允许装修" label-align="left">
                        {{ formData.house_rent_info.fitment }}
                    </el-descriptions-item>
                </el-descriptions>
                <el-descriptions :column="3" title="空闲土地出租" border v-if="formData.land_rent_info.isBreeding">
                    <el-descriptions-item label="面是否可以种养积" label-align="left">
                        {{ formData.land_rent_info.isBreeding}}
                    </el-descriptions-item>
                    <el-descriptions-item label="面积" label-align="left">
                        {{ formData.land_rent_info.area }}
                    </el-descriptions-item>
                    <el-descriptions-item label="种养要求" label-align="left">
                        {{ formData.land_rent_info.request}}
                    </el-descriptions-item>
                    <el-descriptions-item label="租金和支付方式" label-align="left">
                        {{ formData.land_rent_info.payInfo }}
                    </el-descriptions-item>
                    <el-descriptions-item label="土地优势" label-align="left">
                        {{ formData.land_rent_info.advantage }}
                    </el-descriptions-item>
                    <el-descriptions-item label="土地缺点" label-align="left">
                        {{ formData.land_rent_info.shortcoming }}
                    </el-descriptions-item>
                    <el-descriptions-item label="闲置原因" label-align="left">
                        {{ formData.land_rent_info.reson }}
                    </el-descriptions-item>
                    <el-descriptions-item label="使用年限" label-align="left">
                        {{formData.land_rent_info.ageLimit }}
                    </el-descriptions-item>
                </el-descriptions>
                <el-descriptions :column="3" title="农副产品出售" border v-if="formData.product_info.type">
                    <el-descriptions-item label="种养类型" label-align="left">
                        {{ formData.product_info.type }}
                    </el-descriptions-item>
                    <el-descriptions-item label="种养面积" label-align="left">
                        {{ formData.product_info.area}}
                    </el-descriptions-item>
                    <el-descriptions-item label="土地性质" label-align="left">
                        {{ formData.product_info.quality}}
                    </el-descriptions-item>
                    <el-descriptions-item label="种养方式" label-align="left">
                        {{ formData.product_info.manner}}
                    </el-descriptions-item>
                    <el-descriptions-item label="成熟周期" label-align="left">
                        {{ formData.product_info.maturationCycle}}
                    </el-descriptions-item>
                    <el-descriptions-item label="最近成熟时间" label-align="left">
                        {{ formData.product_info.maturationTime}}
                    </el-descriptions-item>
                    <el-descriptions-item label="年产量" label-align="left">
                        {{ formData.product_info.yield}}
                    </el-descriptions-item>
                    <el-descriptions-item label="自己消化/市场销售" label-align="left">
                        {{ formData.product_info.sellType}}
                    </el-descriptions-item>
                    <el-descriptions-item label="销售方式" label-align="left">
                        {{ formData.product_info.sellMethods}}
                    </el-descriptions-item>
                    <el-descriptions-item label="年销量" label-align="left">
                        {{ formData.product_info.Sales}}
                    </el-descriptions-item>
                    <el-descriptions-item label="优势" label-align="left">
                        {{ formData.product_info.productName}}
                    </el-descriptions-item>
                    <el-descriptions-item label="产品名称" label-align="left">
                        {{ formData.product_info.advantage}}
                    </el-descriptions-item>
                    <el-descriptions-item label="产品有无品牌" label-align="left">
                        {{ formData.product_info.isBrand}}
                    </el-descriptions-item>
                    <el-descriptions-item label="是否进行粗加工" label-align="left">
                        {{ formData.product_info.isBrand}}
                    </el-descriptions-item>
                    <el-descriptions-item label="产品诉求" label-align="left">
                        {{ formData.product_info.isDemands}}
                    </el-descriptions-item>
                    <el-descriptions-item label="急需解决的问题" label-align="left">
                        {{ formData.product_info.quesition}}
                    </el-descriptions-item>
                </el-descriptions>
                <el-descriptions :column="3" title="空闲资产出租/出售" border v-if="formData.idle_asset_rent_info.area">
                    <el-descriptions-item label="资产名称" label-align="left">
                        {{ formData.idle_asset_rent_info.area }}
                    </el-descriptions-item>
                    <el-descriptions-item label="资产优势" label-align="left">
                        {{ formData.idle_asset_rent_info.advantage}}
                    </el-descriptions-item>
                    <el-descriptions-item label="数量" label-align="left">
                        {{ formData.idle_asset_rent_info.num}}
                    </el-descriptions-item>
                    <el-descriptions-item label="增收方式" label-align="left">
                        {{ formData.idle_asset_rent_info.type}}
                    </el-descriptions-item>
                    <el-descriptions-item label="其他可变现" label-align="left">
                        {{ formData.idle_asset_rent_info.other}}
                    </el-descriptions-item>
                </el-descriptions>
                <el-descriptions :column="3" title="房屋装饰建设" border v-if="formData.house_decoration_construction.area">
                    <el-descriptions-item label="施工地点" label-align="left">
                        {{ formData.house_decoration_construction.area }}
                    </el-descriptions-item>
                    <el-descriptions-item label="开始时间" label-align="left">
                        {{ formData.house_decoration_construction.startTime }}
                    </el-descriptions-item>
                    <el-descriptions-item label="修/建标准" label-align="left">
                        {{ formData.house_decoration_construction.standard }}
                    </el-descriptions-item>
                    <el-descriptions-item label="事主要求" label-align="left">
                        {{ formData.house_decoration_construction.ask}}
                    </el-descriptions-item>
                    <el-descriptions-item label="房屋建设时长" label-align="left">
                        {{ formData.house_decoration_construction.time}}
                    </el-descriptions-item>
                    <el-descriptions-item label="设计服务" label-align="left">
                        {{ formData.house_decoration_construction.serve}}
                    </el-descriptions-item>
                </el-descriptions>
            </el-form>
        </popup>
    </div>
</template>

<script lang="ts" setup name="customdetail">

import type { FormInstance } from 'element-plus'

const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()



// 表单数据
const formData = reactive({

})




// 获取详情
const setFormData = async (data: Record<any, any>) => {
    Object.assign(formData, data)
    toParse( ['house_decoration_construction','house_rent_info','idle_asset_rent_info','land_rent_info','product_info'] )
    console.log(formData, "fromdar")
}




// 提交按钮
const handleSubmit = async () => {
    popupRef.value?.close()

}

//打开弹窗
const open = () => {
    popupRef.value?.open()
}

// 关闭回调
const handleClose = () => {
    emit('close')
}

//转json
const toParse=(key) => {
    for (let i = 0; i < key.length; i++) {
        formData[key[i]] = JSON.parse(formData[key[i]])
    }
}





defineExpose({
    open,
    setFormData,
})
</script>
<style lang="scss" scoped>
.tit {
    font-size: 1.2em;
    margin-bottom: 10px;
}
</style>
