AkSkCreate.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{ $t('cloudenv.aksk.add') }}</div>
  4. <div slot="body">
  5. <a-form
  6. :form="form.fc"
  7. v-bind="formItemLayout">
  8. <a-form-item :label="$t('cloudenv.text_327')">
  9. <a-textarea
  10. v-decorator="decorators.name"
  11. :placeholder="$t('cloudenv.aksk.placeholder')"
  12. :auto-size="{ minRows: 3, maxRows: 5 }" />
  13. </a-form-item>
  14. </a-form>
  15. </div>
  16. <div slot="footer">
  17. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  18. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  19. </div>
  20. </base-dialog>
  21. </template>
  22. <script>
  23. import DialogMixin from '@/mixins/dialog'
  24. import WindowsMixin from '@/mixins/windows'
  25. export default {
  26. name: 'AkSkCreateDialog',
  27. mixins: [DialogMixin, WindowsMixin],
  28. data () {
  29. return {
  30. loading: false,
  31. userLoading: false,
  32. form: {
  33. fc: this.$form.createForm(this),
  34. },
  35. decorators: {
  36. name: [
  37. 'name',
  38. {
  39. rules: [
  40. { required: false, message: this.$t('common_367') },
  41. ],
  42. },
  43. ],
  44. },
  45. formItemLayout: {
  46. wrapperCol: {
  47. span: 20,
  48. },
  49. labelCol: {
  50. span: 4,
  51. },
  52. },
  53. }
  54. },
  55. methods: {
  56. async handleConfirm () {
  57. this.loading = true
  58. try {
  59. const manager = new this.$Manager('cloudusers')
  60. const values = await this.form.fc.validateFields()
  61. const res = await manager.performAction({
  62. id: this.params.cloudaccountId,
  63. action: 'create-access-key',
  64. data: {
  65. id: this.params.cloudaccountId,
  66. name: values.name,
  67. },
  68. })
  69. this.cancelDialog()
  70. this.params.callback(res.data)
  71. } finally {
  72. this.loading = false
  73. }
  74. },
  75. },
  76. }
  77. </script>