<template>
  <div class="project-admittance">
    <el-form ref="ruleForm" :model="ruleForm" label-position="top" label-width="120px" class="rule-form-orange">
      <el-form-item label="项目类型" prop="projectType">
        <el-input v-model="ruleForm.projectType" placeholder="请输入项目类型" disabled />
      </el-form-item>
      <el-form-item label="项目名称" prop="projectName">
        <el-input v-model="ruleForm.projectName" placeholder="请输入项目名称" disabled />
      </el-form-item>
      <el-form-item label="相关文件" prop="biddingFiles">
        <cy-upload
          ref="fileStorage"
          disabled
          :upload-params="{}"
          :file-data="ruleForm.biddingFiles"
          :upload-from-orange-status="true"
          placeholder="请上传相关文件"
        />
      </el-form-item>
      <el-form-item label="项目地点" prop="projectAddress" class="one-form-item">
        <el-input v-model="ruleForm.projectAddress" placeholder="请输入项目地点" disabled />
      </el-form-item>
      <el-form-item label="评估得分" prop="projectAddressScore" class="one-form-item">
        <el-input v-model="ruleForm.projectAddressScore" placeholder="请输入评估得分" disabled />
      </el-form-item>
      <el-form-item label="相关文件" prop="departmentFiles" style="width: 100%">
        <cy-upload
          ref="fileStorage"
          disabled
          :upload-params="{}"
          :file-data="ruleForm.departmentFiles"
          :upload-from-orange-status="true"
          placeholder="请上传相关文件"
        />
      </el-form-item>
      <el-form-item label="项目周期" prop="projectCycle" class="one-form-item">
        <el-input v-model="ruleForm.projectCycle" placeholder="请输入项目周期" disabled />
      </el-form-item>
      <el-form-item label="评估得分" prop="projectCycleScore" class="one-form-item">
        <el-input v-model="ruleForm.projectCycleScore" placeholder="请输入评估得分" disabled />
      </el-form-item>
      <el-form-item label="项目性质" prop="projectNature" class="one-form-item">
        <el-input :value="ruleForm.projectNature + ' ' + ruleForm.projectNatureDetail + ' ' + ruleForm.projectNatureDetailDes" placeholder="请输入项目性质" disabled />
      </el-form-item>
      <el-form-item label="评估得分" prop="projectNatureScore" class="one-form-item">
        <el-input v-model="ruleForm.projectNatureScore" placeholder="请输入评估得分" disabled />
      </el-form-item>
      <el-form-item label="货物品类" prop="goodsCategory" class="one-form-item">
        <el-input :value="ruleForm.goodsCategory+' '+ruleForm.goodsCategoryDetail + ' ' + ruleForm.goodsCategoryDetailDes" placeholder="请输入用途" disabled />
      </el-form-item>
      <el-form-item label="用途" prop="purpose" class="one-form-item">
        <el-input :value="ruleForm.purpose + ' ' + ruleForm.purposeDetail" placeholder="请输入用途" disabled />
      </el-form-item>
      <el-form-item style="width: 100%">
        <template slot="label">
          <span>资金来源及占比</span>
        </template>
        <div class="three-gird">
          <div class="checkbox-box">
            <el-checkbox v-model="financialFundsCheck">财政资金</el-checkbox>
            <el-input v-model="ruleForm.financialFunds" placeholder="请输入财政资金占比" disabled>
              <!-- <template slot="prepend">占比</template> -->
              <template slot="append">%</template>
            </el-input>
          </div>
          <div class="checkbox-box">
            <el-checkbox v-model="bankLoansCheck">银行贷款</el-checkbox>
            <el-input v-model="ruleForm.bankLoans" placeholder="请输入银行贷款占比" disabled>
              <!-- <template slot="prepend">占比</template> -->
              <template slot="append">%</template>
            </el-input>
          </div>
          <div class="checkbox-box">
            <el-checkbox v-model="foreignCapitalCheck">利用外资</el-checkbox>
            <el-input v-model="ruleForm.foreignCapital" placeholder="请输入利用外资占比" disabled>
              <!-- <template slot="prepend">占比</template> -->
              <template slot="append">%</template>
            </el-input>
          </div>
        </div>
        <div class="three-gird">
          <div class="checkbox-box">
            <el-checkbox v-model="raiseIndependentlyCheck">企事业单位自筹资金</el-checkbox>
            <el-input v-model="ruleForm.raiseIndependently" placeholder="请输入企事业单位自筹自己资金" disabled>
              <!-- <template slot="prepend">占比</template> -->
              <template slot="append">%</template>
            </el-input>
          </div>
          <div class="checkbox-box">
            <el-checkbox v-model="specialFundCheck">专项资金</el-checkbox>
            <el-input v-model="ruleForm.specialFund" placeholder="请输入专项资金占比" disabled>
              <!-- <template slot="prepend">占比</template> -->
              <template slot="append">%</template>
            </el-input>
          </div>
          <div class="checkbox-box">
            <el-checkbox v-model="otherFundsCheck">其他资金</el-checkbox>
            <el-input v-model="ruleForm.otherFunds" placeholder="请输入其他资金占比" disabled>
              <!-- <template slot="prepend">占比</template> -->
              <template slot="append">%</template>
            </el-input>
          </div>
        </div>
        <div class="three-gird">
          <div class="checkbox-box">
            <el-checkbox v-model="unknownCheck">未知</el-checkbox>
            <el-input v-model="ruleForm.unknown" placeholder="请输入未知占比" disabled>
              <!-- <template slot="prepend">占比</template> -->
              <template slot="append">%</template>
            </el-input>
          </div>
        </div>
      </el-form-item>
      <el-form-item label="评估得分" prop="fundScore" style="width: 100%;">
        <el-input v-model="ruleForm.fundScore" placeholder="请输入评估得分" disabled />
      </el-form-item>
    </el-form>
    <cy-info-title style="margin-top: 25px;">项目业主方</cy-info-title>
    <owner type="project" :details="ownerInfo" />
    <cy-info-title style="margin-top: 25px;"> 项目业主方-负面清单</cy-info-title>
    <negative-list :details="negativeInfo" />
    <cy-info-title style="margin-top: 25px;">本次合作相关</cy-info-title>
    <cooperation :details="cooperationInfo" />
    <cy-info-title style="margin-top: 25px;">综合评估</cy-info-title>
    <project-assess :details="evaluationInfo" />
    <div class="submit-btn">
      <el-button @click="closePage"> 关闭</el-button>
    </div>
  </div>
</template>

<script>
import { getProjectReport } from '@/api/creditManage/projectManage'
export default {
  components: {
    Owner: () => import('./components/Owner'),
    NegativeList: () => import('./components/NegativeList'),
    Cooperation: () => import('./components/Cooperation'),
    ProjectAssess: () => import('./components/ProjectAssess')
  },
  data() {
    return {
      detailsInfo: {},
      ruleForm: {},
      ownerInfo: {},
      negativeInfo: {},
      cooperationInfo: {},
      evaluationInfo: {}
    }
  },
  computed: {
    financialFundsCheck() {
      return this.ruleForm.financialFunds !== 0 && this.ruleForm.financialFunds !== '' && this.ruleForm.financialFunds !== null
    },
    bankLoansCheck() {
      return this.ruleForm.bankLoans !== 0 && this.ruleForm.bankLoans !== '' && this.ruleForm.bankLoans !== null
    },
    foreignCapitalCheck() {
      return this.ruleForm.foreignCapital !== 0 && this.ruleForm.foreignCapital !== '' && this.ruleForm.foreignCapital !== null
    },
    raiseIndependentlyCheck() {
      return this.ruleForm.raiseIndependently !== 0 && this.ruleForm.raiseIndependently !== '' && this.ruleForm.raiseIndependently !== null
    },
    specialFundCheck() {
      return this.ruleForm.specialFund !== 0 && this.ruleForm.specialFund !== '' && this.ruleForm.specialFund !== null
    },
    otherFundsCheck() {
      return this.ruleForm.otherFunds !== 0 && this.ruleForm.otherFunds !== '' && this.ruleForm.otherFunds !== null
    },
    unknownCheck() {
      return this.ruleForm.unknown !== 0 && this.ruleForm.unknown !== '' && this.ruleForm.unknown !== null
    }

  },
  created() {
    this.getDetails()
  },
  methods: {
    getDetails() {
      const { id } = this.$route.query
      getProjectReport({ id }).then(({ data }) => {
        this.detailsInfo = data
        // 项目信息
        const {
          projectInformation,
          projectAddressScore,
          projectCycleScore,
          projectNatureScore,
          fundScore,
          projectOwnerEnterprise,
          projectOwnerComprehensiveEvaluation
        } = data
        this.ruleForm = {
          ...projectInformation,
          projectAddressScore,
          projectCycleScore,
          projectNatureScore,
          fundScore
        }

        // 项目业主方
        this.ownerInfo = {
          corporateName: projectOwnerEnterprise.corporateName,
          socialCreditCode: projectOwnerEnterprise.socialCreditCode,
          yearsDiff: projectOwnerEnterprise.yearsDiff,
          companyForProject: projectInformation.companyForProject === 1 ? '是' : '否',
          establishmentPeriodScore: data.establishmentPeriodScore,
          registeredCapital: projectOwnerEnterprise.registeredCapital,
          registeredCapitalScore: data.registeredCapitalScore,
          address: projectOwnerEnterprise.address,
          registeredAddressScore: data.registeredAddressScore,
          businessAddress: projectOwnerEnterprise.businessAddress,
          businessAddressScore: data.businessAddressScore,
          enterpriseNature: data.projectAuditInfo.enterpriseNature + ' ' + data.projectAuditInfo.enterpriseNatureDetail,
          enterpriseNatureScore: data.enterpriseNatureScore,
          holdingRatio: data.projectAuditInfo.holdingRatio,
          holdingRatioScore: data.holdingRatioScore,
          equityHierarchy: data.projectAuditInfo.equityHierarchy + ' ' + data.projectAuditInfo.equityHierarchyDetail,
          equityHierarchyScore: data.equityHierarchyScore,
          creditRating: data.projectAuditInfo.creditRating,
          creditRatingScore: data.creditRatingScore
        }

        // 业主方负面清单
        this.negativeInfo = data

        // 本次合作相关
        this.cooperationInfo = {
          cooperationAmount: projectInformation.cooperationAmount,
          peakValue: projectInformation.peakValue,
          estimatedAccountingPeriod: projectInformation.estimatedAccountingPeriod,
          highPeakUsage: projectInformation.highPeakUsage,
          estimatedAccountingPeriodScore: data.estimatedAccountingPeriodScore
        }

        // 综合
        this.evaluationInfo = { ...projectOwnerComprehensiveEvaluation, evaluationOpinions: data.projectAuditInfo.evaluationOpinions }
      })
    },
    closePage() {
      this.$router.push({
        name: 'ProjectCredit'
      })
    }

  }
}
</script>

<style lang="scss" scoped>
.project-admittance {
padding: 10px 15px;
.el-form {
  padding: 10px 15px;
}
.three-gird {
    display: flex;
    & > div {
      width: calc(33.33% - 10px);
      margin-right: 20px;
      &:last-child {
        margin-right: 0px;
      }
    }
  }
.checkbox-box {
    display: flex;
    margin-bottom: 20px;
    label {
      margin-right: 20px;
    }
  }
}
</style>
