<template>
    <div class="detail-popup">
        <popup ref="popupRef" title="投标决策详情" :async="true" width="80%" @confirm="handleSubmit" @close="handleClose">
            <el-card>
                <el-descriptions :column="3" border>
                    <el-descriptions-item label="流程编号" label-align="left" align="left" label-class-name="my-label">{{
                        formData.code }}</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.project_estimation }}</el-descriptions-item>

                    <el-descriptions-item label="招标项目资金来源" label-align="left" align="left" label-class-name="my-label">{{
                        formData.bidding_project_fund_source_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.bid_type_text }}</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.is_margin_text }}</el-descriptions-item>
                    <el-descriptions-item label="保证金金额(元)" label-align="left" align="left" label-class-name="my-label">{{
                        formData.margin_amount }}</el-descriptions-item>

                    <el-descriptions-item label="开标日期" label-align="left" align="left" label-class-name="my-label">{{
                        formData.bid_opening_date }}</el-descriptions-item>
                    <el-descriptions-item label="保证金退还时间" label-align="left" align="left" label-class-name="my-label">{{
                        formData.margin_amount_return_date }}</el-descriptions-item>

                    <el-descriptions-item label="有无内部资源" label-align="left" align="left" label-class-name="my-label">{{
                        formData.is_internal_resources_text }}</el-descriptions-item>

                    <el-descriptions-item label="项目把握度" label-align="left" align="left" label-class-name="my-label">{{
                        formData.project_assurance_text }}</el-descriptions-item>
                    <el-descriptions-item label="招标项目概况" label-align="left" align="left" label-class-name="my-label">{{
                        formData.bid_project_overview }}</el-descriptions-item>

                    <el-descriptions-item label="项目简介" label-align="left" align="left" label-class-name="my-label">{{
                        formData.project_desc }}</el-descriptions-item>

                    <el-descriptions-item label="附件" label-align="left" align="left" label-class-name="my-label">
                        <annexLink :annex="formData.annex"></annexLink>
                    </el-descriptions-item>
                </el-descriptions>
            </el-card>

            <flowProcess v-if="!formData?.approve_id || formData.approve_check_status == 4" :flows="flows"
                :submitApi="apibid_bidding_decisionApprove" :id="formData?.id" @off="handleClose"></flowProcess>
            <flowDetail v-else :approve_id="formData?.approve_id" @off="handleClose" />
            <!-- import { apibid_bidding_decisionApprove, apibid_bidding_decisionFlows } from '@/api/flowSet.ts'
            // 获取审批流程
            const flows = ref([])
            const getbidDocumentExaminationFlows = async () => {
            if (formData?.approve_id) return
            let res = await apibid_bidding_decisionFlows()
            flows.value = res
            } -->
        </popup>
    </div>
</template>

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

import Popup from '@/components/popup/index.vue'
import { apibid_bidding_decisionApprove, apibid_bidding_decisionFlows } from '@/api/flowSet.ts'
import type { PropType } from 'vue'
defineProps({
    dictData: {
        type: Object as PropType<Record<string, any[]>>,
        default: () => ({})
    }
})
const emit = defineEmits(['success', 'close'])

const popupRef = shallowRef<InstanceType<typeof Popup>>()
const formDataannex = reactive([])



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

// 获取详情
const setFormData = async (data: Record<any, any>) => {
    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)
    }
    Object.assign(formData, data)
    getbidDocumentExaminationFlows()
}


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

}

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

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



// 获取审批流程
const flows = ref([])
const getbidDocumentExaminationFlows = async () => {
    if (formData?.approve_id) return
    let res = await apibid_bidding_decisionFlows()
    flows.value = res
}

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

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