Delete.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('compute.perform_delete')}}</div>
  4. <div slot="body">
  5. <a-alert class="mb-2" type="warning">
  6. <div slot="message">{{$t('compute.text_1392')}}</div>
  7. </a-alert>
  8. <dialog-selected-tips :name="$t('compute.vminstance-container')" :count="params.data.length" :action="this.params.title" />
  9. <dialog-table v-if="params.columns && params.columns.length" :data="params.data" :columns="params.columns.slice(0, 3)" />
  10. </div>
  11. <div slot="footer">
  12. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ confirmText }}</a-button>
  13. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  14. </div>
  15. </base-dialog>
  16. </template>
  17. <script>
  18. import * as R from 'ramda'
  19. import { mapGetters } from 'vuex'
  20. import DialogMixin from '@/mixins/dialog'
  21. import WindowsMixin from '@/mixins/windows'
  22. import WorkflowMixin from '@/mixins/workflow'
  23. export default {
  24. name: 'DeleteVmContainerDialog',
  25. mixins: [DialogMixin, WindowsMixin, WorkflowMixin],
  26. data () {
  27. return {
  28. loading: false,
  29. form: {
  30. fc: this.$form.createForm(this),
  31. fd: {},
  32. },
  33. decorators: {},
  34. formItemLayout: {
  35. wrapperCol: {
  36. span: 19,
  37. },
  38. labelCol: {
  39. span: 5,
  40. },
  41. },
  42. formItemLayoutWithoutLabel: {
  43. wrapperCol: {
  44. span: 19,
  45. offset: 5,
  46. },
  47. },
  48. }
  49. },
  50. computed: {
  51. ...mapGetters(['isAdminMode', 'userInfo']),
  52. confirmText () {
  53. return this.$t('dialog.ok')
  54. },
  55. },
  56. methods: {
  57. async handleConfirm () {
  58. this.loading = true
  59. try {
  60. await this.handleDelete()
  61. this.loading = false
  62. this.cancelDialog()
  63. } catch (error) {
  64. this.loading = false
  65. throw error
  66. }
  67. },
  68. async handleDelete () {
  69. if (this.params.ok) {
  70. await this.params.ok()
  71. } else {
  72. const ids = this.params.data.map(item => item.id)
  73. let params = {}
  74. params = {
  75. ...params,
  76. ...this.params.requestParams,
  77. }
  78. const response = await this.params.onManager('batchDelete', {
  79. id: ids,
  80. managerArgs: { params },
  81. })
  82. if (this.params.vm && this.params.vm.destroySidePages) {
  83. this.params.vm.destroySidePage(this.params.vm.windowId)
  84. }
  85. if (this.params.success && R.is(Function, this.params.success)) {
  86. this.params.success(response)
  87. }
  88. }
  89. this.$message.success(this.$t('compute.text_423'))
  90. },
  91. },
  92. }
  93. </script>