<template>
  <span
    class="btn-back"
    @click="goBackHandler"
  ><i class="el-icon-arrow-left" />返回上一步</span>
</template>

<script>
export default {
  methods: {
    goBackHandler() {
      const pathArray = this.$route.path.split('/')
      if (pathArray[1] === 'advance') {
        this.$router.push('/advance')
      } else if (pathArray.at(-1) === 'flightView') {
        this.$router.push(`/${pathArray[1]}`)
      } else if (['baggageView', 'containerView'].includes(pathArray.at(-1))) {
        this.$router.push(`${pathArray.slice(0, -1).join('/')}/flightView`)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.btn-back {
  margin-left: 24px;
  font-size: 16px;
  font-weight: normal;
  color: #2d67e3;
  cursor: pointer;
}
</style>