MountIso.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('compute.text_366')}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.server')" :count="params.data.length" :action="$t('compute.text_366')" />
  6. <dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. <a-form :form="form.fc" hideRequiredMark>
  8. <a-form-item :label="$t('compute.text_1218')" v-bind="formItemLayout">
  9. <base-select
  10. class="w-100"
  11. remote
  12. filterable
  13. version="v1"
  14. v-decorator="decorators.image_id"
  15. resource="images"
  16. :params="imageParams"
  17. :select-props="{ placeholder: $t('compute.text_1219') }" />
  18. </a-form-item>
  19. </a-form>
  20. </div>
  21. <div slot="footer">
  22. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  23. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  24. </div>
  25. </base-dialog>
  26. </template>
  27. <script>
  28. import { mapGetters } from 'vuex'
  29. import DialogMixin from '@/mixins/dialog'
  30. import WindowsMixin from '@/mixins/windows'
  31. export default {
  32. name: 'VmMountIsoDialog',
  33. mixins: [DialogMixin, WindowsMixin],
  34. data () {
  35. return {
  36. loading: false,
  37. form: {
  38. fc: this.$form.createForm(this),
  39. },
  40. decorators: {
  41. image_id: [
  42. 'image_id',
  43. {
  44. rules: [
  45. { required: true, message: this.$t('compute.text_1219') },
  46. ],
  47. },
  48. ],
  49. },
  50. formItemLayout: {
  51. wrapperCol: {
  52. span: 21,
  53. },
  54. labelCol: {
  55. span: 3,
  56. },
  57. },
  58. }
  59. },
  60. computed: {
  61. ...mapGetters(['scope']),
  62. imageParams () {
  63. return { disk_formats: 'iso', scope: this.scope }
  64. },
  65. },
  66. methods: {
  67. async handleConfirm () {
  68. this.loading = true
  69. try {
  70. const values = await this.form.fc.validateFields()
  71. const ids = this.params.data.map(item => item.id)
  72. await this.params.onManager('batchPerformAction', {
  73. id: ids,
  74. managerArgs: {
  75. action: 'insertiso',
  76. data: values,
  77. },
  78. })
  79. this.params.refresh()
  80. this.cancelDialog()
  81. } finally {
  82. this.loading = false
  83. }
  84. },
  85. },
  86. }
  87. </script>