StartRescue.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{ $t('compute.start_rescue') }}</div>
  4. <div slot="body">
  5. <a-alert class="mb-2" type="warning">
  6. <template v-slot:message>
  7. <div>{{ $t('compute.start_rescue.message') }}</div>
  8. </template>
  9. </a-alert>
  10. <dialog-selected-tips :name="$t('dictionary.server')" :count="params.data.length" :action="$t('compute.start_rescue')" />
  11. <dialog-table :data="params.data" :columns="columns" />
  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 { is } from 'ramda'
  21. import DialogMixin from '@/mixins/dialog'
  22. import WindowsMixin from '@/mixins/windows'
  23. export default {
  24. name: 'VmStartRescueDialog',
  25. mixins: [DialogMixin, WindowsMixin],
  26. data () {
  27. return {
  28. loading: false,
  29. }
  30. },
  31. computed: {
  32. columns () {
  33. const fields = ['name', 'ips', 'brand']
  34. return this.params.columns.filter(item => {
  35. const { field } = item
  36. return fields.indexOf(field) > -1
  37. })
  38. },
  39. },
  40. methods: {
  41. async handleConfirm () {
  42. this.loading = true
  43. try {
  44. const { data, onManager, refresh } = this.params
  45. const ids = data.map(item => item.id)
  46. await onManager('batchPerformAction', {
  47. id: ids,
  48. steadyStatus: ['running', 'ready', 'rescving'],
  49. managerArgs: {
  50. action: 'start-rescue',
  51. },
  52. })
  53. this.$message.success(this.$t('common.success'))
  54. is(Function, refresh) && refresh()
  55. this.cancelDialog()
  56. } finally {
  57. this.loading = false
  58. }
  59. },
  60. },
  61. }
  62. </script>