List.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <page-list
  3. :show-tag-filter="true"
  4. :show-tag-columns="true"
  5. :list="list"
  6. :columns="columns"
  7. :group-actions="groupActions"
  8. :single-actions="singleActions"
  9. :export-data-options="exportDataOptions" />
  10. </template>
  11. <script>
  12. import WindowsMixin from '@/mixins/windows'
  13. import ListMixin from '@/mixins/list'
  14. import {
  15. getNameFilter,
  16. getBrandFilter,
  17. getStatusFilter,
  18. getTenantFilter,
  19. getAccountFilter,
  20. getRegionFilter,
  21. getCloudProviderFilter,
  22. getDescriptionFilter,
  23. } from '@/utils/common/tableFilter'
  24. import SingleActionsMixin from '../mixins/singleActions'
  25. import ColumnsMixin from '../mixins/columns'
  26. export default {
  27. name: 'WebAppList',
  28. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  29. props: {
  30. id: String,
  31. getParams: {
  32. type: Object,
  33. },
  34. },
  35. data () {
  36. return {
  37. list: this.$list.createList(this, {
  38. id: this.id,
  39. resource: 'webapps',
  40. getParams: this.getParam,
  41. filterOptions: {
  42. name: getNameFilter(),
  43. description: getDescriptionFilter(),
  44. brand: getBrandFilter('compute_engine_brands'),
  45. status: getStatusFilter('webapp'),
  46. tech_stack: {
  47. label: this.$t('compute.webapp.tech.stack'),
  48. filter: true,
  49. formatter: val => {
  50. return `tech_stack.contains("${val}")`
  51. },
  52. },
  53. projects: getTenantFilter(),
  54. cloudaccount: getAccountFilter(),
  55. manager: getCloudProviderFilter(),
  56. region: getRegionFilter(),
  57. },
  58. }),
  59. exportDataOptions: {
  60. items: [
  61. { label: 'ID', key: 'id' },
  62. { label: this.$t('compute.text_228'), key: 'name' },
  63. { label: this.$t('compute.text_268'), key: 'status' },
  64. { label: this.$t('compute.webapp.tech.stack'), key: 'tech_stack' },
  65. { label: this.$t('compute.webapp.os_type'), key: 'os_type' },
  66. { label: this.$t('compute.webapp.ip_addr'), key: 'ip_addr' },
  67. { label: this.$t('compute.webapp.domain'), key: 'hostname' },
  68. { label: this.$t('compute.webapp.server_farm'), key: 'server_farm' },
  69. { label: this.$t('table.title.brand'), key: 'provider' },
  70. { label: this.$t('res.cloudaccount'), key: 'manager' },
  71. { label: this.$t('res.region'), key: 'region' },
  72. { label: this.$t('res.project'), key: 'tenant' },
  73. { label: this.$t('table.title.user_tag'), key: 'user_tags' },
  74. ],
  75. },
  76. groupActions: [
  77. {
  78. label: this.$t('common.text00043'),
  79. permission: 'webapps_syncstatus',
  80. action: () => {
  81. this.onManager('batchPerformAction', {
  82. steadyStatus: ['ready'],
  83. managerArgs: {
  84. action: 'syncstatus',
  85. },
  86. })
  87. },
  88. meta: () => ({
  89. validate: this.list.selected.length,
  90. }),
  91. },
  92. {
  93. label: this.$t('table.action.set_tag'),
  94. permission: 'webapps_set_user_metadata',
  95. action: () => {
  96. this.createDialog('SetTagDialog', {
  97. data: this.list.selectedItems,
  98. columns: this.columns,
  99. onManager: this.onManager,
  100. mode: 'add',
  101. params: {
  102. resources: 'webapp',
  103. },
  104. tipName: this.$t('compute.webapp'),
  105. })
  106. },
  107. meta: () => ({
  108. validate: this.list.selected.length,
  109. }),
  110. },
  111. ],
  112. }
  113. },
  114. created () {
  115. this.initSidePageTab('detail')
  116. this.list.fetchData()
  117. },
  118. methods: {
  119. getParam () {
  120. const ret = {
  121. ...this.getParams,
  122. details: true,
  123. }
  124. return ret
  125. },
  126. handleOpenSidepage (row, tab) {
  127. this.sidePageTriggerHandle(this, 'WebAppSidePage', {
  128. id: row.id,
  129. resource: 'webapps',
  130. getParams: this.getParam,
  131. }, {
  132. list: this.list,
  133. tab,
  134. })
  135. },
  136. },
  137. }
  138. </script>