LB.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <page-list
  3. show-tag-columns
  4. show-tag-columns2
  5. show-tag-filter
  6. show-tag-config
  7. :list="list"
  8. :columns="columns"
  9. :showSearchbox="showSearchbox"
  10. :export-data-options="exportDataOptions"
  11. :tag-config-params="tagConfigParams" />
  12. </template>
  13. <script>
  14. import * as R from 'ramda'
  15. import { surpportLb } from '@Network/views/lb/constants'
  16. import ListMixin from '@/mixins/list'
  17. import WindowsMixin from '@/mixins/windows'
  18. import {
  19. getNameFilter,
  20. getBrandFilter,
  21. getTenantFilter,
  22. getDomainFilter,
  23. getAccountFilter,
  24. getStatusFilter,
  25. getCloudProviderFilter,
  26. getDescriptionFilter,
  27. getCreatedAtFilter,
  28. } from '@/utils/common/tableFilter'
  29. import expectStatus from '@/constants/expectStatus'
  30. import ColumnsMixin from '@Network/views/lb/mixins/columns'
  31. export default {
  32. name: 'LbList',
  33. mixins: [WindowsMixin, ListMixin, ColumnsMixin],
  34. props: {
  35. id: String,
  36. getParams: {
  37. type: [Function, Object],
  38. },
  39. },
  40. data () {
  41. const allBrandsFilter = getBrandFilter()
  42. const filterOptions = {
  43. external_id: {
  44. label: this.$t('table.title.external_id'),
  45. },
  46. id: {
  47. label: this.$t('table.title.id'),
  48. },
  49. name: getNameFilter(),
  50. description: getDescriptionFilter(),
  51. status: getStatusFilter('lb'),
  52. address: {
  53. label: this.$t('network.text_248'),
  54. },
  55. brand: {
  56. ...allBrandsFilter,
  57. items: allBrandsFilter.items.filter(val => surpportLb.includes(val.key.toLowerCase())),
  58. },
  59. projects: getTenantFilter(),
  60. project_domains: getDomainFilter(),
  61. cloudaccount: getAccountFilter(),
  62. manager: getCloudProviderFilter(),
  63. region: {
  64. label: this.$t('dashboard.text_101'),
  65. },
  66. zone: {
  67. label: this.$t('compute.text_270'),
  68. hiddenField: 'region',
  69. },
  70. created_at: getCreatedAtFilter(),
  71. }
  72. const { path } = this.$route
  73. if (path.includes('/cluster')) {
  74. delete filterOptions.brand
  75. delete filterOptions.cloudaccount
  76. }
  77. return {
  78. list: this.$list.createList(this, {
  79. ctx: this,
  80. id: this.id,
  81. resource: 'loadbalancers',
  82. getParams: this.getParam,
  83. filterOptions,
  84. steadyStatus: {
  85. status: Object.values(expectStatus.lb).flat(),
  86. },
  87. responseData: this.responseData,
  88. hiddenColumns: ['metadata', 'account', 'cluster', 'created_at'],
  89. autoHiddenFilterKey: 'slb_hidden_columns',
  90. }),
  91. tagConfigParams: {
  92. resource: 'loadbalancers',
  93. queryTreeId: 'project-tag-value-tree',
  94. },
  95. }
  96. },
  97. computed: {
  98. exportDataOptions () {
  99. return {
  100. items: [
  101. { label: 'ID', key: 'id' },
  102. ...this.columns,
  103. ],
  104. title: this.$t('network.text_714'),
  105. downloadType: 'local',
  106. }
  107. },
  108. },
  109. created () {
  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. handleOpenSidepage (row, tab) {
  120. this.sidePageTriggerHandle(this, 'LbSidePage', {
  121. id: row.id,
  122. resource: 'loadbalancers',
  123. getParams: this.getParam,
  124. steadyStatus: {
  125. status: Object.values(expectStatus.lb).flat(),
  126. },
  127. }, {
  128. row: row,
  129. list: this.list,
  130. tab,
  131. })
  132. },
  133. },
  134. }
  135. </script>