create.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <base-dialog :width="900" @cancel="cancelDialog">
  3. <div slot="header">{{ params.type === 'edit' ? $t('table.action.modify') : $t('common.create') }}</div>
  4. <div slot="body">
  5. <llm-sku-create-form
  6. ref="form"
  7. :mode="params.type === 'edit' ? 'edit' : 'create'"
  8. :edit-data="params.data && params.data[0]"
  9. :on-manager="params.onManager"
  10. @success="onFormSuccess"
  11. @cancel="cancelDialog" />
  12. </div>
  13. <div slot="footer">
  14. <a-button type="primary" :loading="submitLoading" @click="handleSubmit">{{ $t('dialog.ok') }}</a-button>
  15. <a-button :disabled="submitLoading" @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  16. </div>
  17. </base-dialog>
  18. </template>
  19. <script>
  20. import DialogMixin from '@/mixins/dialog'
  21. import WindowsMixin from '@/mixins/windows'
  22. import LlmSkuCreateForm from '../create/Form.vue'
  23. export default {
  24. name: 'LlmSkuCreateDialog',
  25. components: {
  26. LlmSkuCreateForm,
  27. },
  28. mixins: [DialogMixin, WindowsMixin],
  29. data () {
  30. return {
  31. submitLoading: false,
  32. }
  33. },
  34. methods: {
  35. async handleSubmit () {
  36. const form = this.$refs.form
  37. if (!form || !form.handleConfirm) return
  38. this.submitLoading = true
  39. try {
  40. await form.handleConfirm()
  41. } catch (e) {
  42. // 表单内会处理校验错误提示
  43. } finally {
  44. this.submitLoading = false
  45. }
  46. },
  47. onFormSuccess () {
  48. if (this.params.callback) this.params.callback()
  49. this.cancelDialog()
  50. },
  51. },
  52. }
  53. </script>