UnbindServer.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('compute.text_716', [params.resourceName || $t('dictionary.instancegroup')])}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="params.resourceName || $t('dictionary.server')" :count="params.data.length" :action="$t('compute.text_715', [$t('dictionary.instancegroup')])" />
  6. <dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. </div>
  8. <div slot="footer">
  9. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  10. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  11. </div>
  12. </base-dialog>
  13. </template>
  14. <script>
  15. import DialogMixin from '@/mixins/dialog'
  16. import WindowsMixin from '@/mixins/windows'
  17. export default {
  18. name: 'InstanceGroupUnbindServerDialog',
  19. mixins: [DialogMixin, WindowsMixin],
  20. data () {
  21. return {
  22. loading: false,
  23. }
  24. },
  25. methods: {
  26. async handleConfirm () {
  27. this.loading = true
  28. const manager = new this.$Manager('instancegroups')
  29. const data = {}
  30. for (let i = 0, len = this.params.data.length; i < len; i++) {
  31. data[`guest.${i}`] = this.params.data[i].id
  32. }
  33. try {
  34. await manager.performAction({
  35. id: this.params.instanceGroupId,
  36. action: 'unbind-guests',
  37. data,
  38. })
  39. this.params.refresh()
  40. this.cancelDialog()
  41. this.$bus.$emit('InstanceGroupListRefresh', this.params.instanceGroupId)
  42. } finally {
  43. this.loading = false
  44. }
  45. },
  46. },
  47. }
  48. </script>