
<template>
    <div class="detail-popup">
        <popup ref="popupRef" title="项目立项详情" :async="true" width="80%" @confirm="handleSubmit" @close="handleClose">
            <el-form ref="formRef" :model="formData" label-width="auto">
                <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
                    <el-tab-pane label="概况" name="demo-1">


                        <el-descriptions :column="3" title="基本信息" border>
                            <el-descriptions-item label="组织名称" label-align="left" align="left" label-class-name="my-label">{{ formData.org_name }}</el-descriptions-item>
                            <el-descriptions-item label="部门名称" label-align="left" align="left" label-class-name="my-label"> {{ formData.dept_name }}</el-descriptions-item>
                            <el-descriptions-item label="项目名称" label-align="left" align="left" label-class-name="my-label">{{ formData.project_name }}</el-descriptions-item>
                            <el-descriptions-item label="项目编码" label-align="left" align="left" label-class-name="my-label"> {{ formData.project_code }}</el-descriptions-item>
                            <el-descriptions-item label="客户名称" label-align="left" align="left" label-class-name="my-label"> {{ formData.custom_name }}</el-descriptions-item>
                            <el-descriptions-item label="项目状态" label-align="left" align="left" label-class-name="my-label">
                                {{ formData.contract_code }}
                            </el-descriptions-item>
                            <el-descriptions-item label="项目类型" label-align="left" align="left" label-class-name="my-label"> {{ formData.project_type_name }}</el-descriptions-item>
                            <el-descriptions-item label="立项日期" label-align="left" align="left" label-class-name="my-label"> {{ formData.create_time }}</el-descriptions-item>
                            <el-descriptions-item label="项目所在地" label-align="left" align="left" label-class-name="my-label"> {{ formData.project_address }}</el-descriptions-item>
                            <el-descriptions-item label="战略意义" label-align="left" align="left" label-class-name="my-label"> {{ formData.strategic_significance_text }}</el-descriptions-item>
                            <el-descriptions-item label="所属行业" label-align="left" align="left" label-class-name="my-label"> {{ formData.industry_text }}</el-descriptions-item>
                            <el-descriptions-item label="单位性质" label-align="left" align="left" label-class-name="my-label"> {{ formData.unit_nature_text }}</el-descriptions-item>
                            <el-descriptions-item label="招标方式" label-align="left" align="left" label-class-name="my-label"> {{ formData.bidding_method_text }}</el-descriptions-item>
                            <el-descriptions-item label="投标时间" label-align="left" align="left" label-class-name="my-label"> {{ formData.bidding_time }}</el-descriptions-item>
                            <el-descriptions-item label="预计工期" label-align="left" align="left" label-class-name="my-label"> {{ formData.estimated_construction }}</el-descriptions-item>
                            <el-descriptions-item label="项目估算(万元)" label-align="left" align="left" label-class-name="my-label"> {{ formData.project_estimation }}</el-descriptions-item>
                            <el-descriptions-item label="项目估算(外币)" label-align="left" align="left" label-class-name="my-label"> {{ formData.name }}</el-descriptions-item>
                            <el-descriptions-item label="联系人" label-align="left" align="left" label-class-name="my-label"> {{ formData.contacts }}</el-descriptions-item>
                            <el-descriptions-item label="联系人部门" label-align="left" align="left" label-class-name="my-label"> {{ formData.department }}</el-descriptions-item>
                            <el-descriptions-item label="联系人职位" label-align="left" align="left" label-class-name="my-label"> {{ formData.position }}</el-descriptions-item>
                            <el-descriptions-item label="关系度" label-align="left" align="left" label-class-name="my-label"> {{ formData.telephone }}</el-descriptions-item>
                            <el-descriptions-item label="发现时间" label-align="left" align="left" label-class-name="my-label"> {{ formData.discovery_time }}</el-descriptions-item>
                            <el-descriptions-item label="信息来源" label-align="left" align="left" label-class-name="my-label"> {{ formData.information_sources_text }}</el-descriptions-item>
                            <el-descriptions-item label="负责人" label-align="left" align="left" label-class-name="my-label"> {{ formData.person }}</el-descriptions-item>
                            <el-descriptions-item label="项目内容" label-align="left" align="left" label-class-name="my-label"> {{ formData.project_content }}</el-descriptions-item>
                            <el-descriptions-item label="竞争对手" label-align="left" align="left" label-class-name="my-label"> {{ formData.competitor }}</el-descriptions-item>
                            <el-descriptions-item label="项目建设资金来源" label-align="left" align="left" label-class-name="my-label"> {{ formData.construction_funds_sources_text }}</el-descriptions-item>
                            <el-descriptions-item label="建设单位付款方式" label-align="left" align="left" label-class-name="my-label"> {{ formData.construction_payment_method }}</el-descriptions-item>
                            <el-descriptions-item label="建设单位财务状况" label-align="left" align="left" label-class-name="my-label"> {{ formData.construction_financial_status_text }}</el-descriptions-item>
                            <el-descriptions-item label="建设单位对我方认可度" label-align="left" align="left" label-class-name="my-label"> {{ formData.construction_recognition_text }}</el-descriptions-item>
                            <el-descriptions-item label="我方对建设单位认可度" label-align="left" align="left" label-class-name="my-label"> {{ formData.my_construction_recognition_text }}</el-descriptions-item>
                            <!-- <el-descriptions-item label="项目开始日期" label-align="left" align="left" label-class-name="my-label"> {{ formData.notes }}</el-descriptions-item>
                            <el-descriptions-item label="项目交付日期" label-align="left" align="left" label-class-name="my-label"> {{ formData.notes }}</el-descriptions-item> -->





                            <el-descriptions-item label="附件" label-align="left" align="left" label-class-name="my-label">
                                <div v-if="formData.annex && formData.annex.length > 0">
                                    <div v-for="(item, index) in formData.annex" style="margin-left: 5px;display: block;">
                                        <el-link style="margin-left: 10px; color: #4a5dff; align-self: flex-start" :href="item" target="_blank">文件{{ index + 1 }}查看</el-link>

                                    </div>
                                </div>
                                <div v-else>
                                    暂无文件
                                </div>
                            </el-descriptions-item>


                        </el-descriptions>

                    </el-tab-pane>
                    <el-tab-pane label="成员" name="demo-2">Config</el-tab-pane>
                    <el-tab-pane label="商机" name="demo-2">Config</el-tab-pane>
                    <el-tab-pane label="投标" name="demo-3">Role</el-tab-pane>
                    <el-tab-pane label="合同" name="demo-4">Task</el-tab-pane>
                    <el-tab-pane label="预算" name="demo-5">User</el-tab-pane>
                    <el-tab-pane label="计划" name="demo-6">Config</el-tab-pane>
                    <el-tab-pane label="材料" name="demo-7">Role</el-tab-pane>
                    <el-tab-pane label="采购" name="demo-8">Task</el-tab-pane>
                    <el-tab-pane label="分包" name="demo-9">Config</el-tab-pane>
                    <el-tab-pane label="进度" name="demo-10">Role</el-tab-pane>
                    <el-tab-pane label="任务" name="demo-11">Task</el-tab-pane>
                    <el-tab-pane label="人力" name="demo-12">Task</el-tab-pane>
                    <el-tab-pane label="机具" name="demo-13">Task</el-tab-pane>
                    <el-tab-pane label="收款" name="demo-14">Task</el-tab-pane>
                    <el-tab-pane label="付款" name="demo-15">Task</el-tab-pane>
                    <el-tab-pane label="费用" name="demo-16">Task</el-tab-pane>
                    <el-tab-pane label="文档" name="demo-17">Task</el-tab-pane>
                    <el-tab-pane label="结算" name="demo-17">Task</el-tab-pane>
                    <el-tab-pane label="售后" name="demo-17">Task</el-tab-pane>
                    <el-tab-pane label="统计" name="demo-18">Task</el-tab-pane>
                </el-tabs>
            </el-form>
        </popup>
    </div>
</template>

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

import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiCustomDetail } from '@/api/custom'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
import type { TabsPaneContext } from 'element-plus'

const activeName = ref('demo-1')

const handleClick = (tab: TabsPaneContext, event: Event) => {
    console.log(tab, event)
}
defineProps({
    dictData: {
        type: Object as PropType<Record<string, any[]>>,
        default: () => ({})
    }
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const formDataannex = reactive([])
const datas = reactive({
    provinceOptions: [],
    cityOptions: [],
    areaOptions: [],
});


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

})




// 获取详情
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]

    //     }

    // }
    Object.assign(formData, data)

    if (data.annex && data.annex.length > 0) {
        const arry1 = data.annex.map((item: any, index: any) => {
            return {
                name: `文件${index + 1}`,
                uri: item
            };
        });
        Object.assign(formDataannex, arry1)
    }


}

const getDetail = async (row: Record<string, any>) => {
    const data = await apiCustomDetail({
        id: formData.id
    })
    setFormData(data)
}


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

}

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

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








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

:deep(.my-label) {
    width: 150px;
}
</style>
