UnbindEip.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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('network.text_714')" :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: 'LbUnbindEipDialog',
  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', 'vpc', 'address']
  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: ['enabled'],
  68. managerArgs: {
  69. action: 'dissociate-eip',
  70. data: values,
  71. },
  72. })
  73. this.params.singleRefresh && this.params.singleRefresh(this.params.data[0].id)
  74. this.cancelDialog()
  75. } finally {
  76. this.loading = false
  77. }
  78. },
  79. },
  80. }
  81. </script>