CloneSecgroup.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('compute.text_983')}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.secgroup')" :count="params.data.length" :action="$t('compute.text_983')" />
  6. <dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. <a-form
  8. :form="form.fc">
  9. <a-form-item :label="$t('compute.text_228')" v-bind="formItemLayout">
  10. <a-input v-decorator="decorators.name" :placeholder="$t('compute.text_210')" />
  11. </a-form-item>
  12. </a-form>
  13. </div>
  14. <div slot="footer">
  15. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  16. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  17. </div>
  18. </base-dialog>
  19. </template>
  20. <script>
  21. import DialogMixin from '@/mixins/dialog'
  22. import WindowsMixin from '@/mixins/windows'
  23. export default {
  24. name: 'CloneSecgroupDialog',
  25. mixins: [DialogMixin, WindowsMixin],
  26. data () {
  27. return {
  28. loading: false,
  29. form: {
  30. fc: this.$form.createForm(this),
  31. },
  32. decorators: {
  33. name: [
  34. 'name',
  35. {
  36. validateFirst: true,
  37. rules: [
  38. { required: true, message: this.$t('compute.text_333') },
  39. // { validator: this.$validate('templateName') },
  40. ],
  41. },
  42. ],
  43. },
  44. formItemLayout: {
  45. wrapperCol: {
  46. span: 22,
  47. },
  48. labelCol: {
  49. span: 2,
  50. },
  51. },
  52. templateOps: {
  53. 1: this.$t('compute.text_1010'),
  54. 2: this.$t('compute.text_1011'),
  55. 3: this.$t('compute.text_144'),
  56. },
  57. }
  58. },
  59. methods: {
  60. doCreate (data) {
  61. return new this.$Manager('secgroups').performAction({
  62. id: this.params.data[0].id,
  63. action: 'clone',
  64. data,
  65. })
  66. },
  67. async handleConfirm () {
  68. this.loading = true
  69. try {
  70. const values = await this.form.fc.validateFields()
  71. this.loading = true
  72. await this.doCreate(values)
  73. this.loading = false
  74. this.cancelDialog()
  75. this.params.refresh()
  76. } catch (error) {
  77. this.loading = false
  78. }
  79. },
  80. },
  81. }
  82. </script>