DowntimeMigrate.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{this.params.name}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.host')" :count="params.data.length" :action="$t('compute.text_547')" />
  6. <dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. <a-form
  8. :form="form.fc">
  9. <a-form-item :label="$t('compute.text_548')" v-bind="formItemLayout" :extra="$t('compute.text_549')">
  10. <a-switch v-decorator="decorators.enable" :checkedChildren="$t('compute.text_115')" :unCheckedChildren="$t('compute.text_116')" />
  11. </a-form-item>
  12. </a-form>
  13. </div>
  14. <div slot="footer">
  15. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  16. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  17. </div>
  18. </base-dialog>
  19. </template>
  20. <script>
  21. import DialogMixin from '@/mixins/dialog'
  22. import WindowsMixin from '@/mixins/windows'
  23. export default {
  24. name: 'DowntimeMigrateDialog',
  25. mixins: [DialogMixin, WindowsMixin],
  26. data () {
  27. return {
  28. loading: false,
  29. scope: this.$store.getters.scope,
  30. form: {
  31. fc: this.$form.createForm(this),
  32. },
  33. decorators: {
  34. enable: [
  35. 'enable',
  36. {
  37. initialValue: this.params.data[0].auto_migrate_on_host_down,
  38. valuePropName: 'checked',
  39. },
  40. ],
  41. },
  42. formItemLayout: {
  43. wrapperCol: {
  44. span: 20,
  45. },
  46. labelCol: {
  47. span: 4,
  48. },
  49. },
  50. }
  51. },
  52. methods: {
  53. doMigrate (data) {
  54. data = {
  55. auto_migrate_on_host_down: data.enable ? 'enable' : 'disable',
  56. }
  57. return this.params.onManager('performAction', {
  58. id: this.params.data[0].id,
  59. managerArgs: {
  60. action: 'auto-migrate-on-host-down',
  61. data,
  62. },
  63. })
  64. },
  65. async handleConfirm () {
  66. this.loading = true
  67. try {
  68. const values = await this.form.fc.validateFields()
  69. await this.doMigrate(values)
  70. this.loading = false
  71. this.cancelDialog()
  72. } catch (error) {
  73. this.loading = false
  74. }
  75. },
  76. },
  77. }
  78. </script>