<template>
  <div class="app-container" v-loading="loading">
    <h3 class="toolbar">
      <span class="title">项目基本信息</span>
    </h3>
    <table class="table_view">
      <tr>
        <th>企业名称</th>
        <td>{{info.entName}}</td>
        <th>通讯地址</th>
        <td>{{info.address}}</td>
      </tr>
      <tr>
        <th>企业联系人</th>
        <td>{{info.linkName}}</td>
        <th>联系人（座机）</th>
        <td>{{info.linkPhone}}</td>
      </tr>
      <tr>
        <th>联系电话（手机）</th>
        <td>{{info.linkMobile}}</td>
        <th>职工总人数（人）</th>
        <td>{{info.totoalPersons}}</td>
      </tr>
      <tr>
        <th>年度企业销售收入（万元）</th>
        <td>{{info.sales}}</td>
        <th>占销售收入比例（%）</th>
        <td>{{info.techRate}}</td>
      </tr>
      <tr>
        <th>研发人数</th>
        <td>{{info.techPersons}}</td>
        <th>年度研发投入(万元)</th>
        <td>{{info.techInvest}}</td>
      </tr>
      <tr>
        <th>企业所属行业</th>
        <td>{{info.industry}}</td>
        <th>国家自主创新示范区企业</th>
        <td>{{innovateFlag}}</td>
      </tr>
      <tr>
        <th>技术分配人</th>
        <th>{{info.techUser}}</th>
        <th>财务分配人</th>
        <th>{{info.finUser}}</th>
      </tr>
    </table>
    <h3 class="toolbar mt20">
      <span class="title">项目是否跨年</span>
    </h3>
    <table class="table_view">
      <tr>
        <th>是否跨年</th>
        <td>{{overYearFlag}}</td>
        <th>项目期限</th>
        <td>{{info.projectStartDate}}-{{info.projectEndDate}}</td>
      </tr>
    </table>
    <h3 class="toolbar mt20">
      <span class="title">科技型中小企业信息</span>
    </h3>
    <table class="table_view">
      <tr>
        <th>是否科技型中小企业</th>
        <td>{{smallFlag}}</td>
      </tr>
    </table>
    <h3 class="toolbar mt20">
      <span class="title">高新技术企业信息</span>
    </h3>
    <table class="table_view">
      <tr>
        <th>企业是否高新技术</th>
        <td>{{techFlag}}</td>
        <th>高新技术企业所属技术领域</th>
        <td>{{info.techScope}}</td>
      </tr>
      <tr>
        <th>证书有限期限</th>
        <td>{{info.techStartDate}}-{{info.techEndDate}}</td>
        <th>高新证书</th>
        <td>
          <a :href="info.techLicense" class="link">高新证书</a>
        </td>
      </tr>
    </table>
    <h3 class="toolbar mt20">
      <span class="title">操作日志</span>
    </h3>
    <h3 class="toolbar">
      <div class="tool">
        <el-button type="text" size="mini" @click="handleMore">更多</el-button>
      </div>
    </h3>
    <el-table v-loading="loading" :data="list" border style="width: 100%">
      <el-table-column type="index" label="日志编号" align="center" width="100"></el-table-column>
      <el-table-column label="日志内容" prop="content" align="center"></el-table-column>
      <el-table-column label="操作人" prop="createBy" align="center"></el-table-column>
      <el-table-column label="操作日期" prop="createTime" align="center"></el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getData"/>
  </div>
</template>

<script>
  import { getProjectInfoApi,getProjectInfoAdminApi,getProjectInfoCommonApi } from "@/api/enterprise/project/project"
  import {getLabel,yesOrNoOptions} from '@/utils/dataFormat'
  export default {
    name: 'projectInfo',
    data () {
      return {
        loading: false,
        id: undefined,
        roleType: '',
        info: {
          projectLogList: []
        },
        list: [],
        total: 0,
        queryParams: {
          pageNum: 1,
          pageSize: 1
        }
      }
    },
    props: {
      projectOwner: {
        type: String
      },
    },
    computed: {
      scopeId() {
        return this.$store.state.user.scopeId
      },
      roles() {
        return this.$store.state.user.roles
      },
      innovateFlag() {
        return getLabel(yesOrNoOptions, this.info.innovateFlag)
      },
      overYearFlag() {
        return getLabel(yesOrNoOptions, this.info.overYearFlag)
      },
      smallFlag() {
        return getLabel(yesOrNoOptions, this.info.smallFlag)
      },
      techFlag() {
        return getLabel(yesOrNoOptions, this.info.techFlag)
      }
    },
    created () {
      this.id = this.$route.params.id || undefined;
      this.roleType = this.roles.join(',')
      if(this.id) {
        this.getData()
      }
    },
    methods: {
      //判断是科德管理员 还是企业角色
      getData() {
        getProjectInfoCommonApi(this.id).then(res => {
          if(this.projectOwner == '1') {
            this.info = res.data.entProject || {}
            if(this.info.projectLogList.length > 0) {
              this.list.push(this.info.projectLogList[0])
            }
          }else if(this.projectOwner == '2') {
            this.info = res.data.techProject || {}
            if(this.info.projectLogList.length > 0 ) {
              this.list.push(this.info.projectLogList[0])
            }
          }else if(this.projectOwner == '3') {
            this.info = res.data.finProject || {}
            if(this.info.projectLogList.length > 0) {
              this.list.push(this.info.projectLogList[0])
            }
          }
        })
      },
      //更多
      handleMore() {
        if(this.info.projectLogList.length <= 1) {
          this.$message('日志已全部加载');
        }else {
          this.list = this.info.projectLogList || []
        }
        
      },
      cancel() {
        this.$store.dispatch("tagsView/delView", this.$route); // 关闭当前tab
        this.$router.go(-1);
      }
    }
  }
</script>

<style>
</style>
