Network.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :single-actions="singleActions" />
  6. </template>
  7. <script>
  8. import { SERVER_TYPE } from '@Compute/constants'
  9. import { getCopyWithContentTableColumn } from '@/utils/common/tableColumn'
  10. import WindowsMixin from '@/mixins/windows'
  11. import { findPlatform } from '@/utils/common/hypervisor'
  12. export default {
  13. name: 'NetworkListForBaremetalSidepage',
  14. mixins: [WindowsMixin],
  15. props: {
  16. resId: String,
  17. data: {
  18. type: Object,
  19. required: true,
  20. },
  21. getParams: {
  22. type: Object,
  23. },
  24. },
  25. data () {
  26. const type = findPlatform(this.data.hypervisor)
  27. const isPublic = type === SERVER_TYPE.private
  28. const isPrivate = type === SERVER_TYPE.public
  29. return {
  30. list: this.$list.createList(this, {
  31. id: 'NetworkListForBaremetalSidepage',
  32. resource: 'networks',
  33. ctx: [['servers', this.resId]],
  34. idKey: 'network_id',
  35. getParams: this.getParams,
  36. }),
  37. columns: [
  38. {
  39. field: 'index',
  40. title: this.$t('compute.text_375'),
  41. width: 50,
  42. formatter: (data) => {
  43. return data.seq
  44. },
  45. },
  46. getCopyWithContentTableColumn({ field: 'network', title: this.$t('compute.text_384'), sortable: true }),
  47. getCopyWithContentTableColumn({ field: 'mac_addr', title: this.$t('compute.text_385'), sortable: true }),
  48. getCopyWithContentTableColumn({ field: 'ip_addr', title: this.$t('compute.text_386'), sortable: true }),
  49. getCopyWithContentTableColumn({ field: 'driver', title: this.$t('compute.text_378') }),
  50. ],
  51. singleActions: [
  52. {
  53. label: this.$t('compute.text_390'),
  54. action: (obj) => {
  55. this.createDialog('VmChangeIpDialog', {
  56. data: [obj],
  57. columns: this.columns,
  58. list: this.list,
  59. zone: this.data.zone_id,
  60. resId: this.resId,
  61. refresh: this.refresh,
  62. })
  63. },
  64. meta: (obj) => {
  65. const ret = {
  66. validate: false,
  67. tooltip: null,
  68. }
  69. if (isPrivate || isPublic) {
  70. ret.tooltip = this.$t('compute.text_391')
  71. return ret
  72. }
  73. ret.validate = true
  74. return ret
  75. },
  76. },
  77. ],
  78. }
  79. },
  80. created () {
  81. this.list.fetchData()
  82. },
  83. }
  84. </script>