<!-- 详情弹窗 -->
<template>
    <ele-modal v-model="visible" title="提现详情" width="700">
        <el-descriptions :column="2" border :label-width="120">
            <el-descriptions-item label="ID" :span="2">{{
                detail.id
            }}</el-descriptions-item>
            <el-descriptions-item label="审核人">{{
                detail.auditName
            }}</el-descriptions-item>
            <el-descriptions-item label="审核时间">{{
                detail.auditTime
            }}</el-descriptions-item>
            <el-descriptions-item label="状态">
                {{
                    statusDicts.find((d) => d.dictValue == detail.status)
                        ?.dictLabel
                }}
            </el-descriptions-item>
        </el-descriptions>

        <template #footer>
            <el-button @click="visible = false">关闭</el-button>
        </template>
    </ele-modal>
</template>

<script setup>
    import { ref, reactive } from 'vue';
    import request from '@/utils/request';
    import { ElMessage } from 'element-plus';
    import { useDictData } from '@/utils/use-dict-data';

    const emit = defineEmits(['success']);
    const visible = defineModel({ type: Boolean });

    const [statusDicts] = useDictData(['withdrawal_status']);
    const detail = reactive({
        id: '',
        createTime: '',
        nickName: '',
        transferNo: '',
        withdrawType: '',
        withdrawMoney: '',
        status: '',
        auditId: '',
        auditName: '',
        auditTime: ''
    });

    // 打开弹窗
    const handleOpen = async (row) => {
        if (row) {
            visible.value = true;
            request
                .get(`/sys/finance/withdrawList/getDetail/${row.id}`)
                .then((res) => {
                    console.log(res, row, 'xxxx');
                    if (res.data.code === 200) {
                        Object.assign(detail, row, res.data.data);
                    } else {
                        ElMessage.error(res.data.msg || '获取详情失败');
                    }
                });
        }
    };

    defineExpose({
        handleOpen
    });
</script>
