index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { getAccessUrlTableColumn, getAccountTableColumn } from '../utils/columns'
  2. import {
  3. getCopyWithContentTableColumn,
  4. getBrandTableColumn,
  5. } from '@/utils/common/tableColumn'
  6. import i18n from '@/locales'
  7. export const getResource = (row) => {
  8. if (row.accounts?.length > 0) {
  9. return 'cloudaccounts'
  10. }
  11. if (row.managers?.length > 0) {
  12. return 'cloudproviders'
  13. }
  14. return ''
  15. }
  16. export const getColumns = (row) => {
  17. if (row.accounts?.length > 0) {
  18. return [
  19. getCopyWithContentTableColumn({
  20. field: 'id',
  21. title: 'ID',
  22. minWidth: 140,
  23. }),
  24. getCopyWithContentTableColumn({
  25. field: 'name',
  26. title: i18n.t('cloudenv.text_95'),
  27. }),
  28. getAccessUrlTableColumn(),
  29. getBrandTableColumn(),
  30. ]
  31. }
  32. if (row.managers?.length > 0) {
  33. return [
  34. getCopyWithContentTableColumn({
  35. field: 'id',
  36. title: 'ID',
  37. minWidth: 140,
  38. }),
  39. getCopyWithContentTableColumn({
  40. field: 'name',
  41. title: i18n.t('cloudenv.text_95'),
  42. }),
  43. getBrandTableColumn(),
  44. getAccountTableColumn(),
  45. ]
  46. }
  47. return []
  48. }
  49. export const getTargetColumns = (type) => {
  50. if (type === 'accounts') {
  51. return [
  52. getCopyWithContentTableColumn({
  53. field: 'id',
  54. title: 'ID',
  55. minWidth: 140,
  56. }),
  57. getCopyWithContentTableColumn({
  58. field: 'name',
  59. title: i18n.t('cloudenv.text_95'),
  60. }),
  61. getAccessUrlTableColumn(),
  62. getBrandTableColumn(),
  63. ]
  64. }
  65. if (type === 'providers') {
  66. return [
  67. getCopyWithContentTableColumn({
  68. field: 'id',
  69. title: 'ID',
  70. minWidth: 140,
  71. }),
  72. getCopyWithContentTableColumn({
  73. field: 'name',
  74. title: i18n.t('cloudenv.text_95'),
  75. }),
  76. getBrandTableColumn(),
  77. getAccountTableColumn(),
  78. ]
  79. }
  80. return []
  81. }