<!-- 通知公告-资讯栏目-详情 -->
<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" />
        <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 } from '@/filters'
import { useEnum } from '@/hooks/enum'
import { useRequest } from '@/hooks/request'
import { columnDetail } 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.ColumnQueryRsp>,
        required: true
    }
})

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

const flagEnum = useEnum('flag')
const columntypeEnum = useEnum('columntype') // 栏目类型

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

const detailProps = computed<CellProp[]>(() => [
    { prop: 'columntype', label: 'notice.newscolumn.details.columntype', formatValue: (val) => columntypeEnum.getEnumTypeName(val) },
    { prop: 'columnname', label: 'notice.newscolumn.details.columnname' },
    { prop: 'isshow', label: 'notice.newscolumn.details.isshow', formatValue: (val) => flagEnum.getEnumTypeName(val) },
    { prop: 'creatoruser', label: 'notice.newscolumn.details.creatoruser' },
    { prop: 'creaedate', label: 'notice.newscolumn.details.creaedate', formatValue: (val) => formatDate(val) },
    { prop: 'modifieruser', label: 'notice.newscolumn.details.modifieruser' },
    { prop: 'updatedate', label: 'notice.newscolumn.details.updatedate', formatValue: (val) => formatDate(val) }
])

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