List.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :export-data-options="exportDataOptions"
  6. :group-actions="groupActions"
  7. :showGroupActions="showGroupActions"
  8. :single-actions="singleActions" />
  9. </template>
  10. <script>
  11. import * as R from 'ramda'
  12. import { mapGetters } from 'vuex'
  13. import ListMixin from '@/mixins/list'
  14. import WindowsMixin from '@/mixins/windows'
  15. import SingleActionsMixin from '../mixins/singleActions'
  16. import ColumnsMixin from '../mixins/columns'
  17. export default {
  18. name: 'CustomHostnameList',
  19. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  20. props: {
  21. id: String,
  22. getParams: {
  23. type: [Function, Object],
  24. },
  25. hiddenActions: {
  26. type: Array,
  27. default: () => ([]),
  28. },
  29. cdnId: {
  30. type: String,
  31. },
  32. },
  33. data () {
  34. return {
  35. list: this.$list.createList(this, {
  36. id: this.id,
  37. resource: `cdn_domains/${this.cdnId}/custom-hostnames`,
  38. getParams: this.getParam,
  39. filterOptions: {
  40. id: {
  41. label: this.$t('table.title.id'),
  42. },
  43. hostname: {
  44. label: this.$t('network.text_21'),
  45. filter: true,
  46. formatter: val => {
  47. return `hostname.contains("${val}")`
  48. },
  49. },
  50. },
  51. hiddenColumns: ['created_at'],
  52. }),
  53. groupActions: [
  54. {
  55. label: this.$t('common.create'),
  56. action: () => {
  57. this.createDialog('CdnHostnameCreateDialog', {
  58. onManager: this.onManager,
  59. data: [],
  60. cdnDomainId: this.cdnId,
  61. success: () => {
  62. this.list.fetchData()
  63. },
  64. })
  65. },
  66. meta: () => {
  67. return {
  68. buttonType: 'primary',
  69. validate: true,
  70. }
  71. },
  72. },
  73. ],
  74. }
  75. },
  76. computed: {
  77. ...mapGetters(['isAdminMode', 'isDomainMode', 'userInfo']),
  78. exportDataOptions () {
  79. return {
  80. items: [
  81. { label: 'ID', key: 'id' },
  82. ...this.columns,
  83. ],
  84. downloadType: 'local',
  85. title: this.$t('dictionary.cdn_domain'),
  86. }
  87. },
  88. },
  89. created () {
  90. this.list.fetchData()
  91. },
  92. methods: {
  93. getParam () {
  94. const ret = {
  95. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  96. detail: true,
  97. }
  98. return ret
  99. },
  100. handleOpenSidepage (row) {
  101. this.sidePageTriggerHandle(this, 'CdnHostnameSidePage', {
  102. id: row.id,
  103. resource: () => {
  104. return {
  105. data: row,
  106. }
  107. },
  108. }, {
  109. list: this.list,
  110. })
  111. },
  112. },
  113. }
  114. </script>