List.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions"
  7. :export-data-options="exportDataOptions"
  8. :expand-config="{ lazy: true, loadMethod: loadPolicy }" />
  9. </template>
  10. <script>
  11. import * as R from 'ramda'
  12. import { getNameFilter, getBrandFilter, getDescriptionFilter, getCreatedAtFilter, getDistinctFieldFilter } from '@/utils/common/tableFilter'
  13. import WindowsMixin from '@/mixins/windows'
  14. import ListMixin from '@/mixins/list'
  15. import expectStatus from '@/constants/expectStatus'
  16. import ColumnsMixin from '../mixins/columns'
  17. import SingleActionsMixin from '../mixins/singleActions'
  18. export default {
  19. name: 'CloudaccountList',
  20. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  21. props: {
  22. id: String,
  23. getParams: {
  24. type: Object,
  25. default: () => ({}),
  26. },
  27. cloudaccount: {
  28. type: Object,
  29. default: () => ({}),
  30. },
  31. },
  32. data () {
  33. const filterOptions = {
  34. name: getNameFilter(),
  35. description: getDescriptionFilter(),
  36. provider: getBrandFilter('cloud_id_brands'),
  37. cloudaccount: getDistinctFieldFilter({
  38. field: 'account',
  39. type: 'extra_field',
  40. label: this.$t('common.text00108'),
  41. }),
  42. manager_id: getDistinctFieldFilter({
  43. field: 'manager',
  44. type: 'extra_field',
  45. label: this.$t('common_624', [this.$t('dictionary.cloudprovider')]),
  46. multiple: false,
  47. }),
  48. created_at: getCreatedAtFilter(),
  49. }
  50. if (this.inBaseSidePage) {
  51. delete filterOptions.cloudaccount
  52. }
  53. return {
  54. list: this.$list.createList(this, {
  55. id: this.id,
  56. resource: 'cloudgroups',
  57. apiVersion: 'v1',
  58. getParams: this.getParam,
  59. steadyStatus: Object.values(expectStatus.cloudgroup).flat(),
  60. filterOptions,
  61. hiddenColumns: ['created_at'],
  62. }),
  63. groupActions: [
  64. {
  65. label: this.$t('common.create'),
  66. permission: 'cloudgroup_create',
  67. action: () => {
  68. this.createDialog('CloudgroupCreateDialog', {
  69. onManager: this.onManager,
  70. provider: this.cloudaccount.provider,
  71. cloudaccount: this.cloudaccount || {},
  72. })
  73. },
  74. meta: () => {
  75. return {
  76. buttonType: 'primary',
  77. }
  78. },
  79. },
  80. {
  81. label: this.$t('common.delete'),
  82. permission: 'cloudgroup_delete',
  83. action: () => {
  84. this.createDialog('DeleteResDialog', {
  85. vm: this,
  86. data: this.list.selectedItems,
  87. columns: this.columns,
  88. title: this.$t('cloudenv.cloudgroup_delete_tip'),
  89. name: this.$t('dictionary.cloudgroup'),
  90. onManager: this.onManager,
  91. })
  92. },
  93. meta: () => this.$getDeleteResult(this.list.selectedItems),
  94. },
  95. ],
  96. }
  97. },
  98. computed: {
  99. exportDataOptions () {
  100. return {
  101. title: this.$t('cloudenv.text_491'),
  102. downloadType: 'local',
  103. items: [
  104. { field: 'id', title: 'ID' },
  105. ...this.columns,
  106. { field: 'manager', title: this.$t('common_624', [this.$t('dictionary.cloudprovider')]) },
  107. ],
  108. }
  109. },
  110. },
  111. created () {
  112. this.initSidePageTab('cloudgroup-detail')
  113. this.list.fetchData()
  114. this.$bus.$on('CloudgroupListSingleRefresh', (...arg) => {
  115. this.list.singleRefresh(...arg)
  116. }, false)
  117. },
  118. methods: {
  119. getParam () {
  120. const ret = {
  121. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  122. }
  123. return ret
  124. },
  125. },
  126. }
  127. </script>