Reset.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{action}}</div>
  4. <div slot="body">
  5. <a-alert class="mb-2" type="warning">
  6. <template v-slot:message>
  7. <div>{{$t('compute.text_1227')}}</div>
  8. <div class="mt-2">{{$t('compute.text_1228')}}</div>
  9. </template>
  10. </a-alert>
  11. <dialog-selected-tips :name="$t('dictionary.server')" :count="params.data.length" :action="action" />
  12. <dialog-table :data="params.data" :columns="columns" />
  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: 'VmResetDialog',
  25. mixins: [DialogMixin, WindowsMixin],
  26. data () {
  27. return {
  28. loading: false,
  29. action: this.$t('compute.text_354'),
  30. }
  31. },
  32. computed: {
  33. columns () {
  34. const showFields = ['name', 'ip', 'instance_type']
  35. return this.params.columns.filter((item) => { return showFields.includes(item.field) })
  36. },
  37. },
  38. methods: {
  39. async doResetSubmit () {
  40. const ids = this.params.data.map(item => item.id)
  41. return this.params.onManager('batchPerformAction', {
  42. id: ids,
  43. steadyStatus: 'running',
  44. managerArgs: {
  45. action: 'reset',
  46. },
  47. })
  48. },
  49. async handleConfirm () {
  50. this.loading = true
  51. try {
  52. await this.doResetSubmit()
  53. this.loading = false
  54. this.cancelDialog()
  55. } catch (error) {
  56. this.loading = false
  57. }
  58. },
  59. },
  60. }
  61. </script>