SelectRegion.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <div class="cloudaccount pt-2">
  3. <a-alert type="info" show-icon class="mt-2 mb-2" v-if="$store.getters.isAdminMode">
  4. <template slot="message">{{ $t('cloudenv.select_region_tips') }}</template>
  5. </a-alert>
  6. <page-list
  7. :showSync="false"
  8. :showSearchbox="false"
  9. :showPage="false"
  10. :list="list"
  11. :columns="columns"
  12. :group-actions="groupActions"
  13. :single-actions="singleActions" />
  14. </div>
  15. </template>
  16. <script>
  17. import { getNameFilter, getEnabledFilter } from '@/utils/common/tableFilter'
  18. import {
  19. getNameDescriptionTableColumn,
  20. } from '@/utils/common/tableColumn'
  21. import WindowsMixin from '@/mixins/windows'
  22. export default {
  23. name: 'SelectRegion',
  24. mixins: [WindowsMixin],
  25. props: {
  26. account: {
  27. type: Object,
  28. required: true,
  29. },
  30. createFormData: {
  31. type: Object,
  32. required: true,
  33. },
  34. },
  35. data () {
  36. // const ownerDomain = obj => this.$store.getters.isAdminMode || obj.cloudaccount_domain_id === this.$store.getters.userInfo.projectDomainId
  37. return {
  38. list: this.$list.createList(this, {
  39. id: this.id,
  40. resource: () => this.fetchData(),
  41. getParams: {},
  42. responseData: this.responseData,
  43. filterOptions: {
  44. name: getNameFilter(),
  45. enabled: getEnabledFilter({ label: this.$t('cloudenv.text_98') }),
  46. },
  47. }),
  48. columns: [
  49. getNameDescriptionTableColumn({
  50. onManager: this.onManager,
  51. hideField: true,
  52. slotCallback: row => {
  53. return (
  54. <side-page-trigger onTrigger={() => this.handleOpenSidepage(row)}>{ row.name }</side-page-trigger>
  55. )
  56. },
  57. }),
  58. {
  59. field: 'status',
  60. title: this.$t('common.status'),
  61. slots: {
  62. default: ({ row }) => {
  63. return [
  64. <status status={ row.status } statusModule='region' />,
  65. ]
  66. },
  67. },
  68. },
  69. ],
  70. groupActions: [
  71. // {
  72. // label: this.$t('cloudenv.text_363'),
  73. // action: () => {
  74. // this.createDialog('SetRegionAutoSyncDialog', {
  75. // data: this.list.selectedItems,
  76. // columns: this.columns,
  77. // refresh: this.refresh,
  78. // cloudproviderId: this.cloudproviderId,
  79. // })
  80. // },
  81. // meta: () => {
  82. // return {
  83. // validate: this.list.selectedItems.length,
  84. // }
  85. // },
  86. // },
  87. ],
  88. singleActions: [
  89. // {
  90. // label: this.$t('cloudenv.text_363'),
  91. // action: obj => {
  92. // this.createDialog('SetRegionAutoSyncDialog', {
  93. // data: [obj],
  94. // columns: this.columns,
  95. // refresh: this.refresh,
  96. // cloudproviderId: this.cloudproviderId,
  97. // })
  98. // },
  99. // meta: obj => {
  100. // return {
  101. // validate: ownerDomain(obj),
  102. // }
  103. // },
  104. // },
  105. ],
  106. }
  107. },
  108. computed: {
  109. chooseRegions () {
  110. return this.list.selectedItems
  111. },
  112. },
  113. created () {
  114. this.list.fetchData()
  115. },
  116. methods: {
  117. fetchData () {
  118. const response = { data: {} }
  119. const data = this.account.sub_accounts.cloudregions
  120. response.data.data = data
  121. return response
  122. },
  123. validateForm () {
  124. return new Promise((resolve, reject) => {
  125. resolve()
  126. })
  127. },
  128. },
  129. }
  130. </script>