
<template>
    <div class="detail-popup">
        <popup ref="popupRef" :async="true" width="80%" @close="handleClose">
            <el-card>
                <el-descriptions :column="3" title="成本调整详情" border>
                    <el-descriptions-item :label="item.lable" label-align="left" align="left" label-class-name="my-label"
                        v-for="(item, index) in descriptionList" :key="index">
                        <span v-if="item.lable != '附件'"> {{ item.value.length > 1 ? formData[item.value[0]][item.value[1]] :
                            formData[item.value[0]]
                        }}</span>
                    </el-descriptions-item>
                </el-descriptions>
                <el-descriptions :column="1" border>
                    <el-descriptions-item 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="apiproject_cost_adjustmentApprove" :id="formData?.id" @off="handleClose">
            </flowProcess>
            <flowDetail v-else :approve_id="formData?.approve_id" @off="handleClose" />
        </popup>
    </div>
</template>

<script lang="ts" setup name="customdetail">
import { ref, reactive } from "vue"
import { apiproject_cost_adjustmentApprove, apiproject_cost_adjustmentFlows } from '@/api/flowSet'
const descriptionList = reactive([
    {
        lable: "项目名称",
        value: ['project_name']
    },
    {
        lable: "项目编码",
        value: ['project_code']
    },
    {
        lable: "调整日期",
        value: ['adjust_date']
    },
    {
        lable: "调整金额",
        value: ['adjust_amount']
    },
    {
        lable: "备注",
        value: ['remark']
    },
])

const emit = defineEmits(['success', 'close'])
const popupRef = ref(null)


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

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

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

// 关闭回调
const handleClose = () => {
    emit('close')
}
// 获取审批流程
const flows = ref([])
const getbidDocumentExaminationFlows = async () => {
    if (formData?.approve_id) return
    let res = await apiproject_cost_adjustmentFlows()
    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>
