index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <base-side-page
  3. @cancel="cancelSidePage"
  4. ref="BaseSidePage"
  5. :title="$t('storage.text_37')"
  6. icon="res-blockstorage"
  7. :res-name="detailData.name"
  8. :tabs="detailTabs"
  9. :current-tab="params.windowData.currentTab"
  10. :loaded="loaded"
  11. @tab-change="handleTabChange">
  12. <template v-slot:actions>
  13. <actions
  14. :options="singleActions"
  15. :row="detailData"
  16. button-type="link"
  17. button-size="small" />
  18. </template>
  19. <component
  20. v-bind="hostListActions"
  21. :is="params.windowData.currentTab"
  22. :data="detailData"
  23. :resource="resource"
  24. :on-manager="onManager"
  25. :refresh="refresh"
  26. @refresh="refresh"
  27. :list="params.list"
  28. :getParams="getParams"
  29. :getColumns="getColumns"
  30. :columns="columns"
  31. :res-id="getParams.storage"
  32. :id="listId" />
  33. </base-side-page>
  34. </template>
  35. <script>
  36. import HostList from '@Compute/views/host/components/List'
  37. import DiskRecoveryList from '@Compute/views/disk-recovery/components/List'
  38. import CachedImages from '@Storage/views/blockstorage/sidepage/CachedImages'
  39. import { getStatusTableColumn, getCopyWithContentTableColumn, getProjectTableColumn, getTimeTableColumn } from '@/utils/common/tableColumn'
  40. import SidePageMixin from '@/mixins/sidePage'
  41. import WindowsMixin from '@/mixins/windows'
  42. import Actions from '@/components/PageList/Actions'
  43. import { STORAGE_TYPES } from '@Storage/constants/index.js'
  44. import SingleActionsMixin from '../mixins/singleActions'
  45. import ColumnsMixin from '../mixins/columns'
  46. import Detail from './Detail'
  47. import DiskList from './Disk'
  48. import Monitor from './Monitor'
  49. import SnapshotList from './Snapshot'
  50. export default {
  51. name: 'BlockStorageSidePage',
  52. components: {
  53. Actions,
  54. Detail,
  55. DiskList,
  56. DiskRecoveryList,
  57. HostList,
  58. Monitor,
  59. CachedImages,
  60. SnapshotList,
  61. },
  62. mixins: [SidePageMixin, WindowsMixin, ColumnsMixin, SingleActionsMixin],
  63. data () {
  64. return {
  65. detailTabs: [
  66. { label: this.$t('storage.text_81'), key: 'detail' },
  67. { label: this.$t('storage.text_50'), key: 'host-list' },
  68. { label: this.$t('storage.text_82'), key: 'disk-list' },
  69. { label: this.$t('compute.text_101'), key: 'snapshot-list' },
  70. { label: this.$t('storage.text_83'), key: 'disk-recovery-list' },
  71. { label: this.$t('storage.text_84'), key: 'cached-images' },
  72. { label: this.$t('compute.text_608'), key: 'monitor' },
  73. { label: this.$t('storage.text_85'), key: 'event-drawer' },
  74. ],
  75. }
  76. },
  77. computed: {
  78. getParams () {
  79. return {
  80. storage: this.data.id,
  81. details: true,
  82. }
  83. },
  84. getColumns () {
  85. if (this.params.windowData.currentTab === 'disk-recovery-list') {
  86. return [
  87. getCopyWithContentTableColumn({ field: 'name', title: this.$t('storage.text_40') }),
  88. getCopyWithContentTableColumn({ field: 'guest', title: this.$t('dictionary.server') }),
  89. {
  90. field: 'disk_type',
  91. title: this.$t('storage.text_86'),
  92. width: 70,
  93. formatter: ({ cellValue }) => {
  94. return cellValue === 'sys' ? this.$t('storage.text_87') : this.$t('storage.text_88')
  95. },
  96. },
  97. getStatusTableColumn({ statusModule: 'disk' }),
  98. getProjectTableColumn(),
  99. getTimeTableColumn({ field: 'auto_delete_at', title: this.$t('storage.text_89') }),
  100. ]
  101. }
  102. return null
  103. },
  104. isBlockStorage () {
  105. return ['rbd', 'slvm', 'nfs', 'gpfs'].includes(this.detailData.storage_type)
  106. },
  107. hostListActions () {
  108. const me = this
  109. return {
  110. // this = hostList
  111. frontGroupActions: function () {
  112. return [
  113. {
  114. label: this.$t('storage.text_66'),
  115. permission: 'storages_perform_storages',
  116. action: () => {
  117. this.createDialog('AssociatedHostDialog', {
  118. data: [me.detailData],
  119. columns: me.columns,
  120. title: this.$t('storage.text_66'),
  121. onManager: this.onManager,
  122. refresh: this.refresh,
  123. })
  124. },
  125. meta: () => {
  126. return {
  127. validate: me.isBlockStorage,
  128. tooltip: !me.isBlockStorage && this.$t('storage.text_67', [STORAGE_TYPES[me.detailData.storage_type] || me.detailData.storage_type]),
  129. }
  130. },
  131. },
  132. {
  133. label: this.$t('storage.text_90'),
  134. action: () => {
  135. this.createDialog('UnAssociatedHostDialog', {
  136. title: this.$t('storage.text_90'),
  137. data: this.list.selectedItems,
  138. columns: this.columns,
  139. list: this.list,
  140. resId: me.getParams.storage,
  141. })
  142. },
  143. meta: () => {
  144. return {
  145. validate: this.list.selectedItems.length > 0 && me.isBlockStorage,
  146. }
  147. },
  148. },
  149. ]
  150. },
  151. frontSingleActions: function () {
  152. return [
  153. {
  154. label: this.$t('storage.text_90'),
  155. action: (row) => {
  156. this.createDialog('UnAssociatedHostDialog', {
  157. title: this.$t('storage.text_90'),
  158. data: [row],
  159. columns: this.columns,
  160. list: this.list,
  161. resId: me.getParams.storage,
  162. })
  163. },
  164. meta: () => {
  165. return {
  166. validate: me.isBlockStorage,
  167. }
  168. },
  169. },
  170. ]
  171. },
  172. }
  173. },
  174. listId () {
  175. switch (this.params.windowData.currentTab) {
  176. case 'event-drawer':
  177. return 'EventListForBlockStorageSidePage'
  178. case 'host-list':
  179. return 'HostListForBlockStorageSidePage'
  180. case 'disk-list':
  181. return 'DiskListForBlockStorageSidePage'
  182. case 'disk-recovery-list':
  183. return 'DiskRecoveryListForBlockStorageSidePage'
  184. default:
  185. return ''
  186. }
  187. },
  188. },
  189. created () {
  190. if (this.params.tab) this.handleTabChange(this.params.tab)
  191. },
  192. }
  193. </script>