List.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <page-list
  3. show-tag-columns
  4. show-tag-filter
  5. :list="list"
  6. :columns="columns"
  7. :single-actions="singleActions"
  8. :group-actions="groupActions"
  9. :export-data-options="exportDataOptions" />
  10. </template>
  11. <script>
  12. import * as R from 'ramda'
  13. import { mapGetters } from 'vuex'
  14. import ColumnsMixin from '../mixins/columns'
  15. import SingleActionsMixin from '../mixins/singleActions'
  16. import ListMixin from '@/mixins/list'
  17. import WindowsMixin from '@/mixins/windows'
  18. import { getDescriptionFilter, getCreatedAtFilter } from '@/utils/common/tableFilter'
  19. export default {
  20. name: 'LoadbalancerclusterList',
  21. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  22. props: {
  23. id: String,
  24. getParams: {
  25. type: [Function, Object],
  26. },
  27. },
  28. data () {
  29. return {
  30. list: this.$list.createList(this, {
  31. id: this.id,
  32. resource: 'loadbalancerclusters',
  33. getParams: this.getParam,
  34. filterOptions: {
  35. name: {
  36. label: this.$t('network.text_21'),
  37. filter: true,
  38. formatter: val => {
  39. return `name.contains(${val})`
  40. },
  41. },
  42. description: getDescriptionFilter(),
  43. region: {
  44. label: this.$t('dashboard.text_101'),
  45. },
  46. zone: {
  47. label: this.$t('compute.text_270'),
  48. },
  49. created_at: getCreatedAtFilter(),
  50. },
  51. hiddenColumns: ['created_at'],
  52. }),
  53. exportDataOptions: {
  54. items: [
  55. { label: 'ID', key: 'id' },
  56. { label: this.$t('network.text_21'), key: 'name' },
  57. { label: this.$t('network.text_199'), key: 'region' },
  58. { label: this.$t('common_715'), key: 'user_tags' },
  59. { label: this.$t('common.createdAt'), key: 'created_at' },
  60. ],
  61. },
  62. groupActions: [
  63. {
  64. label: this.$t('network.text_26'),
  65. permission: 'lb_loadbalancerclusters_create',
  66. action: () => {
  67. this.createDialog('LoadbalancerclusterCreateDialog', {
  68. title: this.$t('network.text_357'),
  69. data: this.list.selectedItems,
  70. onManager: this.onManager,
  71. refresh: this.refresh,
  72. })
  73. },
  74. meta: () => {
  75. return {
  76. buttonType: 'primary',
  77. validate: this.$isAdminMode,
  78. }
  79. },
  80. },
  81. {
  82. label: this.$t('table.action.set_tag'),
  83. permission: 'lb_loadbalancerclusters_perform_set_user_metadata',
  84. action: () => {
  85. this.createDialog('SetTagDialog', {
  86. data: this.list.selectedItems,
  87. columns: this.columns,
  88. onManager: this.onManager,
  89. mode: 'add',
  90. params: {
  91. resources: 'loadbalancercluster',
  92. },
  93. tipName: this.$t('network.text_19'),
  94. })
  95. },
  96. meta: () => {
  97. return {
  98. validate: this.list.selectedItems.length > 0,
  99. }
  100. },
  101. },
  102. ],
  103. }
  104. },
  105. computed: {
  106. ...mapGetters(['isAdminMode']),
  107. },
  108. created () {
  109. this.initSidePageTab('Loadbalancercluster-detail')
  110. this.list.fetchData()
  111. },
  112. methods: {
  113. getParam () {
  114. const ret = {
  115. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  116. }
  117. return ret
  118. },
  119. hasService ($userInfo, service) {
  120. if ($userInfo && $userInfo.services && $userInfo.services.length) {
  121. const results = $userInfo.services.filter(item => {
  122. return item.type === service && item.status === true
  123. })
  124. return results && results.length > 0
  125. }
  126. return false
  127. },
  128. handleOpenSidepage (row) {
  129. this.sidePageTriggerHandle(this, 'LoadbalancerclusterSidePage', {
  130. id: row.id,
  131. resource: 'loadbalancerclusters',
  132. getParams: this.getParam,
  133. }, {
  134. list: this.list,
  135. })
  136. },
  137. },
  138. }
  139. </script>