<!-- 通知公告-资讯来源-详情 -->
<template>
    <app-drawer :title="t('investor.manage.cancelapply.details.title')" width="480" v-model:show="show">
        <app-table-details :data="data" :label-width="120" :cell-props="detailProps" :column="1">
            <!-- 来源LOGO -->
            <template #imageurl="{ value }">
                <el-image style="width: 200px; height: 100px" :src="getFirstPathFullUrl(value)" fit="contain" />
            </template>
        </app-table-details>
        <template #footer>
            <el-button @click="close">{{ 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 { useRequest } from '@/hooks/request'
import { columnsourceDetail } from '@/services/api/notice'
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<Notice.ColumnSourceQueryRsp>,
        required: true
    }
})

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

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

const detailProps = computed<CellProp[]>(() => [
    { prop: 'membername', label: 'notice.newssource.details.membername' },
    { prop: 'membertags', label: 'notice.newssource.details.membertags' },
    { prop: 'imageurl', label: 'notice.newssource.details.imageurl' },
    { prop: 'updatetime', label: 'notice.newssource.details.updatetime', formatValue: (val) => formatDate(val) }
])

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