UnbindDisks.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{action}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :count="params.data.length" :action="action" :name="$t('dictionary.snapshotpolicy')" />
  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: 'UnbindDisksDialog',
  19. mixins: [DialogMixin, WindowsMixin],
  20. data () {
  21. return {
  22. loading: false,
  23. action: this.$t('compute.text_723'),
  24. }
  25. },
  26. computed: {
  27. columns () {
  28. return this.params.columns.slice(0, 3)
  29. },
  30. },
  31. methods: {
  32. async doSubmit () {
  33. const ids = this.params.data.map(item => item.id)
  34. const params = {
  35. snapshotpolicy_id: this.params.resId,
  36. }
  37. return this.params.onManager('batchPerformAction', {
  38. id: ids,
  39. steadyStatus: 'ready',
  40. managerArgs: {
  41. action: 'unbind-snapshotpolicy',
  42. data: params,
  43. },
  44. })
  45. },
  46. async handleConfirm () {
  47. this.loading = true
  48. try {
  49. await this.doSubmit()
  50. this.loading = false
  51. this.params.refresh && this.params.refresh()
  52. this.cancelDialog()
  53. } catch (error) {
  54. this.loading = false
  55. throw error
  56. }
  57. },
  58. },
  59. }
  60. </script>