columns.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { getEnabledTableColumn } from '@/utils/common/tableColumn'
  2. import i18n from '@/locales'
  3. import {
  4. getLastSyncCostTableColumn,
  5. } from '../../cloudaccount/utils/columns'
  6. export default {
  7. created () {
  8. this.columns = [
  9. {
  10. field: 'cloudregion',
  11. title: i18n.t('cloudenv.text_10'),
  12. },
  13. getEnabledTableColumn({ title: i18n.t('cloudenv.text_366') }),
  14. getLastSyncCostTableColumn(),
  15. {
  16. field: 'last_auto_sync',
  17. title: i18n.t('cloudenv.text_103'),
  18. slots: {
  19. default: ({ row }) => {
  20. if (row.sync_status !== 'idle') { // 表示正在同步中
  21. return [
  22. <status status={ row.sync_status } statusModule='cloudaccountSyncStatus' />,
  23. ]
  24. } else {
  25. let time
  26. if (row.last_sync) {
  27. time = this.$moment(row.last_sync)
  28. }
  29. return time ? time.fromNow() : '-'
  30. }
  31. },
  32. },
  33. },
  34. {
  35. field: 'last_sync_end_at',
  36. title: i18n.t('cloudenv.last.sync.end.at'),
  37. slots: {
  38. default: ({ row }) => {
  39. if (row.sync_status !== 'idle') { // 表示正在同步中
  40. return [
  41. <status status={ row.sync_status } statusModule='cloudaccountSyncStatus' />,
  42. ]
  43. }
  44. const time = this.$moment(row.last_sync_end_at)
  45. if (time) {
  46. return time.fromNow()
  47. }
  48. return '-'
  49. },
  50. },
  51. },
  52. {
  53. field: 'sync_status',
  54. title: i18n.t('cloudenv.text_354'),
  55. slots: {
  56. default: ({ row }) => {
  57. return [
  58. <status status={ row.sync_status } statusModule='cloudaccountSyncStatus' />,
  59. ]
  60. },
  61. },
  62. },
  63. ]
  64. },
  65. }