List.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="templateListColumns || columns"
  5. :show-tag-columns="true"
  6. :show-tag-columns2="true"
  7. :show-tag-filter="true"
  8. :export-data-options="exportDataOptions"
  9. :group-actions="groupActions"
  10. :showSearchbox="showSearchbox"
  11. :showGroupActions="showGroupActions"
  12. :single-actions="singleActions"
  13. :show-single-actions="!isTemplate"
  14. :show-page="!isTemplate" />
  15. </template>
  16. <script>
  17. import * as R from 'ramda'
  18. import GlobalSearchMixin from '@/mixins/globalSearch'
  19. import expectStatus from '@/constants/expectStatus'
  20. import WindowsMixin from '@/mixins/windows'
  21. import { getStatusFilter, getNameFilter, getDescriptionFilter, getTenantFilter, getCloudProviderFilter, getAccountFilter } from '@/utils/common/tableFilter'
  22. import { disableDeleteAction } from '@/utils/common/tableActions'
  23. import ListMixin from '@/mixins/list'
  24. import ResTemplateListMixin from '@/mixins/resTemplateList'
  25. import ColumnsMixin from '../mixins/columns'
  26. import SingleActionsMixin from '../mixins/singleActions'
  27. export default {
  28. name: 'ElasticSearchList',
  29. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin, ResTemplateListMixin],
  30. props: {
  31. id: String,
  32. getParams: {
  33. type: [Function, Object],
  34. },
  35. data: {
  36. type: Object,
  37. },
  38. hiddenActions: {
  39. type: Array,
  40. default: () => ([]),
  41. },
  42. },
  43. data () {
  44. return {
  45. list: this.$list.createList(this, {
  46. ctx: this,
  47. id: this.id,
  48. resource: 'elastic_searchs',
  49. getParams: this.getParam,
  50. isTemplate: this.isTemplate,
  51. templateLimit: this.templateLimit,
  52. steadyStatus: Object.values(expectStatus.elasticSearch).flat(),
  53. filterOptions: {
  54. id: {
  55. label: this.$t('table.title.id'),
  56. },
  57. external_id: {
  58. label: this.$t('table.title.external_id'),
  59. },
  60. name: getNameFilter(),
  61. description: getDescriptionFilter(),
  62. status: getStatusFilter('elasticSearch'),
  63. account: getAccountFilter(),
  64. manager: getCloudProviderFilter(),
  65. projects: getTenantFilter(),
  66. region: {
  67. label: this.$t('middleware.cloudregion'),
  68. },
  69. },
  70. responseData: this.responseData,
  71. }),
  72. groupActions: [
  73. {
  74. label: this.$t('middleware.syncstatus'),
  75. permission: 'elastic_searchs_perform_syncstatus',
  76. action: () => {
  77. this.onManager('batchPerformAction', {
  78. steadyStatus: ['available', 'unknown'],
  79. managerArgs: {
  80. action: 'syncstatus',
  81. },
  82. })
  83. },
  84. meta: () => ({
  85. validate: this.list.selected.length,
  86. }),
  87. },
  88. {
  89. label: this.$t('common.batchAction'),
  90. actions: (obj) => {
  91. return [
  92. {
  93. label: this.$t('compute.text_283'),
  94. permission: 'elastic_searchs_perform_set_user_metadata',
  95. action: () => {
  96. this.createDialog('SetTagDialog', {
  97. data: this.list.selectedItems,
  98. columns: this.columns,
  99. onManager: this.onManager,
  100. params: {
  101. resources: 'elastic_searchs',
  102. },
  103. mode: 'add',
  104. })
  105. },
  106. },
  107. disableDeleteAction(Object.assign(this, {
  108. permission: 'elastic_searchs_update',
  109. }), {
  110. name: this.$t('dictionary.elasticsearch'),
  111. }),
  112. {
  113. label: this.$t('middleware.delete'),
  114. permission: 'elastic_searchs_delete',
  115. action: () => {
  116. this.createDialog('DeleteResDialog', {
  117. vm: this,
  118. title: this.$t('middleware.delete'),
  119. data: this.list.selectedItems,
  120. columns: this.columns,
  121. onManager: this.onManager,
  122. refresh: this.refresh,
  123. name: this.$t('dictionary.elasticsearch'),
  124. })
  125. },
  126. meta: () => this.$getDeleteResult(this.list.selectedItems),
  127. },
  128. ]
  129. },
  130. meta: () => {
  131. const selectedLength = this.list.selectedItems.length
  132. return {
  133. validate: selectedLength,
  134. tooltip: '',
  135. }
  136. },
  137. },
  138. ],
  139. }
  140. },
  141. computed: {
  142. exportDataOptions () {
  143. return {
  144. items: [
  145. { label: 'ID', key: 'id' },
  146. ...this.columns,
  147. ],
  148. downloadType: 'local',
  149. title: this.$t('middleware.elasticsearch'),
  150. fixedItems: [
  151. { key: 'disk_size_gb', label: this.$t('table.title.disk') + '(G)' },
  152. { key: 'vmem_size_gb', label: this.$t('table.title.vmem_size') + '(G)' },
  153. { key: 'instance_type', label: this.$t('middleware.config') },
  154. ],
  155. }
  156. },
  157. },
  158. created () {
  159. this.initSidePageTab('elastic-search-detail')
  160. this.list.fetchData()
  161. },
  162. methods: {
  163. getParam () {
  164. const ret = {
  165. ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
  166. detail: true,
  167. }
  168. return ret
  169. },
  170. handleOpenSidepage (row) {
  171. this.sidePageTriggerHandle(this, 'ElasticSearchSidePage', {
  172. id: row.id,
  173. resource: 'elastic_searchs',
  174. getParams: this.getParam,
  175. }, {
  176. list: this.list,
  177. })
  178. },
  179. },
  180. }
  181. </script>