columns.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import {
  2. getNameDescriptionTableColumn,
  3. getStatusTableColumn,
  4. getBrandTableColumn,
  5. getAccountTableColumn,
  6. getTimeTableColumn,
  7. getBillingTableColumn,
  8. getPublicScopeTableColumn,
  9. getProjectDomainTableColumn,
  10. getTagTableColumn,
  11. } from '@/utils/common/tableColumn'
  12. import i18n from '@/locales'
  13. const NatSpec = {
  14. default: '-',
  15. small: i18n.t('network.nat.spec.small'),
  16. medium: i18n.t('network.nat.spec.medium'),
  17. large: i18n.t('network.nat.spec.large'),
  18. xlarge: i18n.t('network.nat.spec.xlarge.1'),
  19. 'xlarge.1': i18n.t('network.nat.spec.xlarge.1'),
  20. }
  21. export const getNatSpecColumn = ({ field = 'nat_spec', title = i18n.t('network.text_268') } = {}) => {
  22. return {
  23. field,
  24. title,
  25. formatter: ({ row }) => {
  26. const spec = row.nat_spec && row.nat_spec.toLowerCase()
  27. return NatSpec[spec] || spec
  28. },
  29. }
  30. }
  31. export default {
  32. created () {
  33. this.columns = [
  34. getNameDescriptionTableColumn({
  35. onManager: this.onManager,
  36. hideField: true,
  37. addLock: true,
  38. slotCallback: row => {
  39. return (
  40. <side-page-trigger onTrigger={ () => this.handleOpenSidepage(row) }>{ row.name }</side-page-trigger>
  41. )
  42. },
  43. }),
  44. getStatusTableColumn({ statusModule: 'nat', vm: this }),
  45. {
  46. field: 'network_type',
  47. title: this.$t('network.text_249'),
  48. formatter: ({ row }) => {
  49. if (row.network_type === 'intranet') {
  50. return this.$t('network.text_271')
  51. }
  52. if (row.network_type === 'internet') {
  53. return this.$t('network.text_270')
  54. }
  55. return '-'
  56. },
  57. },
  58. getTagTableColumn({ onManager: this.onManager, resource: 'natgateways', columns: () => this.columns }),
  59. getNatSpecColumn({}),
  60. getBillingTableColumn({ vm: this }),
  61. getBrandTableColumn(),
  62. getAccountTableColumn(),
  63. getPublicScopeTableColumn({ vm: this, resource: 'natgateways' }),
  64. getProjectDomainTableColumn(),
  65. getTimeTableColumn(),
  66. {
  67. field: 'region',
  68. title: i18n.t('network.text_199'),
  69. width: 150,
  70. },
  71. ]
  72. },
  73. }