Detail.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <detail
  3. :on-manager="onManager"
  4. :data="data"
  5. :base-info="baseInfo"
  6. :extra-info="extraInfo"
  7. status-module="snapshotpolicy" />
  8. </template>
  9. <script>
  10. import { weekOptions, timeOptions } from '../constants'
  11. export default {
  12. name: 'SnapshotPolicyDetail',
  13. props: {
  14. data: {
  15. type: Object,
  16. required: true,
  17. },
  18. onManager: {
  19. type: Function,
  20. required: true,
  21. },
  22. },
  23. data () {
  24. const detailData = {
  25. baseInfo: [
  26. {
  27. field: 'binding_disk_count',
  28. title: this.$t('compute.bind_resource_count'),
  29. minWidth: 120,
  30. slots: {
  31. default: ({ row }) => {
  32. if (row.binding_disk_count === undefined) return [<data-loading />]
  33. if (row.type === 'server') {
  34. if (row.binding_resource_count <= 0) return row.binding_resource_count
  35. return [
  36. <side-page-trigger name='SnapshotPolicySidePage' id={row.id} tab='snapshot-policy-server' vm={this}>{row.binding_resource_count}</side-page-trigger>,
  37. ]
  38. }
  39. if (row.binding_disk_count <= 0) return row.binding_disk_count
  40. return [
  41. <side-page-trigger name='SnapshotPolicySidePage' id={row.id} tab='snapshot-policy-disk' vm={this}>{row.binding_disk_count}</side-page-trigger>,
  42. ]
  43. },
  44. },
  45. },
  46. {
  47. field: 'time_points',
  48. title: this.$t('compute.text_432'),
  49. formatter: ({ cellValue }) => {
  50. let text = ''
  51. if (cellValue && cellValue.length) {
  52. text += cellValue.map(item => timeOptions[item]).join('、')
  53. }
  54. return text || '-'
  55. },
  56. },
  57. {
  58. field: 'repeat_weekdays',
  59. title: this.$t('compute.text_431'),
  60. formatter: ({ cellValue }) => {
  61. let text = ''
  62. if (cellValue && cellValue.length) {
  63. text += this.$t('compute.text_1098') + cellValue.map(item => weekOptions[item - 1]).join('、')
  64. }
  65. return text || '-'
  66. },
  67. },
  68. {
  69. field: 'retention_days',
  70. title: this.$t('compute.text_433'),
  71. formatter: ({ row }) => {
  72. if (row.retention_count) {
  73. return `${this.$t('compute.retention_count_prefix')} ${row.retention_count} ${this.$t('compute.retention_count_suffix')}`
  74. }
  75. if (row.retention_days !== -1) {
  76. return this.$t('compute.text_438', [row.retention_days])
  77. }
  78. return this.$t('compute.text_1094')
  79. },
  80. },
  81. {
  82. field: 'snapshot_count',
  83. title: this.$t('compute.snapshot_count'),
  84. formatter: ({ row }) => {
  85. return row.snapshot_count || '-'
  86. },
  87. },
  88. ],
  89. extraInfo: [],
  90. }
  91. return detailData
  92. },
  93. }
  94. </script>