notificationColumns.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import type { CustomRenderProps } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
  2. import type { Column } from '@/components/StdDesign/types'
  3. import { detailRender } from '@/components/Notification/detailRender'
  4. import { datetime } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
  5. import { NotificationTypeT } from '@/constants'
  6. import { Tag } from 'ant-design-vue'
  7. const columns: Column[] = [{
  8. title: () => $gettext('Type'),
  9. dataIndex: 'type',
  10. customRender: (args: CustomRenderProps) => {
  11. if (args.text === NotificationTypeT.Error) {
  12. return (
  13. <Tag color="error">
  14. { $gettext('Error') }
  15. </Tag>
  16. )
  17. }
  18. else if (args.text === NotificationTypeT.Warning) {
  19. return (
  20. <Tag color="warning">
  21. { $gettext('Warning') }
  22. </Tag>
  23. )
  24. }
  25. else if (args.text === NotificationTypeT.Info) {
  26. return (
  27. <Tag color="info">
  28. { $gettext('Info')}
  29. </Tag>
  30. )
  31. }
  32. else if (args.text === NotificationTypeT.Success) {
  33. return (
  34. <Tag color="success">
  35. { $gettext('Success') }
  36. </Tag>
  37. )
  38. }
  39. },
  40. sorter: true,
  41. pithy: true,
  42. }, {
  43. title: () => $gettext('Title'),
  44. dataIndex: 'title',
  45. customRender: (args: CustomRenderProps) => {
  46. return h('span', $gettext(args.text))
  47. },
  48. pithy: true,
  49. }, {
  50. title: () => $gettext('Details'),
  51. dataIndex: 'details',
  52. customRender: detailRender,
  53. pithy: true,
  54. }, {
  55. title: () => $gettext('Created at'),
  56. dataIndex: 'created_at',
  57. sorter: true,
  58. customRender: datetime,
  59. pithy: true,
  60. }, {
  61. title: () => $gettext('Action'),
  62. dataIndex: 'action',
  63. }]
  64. export default columns