List.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :single-actions="singleActions"
  6. :group-actions="groupActions"
  7. :export-data-options="exportDataOptions" />
  8. </template>
  9. <script>
  10. import * as R from 'ramda'
  11. import ListMixin from '@/mixins/list'
  12. import expectStatus from '@/constants/expectStatus'
  13. import {
  14. getStatusFilter,
  15. getDescriptionFilter,
  16. getCreatedAtFilter,
  17. getProjectFilter,
  18. getBrandFilter,
  19. getAccountFilter,
  20. getCloudProviderFilter,
  21. } from '@/utils/common/tableFilter'
  22. import WindowsMixin from '@/mixins/windows'
  23. import SingleActionsMixin from '../mixins/singleActions'
  24. import ColumnsMixin from '../mixins/columns'
  25. export default {
  26. name: 'HealthCheckList',
  27. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  28. props: {
  29. id: String,
  30. getParams: {
  31. type: [Function, Object],
  32. },
  33. },
  34. data () {
  35. const filterOptions = {
  36. id: {
  37. label: this.$t('table.title.id'),
  38. },
  39. name: {
  40. label: this.$t('network.text_21'),
  41. filter: true,
  42. formatter: val => {
  43. return `name.contains("${val}")`
  44. },
  45. },
  46. description: getDescriptionFilter(),
  47. status: getStatusFilter('healthCheck'),
  48. brand: getBrandFilter(),
  49. account: getAccountFilter(),
  50. manager: getCloudProviderFilter(),
  51. project: getProjectFilter(),
  52. created_at: getCreatedAtFilter(),
  53. }
  54. return {
  55. list: this.$list.createList(this, {
  56. ctx: this,
  57. id: this.id,
  58. resource: 'loadbalancer_health_checks',
  59. getParams: this.getParam,
  60. filterOptions,
  61. responseData: this.responseData,
  62. steadyStatus: {
  63. status: Object.values(expectStatus.healthCheck).flat(),
  64. },
  65. }),
  66. groupActions: [
  67. {
  68. label: this.$t('network.text_26'),
  69. permission: 'sslcertificates_create',
  70. action: () => {
  71. this.createDialog('HealthCheckCreateDialog', {
  72. onManager: this.onManager,
  73. })
  74. },
  75. meta: () => {
  76. return {
  77. buttonType: 'primary',
  78. }
  79. },
  80. },
  81. ],
  82. }
  83. },
  84. computed: {
  85. exportDataOptions () {
  86. return {
  87. downloadType: 'local',
  88. title: this.$t('network.health_check'),
  89. items: this.columns,
  90. }
  91. },
  92. },
  93. created () {
  94. this.list.fetchData()
  95. },
  96. methods: {
  97. getParam () {
  98. const ret = {
  99. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  100. }
  101. if (this.cloudEnv) ret.cloud_env = this.cloudEnv
  102. return ret
  103. },
  104. handleOpenSidepage (row, tab) {
  105. this.sidePageTriggerHandle(this, 'HealthCheckSidePage', {
  106. id: row.id,
  107. resource: 'loadbalancer_health_checks',
  108. getParams: this.getParam,
  109. }, {
  110. list: this.list,
  111. tab,
  112. })
  113. },
  114. },
  115. }
  116. </script>