List.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="templateListColumns || columns"
  5. :export-data-options="exportDataOptions"
  6. :group-actions="groupActions"
  7. :single-actions="singleActions"
  8. :showGroupActions="showGroupActions"
  9. :showSingleActions="isTemplate ? false : showSingleActions"
  10. :show-page="!isTemplate" />
  11. </template>
  12. <script>
  13. import * as R from 'ramda'
  14. import ListMixin from '@/mixins/list'
  15. import ResTemplateListMixin from '@/mixins/resTemplateList'
  16. import {
  17. getDomainFilter,
  18. getStatusFilter,
  19. getAccountFilter,
  20. getCloudProviderFilter,
  21. getBrandFilter,
  22. getRegionFilter,
  23. getDescriptionFilter,
  24. getVpcFilter,
  25. } from '@/utils/common/tableFilter'
  26. import WindowsMixin from '@/mixins/windows'
  27. import expectStatus from '@/constants/expectStatus'
  28. import SingleActionsMixin from '../mixins/singleActions'
  29. import ColumnsMixin from '../mixins/columns'
  30. export default {
  31. name: 'RouteTableList',
  32. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin, ResTemplateListMixin],
  33. props: {
  34. id: String,
  35. getParams: [Object, Function],
  36. showGroupActions: {
  37. type: Boolean,
  38. default: true,
  39. },
  40. showSingleActions: {
  41. type: Boolean,
  42. default: true,
  43. },
  44. defaultHiddenColumns: {
  45. type: Array,
  46. default: () => ([]),
  47. },
  48. hiddenColumns: {
  49. type: Array,
  50. default: () => ([]),
  51. },
  52. },
  53. data () {
  54. return {
  55. list: this.$list.createList(this, {
  56. ctx: this,
  57. id: this.id,
  58. resource: 'route_tables',
  59. getParams: this.getParam,
  60. isTemplate: this.isTemplate,
  61. templateLimit: this.templateLimit,
  62. steadyStatus: Object.values(expectStatus.routeTable).flat(),
  63. filterOptions: {
  64. name: {
  65. label: this.$t('network.text_21'),
  66. filter: true,
  67. formatter: val => {
  68. return `name.contains("${val}")`
  69. },
  70. },
  71. description: getDescriptionFilter(),
  72. status: getStatusFilter('routeTable'),
  73. brand: getBrandFilter('brands'),
  74. project_domains: getDomainFilter(),
  75. cloudaccount: getAccountFilter(),
  76. manager: getCloudProviderFilter(),
  77. region: getRegionFilter(),
  78. vpc: getVpcFilter(),
  79. },
  80. hiddenColumns: this.defaultHiddenColumns,
  81. }),
  82. groupActions: [],
  83. }
  84. },
  85. computed: {
  86. exportDataOptions () {
  87. return {
  88. downloadType: 'local',
  89. title: this.$t('dictionary.route_table'),
  90. items: [
  91. ...this.columns,
  92. ],
  93. }
  94. },
  95. },
  96. created () {
  97. this.list.fetchData()
  98. },
  99. methods: {
  100. getParam () {
  101. const ret = {
  102. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  103. details: true,
  104. }
  105. return ret
  106. },
  107. handleOpenSidepage (row, tab) {
  108. this.sidePageTriggerHandle(this, 'RouteTableSidePage', {
  109. id: row.id,
  110. resource: 'route_tables',
  111. getParams: this.getParam,
  112. }, {
  113. list: this.list,
  114. tab,
  115. })
  116. },
  117. },
  118. }
  119. </script>