Merge.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('network.wire.merge')}}</div>
  4. <div slot="body">
  5. <a-alert class="mb-2" type="warning">
  6. <div slot="message">{{$t('network.text_755')}}</div>
  7. </a-alert>
  8. <dialog-selected-tips :name="$t('dictionary.wire')" :count="params.data.length" :action="$t('network.wire.merge')" />
  9. <dialog-table :data="params.data" :columns="columns" :expandConfig="expandConfig" />
  10. <a-checkbox @change="onChange">
  11. {{ $t('network.wire.merge.subnet') }}
  12. <a-tooltip placement="top">
  13. <template slot="title">
  14. <span>{{ $t('network.wire.merge.tooltip')}}</span>
  15. </template>
  16. <a-icon type="question-circle" />
  17. </a-tooltip>
  18. </a-checkbox>
  19. </div>
  20. <div slot="footer">
  21. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  22. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  23. </div>
  24. </base-dialog>
  25. </template>
  26. <script>
  27. import { getHostsTableColumn } from '../utils/columns'
  28. import DialogMixin from '@/mixins/dialog'
  29. import WindowsMixin from '@/mixins/windows'
  30. export default {
  31. name: 'WireMergeDialog',
  32. mixins: [DialogMixin, WindowsMixin],
  33. data () {
  34. return {
  35. mergeSubnet: false,
  36. }
  37. },
  38. computed: {
  39. columns () {
  40. const cols = this.params.columns.filter((col) => { return ['name', 'networks'].indexOf(col.field) >= 0 })
  41. cols.push(getHostsTableColumn())
  42. return cols
  43. },
  44. expandConfig () {
  45. return this.params.expandConfig
  46. },
  47. },
  48. methods: {
  49. onChange (e) {
  50. this.mergeSubnet = e.target.checked
  51. },
  52. async handleConfirm () {
  53. this.loading = true
  54. try {
  55. await new this.$Manager('wires').performAction({
  56. id: this.params.data[0].id,
  57. action: 'merge-from',
  58. data: {
  59. sources: this.params.data.slice(1).map((item) => { return item.id }),
  60. merge_network: this.mergeSubnet,
  61. },
  62. })
  63. this.loading = false
  64. this.params.refresh()
  65. this.cancelDialog()
  66. } catch (error) {
  67. this.loading = false
  68. throw error
  69. } finally {
  70. this.loading = false
  71. }
  72. },
  73. },
  74. }
  75. </script>
  76. <style scoped>
  77. </style>