SwitchBackup2.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('compute.text_1259')}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.server')" :count="params.data.length" :action="$t('compute.guest_switch_to_backup')" />
  6. <dialog-table :data="params.data" :columns="columns" />
  7. <a-form :form="form.fc" hideRequiredMark>
  8. <a-form-item :label="$t('compute.text_494')" v-bind="formItemLayout" :extra="$t('compute.text_495')">
  9. <a-switch :checkedChildren="$t('compute.text_115')" :unCheckedChildren="$t('compute.text_116')" v-decorator="decorators.auto_start" />
  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: 'VmSwitchBackup2Dialog',
  24. mixins: [DialogMixin, WindowsMixin],
  25. data () {
  26. return {
  27. loading: false,
  28. form: {
  29. fc: this.$form.createForm(this),
  30. },
  31. decorators: {
  32. auto_start: [
  33. 'auto_start',
  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 col = this.params.columns.slice(0, 3)
  53. col.push({
  54. field: 'backup_host_status',
  55. title: this.$t('compute.text_1163'),
  56. width: 120,
  57. showOverflow: 'ellipsis',
  58. slots: {
  59. default: ({ row }) => {
  60. return [<status status={ row.backup_host_status } statusModule='host_status'/>]
  61. },
  62. },
  63. })
  64. return col
  65. },
  66. },
  67. created () {
  68. },
  69. methods: {
  70. async handleConfirm () {
  71. this.loading = true
  72. try {
  73. const values = await this.form.fc.validateFields()
  74. const ids = this.params.data.map(item => item.id)
  75. await this.params.onManager('batchPerformAction', {
  76. id: ids,
  77. steadyStatus: ['running', 'ready'],
  78. managerArgs: {
  79. action: 'switch-to-backup',
  80. data: values,
  81. },
  82. })
  83. this.cancelDialog()
  84. } finally {
  85. this.loading = false
  86. }
  87. },
  88. },
  89. }
  90. </script>