index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div>
  3. <page-header :title="headerTitle" />
  4. <page-body needMarginBottom>
  5. <llm-sku-create-form
  6. ref="createForm"
  7. mode="create"
  8. hide-footer
  9. @success="onFormSuccess"
  10. @cancel="onFormCancel" />
  11. </page-body>
  12. <page-footer>
  13. <template v-slot:right>
  14. <a-button type="primary" :loading="submitLoading" @click="handleConfirm">{{ $t('common.create') }}</a-button>
  15. <a-button class="ml-2" @click="handleCancel">{{ $t('common.cancel') }}</a-button>
  16. </template>
  17. </page-footer>
  18. </div>
  19. </template>
  20. <script>
  21. import LlmSkuCreateForm from './Form.vue'
  22. export default {
  23. name: 'LlmSkuCreate',
  24. components: {
  25. LlmSkuCreateForm,
  26. },
  27. data () {
  28. return {
  29. submitLoading: false,
  30. }
  31. },
  32. computed: {
  33. isApplyType () {
  34. return this.$route.path.includes('app-llm')
  35. },
  36. headerTitle () {
  37. return this.$t('common.create') + ' - ' + (this.isApplyType ? this.$t('aice.app_llm_sku') : this.$t('aice.llm_sku'))
  38. },
  39. },
  40. methods: {
  41. async handleConfirm () {
  42. const form = this.$refs.createForm
  43. if (!form) return
  44. this.submitLoading = true
  45. try {
  46. await form.handleConfirm()
  47. } catch (e) {
  48. // 校验失败等由表单处理
  49. } finally {
  50. this.submitLoading = false
  51. }
  52. },
  53. handleCancel () {
  54. this.$refs.createForm && this.$refs.createForm.handleCancel()
  55. },
  56. onFormSuccess () {
  57. this.$router.push(this.isApplyType ? '/app-llm-sku' : '/llm-sku')
  58. },
  59. onFormCancel () {
  60. this.$router.push(this.isApplyType ? '/app-llm-sku' : '/llm-sku')
  61. },
  62. },
  63. }
  64. </script>