PublicIpToEipDialog.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('compute.text_1121')}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.server')" :count="params.data.length" :action="$t('compute.text_1121')" />
  6. <dialog-table :data="params.data" :columns="columns" />
  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: 'VmPublicIpToEipDialog',
  19. mixins: [DialogMixin, WindowsMixin],
  20. data () {
  21. return {
  22. loading: false,
  23. formItemLayout: {
  24. wrapperCol: {
  25. span: 21,
  26. },
  27. labelCol: {
  28. span: 3,
  29. },
  30. },
  31. }
  32. },
  33. computed: {
  34. columns () {
  35. const showFields = ['name', 'ip', 'brand']
  36. return this.params.columns.filter((item) => { return showFields.includes(item.field) })
  37. },
  38. },
  39. methods: {
  40. doPublicIpToEipSubmit (data) {
  41. const selectedIds = this.params.data.map(item => item.id)
  42. return new this.$Manager('servers', 'v2').batchPerformAction({
  43. ids: selectedIds,
  44. action: 'publicip-to-eip',
  45. })
  46. },
  47. async handleConfirm () {
  48. this.loading = true
  49. try {
  50. await this.doPublicIpToEipSubmit()
  51. this.loading = false
  52. this.cancelDialog()
  53. this.params.refresh()
  54. } catch (error) {
  55. this.loading = false
  56. throw error
  57. }
  58. },
  59. },
  60. }
  61. </script>