index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :export-data-options="exportDataOptions"
  6. :extraExportParams="ExtraListParams"
  7. default-search-key="topic" />
  8. </template>
  9. <script>
  10. import {
  11. getCopyWithContentTableColumn,
  12. getTimeTableColumn,
  13. getStatusTableColumn,
  14. } from '@/utils/common/tableColumn'
  15. import WindowsMixin from '@/mixins/windows'
  16. export default {
  17. name: 'NotificationBaseList',
  18. mixins: [WindowsMixin],
  19. props: {
  20. id: String,
  21. ExtraListParams: {
  22. type: Object,
  23. },
  24. ExtraColumns: {
  25. type: Array,
  26. required: false,
  27. default: () => ([]),
  28. },
  29. ExtraFilterOptions: {
  30. type: Object,
  31. required: false,
  32. default: () => ({}),
  33. },
  34. ExtraExportDataOptions: {
  35. type: Array,
  36. required: false,
  37. default: () => ([]),
  38. },
  39. },
  40. data () {
  41. return {
  42. list: this.$list.createList(this, {
  43. id: this.id,
  44. resource: 'notifications',
  45. apiVersion: 'v1',
  46. getParams: this.getParam,
  47. filterOptions: {
  48. // start_time.between('2020-11-04T16:00:00Z', '2020-11-06T15:59:59Z')
  49. topic: {
  50. label: this.$t('system.text_307'),
  51. filter: true,
  52. formatter: val => {
  53. return `topic.contains("${val}")`
  54. },
  55. },
  56. priority: {
  57. label: this.$t('system.text_315'),
  58. dropdown: true,
  59. filter: true,
  60. items: Object.keys(this.$t('notificationPriority')).map(key => {
  61. return {
  62. label: this.$t(`notificationPriority.${key}`),
  63. key,
  64. }
  65. }),
  66. formatter: val => {
  67. return `priority.contains("${val}")`
  68. },
  69. },
  70. ...this.ExtraFilterOptions,
  71. },
  72. }),
  73. exportDataOptions: {
  74. items: [
  75. { label: this.$t('system.text_307'), key: 'title' },
  76. { label: this.$t('system.text_315'), key: 'priority' },
  77. { label: this.$t('system.text_316'), key: 'received_at' },
  78. ...this.ExtraExportDataOptions,
  79. ],
  80. },
  81. columns: [
  82. getCopyWithContentTableColumn({
  83. title: this.$t('system.text_307'),
  84. field: 'title',
  85. }),
  86. {
  87. title: this.$t('system.text_315'),
  88. field: 'priority',
  89. width: 80,
  90. formatter: ({ cellValue }) => {
  91. return this.$t(`notificationPriority.${cellValue}`)
  92. },
  93. },
  94. {
  95. title: this.$t('system.text_317'),
  96. field: 'receive_details',
  97. type: 'expand',
  98. slots: {
  99. default: ({ row }) => {
  100. return row.receive_details && row.receive_details.length
  101. },
  102. content: ({ row }) => {
  103. return [
  104. <vxe-grid
  105. size="mini"
  106. data={ row.receive_details || [] }
  107. columns={[
  108. getCopyWithContentTableColumn({ title: this.$t('system.text_6'), field: 'receiver_name' }),
  109. getTimeTableColumn({ title: this.$t('system.text_316'), field: 'sendAt' }),
  110. getStatusTableColumn({ statusModule: 'notification', sortable: false }),
  111. ]} />,
  112. ]
  113. },
  114. },
  115. },
  116. ...this.ExtraColumns,
  117. ],
  118. }
  119. },
  120. created () {
  121. this.list.fetchData()
  122. },
  123. methods: {
  124. getParam () {
  125. const ret = {
  126. ...this.ExtraListParams,
  127. details: true,
  128. }
  129. return ret
  130. },
  131. },
  132. }
  133. </script>