List.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div>
  3. <page-list
  4. :list="list"
  5. :columns="templateListColumns || columns"
  6. :show-tag-filter="true"
  7. :show-tag-columns="true"
  8. :group-actions="groupActions"
  9. :single-actions="singleActions"
  10. :showSearchbox="showSearchbox"
  11. :showGroupActions="showGroupActions"
  12. :export-data-options="exportDataOptions"
  13. :show-single-actions="!isTemplate"
  14. :show-page="!isTemplate" />
  15. </div>
  16. </template>
  17. <script>
  18. import * as R from 'ramda'
  19. import expectStatus from '@/constants/expectStatus'
  20. import { getNameFilter, getDescriptionFilter, getBrandFilter, getAccountFilter, getProjectDomainFilter, getRegionFilter, getCloudProviderFilter } from '@/utils/common/tableFilter'
  21. import WindowsMixin from '@/mixins/windows'
  22. import ListMixin from '@/mixins/list'
  23. import GlobalSearchMixin from '@/mixins/globalSearch'
  24. import ResTemplateListMixin from '@/mixins/resTemplateList'
  25. import SingleActionsMixin from '../mixins/singleActions'
  26. import ColumnsMixin from '../mixins/columns'
  27. export default {
  28. name: 'WafList',
  29. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin, ResTemplateListMixin],
  30. props: {
  31. id: String,
  32. getParams: {
  33. type: [Function, Object],
  34. default: () => ({}),
  35. },
  36. },
  37. data () {
  38. return {
  39. list: this.$list.createList(this, {
  40. ctx: this,
  41. id: this.id,
  42. apiVersion: 'v2',
  43. resource: 'waf_instances',
  44. getParams: this.getParam,
  45. isTemplate: this.isTemplate,
  46. templateLimit: this.templateLimit,
  47. filterOptions: {
  48. id: {
  49. label: this.$t('network.waf.id'),
  50. },
  51. external_id: {
  52. label: this.$t('table.title.external_id'),
  53. },
  54. name: getNameFilter(),
  55. description: getDescriptionFilter(),
  56. type: {
  57. label: this.$t('network.waf.type'),
  58. dropdown: true,
  59. multiple: true,
  60. distinctField: {
  61. type: 'field',
  62. key: 'type',
  63. },
  64. },
  65. brand: getBrandFilter(),
  66. account: getAccountFilter(),
  67. manager: getCloudProviderFilter(),
  68. project_domain: getProjectDomainFilter(),
  69. region: getRegionFilter(),
  70. },
  71. hiddenColumns: [],
  72. steadyStatus: {
  73. status: Object.values(expectStatus.waf).flat(),
  74. },
  75. }),
  76. groupActions: [
  77. {
  78. label: this.$t('table.action.set_tag'),
  79. permission: 'waf_instances_perform_set_user_metadata',
  80. action: () => {
  81. this.createDialog('SetTagDialog', {
  82. data: this.list.selectedItems,
  83. columns: this.columns,
  84. onManager: this.onManager,
  85. mode: 'add',
  86. params: {
  87. resources: 'waf_instance',
  88. },
  89. tipName: this.$t('network.waf'),
  90. })
  91. },
  92. meta: () => {
  93. return {
  94. validate: this.list.selectedItems.length,
  95. }
  96. },
  97. },
  98. {
  99. label: this.$t('cloudenv.text_108'),
  100. permission: 'waf_instances_delete',
  101. action: () => {
  102. this.createDialog('DeleteWafInstancesDialog', {
  103. vm: this,
  104. data: this.list.selectedItems,
  105. columns: this.columns,
  106. title: this.$t('network.waf.delete'),
  107. name: this.$t('network.waf'),
  108. onManager: this.onManager,
  109. })
  110. },
  111. meta: () => {
  112. return {
  113. validate: this.list.selectedItems.length,
  114. }
  115. },
  116. },
  117. ],
  118. }
  119. },
  120. computed: {
  121. exportDataOptions () {
  122. return {
  123. items: [
  124. { label: 'ID', key: 'id' },
  125. ...this.columns,
  126. ],
  127. downloadType: 'local',
  128. title: this.$t('dictionary.waf_instance'),
  129. }
  130. },
  131. },
  132. created () {
  133. this.list.fetchData()
  134. },
  135. methods: {
  136. getParam () {
  137. const ret = {
  138. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  139. details: true,
  140. }
  141. return ret
  142. },
  143. refresh () {
  144. this.list.fetchData()
  145. },
  146. handleOpenSidepage (row, tab) {
  147. this.sidePageTriggerHandle(this, 'WafSidePage', {
  148. id: row.id,
  149. title: row.name,
  150. resource: 'waf_instances',
  151. apiVersion: 'v2',
  152. getParams: this.getParams,
  153. refresh: this.refresh,
  154. }, {
  155. list: this.list,
  156. tab,
  157. })
  158. this.initSidePageTab(tab)
  159. },
  160. },
  161. }
  162. </script>