columns.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import {
  2. getNameDescriptionTableColumn,
  3. getStatusTableColumn,
  4. getBrandTableColumn,
  5. getProjectTableColumn,
  6. getRegionTableColumn,
  7. getTagTableColumn,
  8. getTimeTableColumn,
  9. } from '@/utils/common/tableColumn'
  10. import { sizestr } from '@/utils/utils'
  11. import i18n from '@/locales'
  12. import { getAssociateNameTableColumn, getIPWithBgpTypeTableColumn } from '../utils/columns'
  13. export default {
  14. created () {
  15. this.columns = [
  16. getNameDescriptionTableColumn({
  17. onManager: this.onManager,
  18. hideField: true,
  19. slotCallback: row => {
  20. return (
  21. <side-page-trigger onTrigger={ () => this.handleOpenSidepage(row) }>{ row.name }</side-page-trigger>
  22. )
  23. },
  24. hidden: () => {
  25. return this.$isScopedPolicyMenuHidden('eip_hidden_columns.name')
  26. },
  27. }),
  28. getStatusTableColumn({
  29. statusModule: 'eip',
  30. vm: this,
  31. hidden: () => {
  32. return this.$isScopedPolicyMenuHidden('eip_hidden_columns.status')
  33. },
  34. }),
  35. getTagTableColumn({
  36. onManager: this.onManager,
  37. resource: 'eips',
  38. columns: () => this.columns,
  39. hidden: () => {
  40. return this.$isScopedPolicyMenuHidden('eip_hidden_columns.metadata')
  41. },
  42. }),
  43. // {
  44. // field: 'ip_addr',
  45. // title: 'IP',
  46. // width: 140,
  47. // hidden: () => {
  48. // return this.$isScopedPolicyMenuHidden('eip_hidden_columns.ip_addr')
  49. // },
  50. // },
  51. getIPWithBgpTypeTableColumn({
  52. hidden: () => {
  53. return this.$isScopedPolicyMenuHidden('eip_hidden_columns.ip_addr')
  54. },
  55. }),
  56. {
  57. field: 'mode',
  58. title: this.$t('network.text_249'),
  59. formatter: ({ row }) => {
  60. if (row.mode === 'elastic_ip') {
  61. return this.$t('network.text_221')
  62. } else if (row.mode === 'public_ip') {
  63. return this.$t('network.public_ip')
  64. }
  65. return '-'
  66. },
  67. },
  68. {
  69. field: 'bandwidth',
  70. title: i18n.t('network.text_195'),
  71. minWidth: 80,
  72. showOverflow: 'ellipsis',
  73. formatter: ({ row, cellValue }) => {
  74. if (!row.bandwidth) return '-'
  75. return sizestr(row.bandwidth, 'M', 1024)
  76. },
  77. hidden: () => {
  78. return this.$isScopedPolicyMenuHidden('eip_hidden_columns.bandwidth')
  79. },
  80. },
  81. {
  82. field: 'charge_type',
  83. title: i18n.t('network.text_192'),
  84. minWidth: 80,
  85. formatter: ({ row }) => {
  86. const cellValue = row.charge_type
  87. if (cellValue === 'traffic') {
  88. return i18n.t('network.text_193')
  89. }
  90. if (cellValue === 'bandwidth') {
  91. return i18n.t('network.text_194')
  92. }
  93. return cellValue
  94. },
  95. hidden: () => {
  96. return this.$isScopedPolicyMenuHidden('eip_hidden_columns.charge_type')
  97. },
  98. },
  99. getBrandTableColumn({
  100. hidden: () => {
  101. return this.$isScopedPolicyMenuHidden('eip_hidden_columns.brand')
  102. },
  103. }),
  104. {
  105. field: 'account',
  106. title: i18n.t('network.text_196'),
  107. minWidth: 120,
  108. slots: {
  109. default: ({ row }) => {
  110. if (this.isPreLoad && !row.account) return [<data-loading />]
  111. const ret = []
  112. ret.push(
  113. <list-body-cell-wrap hide-field copy field='account' row={row}>
  114. <span style={{ color: '#0A1F44' }}>{ row.account }</span>
  115. </list-body-cell-wrap>,
  116. )
  117. if (row.manager) {
  118. ret.push(
  119. <list-body-cell-wrap hide-field copy field='manager' row={row}>
  120. <span style={{ color: '#53627C' }}>{ row.manager }</span>
  121. </list-body-cell-wrap>,
  122. )
  123. }
  124. return ret
  125. },
  126. },
  127. hidden: () => {
  128. if (this.$store.getters.isProjectMode) return true
  129. return this.$isScopedPolicyMenuHidden('eip_hidden_columns.account')
  130. },
  131. formatter: ({ row }) => {
  132. return row.account || '-'
  133. },
  134. },
  135. getAssociateNameTableColumn({
  136. vm: this,
  137. hidden: () => {
  138. return this.$isScopedPolicyMenuHidden('eip_hidden_columns.associate_name')
  139. },
  140. }),
  141. getProjectTableColumn({
  142. hidden: () => {
  143. return this.$isScopedPolicyMenuHidden('eip_hidden_columns.tenant')
  144. },
  145. }),
  146. getRegionTableColumn({
  147. vm: this,
  148. hidden: () => {
  149. return this.$isScopedPolicyMenuHidden('eip_hidden_columns.region')
  150. },
  151. }),
  152. getTimeTableColumn({
  153. hidden: () => {
  154. return this.$isScopedPolicyMenuHidden('eip_hidden_columns.created_at')
  155. },
  156. }),
  157. ]
  158. },
  159. }