<template>
    <div class="edit-popup">
        <popup ref="popupRef" :async="true" width="80vw" @close="handleClose">
            <el-form ref="formRef" :model="formData" label-width="100px">
                <el-descriptions :column="3" title="项目咨询--新开工项目管理" border>
                    <el-descriptions-item label="项目名称" label-align="left" align="left">
                        {{ formData.project_name }}
                    </el-descriptions-item>
                    <el-descriptions-item label="工程地点" label-align="left" align="left">
                        {{ formData.address }}
                    </el-descriptions-item>
                    <el-descriptions-item label="服务范围" label-align="left" align="left">
                        {{ formData.service_scope }}
                    </el-descriptions-item>
                    <el-descriptions-item label="建筑面积" label-align="left" align="left">
                        {{ formData.area }}
                    </el-descriptions-item>
                    <el-descriptions-item label="投资(万元)" label-align="left" align="left">
                        {{ formData.invest }}
                    </el-descriptions-item>
                    <el-descriptions-item label="基础类型" label-align="left" align="left">
                        {{ formData.basic_type }}
                    </el-descriptions-item>
                    <el-descriptions-item label="工期" label-align="left" align="left">
                        {{ formData.duration }}
                    </el-descriptions-item>
                    <el-descriptions-item label="结构类型" label-align="left" align="left">
                        {{ formData.structure_type }}
                    </el-descriptions-item>
                    <el-descriptions-item label="地上层数" label-align="left" align="left">
                        {{ formData.land_floors }}
                    </el-descriptions-item>
                    <el-descriptions-item label="地下层数" label-align="left" align="left">
                        {{ formData.underground_floors }}
                    </el-descriptions-item>
                    <el-descriptions-item label="业主单位" label-align="left" align="left">
                        {{ formData.owner_unit }}
                    </el-descriptions-item>
                    <el-descriptions-item label="业主单位联系人及电话" label-align="left" align="left">
                        {{ formData.owner_unit_contact }}
                    </el-descriptions-item>
                    <el-descriptions-item label="设计单位" label-align="left" align="left">
                        {{ formData.design_unit }}
                    </el-descriptions-item>
                    <el-descriptions-item label="设计单位联系人及电话" label-align="left" align="left">
                        {{ formData.design_unit_contact }}
                    </el-descriptions-item>
                    <el-descriptions-item label="勘察单位" label-align="left" align="left">
                        {{ formData.survey_unit }}
                    </el-descriptions-item>
                    <el-descriptions-item label="勘察单位" label-align="left" align="left">
                        {{ formData.survey_unit }}
                    </el-descriptions-item>

                    <el-descriptions-item label="勘察单位联系人及电话" label-align="left" align="left">
                        {{ formData.survey_unit_contact }}
                    </el-descriptions-item>

                    <el-descriptions-item label="施工单位" label-align="left" align="left">
                        {{ formData.build_unit }}
                    </el-descriptions-item>
                    <el-descriptions-item label="施工单位联系人及电话" label-align="left" align="left">
                        {{ formData.build_unit_contact }}
                    </el-descriptions-item>
                    <el-descriptions-item label="项目经理" label-align="left" align="left">
                        {{ formData.project_manager }}
                    </el-descriptions-item> <el-descriptions-item label="勘察单位" label-align="left" align="left">
                        {{ formData.survey_unit }}
                    </el-descriptions-item>
                    <el-descriptions-item label="项目副经理" label-align="left" align="left">
                        {{ formData.deputy_project_manager }}
                    </el-descriptions-item>
                    <el-descriptions-item label="专业工程师" label-align="left" align="left">
                        {{ formData.engineer }}
                    </el-descriptions-item> <el-descriptions-item label="其他事项情况说明" label-align="left" align="left">
                        {{ formData.content }}
                    </el-descriptions-item>
                    <el-descriptions-item label="填表人" label-align="left" align="left">
                        {{ formData.create_user }}
                    </el-descriptions-item>
                    <el-descriptions-item label="填表时间" label-align="left" align="left">
                        {{ formData.create_time }}
                    </el-descriptions-item>
                </el-descriptions>
            </el-form>
            <el-card class="mt-5" v-if="formData.evolve.length">
                <template #header>
                    项目组工作开展情况
                </template>
                <el-table :data="formData.evolve">
                    <el-table-column label="名称" prop="name" show-overflow-tooltip />
                    <el-table-column label="进展状态" prop="progress_status" show-overflow-tooltip />
                    <el-table-column label="项目组跟踪责任人" prop="resp_user" show-overflow-tooltip />
                </el-table>
            </el-card>
            <el-card v-if="formData.preparation.length">
                <template #header>
                    项目组后勤准备工作
                </template>
                <el-table :data="formData.preparation">
                    <el-table-column label="名称" prop="name" show-overflow-tooltip />
                    <el-table-column label="进展状态" prop="progress_status" show-overflow-tooltip />
                    <el-table-column label="项目组跟踪责任人" prop="resp_user" show-overflow-tooltip />
                </el-table>
            </el-card>
        </popup>
    </div>
</template>

<script lang="ts" setup name="supervisionInspectionEdit">
import Popup from '@/components/popup/index.vue'
import { apiconsult_project_evolve, apiconsult_project_preparation, } from '@/api/consult_new_start_project'



const emit = defineEmits(['success', 'close'])
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')

// 表单数据
const formData = reactive({
    id: '',
    project_id: '',
    project_name: '',
    address: '',
    service_scope: '',
    area: '',
    invest: '',
    basic_type: '',
    duration: '',
    structure_type: '',
    land_floors: '',
    underground_floors: '',
    owner_unit: '',
    owner_unit_contact: '',
    design_unit: '',
    design_unit_contact: '',
    survey_unit: '',
    survey_unit_contact: '',
    build_unit: '',
    build_unit_contact: '',
    project_manager: '',
    deputy_project_manager: '',
    engineer: '',
    content: '',
    create_user: '',
    create_time: '',
    "evolve": [


    ],
    "preparation": [


    ]
})


// 获取详情
const setFormData = async (data: Record<any, any>) => {
    for (const key in formData) {
        if (data[key] != null && data[key] != undefined) {
            //@ts-ignore
            formData[key] = data[key]
        }
    }
    let res1 = await apiconsult_project_evolve({ new_start_project_id: formData.id })
    formData.evolve = res1.lists
    let res2 = await apiconsult_project_preparation({ new_start_project_id: formData.id })
    formData.preparation = res2.lists
}


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

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



defineExpose({
    open,
    setFormData,
})
</script>
