List.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <page-list
  3. show-tag-column
  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 { mapGetters } from 'vuex'
  13. import ColumnsMixin from '../mixins/columns'
  14. import SingleActionsMixin from '../mixins/singleActions'
  15. import ListMixin from '@/mixins/list'
  16. import expectStatus from '@/constants/expectStatus'
  17. import { getStatusFilter, getProjectDomainFilter, getDescriptionFilter, getCreatedAtFilter } from '@/utils/common/tableFilter'
  18. import WindowsMixin from '@/mixins/windows'
  19. import { getDomainChangeOwnerAction, getSetPublicAction } from '@/utils/common/tableActions'
  20. export default {
  21. name: 'globalVpcList',
  22. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  23. props: {
  24. id: String,
  25. getParams: {
  26. type: Object,
  27. },
  28. },
  29. data () {
  30. return {
  31. list: this.$list.createList(this, {
  32. id: this.id,
  33. resource: 'globalvpcs',
  34. getParams: this.getParam,
  35. steadyStatus: Object.values(expectStatus.globalVpc).flat(),
  36. filterOptions: {
  37. id: {
  38. label: this.$t('table.title.id'),
  39. },
  40. name: {
  41. label: this.$t('network.text_21'),
  42. filter: true,
  43. formatter: val => {
  44. return `name.contains("${val}")`
  45. },
  46. },
  47. description: getDescriptionFilter(),
  48. status: getStatusFilter('globalVpc'),
  49. project_domains: getProjectDomainFilter(),
  50. created_at: getCreatedAtFilter(),
  51. },
  52. hiddenColumns: ['created_at'],
  53. }),
  54. exportDataOptions: {
  55. items: [
  56. { label: 'ID', key: 'id' },
  57. { label: this.$t('network.text_21'), key: 'name' },
  58. { label: this.$t('network.text_27'), key: 'status' },
  59. { label: this.$t('network.text_232'), key: 'public_scope' },
  60. {
  61. label: this.$t('network.text_232'),
  62. key: 'public_scope',
  63. hidden: () => {
  64. return !this.$store.getters.l3PermissionEnable && (this.$store.getters.scopeResource && this.$store.getters.scopeResource.domain.includes('globalvpcs'))
  65. },
  66. },
  67. { label: this.$t('network.text_233', [this.$t('dictionary.domain')]), key: 'project_domain' },
  68. { label: this.$t('common.createdAt'), key: 'created_at' },
  69. ],
  70. },
  71. groupActions: [
  72. {
  73. label: this.$t('network.text_26'),
  74. permission: 'network_globalvpcs_create',
  75. action: () => {
  76. this.$router.push({
  77. path: '/globalvpc/create',
  78. })
  79. },
  80. meta: () => {
  81. return {
  82. buttonType: 'primary',
  83. }
  84. },
  85. },
  86. {
  87. label: this.$t('common.batchAction'),
  88. actions: () => {
  89. return [
  90. {
  91. label: this.$t('network.text_201'),
  92. permission: 'network_globalvpcs_perform_syncstatus',
  93. action: () => {
  94. this.onManager('batchPerformAction', {
  95. steadyStatus: ['running', 'ready'],
  96. managerArgs: {
  97. action: 'syncstatus',
  98. },
  99. })
  100. },
  101. meta: () => {
  102. if (this.list.selectedItems.some(item => !this.isPower(item))) {
  103. return {
  104. validate: false,
  105. tooltip: this.$t('network.text_627'),
  106. }
  107. }
  108. return {
  109. validate: true,
  110. }
  111. },
  112. },
  113. getDomainChangeOwnerAction(this, {
  114. name: this.$t('dictionary.globalvpc'),
  115. resource: 'globalvpcs',
  116. }, {
  117. permission: 'network_globalvpcs_perform_syncstatus',
  118. }),
  119. getSetPublicAction(this, {
  120. name: this.$t('dictionary.globalvpc'),
  121. scope: 'domain',
  122. resource: 'globalvpcs',
  123. }, {
  124. permission: 'network_globalvpcs_perform_public',
  125. }),
  126. {
  127. label: this.$t('table.action.set_tag'),
  128. permission: 'network_globalvpcs_perform_set_user_metadata',
  129. action: () => {
  130. this.createDialog('SetTagDialog', {
  131. data: this.list.selectedItems,
  132. columns: this.columns,
  133. onManager: this.onManager,
  134. mode: 'add',
  135. params: {
  136. resources: 'globalvpc',
  137. },
  138. tipName: this.$t('dictionary.globalvpc'),
  139. })
  140. },
  141. meta: () => {
  142. if (this.list.selectedItems.some(item => !this.isPower(item))) {
  143. return {
  144. validate: false,
  145. tooltip: this.$t('network.text_627'),
  146. }
  147. }
  148. return {
  149. validate: true,
  150. }
  151. },
  152. },
  153. {
  154. label: this.$t('network.text_131'),
  155. permission: 'network_globalvpcs_delete',
  156. action: () => {
  157. this.createDialog('DeleteResDialog', {
  158. vm: this,
  159. name: this.$t('dictionary.globalvpc'),
  160. data: this.list.selectedItems,
  161. columns: this.columns,
  162. title: this.$t('network.text_131'),
  163. onManager: this.onManager,
  164. })
  165. },
  166. meta: () => {
  167. return {
  168. validate: this.list.allowDelete(),
  169. }
  170. },
  171. },
  172. ]
  173. },
  174. meta: () => {
  175. return {
  176. validate: this.list.selectedItems && this.list.selectedItems.length,
  177. }
  178. },
  179. },
  180. ],
  181. }
  182. },
  183. computed: {
  184. ...mapGetters(['isAdminMode', 'isDomainMode', 'userInfo']),
  185. },
  186. created () {
  187. this.initSidePageTab('detail')
  188. this.list.fetchData()
  189. },
  190. methods: {
  191. isPower (obj) {
  192. if (this.isAdminMode) return true
  193. if (this.isDomainMode) return obj.domain_id === this.userInfo.projectDomainId
  194. return false
  195. },
  196. getParam () {
  197. const ret = {
  198. ...this.getParams,
  199. details: true,
  200. }
  201. return ret
  202. },
  203. handleOpenSidepage (row, tab) {
  204. this.sidePageTriggerHandle(this, 'globalVpcSidePage', {
  205. id: row.id,
  206. resource: 'globalvpcs',
  207. getParams: this.getParam,
  208. }, {
  209. list: this.list,
  210. tab,
  211. })
  212. },
  213. },
  214. }
  215. </script>