<!-- 交易商管理-交易商管理-交易商销户审核-详情 -->
<template>
    <app-drawer :title="t('investor.manage.cancelapply.details.title')" width="900" v-model:show="show">
        <app-table-details :data="data" :label-width="120" :cell-props="detailProps" :column="2">
            <!-- 确认半身照 -->
            <template #imageurl="{ value }">
                <el-image :src="getFirstPathFullUrl(value)" fit="cover" lazy style="width: 128px; height: 72px" />
            </template>
        </app-table-details>
        <template #footer>
            <el-button @click="onCancel">{{ t('operation.close') }}</el-button>
        </template>
    </app-drawer>
</template>

<script lang="ts" setup>
import { shallowRef, PropType, computed } from 'vue'
import { ElMessage } from 'element-plus'
import { formatDate, getFirstPathFullUrl } from '@/filters'
import { useEnum } from '@/hooks/enum'
import { useRequest } from '@/hooks/request'
import { investorCancelview } from '@/services/api/investor'
import { CellProp } from '@pc/components/base/table-details/types'
import AppDrawer from '@pc/components/base/drawer/index.vue'
import AppTableDetails from '@pc/components/base/table-details/index.vue'
import { i18n } from '@/stores'

const props = defineProps({
    record: {
        type: Object as PropType<Investor.InvestorUserCancelApplyRsp>,
        required: true
    }
})

const { global: { t } } = i18n
const show = shallowRef(true)

// 处理状态
const handlestatusEnum = useEnum('handlestatus')

const { data } = useRequest(investorCancelview, {
    params: {
        autoid: props.record.autoid,
    },
    onError: (err) => {
        ElMessage.error(err)
    }
})

const detailProps = computed<CellProp[]>(() => [
    { prop: 'userid', label: 'investor.manage.cancelapply.details.userid', formatValue: (val) => val && `(${val})${data.value?.accountname}` },
    { prop: 'applytime', label: 'investor.manage.cancelapply.details.applytime', formatValue: (val) => formatDate(val) },
    { prop: 'handlestatus', label: 'investor.manage.cancelapply.details.handlestatus', formatValue: (val) => handlestatusEnum.getEnumTypeName(val) },
    { prop: 'auditusername', label: 'investor.manage.cancelapply.details.auditusername' },
    { prop: 'audittime', label: 'investor.manage.cancelapply.details.audittime', formatValue: (val) => formatDate(val) },
    { prop: 'auditremark', label: 'investor.manage.cancelapply.details.auditremark' },
    { prop: 'imageurl', label: 'investor.manage.cancelapply.details.imageurl' },
])

const onCancel = () => {
    show.value = false
}
</script>