Detail.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. import { DescriptionsSchema } from '@/types/descriptions'
  8. const { t } = useI18n()
  9. defineProps({
  10. currentRow: {
  11. type: Object as PropType<Nullable<TableData>>,
  12. default: () => null
  13. },
  14. detailSchema: {
  15. type: Array as PropType<DescriptionsSchema[]>,
  16. default: () => []
  17. }
  18. })
  19. </script>
  20. <template>
  21. <Descriptions :schema="detailSchema" :data="currentRow || {}">
  22. <template #importance="{ row }: { row: TableData }">
  23. <ElTag :type="row.importance === 1 ? 'success' : row.importance === 2 ? 'warning' : 'danger'">
  24. {{
  25. row.importance === 1
  26. ? t('tableDemo.important')
  27. : row.importance === 2
  28. ? t('tableDemo.good')
  29. : t('tableDemo.commonly')
  30. }}
  31. </ElTag>
  32. </template>
  33. <template #content="{ row }: { row: TableData }">
  34. <div v-html="row.content"></div>
  35. </template>
  36. </Descriptions>
  37. </template>