RevokeSecgroup.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{ action }}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.secgroup')" :count="params.data.length" 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. import { getStatusTableColumn } from '@/utils/common/tableColumn'
  18. export default {
  19. name: 'VmSidepageRevokeSecgroupDialog',
  20. mixins: [DialogMixin, WindowsMixin],
  21. data () {
  22. return {
  23. action: this.$t('compute.text_950'),
  24. loading: false,
  25. columns: [
  26. {
  27. field: 'name',
  28. title: this.$t('common.name'),
  29. slots: {
  30. default: ({ row }, h) => {
  31. return row.name
  32. },
  33. },
  34. },
  35. getStatusTableColumn({ statusModule: 'secgroup', vm: this }),
  36. ],
  37. }
  38. },
  39. methods: {
  40. async handleConfirm () {
  41. this.loading = true
  42. try {
  43. const secgroup_ids = this.params.data.map(item => item.id)
  44. await new this.$Manager('servers').batchPerformAction({
  45. ids: [this.params.detailData.id],
  46. action: 'revoke-secgroup',
  47. data: {
  48. secgroup_ids,
  49. },
  50. })
  51. this.params.refresh && this.params.refresh()
  52. this.cancelDialog()
  53. this.$message.success(this.$t('compute.text_1021'))
  54. } finally {
  55. this.loading = false
  56. }
  57. },
  58. },
  59. }
  60. </script>