ConcatSecgroup.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('compute.text_1012')}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.secgroup')" :count="params.data.length" :action="$t('compute.text_1013')" />
  6. <dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. <a-form
  8. :form="form.fc"
  9. v-bind="formItemLayout">
  10. <a-form-item :label="$t('compute.text_1014')">
  11. <a-select v-decorator="decorators.name" mode="multiple">
  12. <a-select-option v-for="item in secgroupOps" :key="item.id" :value="item.id">
  13. {{item.name}}
  14. </a-select-option>
  15. </a-select>
  16. </a-form-item>
  17. </a-form>
  18. </div>
  19. <div slot="footer">
  20. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  21. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  22. </div>
  23. </base-dialog>
  24. </template>
  25. <script>
  26. import DialogMixin from '@/mixins/dialog'
  27. import WindowsMixin from '@/mixins/windows'
  28. export default {
  29. name: 'ConcatSecgroupDialog',
  30. mixins: [DialogMixin, WindowsMixin],
  31. data () {
  32. return {
  33. loading: false,
  34. form: {
  35. fc: this.$form.createForm(this),
  36. },
  37. decorators: {
  38. name: [
  39. 'name',
  40. {
  41. rules: [
  42. { required: true, message: this.$t('compute.text_1015') },
  43. ],
  44. },
  45. ],
  46. },
  47. formItemLayout: {
  48. wrapperCol: {
  49. span: 16,
  50. },
  51. labelCol: {
  52. span: 8,
  53. },
  54. },
  55. secgroupOps: [],
  56. }
  57. },
  58. computed: {
  59. scope () {
  60. return this.$store.getters.scope
  61. },
  62. },
  63. created () {
  64. this.remoteMethod()
  65. },
  66. methods: {
  67. remoteMethod () {
  68. const params = {
  69. details: true,
  70. equals: this.params.data[0].id,
  71. limit: 0,
  72. scope: this.scope,
  73. }
  74. new this.$Manager('secgroups').list({ params })
  75. .then(({ data: { data = [] } }) => {
  76. this.secgroupOps = data.filter(val => val.id !== this.params.data[0].id)
  77. })
  78. },
  79. doConcat (data) {
  80. return new this.$Manager('secgroups').performAction({
  81. id: this.params.data[0].id,
  82. action: 'merge',
  83. data: {
  84. secgroups: data.name,
  85. },
  86. })
  87. },
  88. async handleConfirm () {
  89. this.loading = true
  90. try {
  91. const values = await this.form.fc.validateFields()
  92. await this.doConcat(values)
  93. this.loading = false
  94. this.cancelDialog()
  95. this.params.refresh()
  96. } catch (error) {
  97. this.loading = false
  98. }
  99. },
  100. },
  101. }
  102. </script>