DnsAssociateVpcList.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <page-list
  3. show-tag-columns
  4. show-tag-filter
  5. :list="list"
  6. :columns="columns"
  7. :single-actions="singleActions"
  8. :group-actions="groupActions"
  9. :export-data-options="exportDataOptions" />
  10. </template>
  11. <script>
  12. import * as R from 'ramda'
  13. import ColumnsMixin from '@Network/views/vpc/mixins/columns'
  14. import ListMixin from '@/mixins/list'
  15. import expectStatus from '@/constants/expectStatus'
  16. import { getStatusFilter, getBrandFilter, getAccountFilter, getProjectDomainFilter } from '@/utils/common/tableFilter'
  17. import WindowsMixin from '@/mixins/windows'
  18. export default {
  19. name: 'DnsAssocoateVpcList',
  20. mixins: [WindowsMixin, ListMixin, ColumnsMixin],
  21. props: {
  22. id: String,
  23. data: {
  24. type: Object,
  25. },
  26. getParams: {
  27. type: [Function, Object],
  28. },
  29. },
  30. data () {
  31. return {
  32. list: this.$list.createList(this, {
  33. id: this.id,
  34. resource: 'vpcs',
  35. getParams: this.getParam,
  36. steadyStatus: Object.values(expectStatus.vpc).flat(),
  37. filterOptions: {
  38. name: {
  39. label: this.$t('network.text_21'),
  40. filter: true,
  41. formatter: val => {
  42. return `name.contains("${val}")`
  43. },
  44. },
  45. status: getStatusFilter('vpc'),
  46. cloudaccount: getAccountFilter(),
  47. brand: getBrandFilter('brands', ['VMware']),
  48. cidr_block: {
  49. label: this.$t('network.vpc.cidr_block.ipv4.label'),
  50. },
  51. project_domains: getProjectDomainFilter(),
  52. region: {
  53. label: this.$t('common_282'),
  54. },
  55. },
  56. }),
  57. exportDataOptions: {
  58. items: [
  59. { label: 'ID', key: 'id' },
  60. { label: this.$t('network.text_21'), key: 'name' },
  61. { label: this.$t('network.text_27'), key: 'status' },
  62. { label: this.$t('network.vpc.cidr_block.ipv4.label'), key: 'cidr_block' },
  63. { label: this.$t('network.text_199'), key: 'region' },
  64. { label: this.$t('network.text_198'), key: 'provider' },
  65. { label: this.$t('network.text_196'), key: 'manager' },
  66. { label: this.$t('network.text_571'), key: 'wire_count' },
  67. { label: this.$t('network.text_682'), key: 'network_count' },
  68. {
  69. label: this.$t('common_101'),
  70. key: 'public_scope',
  71. hidden: () => {
  72. return !this.$store.getters.l3PermissionEnable && (this.$store.getters.scopeResource && this.$store.getters.scopeResource.domain.includes('vpcs'))
  73. },
  74. },
  75. { label: this.$t('network.text_233', [this.$t('dictionary.domain')]), key: 'project_domain' },
  76. ],
  77. },
  78. groupActions: [
  79. {
  80. label: this.$t('network.text_719'),
  81. permission: 'dns_zones_add_vpcs',
  82. action: () => {
  83. this.createDialog('AssociateVpcDialog', {
  84. title: this.$t('network.text_719'),
  85. data: [this.data],
  86. resData: this.data,
  87. columns: this.columns,
  88. onManager: this.onManager,
  89. refresh: this.refresh,
  90. })
  91. },
  92. meta: () => {
  93. const ret = { ...this.$isOwner(this.data), buttonType: 'primary' }
  94. if (!ret.validate) return ret
  95. if (!this.isAvailable) {
  96. ret.validate = false
  97. ret.tooltip = this.$t('network.text_730')
  98. return ret
  99. }
  100. return ret
  101. },
  102. },
  103. {
  104. label: this.$t('cloudenv.text_452'),
  105. permission: 'dns_zones_remove_vpcs',
  106. action: () => {
  107. this.createDialog('RemoveVpcDialog', {
  108. title: this.$t('cloudenv.text_452'),
  109. data: this.list.selectedItems,
  110. resData: this.data,
  111. columns: this.columns,
  112. onManager: this.onManager,
  113. refresh: this.refresh,
  114. })
  115. },
  116. meta: () => {
  117. const ret = this.$isOwner(this.data)
  118. if (!ret.validate) return ret
  119. if (!this.list.selectedItems.length) {
  120. ret.validate = false
  121. return ret
  122. }
  123. if (!this.isAvailable) {
  124. ret.validate = false
  125. ret.tooltip = this.$t('network.text_730')
  126. return ret
  127. }
  128. return ret
  129. },
  130. },
  131. ],
  132. singleActions: [
  133. {
  134. label: this.$t('cloudenv.text_452'),
  135. permission: 'dns_zones_remove_vpcs',
  136. action: (obj) => {
  137. this.createDialog('RemoveVpcDialog', {
  138. title: this.$t('cloudenv.text_452'),
  139. data: [obj],
  140. resData: this.data,
  141. columns: this.columns,
  142. onManager: this.onManager,
  143. refresh: this.refresh,
  144. })
  145. },
  146. meta: (obj) => {
  147. const ret = this.$isOwner(this.data)
  148. if (!ret.validate) return ret
  149. if (!this.isAvailable) {
  150. ret.validate = false
  151. ret.tooltip = this.$t('network.text_730')
  152. return ret
  153. }
  154. return ret
  155. },
  156. },
  157. ],
  158. }
  159. },
  160. computed: {
  161. isPublicZone () {
  162. return this.data.zone_type === 'PublicZone'
  163. },
  164. isAvailable () {
  165. return this.data.status === 'available'
  166. },
  167. },
  168. created () {
  169. this.initSidePageTab('vpc-detail')
  170. this.list.fetchData()
  171. },
  172. methods: {
  173. getParam () {
  174. const ret = {
  175. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  176. }
  177. return ret
  178. },
  179. handleOpenSidepage (row) {
  180. this.sidePageTriggerHandle(this, 'VpcSidePage', {
  181. id: row.id,
  182. resource: 'vpcs',
  183. getParams: this.getParam,
  184. }, {
  185. list: this.list,
  186. })
  187. },
  188. },
  189. }
  190. </script>