Syncconfig.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{action}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.server')" :count="params.data.length" :action="action" />
  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 DialogMixin from '@/mixins/dialog'
  16. import WindowsMixin from '@/mixins/windows'
  17. export default {
  18. name: 'VmSyncConfigDialog',
  19. mixins: [DialogMixin, WindowsMixin],
  20. data () {
  21. return {
  22. loading: false,
  23. action: this.$t('compute.sync_config'),
  24. }
  25. },
  26. computed: {
  27. columns () {
  28. const showFields = ['name', 'ip', 'instance_type']
  29. return this.params.columns.filter((item) => { return showFields.includes(item.field) })
  30. },
  31. },
  32. methods: {
  33. async doResetSubmit () {
  34. const ids = this.params.data.map(item => item.id)
  35. return this.params.onManager('batchPerformAction', {
  36. id: ids,
  37. steadyStatus: ['running', 'ready'],
  38. managerArgs: {
  39. action: 'sync',
  40. },
  41. })
  42. },
  43. async handleConfirm () {
  44. this.loading = true
  45. try {
  46. await this.doResetSubmit()
  47. this.loading = false
  48. this.cancelDialog()
  49. } catch (error) {
  50. this.loading = false
  51. }
  52. },
  53. },
  54. }
  55. </script>