StopRescue.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{ $t('compute.stop_rescue') }}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.server')" :count="params.data.length" :action="$t('compute.stop_rescue')" />
  6. <dialog-table :data="params.data" :columns="columns" />
  7. </div>
  8. <div slot="footer">
  9. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  10. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  11. </div>
  12. </base-dialog>
  13. </template>
  14. <script>
  15. import { is } from 'ramda'
  16. import DialogMixin from '@/mixins/dialog'
  17. import WindowsMixin from '@/mixins/windows'
  18. export default {
  19. name: 'VmStopRescueDialog',
  20. mixins: [DialogMixin, WindowsMixin],
  21. data () {
  22. return {
  23. loading: false,
  24. }
  25. },
  26. computed: {
  27. columns () {
  28. const fields = ['name', 'ips', 'brand']
  29. return this.params.columns.filter(item => {
  30. const { field } = item
  31. return fields.indexOf(field) > -1
  32. })
  33. },
  34. },
  35. methods: {
  36. async handleConfirm () {
  37. this.loading = true
  38. try {
  39. const { data, onManager, refresh } = this.params
  40. const ids = data.map(item => item.id)
  41. await onManager('batchPerformAction', {
  42. id: ids,
  43. steadyStatus: ['running', 'ready', 'rescving'],
  44. managerArgs: {
  45. action: 'stop-rescue',
  46. },
  47. })
  48. this.$message.success(this.$t('common.success'))
  49. is(Function, refresh) && refresh()
  50. this.cancelDialog()
  51. } finally {
  52. this.loading = false
  53. }
  54. },
  55. },
  56. }
  57. </script>