<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="dueForm.id"
                ref="dueForm"
                class="special-el-form public-padded-t-20"
                :model="dueForm"
                label-width="170px"
              >
                <el-form-item label="尽调名称" class="special-el-form-item">
                  <el-input
                    disabled
                    v-model="dueForm.investigateName"
                    placeholder="请输入尽调名称"
                  />
                </el-form-item>
                <el-form-item
                  label="尽调地点"
                  prop="investigatePlace"
                  class="special-el-form-item"
                >
                  <el-input
                    disabled
                    maxlength="100"
                    v-model="dueForm.investigatePlace"
                  />
                </el-form-item>
                <el-form-item label="期望尽调开始时间" prop="startTime">
                  <el-date-picker
                    disabled
                    clearable
                    v-model="dueForm.startTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                  >
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="期望尽调结束时间" prop="endTime">
                  <el-date-picker
                    disabled
                    clearable
                    v-model="dueForm.endTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                  >
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="尽调资料是否齐全" prop="readiness">
                  <el-radio-group v-model="dueForm.readiness" disabled>
                    <el-radio label="1">是</el-radio>
                    <el-radio label="0">否</el-radio>
                  </el-radio-group>
                </el-form-item>
                <el-form-item label="是否有第三方投资机构" prop="thirdParty">
                  <el-radio-group v-model="dueForm.thirdParty" disabled>
                    <el-radio label="1">是</el-radio>
                    <el-radio label="0">否</el-radio>
                  </el-radio-group>
                </el-form-item>
                <el-form-item label="尽调费用(元)">
                  <el-input disabled v-model="dueForm.investigateCost" />
                </el-form-item>

                <el-form-item label="尽调财务数据截止日期" prop="deadDate">
                  <el-date-picker
                    disabled
                    clearable
                    v-model="dueForm.deadDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                  >
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="尽调人员" class="special-el-form-item">
                  <el-input
                    type="textarea"
                    rows="2"
                    disabled
                    v-model="dueForm.investigatePerson"
                  />
                </el-form-item>
                <el-form-item label="尽调资料" class="special-el-form-item">
                  <fileItem ref="fileItems1" :id="dueForm.id" :is-detail="true"></fileItem>
                </el-form-item>
                <el-form-item label="描述" class="special-el-form-item">
                  <el-input
                    disabled
                    rows="4"
                    v-model="dueForm.describe"
                    type="textarea"
                  />
                </el-form-item>
                <el-form-item label="备注" class="special-el-form-item">
                  <el-input
                    disabled
                    rows="4"
                    type="textarea"
                    v-model="dueForm.remark"
                  />
                </el-form-item>
                <el-form-item label="财务评估报告" class="special-el-form-item">
                  <fileItem ref="financeFileItem" :id="dueForm.id" :is-detail="true"></fileItem>
                </el-form-item>
                <el-form-item label="法务评估报告"  class="special-el-form-item">
                  <fileItem ref="legalFileItem" :id="dueForm.id" :is-detail="true"></fileItem>
                </el-form-item>
                <el-form-item label="其他" class="special-el-form-item">
                  <fileItem ref="otherFileItem" :id="dueForm.id" :is-detail="true"></fileItem>
                </el-form-item>
              </el-form>
              <div
                v-else
                class="public-flex-center public-padded-20"
                style="color: #909399"
              >
                暂无数据
              </div>
            </el-tab-pane>
            <el-tab-pane label="尽职背调报告汇总表" v-if="dueAllPeportList.length > 0&&dueForm.taskDefKey!='modifyApply'&&dueForm.taskDefKey!='deptLeader'&&dueForm.taskDefKey!='upload'">
              <div v-if="dueAllPeportList.length > 0">
                <el-form
                  v-for="(item, index) in dueAllPeportList"
                  :key="index"
                  class="special-el-form public-padded-t-20"
                  :model="item"
                  label-width="100px"
                >
                  <el-form-item label="尽调人员" class="special-el-form-item">
                    <el-input disabled v-model="item.investigatePerson" />
                  </el-form-item>
                  <el-form-item label="报告" class="special-el-form-item">
                    <fileItem
                      ref="dueAllreportFileItems"
                      :id="item.id"
                      :is-detail="true"
                    ></fileItem>
                  </el-form-item>
<!--                  <el-form-item label="备注" class="special-el-form-item">
                    <el-input
                      disabled
                      rows="4"
                      type="textarea"
                      v-model="item.remark"
                      placeholder="请输入备注"
                    />
                  </el-form-item>-->
                  <el-divider></el-divider>
                </el-form>
              </div>
              <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="pInstId" v-if="pInstId"></flowBase>
    </section>
  </div>
</template>
<script>
import poolForm from "../../invest/components/poolForm";
import fileItem from "../../invest/components/fileItem";
import flowBase from "../flowBase.vue";

import {
  getPool,
  getDueAllPeportList,
} from "@/api/invest/pool";
import{
  getInvestigateInfo,
} from "@/api/project/investigate/pool"

import { mapGetters } from "vuex";

export default {
  name: "decisionDetail",
  components: {
    poolForm,
    fileItem,
    flowBase
  },
  data() {
    return {
      meetingId: "0",
      type: "2",
      id: "",
      active: 0,
      detailInfo: {
        projectName: "",
      },
      activeName: "0",
      pInstId: null,
      dueForm: {
        id: null,
        investigateName: null,
        investigateCode: null,
        projectPoolId: null,
        investigatePerson: null,
        investigatePersonId: null,
        investigateCost: null,
        //
        startTime: null,
        endTime: null,
        investigatePlace: null,
        readiness: null,
        thirdParty: null,
        deadDate: null,
        //
        describe: null,
        remark: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        projectName: null,
        flag:null,
        taskDefKey:null,
      },
      dueAllPeportList:[]
    };
  },
  computed: {
    ...mapGetters(["user"]),
  },
  created() {
    this.id = this.$route.query.id;
    this.pInstId=this.$route.query.pInstId;
    this.getDetail();
    this.getInvestigateListProjectPoolIdNew();
    if (this.$route.query.activeName) {
      this.activeName = this.$route.query.activeName;
    }
  },
  methods: {

    handleClick(tab, event) {
      let that = this;
      if (this.activeName === "0") {
        // 尽职背调
        this.getInvestigateListProjectPoolIdNew();
      } else if (this.activeName === "1") {
        // 项目报备
        this.getDetail();
      }
    },
// 根据项目ID获取最新尽调申请
    getInvestigateListProjectPoolIdNew() {
      let that = this;
      getInvestigateInfo(this.$route.query.pInstId).then((response) => {
        if (response && response.data) {
          that.dueForm = response.data;
          setTimeout(() => {
            this.$refs.fileItems1.handleButton();
            this.$refs.fileItems1.listFile = [];
            this.$refs.fileItems1.getListFileBusinessId(that.dueForm.id,"11");
            //财务评估报告
            this.$refs.financeFileItem.handleButton();
            this.$refs.financeFileItem.fileList = [];
            this.$refs.financeFileItem.getListFileBusinessId(that.dueForm.id, "14");
            //法务评估报告
            this.$refs.legalFileItem.handleButton();
            this.$refs.legalFileItem.fileList = [];
            this.$refs.legalFileItem.getListFileBusinessId(that.dueForm.id, "15");
            //其他
            this.$refs.otherFileItem.handleButton();
            this.$refs.otherFileItem.fileList = [];
            this.$refs.otherFileItem.getListFileBusinessId(that.dueForm.id, "0");
          }, 300);
          this.handleLook(response.data);
        }
      });
    },
    // 根据尽调申请id查下面所有的报告
    handleLook(row) {
      let that = this;
      getDueAllPeportList(row.id).then((response) => {
        let rows = response.rows;
        this.dueAllPeportList = rows;
        this.dueDiligenceOpen2 = true;
        if (rows && rows.length > 0) {
          setTimeout(() => {
            for (let i in rows) {
              this.$refs.dueAllreportFileItems[i].handleButton();
              this.$refs.dueAllreportFileItems[i].getListFileBusinessId(
                rows[i].id
              );
            }
          }, 300);
        }
      });
    },
    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;
}
/*表格样式开始*/
.ss_scoreTable {
  padding-bottom: 50px;
  ::v-deep .el-input.is-disabled .el-input__inner {
    background-color: #fff !important;
    color: #606266;
  }
  ::v-deep .el-input__inner {
    border: 1px solid transparent;
    text-align: center;
  }
  ::v-deep.el-textarea__inner {
    border: none;
    height: 50px;
    resize: none;
  }
  ::v-deep .el-textarea.is-disabled .el-textarea__inner {
    background-color: #fff !important;
  }
  textarea:disabled,
  input:disabled {
    background-color: #fff !important;
  }
  // ::v-deep .el-textarea__inner {
  //   // border: 1px solid transparent!important;
  // }
  table {
    // width:80%;
    // width: 600px;
    margin: 0 30px;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    -khtml-user-selece: none;
    /*上面都是兼容性问题，具体看浏览器版本或什么浏览器*/
    user-select: none; /*内容禁止选中*/
  }
  tbody td {
    font-size: 14px;
  }
  thead th,
  .big-font {
    font-size: 16px !important;
    font-weight: bold;
  }
  .public-pedded-0 {
    padding: 0;
  }
  .text-center {
    text-align: center;
  }
  .text-left {
    text-align: left;
  }
  .table-textarea {
    width: 100%;
    // width: 180px;
    border: none;
    height: 50px;
    resize: none;
  }
  .table-input {
    width: 100%;
    // width: 100%;
    // height: 80px;
    border: none;
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    margin-top: 20px;
  }
  .bg-blue,
  .specificTr > th:nth-child(2n-1) {
    background-color: #9bc2e6;
  }
  .specificTr > th:nth-child(2n-1) {
    white-space: nowrap;
    padding: 0 15px;
  }
  .specificTr .table-textarea {
    padding-top: 16px;
    background-color: #fff;
  }
  tr > th {
    height: 50px;
  }
  input:disabled {
    // background-color: #fff !important;
  }
  .btnList {
    width: 100%;
    display: flex;
    justify-content: center;
    padding-bottom: 40px;
    margin-top: 30px;
  }
}
</style>
