
<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">
                        {{ item.value.length > 1 ? formData[item.value[0]][item.value[1]] : formData[item.value[0]] }}
                    </el-descriptions-item>
                </el-descriptions>
            </el-card>
            <flowProcess v-if="!formData?.approve_id || formData.approve_check_status == 4" :flows="flows"
                :submitApi="apiproject_expense_reimbursementApprove" :id="formData?.id" @off="handleClose">
            </flowProcess>
            <flowDetail v-else :approve_id="formData?.approve_id" @off="handleClose" />
            <!-- import { apiproject_expense_reimbursementApprove, apiproject_expense_reimbursementFlows } from '@/api/flowSet'
            // 获取审批流程
            const flows = ref([])
            const getbidDocumentExaminationFlows = async () => {
            if (formData?.approve_id) return
            let res = await apiproject_expense_reimbursementFlows()
            flows.value = res
            } -->
        </popup>
    </div>
</template>

<script lang="ts" setup name="customdetail">
import { ref, reactive } from "vue"
import { apiproject_expense_reimbursementApprove, apiproject_expense_reimbursementFlows } from '@/api/flowSet'
const descriptionList = reactive([
    {
        lable: "项目名称",
        value: ['project_name']
    },
    {
        lable: "项目编码",
        value: ['project_code']
    },
    {
        lable: "借款单号",
        value: ['loan_apply_code']
    },
    {
        lable: "冲抵借款金额",
        value: ['offset_loan_amount']
    },
    {
        lable: "报销人",
        value: ['apply_user']
    },
    {
        lable: "报销类型",
        value: ['reimbursement_type_text']
    },
    {
        lable: "报销日期",
        value: ['apply_date']
    },
    {
        lable: "收款人姓名",
        value: ['payee_name']
    },
    {
        lable: "收款银行",
        value: ['payee_bank']
    },
    {
        lable: "收款账号",
        value: ['payee_account']
    },
    {
        lable: "账户编码",
        value: ['bank_account', 'account_sn']
    },
    {
        lable: "开户银行",
        value: ['bank_account', 'deposit_bank']
    },
    {
        lable: "开户名称",
        value: ['bank_account', 'account_name']
    },
    {
        lable: "开户账号",
        value: ['bank_account', 'account']
    },
    {
        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_expense_reimbursementFlows()
    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>
