Delete.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{this.params.title}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('network.text_19')" :count="params.data.length" :action="params.title" />
  6. <dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. <a-checkbox class="mt-2" v-model="canDelete">{{$t('network.text_358')}}</a-checkbox>
  8. </div>
  9. <div slot="footer">
  10. <a-button :disabled="!canDelete" type="primary" @click="handleConfirm" :loading="loading">{{ $t("dialog.ok") }}</a-button>
  11. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  12. </div>
  13. </base-dialog>
  14. </template>
  15. <script>
  16. import DialogMixin from '@/mixins/dialog'
  17. import WindowsMixin from '@/mixins/windows'
  18. export default {
  19. name: 'ClusterDeleteDialog',
  20. mixins: [DialogMixin, WindowsMixin],
  21. data () {
  22. return {
  23. loading: false,
  24. canDelete: false,
  25. }
  26. },
  27. methods: {
  28. async handleConfirm () {
  29. this.loading = true
  30. try {
  31. this.loading = false
  32. if (this.params.data && this.params.data.length > 1) {
  33. const ids = this.params.data.map(({ id }) => id)
  34. await this.params.onManager('batchDelete', {
  35. id: ids,
  36. })
  37. } else {
  38. await this.params.onManager('delete', {
  39. id: this.params.data[0].id,
  40. })
  41. }
  42. this.cancelDialog()
  43. this.$message.success(this.$t('network.text_290'))
  44. } catch (error) {
  45. this.loading = false
  46. throw error
  47. }
  48. },
  49. },
  50. }
  51. </script>