create.vue 720 B

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <div>
  3. <Schema v-if="active === 1" @next="next" @prev="prev" />
  4. <Structure v-if="active === 2" @next="next" @prev="prev" />
  5. </div>
  6. </template>
  7. <script lang="ts" setup>
  8. import {ref, watch} from 'vue'
  9. import Schema from './steps/schema.vue'
  10. import Structure from './steps/structure.vue'
  11. import {useSchemaStore} from './store'
  12. const schemaStore = useSchemaStore()
  13. const active = ref(1)
  14. const next = () => {
  15. if (active.value++ >= 2) {
  16. active.value = 2
  17. }
  18. }
  19. const prev = () => {
  20. if (active.value-- === 1) {
  21. active.value = 1
  22. }
  23. }
  24. const emit = defineEmits(['close'])
  25. watch(
  26. () => schemaStore.getFinished,
  27. function (value) {
  28. if (value) {
  29. emit('close')
  30. }
  31. },
  32. )
  33. </script>