<template>
  <div class="mark-step grade-step">
    <div
      class="grade-step-other"
      v-if="steps.otherStep && steps.otherStep.length"
    >
      <div
        v-for="(step, sindex) in steps.otherStep"
        :key="sindex"
        :class="[
          'step-item',
          {
            'step-act': curStep.name === step.name,
            'step-other': step.type !== 'done'
          }
        ]"
        @click="selectStep(step)"
      >
        <p class="step-name">{{ step.name }}</p>
        <p>{{ step.count }}</p>
      </div>
    </div>
    <div class="grade-step-level">
      <div
        v-for="(step, sindex) in steps.levelStep"
        :key="sindex"
        :class="[
          'step-item',
          {
            'step-act': curStep.name === step.name,
            'step-other': step.type !== 'done'
          }
        ]"
        @click="selectStep(step)"
      >
        <p class="step-name">{{ step.name }}</p>
        <p>{{ step.count }}</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "mark-step",
  props: {
    showAnalysis: {
      type: Boolean,
      default: true
    },
    steps: {
      type: Object,
      default() {
        return { levelStep: [], otherStep: [] };
      }
    },
    initStep: {
      type: Object,
      default() {
        return { type: "", name: "" };
      }
    }
  },
  data() {
    return {
      curStep: {}
    };
  },
  mounted() {
    this.selectStep(this.initStep);
  },
  methods: {
    selectStep(step) {
      this.curStep = { ...step };
      this.$emit("on-change", this.curStep);
    }
  }
};
</script>
