Detail.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <script setup lang="ts">
  2. import { PropType } from 'vue'
  3. import type { TableData } from '@/api/table/types'
  4. import { Descriptions } 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. detailSchema: {
  14. type: Array as PropType<DescriptionsSchema[]>,
  15. default: () => []
  16. }
  17. })
  18. </script>
  19. <template>
  20. <Descriptions :schema="detailSchema" :data="currentRow || {}">
  21. <template #importance="{ row }: { row: TableData }">
  22. <ElTag :type="row.importance === 1 ? 'success' : row.importance === 2 ? 'warning' : 'danger'">
  23. {{
  24. row.importance === 1
  25. ? t('tableDemo.important')
  26. : row.importance === 2
  27. ? t('tableDemo.good')
  28. : t('tableDemo.commonly')
  29. }}
  30. </ElTag>
  31. </template>
  32. <template #content="{ row }: { row: TableData }">
  33. <div v-html="row.content"></div>
  34. </template>
  35. </Descriptions>
  36. </template>