VIPList.vue 2.5 KB

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