List.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions"
  7. :showSearchbox="showSearchbox"
  8. :showGroupActions="showGroupActions"
  9. :export-data-options="exportDataOptions" />
  10. </template>
  11. <script>
  12. // import * as R from 'ramda'
  13. import ColumnsMixin from '../mixins/columns'
  14. import SingleActionsMixin from '../mixins/singleActions'
  15. import { getStatusFilter, getEnabledFilter, getTenantFilter, getDomainFilter, getDescriptionFilter } from '@/utils/common/tableFilter'
  16. import WindowsMixin from '@/mixins/windows'
  17. import GlobalSearchMixin from '@/mixins/globalSearch'
  18. import ListMixin from '@/mixins/list'
  19. import expectStatus from '@/constants/expectStatus'
  20. export default {
  21. name: 'ScalingGroupList',
  22. mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin],
  23. props: {
  24. id: String,
  25. getParams: {
  26. type: [Function, Object],
  27. },
  28. },
  29. data () {
  30. return {
  31. list: this.$list.createList(this, {
  32. id: this.id,
  33. resource: 'scalinggroups',
  34. apiVersion: 'v1',
  35. getParams: this.getParam,
  36. steadyStatus: Object.values(expectStatus.scalinggroup).flat(),
  37. filterOptions: {
  38. id: {
  39. label: this.$t('table.title.id'),
  40. },
  41. name: {
  42. label: this.$t('table.title.name'),
  43. filter: true,
  44. formatter: val => {
  45. return `name.contains("${val}")`
  46. },
  47. },
  48. description: getDescriptionFilter(),
  49. status: getStatusFilter('scalinggroup'),
  50. enabled: getEnabledFilter(),
  51. projects: getTenantFilter(),
  52. project_domains: getDomainFilter(),
  53. brand: {
  54. label: this.$t('table.title.brand'),
  55. dropdown: true,
  56. multiple: true,
  57. items: [
  58. { label: this.$t('brand'), key: 'OneCloud' },
  59. ],
  60. },
  61. // region: {
  62. // label: '区域',
  63. // },
  64. guest_template: {
  65. label: this.$t('res.servertemplate'),
  66. },
  67. },
  68. hiddenColumns: ['status', 'created_at'],
  69. }),
  70. exportDataOptions: {
  71. items: [
  72. { label: 'ID', key: 'id' },
  73. { label: this.$t('compute.text_228'), key: 'name' },
  74. { label: this.$t('compute.text_241'), key: 'enabled' },
  75. { label: this.$t('compute.text_268'), key: 'status' },
  76. { label: this.$t('compute.text_873'), key: 'guest_template' },
  77. { label: this.$t('compute.text_874'), key: 'instance_number' },
  78. { label: this.$t('compute.text_875'), key: 'desire_instance_number' },
  79. { label: this.$t('compute.text_876'), key: 'min_instance_number' },
  80. { label: this.$t('compute.text_877'), key: 'max_instance_number' },
  81. { label: this.$t('dictionary.project'), key: 'tenant' },
  82. { label: this.$t('compute.text_176'), key: 'brand' },
  83. ],
  84. },
  85. groupActions: [
  86. {
  87. label: this.$t('compute.perform_create'),
  88. permission: 'scalinggroups_create',
  89. action: () => {
  90. this.$router.push({
  91. name: 'ScalingGroupCreate',
  92. })
  93. },
  94. meta: () => ({
  95. buttonType: 'primary',
  96. }),
  97. },
  98. {
  99. label: this.$t('common.batchAction'),
  100. actions: () => {
  101. return [
  102. {
  103. label: this.$t('compute.text_656'),
  104. permission: 'scalinggroups_perform_enable',
  105. action: () => {
  106. this.createDialog('ScalingGroupEnable', {
  107. data: this.list.selectedItems,
  108. columns: this.columns,
  109. onManager: this.onManager,
  110. })
  111. },
  112. meta: () => ({
  113. validate: this.list.selectedItems.length,
  114. }),
  115. },
  116. {
  117. label: this.$t('compute.text_569'),
  118. permission: 'scalinggroups_perform_disable',
  119. action: () => {
  120. this.createDialog('ScalingGroupDisable', {
  121. data: this.list.selectedItems,
  122. columns: this.columns,
  123. onManager: this.onManager,
  124. })
  125. },
  126. meta: () => ({
  127. validate: this.list.selectedItems.length,
  128. }),
  129. },
  130. {
  131. label: this.$t('compute.perform_delete'),
  132. permission: 'scalinggroups_delete',
  133. action: () => {
  134. this.createDialog('DeleteResDialog', {
  135. title: this.$t('compute.perform_delete'),
  136. name: this.$t('compute.text_95'),
  137. data: this.list.selectedItems,
  138. columns: this.columns,
  139. onManager: this.onManager,
  140. steadyStatus: Object.values(expectStatus.scalinggroup).flat(),
  141. })
  142. },
  143. meta: () => this.$getDeleteResult(this.list.selectedItems),
  144. },
  145. ]
  146. },
  147. meta: () => ({
  148. validate: this.list.selectedItems.length > 0,
  149. }),
  150. },
  151. ],
  152. }
  153. },
  154. created () {
  155. this.list.fetchData()
  156. },
  157. methods: {
  158. handleOpenSidepage (row, tab) {
  159. this.sidePageTriggerHandle(this, 'ScalingGroupSidePage', {
  160. id: row.id,
  161. resource: 'scalinggroups',
  162. getParams: this.getParam,
  163. }, {
  164. list: this.list,
  165. tab,
  166. })
  167. },
  168. },
  169. }
  170. </script>