UnbindEip.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('compute.text_1264')}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.instancegroup')" :count="params.data.length" :action="$t('compute.text_1264')" />
  6. <dialog-table :data="params.data" :columns="columns" />
  7. <a-form :form="form.fc" hideRequiredMark>
  8. <a-form-item :label="$t('compute.text_1265')" v-bind="formItemLayout" :extra="$t('compute.text_1266')">
  9. <a-switch :checkedChildren="$t('compute.text_115')" :unCheckedChildren="$t('compute.text_116')" v-decorator="decorators.auto_delete" />
  10. </a-form-item>
  11. </a-form>
  12. </div>
  13. <div slot="footer">
  14. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  15. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  16. </div>
  17. </base-dialog>
  18. </template>
  19. <script>
  20. import DialogMixin from '@/mixins/dialog'
  21. import WindowsMixin from '@/mixins/windows'
  22. export default {
  23. name: 'InstanceGroupUnbindEipDialog',
  24. mixins: [DialogMixin, WindowsMixin],
  25. data () {
  26. return {
  27. loading: false,
  28. form: {
  29. fc: this.$form.createForm(this),
  30. },
  31. decorators: {
  32. auto_delete: [
  33. 'auto_delete',
  34. {
  35. initialValue: false,
  36. valuePropName: 'checked',
  37. },
  38. ],
  39. },
  40. formItemLayout: {
  41. wrapperCol: {
  42. span: 21,
  43. },
  44. labelCol: {
  45. span: 3,
  46. },
  47. },
  48. }
  49. },
  50. computed: {
  51. columns () {
  52. const fields = ['name', 'metadata', 'ip']
  53. return this.params.columns.filter(item => {
  54. const { field } = item
  55. return fields.indexOf(field) > -1
  56. })
  57. },
  58. },
  59. methods: {
  60. async handleConfirm () {
  61. this.loading = true
  62. try {
  63. const values = await this.form.fc.validateFields()
  64. const ids = this.params.data.map(item => item.id)
  65. await this.params.onManager('batchPerformAction', {
  66. id: ids,
  67. steadyStatus: ['running', 'ready'],
  68. managerArgs: {
  69. action: 'dissociate-eip',
  70. data: values,
  71. },
  72. })
  73. this.cancelDialog()
  74. } finally {
  75. this.loading = false
  76. }
  77. },
  78. },
  79. }
  80. </script>