<!--
  @description:招标计划(步骤条)
  @Modifier:sunxinman
  @routerPath:
  @date:2019/12/23-17:27
-->
<template>
  <div class="set-up-project">
    <div class="step-wrapper">
      <stepsBar ref="stepsBar" :list="stepsList" :save="save" :parent-page-data="tenderPlanData" />
    </div>
    <div class="p0-16">
      <router-view ref="project" :tender-plan-data="tenderPlanData" @stepPage="_stepPage" @watchStep="listenStep" />
      <!-- router-view  嵌套子组件页面-->
      <!--changeStep  stepPage procurementP  给子组件传值  自定义的名称-->
    </div>
  </div>
</template>

<script>
import stepsBar from '@comp/common/stepsBarParams'

export default {
  name: 'SetUpProject',
  components: {
    stepsBar
  },
  data() {
    return {
      stepsList: [// 资格预审
        {
          name: '招标计划信息',
          path: '/tenderPlan/tenderPlanAdd/baseInfo'
        },
        {
          name: '物料组信息',
          path: '/tenderPlan/tenderPlanAdd/materielInfo'
        },
        {
          name: '评标办法',
          path: '/tenderPlan/tenderPlanAdd/methodInfo'
        },
        {
          name: '招标人集合',
          path: '/tenderPlan/tenderPlanAdd/tendereeInfo'
        },
        {
          name: '评委会信息',
          path: '/tenderPlan/tenderPlanAdd/discussInfo'
        }
      ],
      // 传给子组件编辑带入计划主键id
      tenderPlanData: {
        id: this.$route.params.id
      }
    }
  },
  destroyed() {
    // 销毁时清除所有cookie
    sessionStorage.clear()
  },
  methods: {
    // 控制上一步 下一步跳转页面 子组件传给父组件
    // prev 上一步 next 下一步 或者是数字直接指定展示第几步的页面
    _stepPage(page) {
      // 调用步骤条-组件方法
      this.$refs.stepsBar.stepPage(page)
    },
    // 暂存接口
    save(type) {
      // 调用招标计划页面的方法-保存
      // if (this.$refs.project.saveData) {
      //   this.$refs.project.saveData(type)
      // }
    },
    // 监听资格预审还是后审
    listenStep(biddingMethod, screenProject) { // 招标方式,年度资格预审筛选项目
      // 邀请招标且不使用年度资格预审结果的招标计划，步骤条为6步，分别为招标计划信息、物料组信息、评审办法、供应商集合、招标人集合、评委会信息。
      // 其他情况步骤条为5步，分别为招标计划信息、物料组信息、评审办法、招标人集合、评委会信息
      if (biddingMethod === '01' && screenProject === '01') {
        this.stepsList = [
          {
            name: '招标计划信息',
            path: '/tenderPlan/tenderPlanAdd/baseInfo'
          },
          {
            name: '物料组信息',
            path: '/tenderPlan/tenderPlanAdd/materielInfo'
          },
          {
            name: '评标办法',
            path: '/tenderPlan/tenderPlanAdd/methodInfo'
          },
          {
            name: '供应商信息集合',
            path: '/tenderPlan/tenderPlanAdd/supplierInfo'
          },
          {
            name: '招标人集合',
            path: '/tenderPlan/tenderPlanAdd/tendereeInfo'
          },
          {
            name: '评委会信息',
            path: '/tenderPlan/tenderPlanAdd/discussInfo'
          }]
      } else {
        this.stepsList = [
          {
            name: '招标计划信息',
            path: '/tenderPlan/tenderPlanAdd/baseInfo'
          },
          {
            name: '物料组信息',
            path: '/tenderPlan/tenderPlanAdd/materielInfo'
          },
          {
            name: '评标办法',
            path: '/tenderPlan/tenderPlanAdd/methodInfo'
          },
          {
            name: '招标人集合',
            path: '/tenderPlan/tenderPlanAdd/tendereeInfo'
          },
          {
            name: '评委会信息',
            path: '/tenderPlan/tenderPlanAdd/discussInfo'
          }
        ]
      }
    }
  }
}
</script>

<style lang="less" scoped>
.step-wrapper {
  padding: 20px 14px;
}
</style>
