ServerRemove.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('compute.text_950')}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :count="params.data.length" :action="$t('compute.text_950')" :name="$t('compute.text_91')" />
  6. <dialog-table :data="params.data" :columns="columns" />
  7. <a-form v-bind="formItemLayout">
  8. <a-form-item :label="$t('compute.text_951')">
  9. <a-radio-group v-model="isDelete">
  10. <a-radio :value="true">{{$t('compute.text_952')}}</a-radio>
  11. <a-radio :value="false">{{$t('compute.text_953')}}</a-radio>
  12. </a-radio-group>
  13. </a-form-item>
  14. </a-form>
  15. </div>
  16. <div slot="footer">
  17. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  18. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  19. </div>
  20. </base-dialog>
  21. </template>
  22. <script>
  23. import DialogMixin from '@/mixins/dialog'
  24. import WindowsMixin from '@/mixins/windows'
  25. export default {
  26. name: 'ScalingGroupServerRemoveDialog',
  27. mixins: [DialogMixin, WindowsMixin],
  28. data () {
  29. return {
  30. loading: false,
  31. isDelete: true,
  32. formItemLayout: {
  33. labelCol: { span: 3 },
  34. wrapperCol: { span: 20 },
  35. },
  36. }
  37. },
  38. computed: {
  39. columns () {
  40. const fields = ['name', 'scaling_status', 'status']
  41. return this.params.columns.filter(item => {
  42. const { field } = item
  43. return fields.indexOf(field) > -1
  44. })
  45. },
  46. },
  47. methods: {
  48. async handleConfirm () {
  49. this.loading = true
  50. const { data } = this.params
  51. const manager = new this.$Manager('servers')
  52. try {
  53. const ids = data.map(({ id }) => id)
  54. await manager.batchPerformAction({
  55. ids,
  56. action: 'detach-scaling-group',
  57. data: {
  58. scaling_group: this.params.resId,
  59. delete_server: this.isDelete,
  60. },
  61. })
  62. this.cancelDialog()
  63. this.params.refresh()
  64. } catch (err) {
  65. throw err
  66. } finally {
  67. this.loading = false
  68. }
  69. },
  70. },
  71. }
  72. </script>