columns.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import {
  2. getNameDescriptionTableColumn,
  3. getStatusTableColumn,
  4. getBrandTableColumn,
  5. getAccountTableColumn,
  6. getTimeTableColumn,
  7. getPublicScopeTableColumn,
  8. getProjectTableColumn,
  9. getTagTableColumn,
  10. } from '@/utils/common/tableColumn'
  11. import i18n from '@/locales'
  12. const Areas = {
  13. mainland: i18n.t('network.cdn.area.mainland'),
  14. overseas: i18n.t('network.cdn.area.overseas'),
  15. global: i18n.t('network.cdn.area.global'),
  16. }
  17. const ServiceTypes = {
  18. web: i18n.t('network.cdn.service_type.web'),
  19. download: i18n.t('network.cdn.service_type.download'),
  20. media: i18n.t('network.cdn.service_type.media'),
  21. }
  22. export const getAreaColumn = ({ field = 'area', title = i18n.t('network.cdn.area') } = {}) => {
  23. return {
  24. field,
  25. title,
  26. slots: {
  27. default: ({ row }, h) => {
  28. const area = row.area && row.area.toLowerCase()
  29. return Areas[area] || area || '-'
  30. },
  31. },
  32. }
  33. }
  34. export const getServiceTypeColumn = ({ field = 'service_type', title = i18n.t('network.cdn.service_type') } = {}) => {
  35. return {
  36. field,
  37. title,
  38. slots: {
  39. default: ({ row }, h) => {
  40. const serviceType = row.service_type && row.service_type.toLowerCase()
  41. return ServiceTypes[serviceType] || serviceType || '-'
  42. },
  43. },
  44. }
  45. }
  46. export const getCnameTableColumn = ({ field = 'cname', title = i18n.t('network.cdn.cname') } = {}) => {
  47. return {
  48. field,
  49. title,
  50. slots: {
  51. default: ({ row }, h) => {
  52. return row.cname || '-'
  53. },
  54. },
  55. }
  56. }
  57. export const getDomainTableColumn = ({ field = 'external_id', title = i18n.t('network.cdn.domain') } = {}) => {
  58. return {
  59. field,
  60. title,
  61. slots: {
  62. default: ({ row }, h) => {
  63. return row.external_id || '-'
  64. },
  65. },
  66. }
  67. }
  68. export default {
  69. created () {
  70. this.columns = [
  71. getNameDescriptionTableColumn({
  72. onManager: this.onManager,
  73. hideField: true,
  74. addLock: true,
  75. slotCallback: row => {
  76. return (
  77. <side-page-trigger onTrigger={ () => this.handleOpenSidepage(row) }>{ row.name }</side-page-trigger>
  78. )
  79. },
  80. }),
  81. getStatusTableColumn({ statusModule: 'cdnDomain', vm: this }),
  82. getTagTableColumn({ onManager: this.onManager, resource: 'cdn_domains', columns: () => this.columns }),
  83. getAreaColumn({}),
  84. getCnameTableColumn({}),
  85. getServiceTypeColumn({}),
  86. getBrandTableColumn(),
  87. getAccountTableColumn(),
  88. getPublicScopeTableColumn({ vm: this, resource: 'cdn_domains' }),
  89. getProjectTableColumn(),
  90. getTimeTableColumn(),
  91. ]
  92. },
  93. }