<!--
  @description: 建设项目-查看 建设项目审核-查看 建设项目台账-查看
  @author: 肖文龙
  @routerPath:/buildingProject/buildingProjectDetail
  @date： 2019-12-4 15:51:12
-->
<template>
  <div :class="flowStatus?'main':'p0-16'">
    <!--flowStatus01 待办列表进入 则不显示标题-->
    <section v-if="!flowStatus" class="title">
      <i class="iconfont icon-fanhui pointer" @click="back()" />
      {{ titleData.title }}
    </section>
    <table class="tableData">
      <tr>
        <td>建设项目编码</td>
        <td>{{ formData.projectNo }}</td>
        <td>建设项目名称</td>
        <td>{{ formData.projectName }}</td>
      </tr>
      <tr>
        <td>建设项目类型</td>
        <td :colspan="formData.constructionProjectType=='01' ? 1:3">
          <span
            v-for="(item,index) in constructionProjectTypeList"
            v-if="formData.constructionProjectType===item.typecode"
            :key="index"
          >{{ item.typename }}</span>
        </td>
        <td v-if="formData.constructionProjectType=='01'">
          年份
        </td>
        <td v-if="formData.constructionProjectType=='01'">
          {{ formData.particularYear | formatTime }}
        </td>
      </tr>
      <tr>
        <td>批准文号</td>
        <td>{{ formData.approvalNo }}</td>
        <td>所属机构</td>
        <td>{{ formData.projectDeptname }}</td>
      </tr>
      <tr>
        <td>项目地点</td>
        <td>{{ formData.projectLocation }}</td>
        <td>项目总投资（万元）</td>
        <td>{{ formData.projectBudget }}</td>
      </tr>
      <tr>
        <td>立项或审批部门</td>
        <td>{{ formData.approvalDeptname }}</td>
        <td>项目法人</td>
        <td>{{ formData.projectManagername }}</td>
      </tr>
      <tr>
        <td>行业分类</td>
        <td>
          {{ filterDictText(industryClassList,formData.industryClass) }}
        </td>
        <td>项目规模</td>
        <td>{{ formData.projectScale }}</td>
      </tr>
      <tr>
        <td>资金来源</td>
        <td>
          {{ formData.fundingSource }}
        </td>
        <td>项目内容</td>
        <td>
          {{ formData.projectContent }}
        </td>
      </tr>
      <tr>
        <td>出资比例</td>
        <td>
          {{ formData.contributionScale }}
        </td>
        <td>行业监管部门</td>
        <td>
          {{ formData.monitorDeptName }}
        </td>
      </tr>
      <tr>
        <td>项目级别</td>
        <td>
          {{ formData.proLevelName }}
        </td>
        <td>联系人</td>
        <td>
          {{ formData.linkName }}
        </td>
      </tr>
      <tr>
        <td>联系方式</td>
        <td colspan="3">
          {{ formData.linkPhone }}
        </td>
      </tr>
      <tr>
        <td>附件</td>
        <td colspan="3">
          <downloadFile :data="upLoadData" />
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
/* api接口*/
import { getConstructionProjectById, initMultiStageTypeGroup } from '@/api/purchasePlan/taskplan'
/* 混合开发方法-参数字段*/
import { buildingProjectGroupMixin } from '../../mixins/buildingProjectGroupMixin'// 字典信息
import { buildingProjectMixin } from '../../mixins/buildingProjectMixin'// 建设项目公共方法
import moment from 'moment'
/* 组件*/
import downloadFile from '@comp/common/updownload/downloadFile'
import { filterDictText } from '@assets/js/utils'// 常用方法
export default {
  name: 'BuildingProjectDetail',
  components: {
    downloadFile
  },
  filters: {
    formatTime(val) {
      return moment(new Date(val)).format('YYYY')
    }
  },
  mixins: [buildingProjectGroupMixin, buildingProjectMixin],
  data() {
    return {
      // 当前标题
      titleData: {
        title: '',
        path: ''
      },
      titleList: [
        {
          title: '查看建设项目',
          path: '/buildingProject/buildingProjectList',
          detailType: '00'
        },
        {
          title: '查看建设项目',
          path: '/buildingProject/buildingProjectLedgerList',
          detailType: '01'
        },
        {
          title: '审批建设项目',
          path: '/buildingProject/buildingProjectAuditList',
          detailType: '02'
        }
      ],
      industryClassList: [] // 行业分类列表数据
    }
  },
  created() {
    this.upLoadData.bizId = this.buildingProjectId // 附件主键id
  },
  mounted() {
    this.initTitle()
    // 获取建设项目信息
    this.getConstructionProject()
    // 获取字典信息
    this.getInitMultiStageTypeGroup()
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    // 获取建设项目信息
    getConstructionProject() {
      getConstructionProjectById(this.buildingProjectId).then(res => {
        this.formData = res.data
      }).catch(() => {
      })
    },
    // 获取字典信息
    getInitMultiStageTypeGroup() {
      const projectIndustry = 'pretProjectIndustry'
      initMultiStageTypeGroup(projectIndustry).then(response => {
        this.industryClassList = response.data.typeList
        this.industryClassList.forEach((item) => {
          if (item.typecode === this.formData.industryClass) {
            if (item.child.length) {
              item.child.forEach(el => {
                if (el.typecode === this.formData.industryInfo) {
                  this.formData.industryInfo = el.typename
                }
              })
            }
            this.formData.industryClass = item.typename
          }
        })
      })
    },
    // 返回按钮
    back() {
      this.$router.push({ path: this.titleData.path })
    },
    // 初始化标题
    initTitle() {
      // 通过路由传值过来的query.detailType字段取到对应的数据
      // 状态值 00 查看建设项目 01 台账查看建设项目 02 审批建设项目
      this.titleList.forEach(item => {
        if (this.$route.params.detailType === item.detailType) {
          this.titleData = item
        }
      })
    }
  }
}
</script>

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