index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <div>
  3. <page-header :title="$t('k8s.text_387')" />
  4. <page-body needMarginBottom>
  5. <role-form @submit="submit" ref="formRef" />
  6. </page-body>
  7. <page-footer>
  8. <template class="content" #right>
  9. <a-button class="mr-2" type="primary" @click="handleConfirm" :loading="loading">{{$t('common.create')}}</a-button>
  10. <a-button @click="handleCancel">{{ $t('dialog.cancel') }}</a-button>
  11. </template>
  12. </page-footer>
  13. </div>
  14. </template>
  15. <script>
  16. import RoleForm from '../form'
  17. export default {
  18. name: 'RbacroleCreate',
  19. components: {
  20. RoleForm,
  21. },
  22. data () {
  23. return {
  24. loading: false,
  25. }
  26. },
  27. methods: {
  28. handleConfirm () {
  29. this.$refs.formRef.doCreate()
  30. },
  31. handleCancel () {
  32. this.$router.push('/k8s-federatedclusterrolebinding')
  33. },
  34. async submit (data) {
  35. try {
  36. this.loading = true
  37. await new this.$Manager('federatedclusterrolebindings', 'v1').create({ data })
  38. this.$message.success(this.$t('k8s.text_46'))
  39. this.loading = false
  40. this.handleCancel()
  41. } catch (error) {
  42. this.loading = false
  43. throw error
  44. }
  45. },
  46. },
  47. }
  48. </script>