columns.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import {
  2. getStatusTableColumn,
  3. getEnabledTableColumn,
  4. getNameDescriptionTableColumn,
  5. getCopyWithContentTableColumn,
  6. } from '@/utils/common/tableColumn'
  7. import i18n from '@/locales'
  8. import {
  9. getResourceMatchProjectTableColumn,
  10. } from '../utils/columns'
  11. import {
  12. getLastSyncCostTableColumn,
  13. } from '../../cloudaccount/utils/columns'
  14. export default {
  15. created () {
  16. this.columns = [
  17. getNameDescriptionTableColumn({
  18. onManager: this.onManager,
  19. hideField: true,
  20. slotCallback: row => {
  21. return (
  22. <side-page-trigger onTrigger={() => this.handleOpenSidepage(row)}>{ row.name }</side-page-trigger>
  23. )
  24. },
  25. }),
  26. {
  27. field: 'account',
  28. title: i18n.t('cloudenv.text_353'),
  29. showOverflow: 'ellipsis',
  30. minWidth: 160,
  31. slots: {
  32. default: ({ row }) => {
  33. const subscribeIds = (row.account && row.account.split('/')) || []
  34. const text = subscribeIds.length > 1 ? subscribeIds[1] : subscribeIds[0]
  35. return [
  36. <list-body-cell-wrap message={text} copy hideField={true}>
  37. <span>{text}</span>
  38. </list-body-cell-wrap>,
  39. ]
  40. },
  41. },
  42. formatter: ({ row }) => {
  43. const subscribeIds = (row.account && row.account.split('/')) || []
  44. const text = subscribeIds.length > 1 ? subscribeIds[1] : subscribeIds[0]
  45. return text
  46. },
  47. },
  48. getEnabledTableColumn(),
  49. getStatusTableColumn({ statusModule: 'cloudaccount' }),
  50. {
  51. field: 'last_sync',
  52. title: i18n.t('cloudenv.text_103'),
  53. width: 80,
  54. slots: {
  55. default: ({ row }) => {
  56. if (row.sync_status !== 'idle') { // 表示正在同步中
  57. return [
  58. <status status={ row.sync_status } statusModule='cloudaccountSyncStatus' />,
  59. ]
  60. } else {
  61. const time = this.$moment(row.last_sync)
  62. if (time) {
  63. return time.fromNow()
  64. } else {
  65. return '-'
  66. }
  67. }
  68. },
  69. },
  70. formatter: ({ row }) => {
  71. if (row.sync_status !== 'idle') { // 表示正在同步中
  72. return row.sync_status
  73. } else {
  74. const time = this.$moment(row.last_sync)
  75. if (time) {
  76. return time.fromNow()
  77. } else {
  78. return '-'
  79. }
  80. }
  81. },
  82. },
  83. getLastSyncCostTableColumn(),
  84. getStatusTableColumn({
  85. field: 'sync_status',
  86. title: i18n.t('cloudenv.text_354'),
  87. minWidth: 100,
  88. statusModule: 'cloudaccountSyncStatus',
  89. }),
  90. getCopyWithContentTableColumn({
  91. field: 'project_domain',
  92. title: i18n.t('cloudenv.text_355', [i18n.t('dictionary.domain')]),
  93. }),
  94. getResourceMatchProjectTableColumn(),
  95. ]
  96. },
  97. }