Network.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns" />
  5. </template>
  6. <script>
  7. // import { SERVER_TYPE } from '@Compute/constants'
  8. import { getCopyWithContentTableColumn } from '@/utils/common/tableColumn'
  9. import WindowsMixin from '@/mixins/windows'
  10. // import { findPlatform } from '@/utils/common/hypervisor'
  11. export default {
  12. name: 'NetworkList',
  13. mixins: [WindowsMixin],
  14. props: {
  15. resId: String,
  16. data: {
  17. type: Object,
  18. required: true,
  19. },
  20. },
  21. data () {
  22. // const type = findPlatform(this.data.host_type)
  23. // const isPublic = type === SERVER_TYPE.private
  24. // const isPrivate = type === SERVER_TYPE.public
  25. return {
  26. list: this.$list.createList(this, {
  27. id: 'NetworkListForHostSidePage',
  28. resource: 'networks',
  29. ctx: [['hosts', this.resId]],
  30. getParams: this.getParams,
  31. filterOptions: {
  32. network: {
  33. label: this.$t('compute.text_228'),
  34. filter: true,
  35. formatter: val => {
  36. return `network.contains("${val}")`
  37. },
  38. },
  39. },
  40. }),
  41. columns: [
  42. {
  43. field: 'index',
  44. title: this.$t('compute.text_375'),
  45. formatter: ({ row }) => {
  46. return row.index ? row.index : '0'
  47. },
  48. },
  49. getCopyWithContentTableColumn({
  50. field: 'network',
  51. title: this.$t('compute.text_106'),
  52. hideField: true,
  53. slotCallback: row => {
  54. return [
  55. <side-page-trigger permission='networks_get' name='NetworkSidePage' id={row.network_id} vm={this}>{ row.network }</side-page-trigger>,
  56. ]
  57. },
  58. }),
  59. {
  60. field: 'nic_type',
  61. title: this.$t('compute.text_860'),
  62. width: 80,
  63. formatter: ({ row }) => {
  64. if (row.nic_type === 'admin') {
  65. return this.$t('compute.text_861')
  66. } else if (row.nic_type === 'ipmi') {
  67. return this.$t('compute.text_862')
  68. } else {
  69. return '-'
  70. }
  71. },
  72. },
  73. getCopyWithContentTableColumn({ field: 'mac_addr', title: this.$t('compute.text_385'), sortable: true }),
  74. getCopyWithContentTableColumn({ field: 'ip_addr', title: this.$t('compute.text_386'), sortable: true }),
  75. getCopyWithContentTableColumn({
  76. field: 'wire',
  77. title: this.$t('network.text_571'),
  78. }),
  79. getCopyWithContentTableColumn({ field: 'driver', title: this.$t('compute.text_378') }),
  80. // {
  81. // field: 'bw_limit',
  82. // title: '带宽限制',
  83. // formatter: ({ row }) => {
  84. // return `${row.bw_limit}Mbps`
  85. // },
  86. // slots: {
  87. // header: ({ column }) => {
  88. // return [
  89. // <a-tooltip title='"0"代表带宽没有限制'>
  90. // <span class='mr-1'>{ column.title }</span>
  91. // <icon type="question" />
  92. // </a-tooltip>,
  93. // ]
  94. // },
  95. // },
  96. // },
  97. ],
  98. // singleActions: [
  99. // {
  100. // label: '修改带宽',
  101. // action: (obj) => {
  102. // this.createDialog('VmChangeBandwidthDialog', {
  103. // data: [obj],
  104. // columns: this.columns,
  105. // list: this.list,
  106. // })
  107. // },
  108. // },
  109. // {
  110. // label: '更换IP',
  111. // action: (obj) => {
  112. // this.createDialog('VmChangeIpDialog', {
  113. // data: [obj],
  114. // columns: this.columns,
  115. // list: this.list,
  116. // zone: this.data.zone_id,
  117. // resId: this.resId,
  118. // })
  119. // },
  120. // meta: (obj) => {
  121. // const ret = {
  122. // validate: false,
  123. // tooltip: null,
  124. // }
  125. // if (isPrivate || isPublic) {
  126. // ret.tooltip = '私有云、公有云不支持此操作'
  127. // return ret
  128. // }
  129. // ret.validate = true
  130. // return ret
  131. // },
  132. // },
  133. // ],
  134. }
  135. },
  136. created () {
  137. this.list.fetchData()
  138. },
  139. methods: {
  140. getParams () {
  141. return {
  142. details: true,
  143. }
  144. },
  145. },
  146. }
  147. </script>