List.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 WindowsMixin from '@/mixins/windows'
  10. import { typeClouds } from '@/utils/common/hypervisor'
  11. import ListMixin from '@/mixins/list'
  12. import ColumnsMixin from '../mixins/columns'
  13. import SingleActionsMixin from '../mixins/singleActions'
  14. export default {
  15. name: 'NetworkList',
  16. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
  17. props: {
  18. id: String,
  19. resId: String,
  20. data: {
  21. type: Object,
  22. required: true,
  23. },
  24. serverColumns: {
  25. type: Array,
  26. default: () => ([]),
  27. },
  28. getParams: {
  29. type: Object,
  30. default: () => ({}),
  31. },
  32. hiddenActions: {
  33. type: Array,
  34. default: () => ([]),
  35. },
  36. },
  37. data () {
  38. return {
  39. list: this.$list.createList(this, {
  40. id: this.id,
  41. resource: 'networks',
  42. ctx: [['servers', this.resId]],
  43. idKey: 'index',
  44. getParams: {
  45. order_by: 'index',
  46. order: 'asc',
  47. ...this.getParams,
  48. },
  49. hiddenColumns: ['created_at'],
  50. }),
  51. groupActions: [
  52. {
  53. label: this.$t('compute.text_199'),
  54. permission: 'server_perform_attachnetwork',
  55. action: () => {
  56. this.createDialog('VmSetNetworkDialog', {
  57. title: this.$t('compute.text_199'),
  58. data: [this.data],
  59. columns: this.serverColumns,
  60. resId: this.resId,
  61. refresh: this.refresh,
  62. total: this.list.total,
  63. })
  64. },
  65. meta: () => {
  66. const isOneCloud = this.data.hypervisor === typeClouds.hypervisorMap.kvm.key
  67. let tooltip = null
  68. if (!isOneCloud) {
  69. tooltip = this.$t('compute.text_355')
  70. }
  71. if (this.list.total >= 8) {
  72. tooltip = this.$t('compute.text_731')
  73. }
  74. return {
  75. buttonType: 'primary',
  76. validate: isOneCloud && this.list.total < 8,
  77. tooltip,
  78. }
  79. },
  80. hidden: this.$isScopedPolicyMenuHidden('vminstance_hidden_menus.server_add_network_card'),
  81. },
  82. ],
  83. }
  84. },
  85. created () {
  86. this.initSidePageTab('event-drawer')
  87. this.list.fetchData()
  88. },
  89. methods: {
  90. handleOpenNetworkDetail (id) {
  91. this.initSidePageTab('network-detail')
  92. this.sidePageTriggerHandle(this, 'NetworkSidePage', {
  93. id,
  94. resource: 'networks',
  95. })
  96. },
  97. },
  98. }
  99. </script>