columns.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import moment from 'moment'
  2. import i18n from '@/locales'
  3. export const getOperationColumns = () => {
  4. return {
  5. field: 'operation',
  6. title: i18n.t('cloudenv.text_425'),
  7. width: 80,
  8. showOverflow: 'title',
  9. formatter: ({ row }) => {
  10. return i18n.t('cloudenvScheduledtaskRuleAction')[row.operation] || '-'
  11. },
  12. }
  13. }
  14. export const getResourceColumns = () => {
  15. return {
  16. field: 'operation',
  17. title: i18n.t('cloudenv.text_426'),
  18. width: 80,
  19. showOverflow: 'title',
  20. formatter: ({ row }) => {
  21. return i18n.t('cloudenv.ScheduledtaskResource')[row.operation] || '-'
  22. },
  23. }
  24. }
  25. export const getResourceTypeColumns = () => {
  26. return {
  27. field: 'resource_type',
  28. title: i18n.t('cloudenv.text_384'),
  29. width: 110,
  30. showOverflow: 'title',
  31. formatter: ({ row }) => {
  32. return i18n.t('cloudenvScheduledtaskResourceType')[row.resource_type] || '-'
  33. },
  34. }
  35. }
  36. export const getResourceNumberColumns = (that) => {
  37. return {
  38. field: 'labels',
  39. title: i18n.t('cloudenv.text_417'),
  40. width: 110,
  41. showOverflow: 'title',
  42. formatter: ({ row }) => {
  43. return (row.labels && row.labels.length) || 0
  44. },
  45. }
  46. }
  47. export const getLabelTypeColumns = () => {
  48. return {
  49. field: 'label_type',
  50. title: i18n.t('cloudenv.text_426'),
  51. width: 110,
  52. showOverflow: 'title',
  53. formatter: ({ row }) => {
  54. return i18n.t('cloudenvScheduledtaskLabelType')[row.label_type] || '-'
  55. },
  56. }
  57. }
  58. export const getCycleTypeCloumns = () => {
  59. return {
  60. field: 'cycle_type',
  61. title: i18n.t('cloudenv.text_433'),
  62. width: 80,
  63. formatter: ({ row }) => {
  64. if (row.scheduled_type === 'timing') {
  65. row.cycle_timer.cycle_type = 'one'
  66. }
  67. return i18n.t('cloudenvScheduledtaskGroupCycleType')[row.cycle_timer.cycle_type]
  68. },
  69. }
  70. }
  71. export const getCycleTimerColumns = ({ timeFormat = 'YYYY-MM-DD HH:mm:ss' } = {}) => {
  72. return {
  73. field: 'cycle_timer',
  74. title: i18n.t('cloudenv.text_427'),
  75. minWidth: 200,
  76. showOverflow: 'title',
  77. slots: {
  78. default: ({ row }, h) => {
  79. const hour = row.cycle_timer.hour
  80. const minute = row.cycle_timer.minute
  81. const timer = i18n.t('cloudenv.text_465', [`${hour > 9 ? hour : `0${hour}`}:${minute > 9 ? minute : `0${minute}`}`])
  82. if (row.scheduled_type === 'cycle') {
  83. const cycleType = i18n.t('cloudenvScheduledtaskGroupCycleType')[row.cycle_timer.cycle_type]
  84. const startEndTime = i18n.t('cloudenv.text_466', [moment(row.cycle_timer.start_time).format(timeFormat), moment(row.cycle_timer.end_time).format(timeFormat)])
  85. if (row.cycle_timer.cycle_type === 'day') {
  86. return `${cycleType} ${timer} ${startEndTime}`
  87. } else if (row.cycle_timer.cycle_type === 'week') {
  88. const weekDays = row.cycle_timer.week_days.map((v) => {
  89. return i18n.t('flexGroupSubCycleTypeWeek')[v]
  90. })
  91. return `${cycleType} 【${weekDays.join('|')}】 ${timer} ${startEndTime}`
  92. } if (row.cycle_timer.cycle_type === 'month') {
  93. const monthDays = row.cycle_timer.month_days.map((v) => {
  94. return i18n.t('cloudenv.text_436', [v])
  95. })
  96. return `${cycleType} 【${monthDays.join('|')}】 ${timer} ${startEndTime}`
  97. }
  98. } else {
  99. return i18n.t('cloudenv.text_467', [moment(row.timer.exec_time).format(timeFormat)])
  100. }
  101. },
  102. },
  103. }
  104. }
  105. export const getTimerDescColumns = () => {
  106. return {
  107. field: 'timer_desc',
  108. title: i18n.t('cloudenv.text_427'),
  109. minWidth: 300,
  110. showOverflow: 'title',
  111. formatter: ({ row }) => {
  112. return row.timer_desc || '-'
  113. },
  114. }
  115. }