<template>
  <div>
    <c-list v-if="step==1" @changeStep="changeStep" />
    <c-cditor v-if="step==2" :detailItem="detailItem" :isView="isView" @changeStep="changeStep" />
  </div>
</template>

<script>
import List from "./list";
import Editor from "./editor";

export default {
  components: {
    'c-list': List,
    'c-cditor': Editor
  },
  data() {
    return {
      step: 1,
      detailItem: null,
      isView: false,
    }
  },
  beforeRouteEnter(to, from, next) {
    next(vm => {
      vm.step = 1;
      vm.detailItem = null;
      vm.isView = false;
    })
  },
  methods: {
    changeStep(obj) {
      this.step = obj.step;
      this.detailItem = obj.item;
      this.isView = !!obj.isView;
    }
  }
}
</script>

<style>
</style>