EncryptKeyCreate.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{this.params.title}}</div>
  4. <div slot="body" v-loading="loading">
  5. <a-form :form="form.fc" v-bind="formItemLayout">
  6. <a-form-item :label="$t('scope.encrypt_key.title.name')">
  7. <a-input :placeholder="$t('scope.encrypt_key.title.name')" v-decorator="decorators.name" />
  8. </a-form-item>
  9. <a-form-item :label="$t('scope.encrypt_key.title.alg')">
  10. <a-radio-group v-decorator="decorators.alg">
  11. <a-radio-button value="">{{ $t('compute.text_1') }}</a-radio-button>
  12. <a-radio-button value="aes-256">AES-256</a-radio-button>
  13. <a-radio-button value="sm4">SM4</a-radio-button>
  14. </a-radio-group>
  15. </a-form-item>
  16. </a-form>
  17. </div>
  18. <div slot="footer">
  19. <a-button type="primary" @click="handleConfirm">{{ $t("dialog.ok") }}</a-button>
  20. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  21. </div>
  22. </base-dialog>
  23. </template>
  24. <script>
  25. import DialogMixin from '@/mixins/dialog'
  26. import WindowsMixin from '@/mixins/windows'
  27. export default {
  28. name: 'CredentialEncryptKeyCreate',
  29. mixins: [DialogMixin, WindowsMixin],
  30. data () {
  31. return {
  32. loading: false,
  33. form: {
  34. fc: this.$form.createForm(this),
  35. },
  36. formItemLayout: {
  37. wrapperCol: {
  38. span: 19,
  39. },
  40. labelCol: {
  41. span: 5,
  42. },
  43. },
  44. decorators: {
  45. name: [
  46. 'name',
  47. {
  48. rules: [
  49. { required: true, message: this.$t('scope.encrypt_key.require_name.prompt') },
  50. ],
  51. },
  52. ],
  53. alg: [
  54. 'alg',
  55. {
  56. initialValue: '',
  57. },
  58. ],
  59. },
  60. }
  61. },
  62. destroyed () {
  63. this.manager = null
  64. },
  65. created () {
  66. this.manager = new this.$Manager('rpc/credentials', 'v1')
  67. },
  68. methods: {
  69. async handleConfirm () {
  70. try {
  71. const values = await this.form.fc.validateFields()
  72. await this.manager.performClassAction({
  73. action: 'create-encrypt-key',
  74. data: values,
  75. })
  76. this.params.refresh()
  77. this.cancelDialog()
  78. } catch (err) {
  79. throw err
  80. }
  81. },
  82. },
  83. }
  84. </script>