RelatedResourceServer.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :group-actions="groupActions"
  6. :single-actions="singleActions" />
  7. </template>
  8. <script>
  9. import { getNameDescriptionTableColumn, getStatusTableColumn } from '@/utils/common/tableColumn'
  10. import { getStatusFilter, getHostFilter } from '@/utils/common/tableFilter'
  11. import expectStatus from '@/constants/expectStatus'
  12. import WindowsMixin from '@/mixins/windows'
  13. import ListMixin from '@/mixins/list'
  14. import { RES_SIDEPAGE_MAP } from '../constants'
  15. export default {
  16. name: 'RelatedResourceServerListSidePage',
  17. mixins: [WindowsMixin, ListMixin],
  18. props: {
  19. id: String,
  20. data: {
  21. type: Object,
  22. },
  23. params: {
  24. type: Object,
  25. },
  26. },
  27. data () {
  28. const labels = this.data.labels || []
  29. return {
  30. list: this.$list.createList(this, {
  31. id: this.id,
  32. key: 'id',
  33. resource: `${this.data.resource_type}s`,
  34. getParams: {
  35. filter: `id.in(${labels.join(',')})`,
  36. ...this.params,
  37. },
  38. steadyStatus: Object.values(expectStatus.scalingserver).flat().concat(Object.values(expectStatus.server).flat()),
  39. filterOptions: {
  40. name: {
  41. label: this.$t('cloudenv.text_95'),
  42. filter: true,
  43. formatter: val => {
  44. return `name.contains("${val}")`
  45. },
  46. },
  47. status: getStatusFilter(this.data.resource_type),
  48. host: getHostFilter(),
  49. },
  50. }),
  51. columns: [
  52. getNameDescriptionTableColumn({
  53. onManager: this.onManager,
  54. hideField: true,
  55. addLock: true,
  56. addBackup: true,
  57. formRules: [
  58. { required: true, message: this.$t('cloudenv.text_190') },
  59. { validator: this.$validate('serverCreateName') },
  60. ],
  61. slotCallback: row => {
  62. return (
  63. <side-page-trigger permission={`${this.data.resource_type}_get`} name={RES_SIDEPAGE_MAP[this.data.resource_type]} id={row.id} vm={this}>{ row.name }</side-page-trigger>
  64. )
  65. },
  66. }),
  67. getStatusTableColumn({ title: this.$t('cloudenv.text_98'), statusModule: this.data.resource_type, width: 130 }),
  68. ],
  69. singleActions: [
  70. {
  71. label: this.$t('cloudenv.text_452'),
  72. permission: 'scheduledtasks_perform_set_label',
  73. action: (row) => {
  74. this.createDialog('RelatedResourceRemoveDialog', {
  75. title: this.$t('cloudenv.text_452'),
  76. data: [row],
  77. resData: this.data,
  78. columns: this.columns,
  79. refresh: this.refresh,
  80. onManager: this.onManager,
  81. success: (labels) => {
  82. this.list.getParams = {
  83. filter: `id.in(${labels.join(',')})`,
  84. }
  85. this.list.fetchData()
  86. },
  87. })
  88. },
  89. },
  90. ],
  91. groupActions: [
  92. // {
  93. // label: this.$t('cloudenv.text_454'),
  94. // permission: 'scheduledtasks_perform_set_label',
  95. // action: () => {
  96. // this.createDialog('ScheduledtaskEditDialog', {
  97. // data: [this.data],
  98. // columns: this.columns,
  99. // onManager: this.onManager,
  100. // title: this.$t('cloudenv.text_454'),
  101. // success: (labels) => {
  102. // this.list.getParams = {
  103. // filter: `id.in(${labels.join(',')})`,
  104. // }
  105. // this.list.fetchData()
  106. // },
  107. // })
  108. // },
  109. // meta: () => {
  110. // return {
  111. // buttonType: 'primary',
  112. // }
  113. // },
  114. // },
  115. {
  116. label: this.$t('cloudenv.text_452'),
  117. permission: 'scheduledtasks_perform_set_label',
  118. action: () => {
  119. this.createDialog('RelatedResourceRemoveDialog', {
  120. title: this.$t('cloudenv.text_452'),
  121. data: this.list.selectedItems,
  122. resData: this.data,
  123. columns: this.columns,
  124. // refresh: this.refresh,
  125. onManager: this.onManager,
  126. success: (labels) => {
  127. this.list.getParams = {
  128. filter: `id.in(${labels.join(',')})`,
  129. }
  130. this.list.fetchData()
  131. },
  132. })
  133. },
  134. meta: () => {
  135. const ret = {
  136. validate: false,
  137. tooltip: null,
  138. }
  139. ret.validate = this.list.selectedItems.length > 0
  140. return ret
  141. },
  142. },
  143. ],
  144. }
  145. },
  146. created () {
  147. this.list.fetchData()
  148. this.$bus.$on('RelatedResourceServerListSidePageRefresh', labels => {
  149. this.list.getParams = {
  150. filter: `id.in(${labels.join(',')})`,
  151. }
  152. this.list.fetchData()
  153. }, this)
  154. },
  155. }
  156. </script>