<!--
  @description: 供应商编辑申报材料-content
  @Modifier:肖文龙
  @routerPath:/supplierDeclaration
  @date: 2020/2/21-15:41
-->
<template>
  <div>
    <!-- 审报材料-新增 -->
    <!--showStatus展示状态 00查看 01不可编辑 02可编辑 null可编辑 03都不展示  -->
    <editorDeclarationStep v-if="showStatus==='02'||!showStatus" />
    <!-- 审报材料-查看 -->
    <template v-if="showStatus==='00'||showStatus==='01'||showStatus==='03'">
      <!--标题-->
      <div class="title title_border p0-16">
        <i class="el-icon-s-home" />申报材料
      </div>
      <editorDeclarationDetail v-if="showStatus==='00'||showStatus==='01'" :judge-page-data="judgePageData" />
    </template>
  </div>
</template>
<script>
/* 接口*/
import { getUpdateDepartInfo } from '@/api/supplier/supplierBaseInfo'// 获取
/* 组件 */
import editorDeclarationStep from './editorDeclarationStep'// 审报材料-新增
import editorDeclarationDetail from './editorDeclaration-detail'// 审报材料-查看
export default {
  name: 'EditorDeclarationContent',
  components: {
    editorDeclarationStep, // 审报材料-新增
    editorDeclarationDetail// 审报材料-查看
  },
  data() {
    return {
      // 获取数据所需参数
      judgePageData: {
        departId: '', // 供应商id
        declarationId: '', // 申报id
        isViewPage: '', // 非变更查看页面传01 否则传空
        departInfoId: '' // 申报id
      },
      showStatus: '03'// 展示状态 00查看 01不可编辑 02可编辑 null可编辑 03都不展示
    }
  },
  watch: {
    $route: {
      handler() {
        this.initData()// 获取基本信息-判断是否已提交
      },
      deep: true
    }
  },
  created() {
    this.initData()// 获取基本信息-判断是否已提交
  },
  methods: {
    // 获取基本信息-判断是否已提交
    initData() {
      const params = {
        departId: this.judgePageData.departId,
        declarationId: this.judgePageData.declarationId, // 申报id
        isViewPage: this.judgePageData.isViewPage // 判断是否为变更数据
      }
      getUpdateDepartInfo(params).then((response) => {
        const { info, showStatus } = response.data
        this.showStatus = showStatus// 展示状态 00查看 01不可编辑 02可编辑
        this.judgePageData.departInfoId = info.id || ''
        const query = {
          id: info && info.id, // 供应商departInfo主键
          departId: info && info.departId // 供应商主键
          // showStatus: showStatus // 显示状态
        }
        this.$router.push({
          query: query
        })
      })
    }
  }
}
</script>

<style lang="less" scoped>
</style>
