Detail.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <detail
  3. :onManager="onManager"
  4. :data="data"
  5. :base-info="baseInfo"
  6. :extra-info="extraInfo"
  7. resource="storages"
  8. statusModule="blockstorage" />
  9. </template>
  10. <script>
  11. // import BrandIcon from '@/sections/BrandIcon'
  12. import { STORAGE_TYPES, MEDIUM_TYPES } from '@Storage/constants/index.js'
  13. import { sizestr } from '@/utils/utils'
  14. import WindowsMixin from '@/mixins/windows'
  15. import {
  16. getBrandTableColumn,
  17. getEnabledTableColumn,
  18. getPublicScopeTableColumn,
  19. } from '@/utils/common/tableColumn'
  20. import {
  21. getUserTagColumn,
  22. getExtTagColumn,
  23. } from '@/utils/common/detailColumn'
  24. import ColumnsMixin from '../mixins/columns'
  25. export default {
  26. name: 'BlockStorageDetail',
  27. mixins: [WindowsMixin, ColumnsMixin],
  28. props: {
  29. data: {
  30. type: Object,
  31. required: true,
  32. },
  33. onManager: {
  34. type: Function,
  35. required: true,
  36. },
  37. refresh: {
  38. type: Function,
  39. required: true,
  40. },
  41. columns: Array,
  42. },
  43. data () {
  44. return {
  45. baseInfo: [
  46. getUserTagColumn({
  47. onManager: this.onManager,
  48. resource: 'storage',
  49. columns: () => this.columns,
  50. tipName: this.$t('storage.text_37'),
  51. editCheck: (row) => (row.provider || '').toLowerCase() !== 'bingocloud',
  52. }),
  53. getExtTagColumn({
  54. onManager: this.onManager,
  55. resource: 'storage',
  56. columns: () => this.columns,
  57. tipName: this.$t('storage.text_37'),
  58. editCheck: (row) => (row.provider || '').toLowerCase() !== 'bingocloud',
  59. }),
  60. getPublicScopeTableColumn({ vm: this, resource: 'storages' }),
  61. getBrandTableColumn(),
  62. getEnabledTableColumn(),
  63. {
  64. field: 'storage_type',
  65. title: this.$t('storage.text_38'),
  66. slots: {
  67. default: ({ row }) => {
  68. return STORAGE_TYPES[row.storage_type] || row.storage_type || '-'
  69. },
  70. },
  71. },
  72. {
  73. field: 'medium_type',
  74. title: this.$t('storage.text_39'),
  75. slots: {
  76. default: ({ row }) => {
  77. return MEDIUM_TYPES[row.medium_type] || '-'
  78. },
  79. },
  80. },
  81. {
  82. field: 'schedtags',
  83. title: this.$t('compute.text_541'),
  84. formatter: ({ cellValue, row }) => {
  85. if (row.schedtags && row.schedtags.length > 0) {
  86. const schedtags = row.schedtags.map(v => v.name)
  87. return schedtags.join(',')
  88. }
  89. return '-'
  90. },
  91. },
  92. ],
  93. }
  94. },
  95. computed: {
  96. extraInfo () {
  97. const _extraInfo = [
  98. {
  99. title: this.$t('storage.text_76'),
  100. items: [
  101. {
  102. field: 'capacity',
  103. title: this.$t('storage.text_177'),
  104. formatter: ({ row }) => {
  105. const capacity = this._sizestr(row.capacity)
  106. const allowedBrands = ['VMware', 'OneCloud']
  107. const actual_capacity_used = sizestr(row.actual_capacity_used, 'M', 1024)
  108. return allowedBrands.includes(row.brand) ? this.$t('storage.text_179', [actual_capacity_used, capacity]) : capacity
  109. },
  110. },
  111. {
  112. field: 'commit_bound',
  113. title: this.$t('storage.text_60'),
  114. slots: {
  115. default: ({ row }) => {
  116. return [
  117. <a class="edit-item" onClick={this.updateCommitBound}>{row.commit_bound} <a class="edit-icon"><a-icon type='edit' /></a></a>,
  118. ]
  119. },
  120. },
  121. },
  122. {
  123. field: 'virtual_capacity',
  124. title: this.$t('storage.text_43'),
  125. slots: {
  126. default: ({ row }) => {
  127. return this._sizestr(row.virtual_capacity)
  128. },
  129. },
  130. },
  131. {
  132. field: 'commit_rate',
  133. title: this.$t('storage.text_77'),
  134. },
  135. {
  136. field: 'used_capacity',
  137. title: this.$t('storage.text_44'),
  138. slots: {
  139. default: ({ row }) => {
  140. return this._sizestr(row.used_capacity)
  141. },
  142. },
  143. },
  144. {
  145. field: 'reserved',
  146. title: this.$t('storage.text_78'),
  147. slots: {
  148. default: ({ row }) => {
  149. return this._sizestr(row.reserved)
  150. },
  151. },
  152. },
  153. {
  154. field: 'waste_capacity',
  155. title: this.$t('storage.text_79'),
  156. slots: {
  157. default: ({ row }) => {
  158. return this._sizestr(row.waste_capacity)
  159. },
  160. },
  161. },
  162. ],
  163. },
  164. ]
  165. if (this.data.storage_type === 'rbd') {
  166. return _extraInfo.concat({
  167. title: this.$t('storage.text_80'),
  168. items: [
  169. {
  170. field: 'storage_conf.mon_host',
  171. title: 'Ceph Mon Host',
  172. },
  173. {
  174. field: 'storage_conf.pool',
  175. title: 'Ceph Pool',
  176. },
  177. ],
  178. })
  179. }
  180. if (this.data.storage_type === 'nfs') {
  181. return _extraInfo.concat({
  182. title: this.$t('storage.text_80'),
  183. items: [
  184. {
  185. field: 'storage_conf.nfs_host',
  186. title: 'NFS Host',
  187. },
  188. {
  189. field: 'storage_conf.nfs_shared_dir',
  190. title: 'NFS Shared Dir',
  191. },
  192. ],
  193. })
  194. }
  195. return _extraInfo
  196. },
  197. },
  198. methods: {
  199. _sizestr (value) {
  200. if (!value) return '-'
  201. return sizestr(value, 'M', 1024)
  202. },
  203. updateCommitBound () {
  204. this.createDialog('BlockStorageUpdateCommitBoundDialog', {
  205. data: [this.data],
  206. columns: this.columns,
  207. title: this.$t('storage.text_34'),
  208. onManager: this.onManager,
  209. refresh: this.refresh,
  210. })
  211. },
  212. },
  213. }
  214. </script>
  215. <style lang="less" scoped>
  216. .edit-item {
  217. .edit-icon {
  218. display: none;
  219. }
  220. &:hover .edit-icon {
  221. display: inline;
  222. }
  223. }
  224. </style>