<template>
  <div class="detailWrapper">
    <section class="section1 public-flex">
      <div class="public-margin-r-20">
        <h4>
          投资项目
          <span class="alreadyStop" v-if="detailInfo.delFlag === '1'"
            >已终止</span
          >
        </h4>
        <p class="projectNameTit">{{ detailInfo.projectName }}</p>
      </div>

    </section>
    <el-divider></el-divider>
    <section>
      <!-- :space="200" -->
      <el-divider></el-divider>
      <div
        class="public-flex-between basicsInfo"
        v-if="detailInfo.projectState != '1'"
      >
        <div class="public-flex-center-column">
          <div>项目公司名称</div>
          <p
            style="width: 250px; text-align: center"
            class="yichu1"
            v-if="
              detailInfo.tProjectCompany &&
              detailInfo.tProjectCompany.companyName
            "
          >
            {{ detailInfo.tProjectCompany.companyName }}
          </p>
        </div>
        <div class="public-flex-center-column">
          <div>渠道</div>
          <p
            v-if="
              detailInfo.tProjectChannel &&
              detailInfo.tProjectChannel.channelName
            "
          >
            {{ detailInfo.tProjectChannel.channelName }}
          </p>
          <p v-else-if="scope.row.channel=='1'" >
            直接触达
          </p>
          <p v-else="scope.row.channel=='2'" >
            内部推荐
          </p>
        </div>
        <div class="public-flex-center-column">
          <div>项目负责人</div>
          <p>{{ detailInfo.investHead }}</p>
        </div>
        <div class="public-flex-center-column" v-if="detailInfo.projectDate">
          <div>立项通过日期</div>
          <p>{{ detailInfo.projectDate }}</p>
        </div>
        <div class="public-flex-center-column" v-if="detailInfo.decisionDate">
          <div>投决通过日期</div>
          <p>{{ detailInfo.decisionDate }}</p>
        </div>
        <div class="public-flex-center-column">
          <div>投前估值（万元）</div>
          <p>{{ detailInfo.investValuation }}</p>
        </div>
        <div class="public-flex-center-column">
          <div>预计投资金额（万元）</div>
          <p>{{ detailInfo.investMoney }}</p>
        </div>
      </div>
    </section>
    <section class="section3">
      <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
        <el-tab-pane label="终止申请信息" name="0"></el-tab-pane>
        <el-tab-pane label="项目基本信息" name="1"></el-tab-pane>
      </el-tabs>
      <section>
        <div v-if="activeName === '0'" class="public-padded-20 detail-meeting">
          <el-tabs type="border-card" style="border: 1px solid #DCDFE6;">
            <el-tab-pane label="项目终止申请表">
              <el-form
                v-if="formZZApply.id"
                class="special-el-form public-padded-t-20"
                ref="formTJApply"
                :model="formZZApply"
                label-width="120px"
              >
                <el-form-item
                  label="终止原因"
                  prop="reason"
                  class="special-el-form-item"
                >
                  <el-input
                    rows="4"
                    type="textarea"
                    maxlength="200"
                    v-model="formZZApply.reason"
                    disabled
                  />
                </el-form-item>
              </el-form>
              <div
                v-else
                class="public-flex-center public-padded-20"
                style="color: #909399"
              >
                暂无数据
              </div>
            </el-tab-pane>
          </el-tabs>
        </div>
        <div v-show="activeName === '1'">
          <poolForm :type="type" :id="id"></poolForm>
        </div>
      </section>
    </section>
    <section>
      <flowBase :procInstId="formZZApply.procInstId" v-if="formZZApply.procInstId"></flowBase>
    </section>
  </div>
</template>
<script>
import poolForm from "../../invest/components/poolForm";
import flowBase from "../flowBase.vue";
import{
  getTerminationInfo,
} from "@/api/project/termination/pool"

import {
  getPool
} from "@/api/invest/pool";
import {
  listProjectPoolIdNewTermination
} from "@/api/invest/meeting";

import { mapGetters } from "vuex";

export default {
  name: "terminationDetail",
  components: {
    poolForm,
    flowBase
  },
  data() {
    return {
      type: "2",
      id: "",
      active: 0,
      detailInfo: {
        projectName: "",
      },
      activeName: "0",
      formZZApply: {
        id: null,
        procInstId:null,
        projectPoolId: null,
        projectName: null,
        reason: null,
      },
    };
  },
  computed: {
    ...mapGetters(["user"]),
  },
  created() {
    this.id = this.$route.query.id;
    this.getDetail();
    this.getlistProjectPoolIdNewTermination();
    if (this.$route.query.activeName) {
      this.activeName = this.$route.query.activeName;
    }
  },
  methods: {

    handleClick(tab, event) {
      let that = this;
      if (this.activeName === "0") {
        // 项目投决
        this.getlistProjectPoolIdNewTermination();
      } else if (this.activeName === "1") {
        // 项目报备
        this.getDetail();
      }
    },

    // 获取投决申请
    getlistProjectPoolIdNewTermination() {
      let that = this;
      getTerminationInfo(this.$route.query.pInstId).then((response) => {
        if (response && response.data) {
          that.formZZApply = response.data;
        }
      });
    },
    getDetail() {
      getPool(this.id).then((response) => {
        this.detailInfo = response.data;
        // 项目退出完成n
        if (response.data.projectState === "n") {
          this.active = parseInt(response.data.projectStage);
        } else {
          this.active = parseInt(response.data.projectStage) - 1;
        }
      });
    },

  },
};
</script>
<style lang="scss" scoped>
.detailWrapper {
  padding: 20px 0;
  width: 92%;
  margin: 0 auto;
  .section1 {
    p {
      font-size: 24px;
      font-weight: bold;
      margin: 0;
    }
    > div:first-child {
      // width: calc(100% - 700px);
      width: 100%;
    }
    .btnList {
      width: 700px;
      display: flex;
      justify-content: flex-end;
    }
  }
  .basicsInfo {
    font-size: 14px;
    background: #f1f1f1;
    margin-top: -24px;
    width: 100%;
    padding: 30px 20px 10px;
    div {
      color: #7e7d7d;
    }
    p {
      font-size: 16px;
      color: #333;
      font-weight: bold;
    }
  }
  .section3 {
    border: 1px solid #DCDFE6;
    margin-top: 40px;
  }
}
.projectNameTit {
}
.alreadyStop {
  font-weight: normal;
  font-size: 12px;
  background: #ff0000;
  color: #fff;
  border-radius: 5px;
  padding: 5px 10px;
  margin-left: 10px;
}

</style>
