Detail.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <script setup lang="tsx">
  2. import { PropType, reactive } from 'vue'
  3. import type { TableData } from '@/api/table/types'
  4. import { Descriptions, DescriptionsSchema } from '@/components/Descriptions'
  5. import { useI18n } from '@/hooks/web/useI18n'
  6. import { ElTag } from 'element-plus'
  7. const { t } = useI18n()
  8. defineProps({
  9. currentRow: {
  10. type: Object as PropType<Nullable<TableData>>,
  11. default: () => null
  12. }
  13. })
  14. const schema = reactive<DescriptionsSchema[]>([
  15. {
  16. field: 'title',
  17. label: '新闻标题',
  18. span: 24
  19. },
  20. {
  21. field: 'author',
  22. label: t('exampleDemo.author')
  23. },
  24. {
  25. field: 'display_time',
  26. label: t('exampleDemo.displayTime')
  27. },
  28. {
  29. field: 'importance',
  30. label: t('exampleDemo.importance'),
  31. slots: {
  32. default: (data: any) => {
  33. return (
  34. <ElTag
  35. type={data.importance === 1 ? 'success' : data.importance === 2 ? 'warning' : 'danger'}
  36. >
  37. {data.importance === 1
  38. ? t('tableDemo.important')
  39. : data.importance === 2
  40. ? t('tableDemo.good')
  41. : t('tableDemo.commonly')}
  42. </ElTag>
  43. )
  44. }
  45. }
  46. },
  47. {
  48. field: 'pageviews',
  49. label: t('exampleDemo.pageviews')
  50. },
  51. {
  52. field: 'content',
  53. label: t('exampleDemo.content'),
  54. span: 24,
  55. slots: {
  56. default: (data: any) => {
  57. return <div innerHTML={data.content}></div>
  58. }
  59. }
  60. }
  61. ])
  62. </script>
  63. <template>
  64. <Descriptions :schema="schema" :data="currentRow || {}" />
  65. </template>