<template>
  <div class="add-project-container">
    <div class="add-project-content" v-loading="loading">
      <routerBack />
      <div class="tabs-content">
        <el-collapse v-model="activeCollapse">
          <el-tabs v-model="pageActiveName" type="border-card">
            <el-tab-pane label="基础信息" name="基础信息">
              <div class="project-tab-content">
                <el-form :model="formData" :disabled="isPreview">
                  <!-- 1. 项目基本信息 -->
                  <el-collapse-item title="项目基本信息" name="项目基本信息">
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item label="项目名称" required>
                          <el-select
                            v-model="formData.projectId"
                            placeholder="请选择项目名称"
                            no-data-text="暂无数据"
                            @change="changeProject"
                          >
                            <el-option
                              v-for="item in projectList"
                              :key="item.id"
                              :label="item.projectName"
                              :value="item.id"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="项目编号">
                          <el-input
                            v-model="formData.projectCode"
                            placeholder="请输入项目编号"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="是否再决策">
                          <CommonSelector
                            :radio="true"
                            v-model="formData.isReDecision"
                            dictName="sf"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="项目外文名称">
                          <el-input
                            v-model="formData.projectForeignName"
                            placeholder="请输入项目外文名称"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="是否能建联合体项目">
                          <CommonSelector
                            :radio="true"
                            v-model="formData.isUnionProject"
                            dictName="sf"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="投资主体">
                          <el-input
                            v-model="formData.investmentSubject"
                            placeholder="请输入投资主体"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="是否一体化子项目">
                          <CommonSelector
                            :radio="true"
                            v-model="formData.isIntegratedSubProject"
                            dictName="sf"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="直属企业">
                          <el-input
                            v-model="formData.directEnterprise"
                            placeholder="请输入直属企业"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="是否能建重大或重要投资项目">
                          <CommonSelector
                            :radio="true"
                            v-model="formData.isImportantInvestProject"
                            dictName="sf"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="决策审批单位">
                          <el-input
                            v-model="formData.approvalUnit"
                            placeholder="请输入决策审批单位"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="财务报表类型">
                          <el-input
                            v-model="formData.financialReportType"
                            placeholder="请输入财务报表类型"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="政府(核准、备案)审批级别">
                          <el-input
                            v-model="formData.governmentApprovalLevel"
                            placeholder="请输入审批级别"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="是否自主决策">
                          <CommonSelector
                            :radio="true"
                            v-model="formData.isIndependentDecision"
                            dictName="sf"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="主业/非主业">
                          <el-select
                            v-model="formData.businessType"
                            placeholder="请选择"
                          >
                            <el-option label="主业" value="主业"></el-option>
                            <el-option
                              label="非主业"
                              value="非主业"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="联系人">
                          <el-input
                            v-model="formData.contactPerson"
                            placeholder="请输入联系人"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="联系电话">
                          <el-input
                            v-model="formData.contactPhone"
                            placeholder="请输入联系电话"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 2. 项目所在地 -->
                  <el-collapse-item title="项目所在地" name="项目所在地">
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item label="境内/外">
                          <el-select
                            v-model="formData.domesticOverseas"
                            placeholder="请选择"
                          >
                            <el-option label="境内" value="境内"></el-option>
                            <el-option label="境外" value="境外"></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="省(境内)/洲际(境外)">
                          <el-input
                            v-model="formData.provinceContinent"
                            placeholder="请输入"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="地市（境内）/国家（境外）">
                          <el-input
                            v-model="formData.cityCountry"
                            placeholder="请输入"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="区县(境内)/国家(境外)">
                          <el-input
                            v-model="formData.districtCountry"
                            placeholder="请输入"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="项目区域">
                          <el-input
                            v-model="formData.projectArea"
                            placeholder="请输入项目区域"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="是否一带一路沿线国家">
                          <CommonSelector
                            :radio="true"
                            v-model="formData.isBeltRoadCountry"
                            dictName="sf"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 3. 计量币种 -->
                  <el-collapse-item title="计量币种" name="计量币种">
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item label="币种">
                          <el-select
                            v-model="formData.currencyType"
                            placeholder="请选择币种"
                          >
                            <el-option label="人民币" value="CNY"></el-option>
                            <el-option label="美元" value="USD"></el-option>
                            <el-option label="欧元" value="EUR"></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="汇率">
                          <el-input
                            v-model="formData.exchangeRate"
                            placeholder="请输入汇率"
                            :precision="6"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 4. 实施时间 -->
                  <el-collapse-item title="实施时间" name="实施时间">
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item label="项目建设期 (月)">
                          <el-input
                            v-model="formData.constructionPeriod"
                            placeholder="请输入"
                            type="number"
                            min="0"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="运营年限 (年)">
                          <el-input
                            v-model="formData.operationYears"
                            placeholder="请输入"
                            type="number"
                            min="0"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="项目合作期 (年)">
                          <el-input
                            v-model="formData.cooperationPeriod"
                            placeholder="请输入"
                            type="number"
                            min="0"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="项目开工时间(预计)">
                          <el-date-picker
                            v-model="formData.plannedStartDate"
                            type="date"
                            placeholder="请选择"
                            value-format="YYYY-MM-DD"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="项目交工时间(预计)">
                          <el-date-picker
                            v-model="formData.plannedCompletionDate"
                            type="date"
                            placeholder="请选择"
                            value-format="YYYY-MM-DD"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 5. 投资分类 -->
                  <el-collapse-item title="投资分类" name="投资分类">
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-tabs v-model="activeInvestTab">
                          <el-tab-pane label="投资属性分类" name="attribute">
                            <el-row :gutter="20">
                              <el-col :span="8">
                                <el-form-item label="一级分类">
                                  <el-input
                                    v-model="formData.investAttributeFirst"
                                    placeholder="请输入"
                                  />
                                </el-form-item>
                              </el-col>
                              <el-col :span="8">
                                <el-form-item label="二级分类">
                                  <el-input
                                    v-model="formData.investAttributeSecond"
                                    placeholder="请输入"
                                  />
                                </el-form-item>
                              </el-col>
                              <el-col :span="8">
                                <el-form-item label="投资板块">
                                  <el-input
                                    v-model="formData.investPlate1"
                                    placeholder="请输入"
                                  />
                                </el-form-item>
                              </el-col>
                              <el-col :span="8">
                                <el-form-item label="投资板块">
                                  <el-input
                                    v-model="formData.investPlate2"
                                    placeholder="请输入"
                                  />
                                </el-form-item>
                              </el-col>
                            </el-row>
                          </el-tab-pane>
                          <el-tab-pane label="投资目的分类" name="purpose">
                            <el-row :gutter="20">
                              <el-col :span="8">
                                <el-form-item label="一级分类">
                                  <el-input
                                    v-model="formData.investPurposeFirst"
                                    placeholder="请输入"
                                  />
                                </el-form-item>
                              </el-col>
                              <el-col :span="8">
                                <el-form-item label="2+9布局分类">
                                  <el-input
                                    v-model="formData.layout29"
                                    placeholder="请输入"
                                  />
                                </el-form-item>
                              </el-col>
                              <el-col :span="8">
                                <el-form-item label="二级分类">
                                  <el-input
                                    v-model="formData.investPurposeSecond"
                                    placeholder="请输入"
                                  />
                                </el-form-item>
                              </el-col>
                              <el-col :span="8">
                                <el-form-item label="国民经济行业">
                                  <el-input
                                    v-model="formData.nationalEconomicIndustry"
                                    placeholder="请输入"
                                  />
                                </el-form-item>
                              </el-col>
                              <el-col :span="8">
                                <el-form-item label="四新分类">
                                  <el-input
                                    v-model="formData.fourNewClassification"
                                    placeholder="请输入"
                                  />
                                </el-form-item>
                              </el-col>
                            </el-row>
                          </el-tab-pane>
                        </el-tabs>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 6. 特别关注、特别监管类等信息 -->
                  <el-collapse-item
                    title="特别关注、特别监管类等信息"
                    name="特别关注、特别监管类等信息"
                  >
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item
                          label="是否须报国家发展改革委和商务部核准"
                        >
                          <CommonSelector
                            :radio="true"
                            v-model="formData.isReportedToNDRC"
                            dictName="sf"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="是否国家领导见签">
                          <CommonSelector
                            :radio="true"
                            v-model="formData.isLeaderSigned"
                            dictName="sf"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="是否境内特别监管类">
                          <CommonSelector
                            :radio="true"
                            v-model="formData.isDomesticSpecialSupervision"
                            dictName="sf"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="是否列入国资委负面清单">
                          <CommonSelector
                            :radio="true"
                            v-model="formData.isInSASACNegaticveList"
                            dictName="sf"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 7. 建设规模（实物量指标） -->
                  <el-collapse-item
                    title="建设规模（实物量指标）"
                    name="建设规模（实物量指标）"
                  >
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-form-item label=" ">
                          <DynamicTable
                            :showAddButton="!isPreview"
                            :columns="constructionScaleColumns"
                            :disabled="isPreview"
                            v-model="formData.constructionScaleList"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 8. 股东信息 -->
                  <el-collapse-item title="股东信息" name="股东信息">
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-form-item label=" ">
                          <DynamicTable
                            :showAddButton="!isPreview"
                            :columns="shareholderColumns"
                            :disabled="isPreview"
                            v-model="formData.shareholderList"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 9. 我方担保及股权融资情况 -->
                  <el-collapse-item
                    title="我方担保及股权融资情况"
                    name="我方担保及股权融资情况"
                  >
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item label="我方负责的股权融资金额（万元）">
                          <el-input
                            v-model="formData.equityFinancingAmount"
                            placeholder="请输入"
                            type="number"
                            :precision="2"
                            min="0"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="融资成本（%）">
                          <el-input
                            v-model="formData.equityFinancingCost"
                            placeholder="请输入"
                            type="number"
                            :precision="2"
                            min="0"
                            max="100"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="期限（年）">
                          <el-input
                            v-model="formData.equityFinancingTerm"
                            placeholder="请输入"
                            type="number"
                            min="0"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="担保金额（万元）">
                          <el-input
                            v-model="formData.guaranteeAmount"
                            placeholder="请输入"
                            type="number"
                            :precision="2"
                            min="0"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 10. 我方担保及债权融资情况 -->
                  <el-collapse-item
                    title="我方担保及债权融资情况"
                    name="我方担保及债权融资情况"
                  >
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-form-item label=" ">
                          <DynamicTable
                            :showAddButton="!isPreview"
                            :columns="debtFinancingColumns"
                            :disabled="isPreview"
                            v-model="formData.debtFinancingList"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 11. 项目内容及必要性 -->
                  <el-collapse-item
                    title="项目内容及必要性"
                    name="项目内容及必要性"
                  >
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-form-item label="建设内容及规模">
                          <el-input
                            v-model="formData.constructionContent"
                            type="textarea"
                            rows="4"
                            placeholder="请输入"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="项目必要性">
                          <el-input
                            v-model="formData.projectNecessity"
                            type="textarea"
                            rows="4"
                            placeholder="请输入"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="其他说明">
                          <el-input
                            v-model="formData.otherDescription"
                            type="textarea"
                            rows="4"
                            placeholder="请输入"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 12. 风险管理 -->
                  <el-collapse-item title="风险管理" name="风险管理">
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-form-item label=" ">
                          <DynamicTable
                            :showAddButton="!isPreview"
                            :columns="riskManagementColumns"
                            :disabled="isPreview"
                            v-model="formData.riskManagementList"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 13. 里程碑节点 -->
                  <el-collapse-item title="里程碑节点" name="里程碑节点">
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-form-item label=" ">
                          <DynamicTable
                            :showAddButton="!isPreview"
                            :columns="milestoneColumns"
                            :disabled="isPreview"
                            v-model="formData.milestoneList"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24" style="margin-top: 20px">
                        <el-form-item label="里程碑计划审批表">
                          <FileUploader
                            v-model="formData.milestoneApprovalFile"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 14. 投决申报材料 -->
                  <el-collapse-item title="投决申报材料" name="投决申报材料">
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-form-item label="可研材料">
                          <FileUploader
                            v-model="formData.feasibilityStudyFile"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="经济指标初步测算资料">
                          <FileUploader
                            v-model="formData.economicIndicatorFile"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="补充相关支撑材料">
                          <FileUploader
                            v-model="formData.supplementarySupportFile"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="其他相关支撑材料">
                          <FileUploader v-model="formData.otherSupportFile" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="上会议案">
                          <FileUploader
                            v-model="formData.meetingProposalFile"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>
                </el-form>
              </div>
            </el-tab-pane>
            <el-tab-pane label="财务评价" name="财务评价">
              <div class="project-tab-content">
                <FinancialTable
                  v-model="formData.cwpj"
                  :is-preview="isPreview"
                />

                <el-collapse-item title="项目可行性" name="项目可行性">
                  <el-tabs v-model="kxxName">
                    <el-tab-pane
                      label="项目投资现金流量表"
                      name="项目投资现金流量表"
                    >
                      <!-- 测试数据 -->
                      <!-- {{
                        formData.jzymljsh?.tableData?.length > 0 &&
                        formData.jzymljsh.tableData[0]
                      }} -->
                      <FinancialTable
                        v-model="formData.jzymljsh"
                        :is-preview="isPreview"
                      />
                    </el-tab-pane>
                    <el-tab-pane
                      label="项目资本金现金流量表"
                      name="项目资本金现金流量表"
                      >项目资本金现金流量表</el-tab-pane
                    >
                    <el-tab-pane
                      label="投资各方现金流量表"
                      name="投资各方现金流量表"
                      >投资各方现金流量表</el-tab-pane
                    >
                    <el-tab-pane label="利润表" name="利润表"
                      >利润表</el-tab-pane
                    >
                  </el-tabs>
                </el-collapse-item>

                <el-col :span="24" style="margin-top: 20px">
                  投屏报告以及测试表
                  <FileUploader v-model="formData.milestoneApprovalFile" />
                </el-col>
              </div>
            </el-tab-pane>
            <el-tab-pane label="决策批复" name="决策批复">
              <el-collapse-item
                title="项目投资总额（全口径）"
                name="项目投资总额（全口径）"
              >
                <FinancialTable
                  v-model="formData.tzze"
                  :is-preview="isPreview"
                />
              </el-collapse-item>
              <el-collapse-item
                title="财务评价指标（已评审指标请必填）"
                name="财务评价指标（已评审指标请必填）"
              >
                <FinancialTable
                  v-model="formData.cwpjzb"
                  :is-preview="isPreview"
                />
              </el-collapse-item>
              <el-collapse-item title="核心边界条件 " name="核心边界条件 ">
                <el-form-item label=" ">
                  <DynamicTable
                    :showAddButton="!isPreview"
                    :columns="transferColumns"
                    :disabled="isPreview"
                    v-model="formData.projectGdxxs"
                  />
                </el-form-item>
              </el-collapse-item>
              <el-collapse-item
                title="投资主体审核情况 "
                name="投资主体审核情况 "
              >
                <DynamicTable
                  :showAddButton="!isPreview"
                  :columns="shqkColumns"
                  :disabled="isPreview"
                  v-model="formData.projectTzztshqk"
                />
              </el-collapse-item>
              <el-collapse-item title="项目批复信息 " name="项目批复信息 ">
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item label="最终审批意见">
                      <el-input
                        v-model="formData.projectCode"
                        placeholder="请输入最终审批意见"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="项目批复时间">
                      <el-input
                        v-model="formData.projectCode"
                        placeholder="请输入项目批复时间"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="项目批复编号">
                      <el-input
                        v-model="formData.projectCode"
                        placeholder="请输入项目批复编号"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="24">
                    <el-form-item label="未通过主要原因和要求">
                      <el-input
                        v-model="formData.projectCode"
                        placeholder="请输入未通过主要原因和要求"
                        type="textarea"
                        rows="3"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="24">
                    <el-form-item label="批复文件">
                      <FileUploader v-model="formData.pfwj" />
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-collapse-item>
              <el-collapse-item title="审批意见 " name="审批意见 ">
                <DynamicTable
                  :showAddButton="!isPreview"
                  :columns="spyjColumns"
                  :disabled="isPreview"
                  v-model="formData.projectSpyj"
                />
              </el-collapse-item>
              <el-collapse-item title="其他 " name="其他 ">
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item label="投资主体首次申报时间">
                      <el-input
                        v-model="formData.projectCode"
                        placeholder="请输入投资主体首次申报时间"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="会签完成时间">
                      <el-input
                        v-model="formData.projectCode"
                        placeholder="请输入会签完成时间"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="首次发函时间">
                      <el-input
                        v-model="formData.projectCode"
                        placeholder="请输入首次发函时间"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="补充材料时间">
                      <el-input
                        v-model="formData.projectCode"
                        placeholder="请输入补充材料时间"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="审核人">
                      <el-input
                        v-model="formData.projectCode"
                        placeholder="请输入审核人"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-collapse-item>
            </el-tab-pane>
            <el-tab-pane label="申请报告" name="申请报告">
              <div class="project-tab-content">
                <el-form :model="formData" :disabled="isPreview">
                  <!-- 一、项目背景 -->
                  <el-collapse-item title="一、项目背景" name="一、项目背景">
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-form-item label="项目获取">
                          <el-input
                            v-model="formData.projectAcquisition"
                            type="textarea"
                            rows="4"
                            placeholder="请输入项目获取相关内容"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="前期论证主要节点">
                          <el-input
                            v-model="formData.preDemonstrationNodes"
                            type="textarea"
                            rows="4"
                            placeholder="请输入前期论证主要节点"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 二、项目基本情况 -->
                  <el-collapse-item
                    title="二、项目基本情况"
                    name="二、项目基本情况"
                  >
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item label="项目类型">
                          <el-input
                            v-model="formData.projectType"
                            placeholder="请输入项目类型"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="总投资">
                          <el-input
                            v-model="formData.totalInvestment"
                            placeholder="请输入总投资（亿元）"
                            type="number"
                            :precision="2"
                            min="0"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="单位造价">
                          <el-input
                            v-model="formData.unitCost"
                            placeholder="请输入单位造价（亿元/km）"
                            type="number"
                            :precision="2"
                            min="0"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="所在地">
                          <el-input
                            v-model="formData.location"
                            placeholder="请输入所在地"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="建设规模">
                          <el-input
                            v-model="formData.constructionScale"
                            placeholder="请输入建设规模"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="是否标前决策">
                          <CommonSelector
                            :radio="true"
                            v-model="formData.isPreDecision"
                            dictName="sf"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="建设内容">
                          <el-input
                            v-model="formData.constructionContent"
                            type="textarea"
                            rows="4"
                            placeholder="请输入建设内容"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="建设期">
                          <el-input
                            v-model="formData.constructionPeriod"
                            placeholder="请输入建设期（月）"
                            type="number"
                            min="0"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="运营期">
                          <el-input
                            v-model="formData.operationPeriod"
                            placeholder="请输入运营期（年）"
                            type="number"
                            min="0"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="合规情况">
                          <el-input
                            v-model="formData.complianceStatus"
                            type="textarea"
                            rows="2"
                            placeholder="请输入合规情况"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="实施机构">
                          <el-input
                            v-model="formData.implementationAgency"
                            placeholder="请输入实施机构"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="政府出资代表">
                          <el-input
                            v-model="
                              formData.governmentInvestmentRepresentative
                            "
                            placeholder="请输入政府出资代表"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="地方财政情况">
                          <el-input
                            v-model="formData.localFinanceStatus"
                            type="textarea"
                            rows="2"
                            placeholder="请输入地方财政情况"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="回报机制">
                          <el-input
                            v-model="formData.returnMechanism"
                            type="textarea"
                            rows="2"
                            placeholder="请输入回报机制"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="保函情况">
                          <DynamicTable
                            :showAddButton="!isPreview"
                            :columns="guaranteeColumns"
                            :disabled="isPreview"
                            v-model="formData.guaranteeList"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="绩效考核">
                          <el-input
                            v-model="formData.performanceEvaluation"
                            type="textarea"
                            rows="2"
                            placeholder="请输入绩效考核"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 三、项目必要性 -->
                  <el-collapse-item
                    title="三、项目必要性"
                    name="三、项目必要性"
                  >
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-form-item label="必要性">
                          <el-input
                            v-model="formData.necessity"
                            type="textarea"
                            rows="4"
                            placeholder="请输入项目必要性"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 四、项目可行性 -->
                  <el-collapse-item
                    title="四、项目可行性"
                    name="四、项目可行性"
                  >
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item label="可研编制单位">
                          <el-input
                            v-model="formData.feasibilityStudyUnit"
                            placeholder="请输入可研编制单位"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="可研评审单位">
                          <el-input
                            v-model="formData.feasibilityReviewUnit"
                            placeholder="请输入可研评审单位"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="经济可行性">
                          <FinancialTable
                            v-model="formData.economicFeasibility"
                            :is-preview="isPreview"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="敏感性分析">
                          <el-input
                            v-model="formData.sensitivityAnalysis"
                            type="textarea"
                            rows="4"
                            placeholder="请输入敏感性分析"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="工程收益">
                          <el-input
                            v-model="formData.projectBenefits"
                            type="textarea"
                            rows="2"
                            placeholder="请输入工程收益"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 五、风险防控 -->
                  <el-collapse-item title="五、风险防控" name="五、风险防控">
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-form-item label=" ">
                          <DynamicTable
                            :showAddButton="!isPreview"
                            :columns="riskPreventionColumns"
                            :disabled="isPreview"
                            v-model="formData.riskPreventionList"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 六、内部决策情况 -->
                  <el-collapse-item
                    title="六、内部决策情况"
                    name="六、内部决策情况"
                  >
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-form-item label="各级决策情况">
                          <el-input
                            v-model="formData.internalDecisionStatus"
                            type="textarea"
                            rows="4"
                            placeholder="请输入各级决策情况"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 七、需要说明的问题 -->
                  <el-collapse-item
                    title="七、需要说明的问题"
                    name="七、需要说明的问题"
                  >
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-form-item
                          label="股东出资能力、特殊合同条款、协同经营情况等需要特殊说明事项"
                        >
                          <el-input
                            v-model="formData.specialInstructions"
                            type="textarea"
                            rows="4"
                            placeholder="请输入需要特殊说明的事项"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>

                  <!-- 投资模式、资金方案、股权结构、股东方情况、项目公司治理结构 -->
                  <el-collapse-item
                    title="投资模式及相关信息"
                    name="投资模式及相关信息"
                  >
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-form-item label="投资模式">
                          <el-input
                            v-model="formData.investmentMode"
                            type="textarea"
                            rows="2"
                            placeholder="请输入投资模式"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="投资能力">
                          <el-input
                            v-model="formData.investmentCapacity"
                            type="textarea"
                            rows="4"
                            placeholder="请输入投资能力"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="资金方案">
                          <DynamicTable
                            :showAddButton="!isPreview"
                            :columns="fundingPlanColumns"
                            :disabled="isPreview"
                            v-model="formData.fundingPlanList"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="股权结构">
                          <DynamicTable
                            :showAddButton="!isPreview"
                            :columns="equityStructureColumns"
                            :disabled="isPreview"
                            v-model="formData.equityStructureList"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="股东方情况">
                          <el-input
                            v-model="formData.shareholderSituation"
                            type="textarea"
                            rows="4"
                            placeholder="请输入股东方情况"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="项目公司治理结构">
                          <DynamicTable
                            :showAddButton="!isPreview"
                            :columns="governanceStructureColumns"
                            :disabled="isPreview"
                            v-model="formData.governanceStructureList"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="建设管理方案">
                          <el-input
                            v-model="formData.constructionManagementPlan"
                            type="textarea"
                            rows="2"
                            placeholder="请输入建设管理方案"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="运营管理方案">
                          <el-input
                            v-model="formData.operationManagementPlan"
                            type="textarea"
                            rows="2"
                            placeholder="请输入运营管理方案"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="退出机制">
                          <DynamicTable
                            :showAddButton="!isPreview"
                            :columns="exitMechanismColumns"
                            :disabled="isPreview"
                            v-model="formData.exitMechanismList"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="调价机制">
                          <el-input
                            v-model="formData.priceAdjustmentMechanism"
                            type="textarea"
                            rows="2"
                            placeholder="请输入调价机制"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="征地拆迁">
                          <el-input
                            v-model="formData.landAcquisition"
                            type="textarea"
                            rows="2"
                            placeholder="请输入征地拆迁"
                          />
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="前期费用">
                          <el-input
                            v-model="formData.preCosts"
                            type="textarea"
                            rows="2"
                            placeholder="请输入前期费用"
                          />
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>
                </el-form>
              </div>
            </el-tab-pane>
          </el-tabs>
        </el-collapse>
      </div>
      <div class="add-project-header">
        <div class="header-left"></div>
        <div class="header-right">
          <el-button type="default" @click="backClick">返回</el-button>
          <template v-if="!loading && !isPreview">
            <el-button type="primary" @click="saveClick">保存</el-button>
          </template>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { reactive, ref, onMounted, getCurrentInstance } from "vue";
import { useRouter, useRoute } from "vue-router";
import { ElMessage } from "element-plus";
import DynamicTable from "@/components/FormDynamicTable/index.vue";
import routerBack from "@/components/common/routerBack.vue";
import FileUploader from "@/components/FileUploader/index.vue";
import FinancialTable from "@/components/FinancialTable.vue";

const pageActiveName = ref("基础信息");

const kxxName = ref("项目投资现金流量表");

const constructionScaleColumns = ref([
  {
    prop: "indicatorName",
    label: "指标名称",
    type: "input",
    placeholder: "请输入指标名称",
  },
  {
    prop: "quantity",
    label: "数量",
    type: "input",
    placeholder: "请输入数量",
    typeParams: { type: "number", min: 0 },
  },
  { prop: "unit", label: "单位", type: "input", placeholder: "请输入单位" },
  {
    prop: "supplement",
    label: "补充说明",
    type: "input",
    placeholder: "请输入补充说明",
  },
]);

// 8. 股东信息列配置
const shareholderColumns = ref([
  {
    prop: "shareholderType",
    label: "股东类型",
    type: "input",
    placeholder: "请输入股东类型",
  },
  {
    prop: "shareholderName",
    label: "股东名称",
    type: "input",
    placeholder: "请输入股东名称",
  },
  {
    prop: "shareholdingRatio",
    label: "持股比例（%）",
    type: "input",
    placeholder: "请输入",
    typeParams: { type: "number", min: 0, max: 100, precision: 2 },
  },
  {
    prop: "contributionAmount",
    label: "出资额(万元)",
    type: "input",
    placeholder: "请输入",
    typeParams: { type: "number", min: 0, precision: 2 },
  },
  {
    prop: "registeredCapital",
    label: "应缴注册资本(万元)",
    type: "input",
    placeholder: "请输入",
    typeParams: { type: "number", min: 0, precision: 2 },
  },
  {
    prop: "projectCapital",
    label: "应出项目资本金(万元)",
    type: "input",
    placeholder: "请输入",
    typeParams: { type: "number", min: 0, precision: 2 },
  },
  {
    prop: "cooperatorSituation",
    label: "合作方情况",
    type: "input",
    placeholder: "请输入",
  },
  { prop: "remark", label: "备注", type: "input", placeholder: "请输入备注" },
]);

const transferColumns = ref([
  {
    prop: "njfcgbl",
    label: "业务类型",
    type: "input",
    headerGroup: " ",
    placeholder: "请填写能建方持股比例",
  },
  {
    prop: "szdt",
    label: "数值",
    type: "input",
    headerGroup: "单位工程造价（动态）",
    placeholder: "请填写能建方持股比例情况",
  },
  {
    prop: "dwdt",
    label: "单位",
    type: "input",
    headerGroup: "单位工程造价（动态）",
    placeholder: "请填写单位工程造价（动态）",
  },
  {
    prop: "zjsz",
    label: "数值",
    type: "input",
    headerGroup: "单位工程造价（静态）",
    placeholder: "请填写单位工程造价（静态）",
  },
  {
    prop: "zjdw",
    label: "单位",
    type: "input",
    headerGroup: "单位工程造价（静态）",
    placeholder: "请填写单位工程造价（静态）",
  },
  {
    prop: "xsfwsz",
    label: "数值",
    type: "input",
    headerGroup: "销售/服务能力",
    placeholder: "请填写销售/服务能力",
  },
  {
    prop: "xsfwdw",
    label: "造价",
    type: "input",
    headerGroup: "销售/服务能力",
    placeholder: "请填写销售/服务能力",
  },
  {
    prop: "fhsz",
    label: "数值",
    type: "input",
    headerGroup: "年均负荷率",
    placeholder: "请填写年均负荷率",
  },
  {
    prop: "fhdw",
    label: "造价",
    type: "input",
    headerGroup: "年均负荷率",
    placeholder: "请填写年均负荷率",
  },
  {
    prop: "scfwsz",
    label: "数值",
    type: "input",
    headerGroup: "单位生产/服务总成本",
    placeholder: "请填写单位生产/服务总成本",
  },
  {
    prop: "scfwzj",
    label: "造价",
    type: "input",
    headerGroup: "单位生产/服务总成本",
    placeholder: "请填写单位生产/服务总成本",
  },
]);
const shqkColumns = ref([
  {
    prop: "shareholderType",
    label: "会议类型",
    type: "input",
    placeholder: "请输入会议类型",
  },
  {
    prop: "shareholderName",
    label: "会议届次",
    type: "input",
    placeholder: "请输入会议届次",
  },
  {
    prop: "shareholderName",
    label: "审核时间",
    type: "input",
    placeholder: "请输入审核时间",
  },
  {
    prop: "shareholderName",
    label: "结论",
    type: "input",
    placeholder: "请输入结论",
  },
  {
    prop: "shareholderName",
    label: "附件",
    type: "input",
    placeholder: "请输入附件",
  },
]);
const spyjColumns = ref([
  {
    prop: "shareholderType",
    label: "类型",
    type: "input",
    placeholder: "请输入类型",
  },
  {
    prop: "shareholderName",
    label: "审批意见",
    type: "input",
    placeholder: "请输入审批意见",
  },
  {
    prop: "shareholderName",
    label: "批复意见时间",
    type: "input",
    placeholder: "请输入批复意见时间",
  },
]);

// 10. 债权融资列配置
const debtFinancingColumns = ref([
  {
    disabled: true,
    prop: "amount",
    label: "金额(万元)",
    type: "input",
    placeholder: "请输入",
    typeParams: { type: "number", min: 0, precision: 2 },
  },
  {
    prop: "financingCost",
    label: "融资成本(%)",
    type: "input",
    placeholder: "请输入",
    typeParams: { type: "number", min: 0, max: 100, precision: 2 },
  },
  {
    prop: "term",
    label: "期限(年)",
    type: "input",
    placeholder: "请输入",
    typeParams: { type: "number", min: 0 },
  },
  {
    prop: "expectedLandingTime",
    label: "预计落地时间",
    type: "date",
    placeholder: "请选择",
    typeParams: { valueFormat: "YYYY-MM-DD" },
  },
]);

// 12. 风险管理列配置
const riskManagementColumns = ref([
  {
    prop: "riskType",
    label: "风险类别",
    type: "input",
    placeholder: "请输入风险类别",
  },
  {
    prop: "riskDescription",
    label: "风险描述",
    type: "input",
    placeholder: "请输入风险描述",
  },
  {
    prop: "responseMeasures",
    label: "应对措施",
    type: "input",
    placeholder: "请输入应对措施",
  },
]);

// 13. 里程碑节点列配置
const milestoneColumns = ref([
  {
    prop: "milestoneName",
    label: "里程碑节点名称",
    type: "input",
    placeholder: "请输入节点名称",
  },
  {
    prop: "completionDescription",
    label: "节点完成描述",
    type: "input",
    placeholder: "请输入完成描述",
  },
  {
    prop: "expectedCompletionTime",
    label: "预计完成时间",
    type: "date",
    placeholder: "请选择",
    typeParams: { valueFormat: "YYYY-MM-DD" },
  },
]);

// ========== 路由/实例/全局方法 ==========
const router = useRouter();
const route = useRoute();
const { proxy } = getCurrentInstance();

// ========== 基础配置 ==========
const activeCollapse = ref([
  "项目基本信息",
  "项目所在地",
  "计量币种",
  "实施时间",
  "投资分类",
  "项目可行性",
  "特别关注、特别监管类等信息",
  "建设规模（实物量指标）",
  "股东信息",
  "我方担保及股权融资情况",
  "我方担保及债权融资情况",
  "项目内容及必要性",
  "风险管理",
  "里程碑节点",
  "投决申报材料",
]);
const activeInvestTab = ref("attribute"); // 投资分类默认选中属性分类
const loading = ref(false);
const isPreview = ref(!!route.query.isPreview);
const projectList = ref([]);
const rcCgqyglId = ref(route.query.id || "");

// ========== 表单数据 ==========
const formData = reactive({
  // 1. 项目基本信息
  projectId: "",
  projectCode: "",
  isReDecision: "",
  projectForeignName: "",
  isUnionProject: "",
  investmentSubject: "",
  isIntegratedSubProject: "",
  directEnterprise: "",
  isImportantInvestProject: "",
  approvalUnit: "",
  financialReportType: "",
  governmentApprovalLevel: "",
  isIndependentDecision: "",
  businessType: "",
  contactPerson: "",
  contactPhone: "",

  // 2. 项目所在地
  domesticOverseas: "",
  provinceContinent: "",
  cityCountry: "",
  districtCountry: "",
  projectArea: "",
  isBeltRoadCountry: "",

  // 3. 计量币种
  currencyType: "",
  exchangeRate: "",

  // 4. 实施时间
  constructionPeriod: "",
  operationYears: "",
  cooperationPeriod: "",
  plannedStartDate: "",
  plannedCompletionDate: "",

  // 5. 投资分类
  investAttributeFirst: "",
  investAttributeSecond: "",
  investPlate1: "",
  investPlate2: "",
  investPurposeFirst: "",
  layout29: "",
  investPurposeSecond: "",
  nationalEconomicIndustry: "",
  fourNewClassification: "",

  // 6. 特别关注、特别监管类等信息
  isReportedToNDRC: "",
  isLeaderSigned: "",
  isDomesticSpecialSupervision: "",
  isInSASACNegativeList: "",

  // 7. 建设规模（实物量指标）- 动态表格
  constructionScaleList: [
    { indicatorName: "", quantity: "", unit: "", supplement: "" },
  ],

  // 8. 股东信息 - 动态表格
  shareholderList: [
    {
      shareholderType: "",
      shareholderName: "",
      shareholdingRatio: "",
      contributionAmount: "",
      registeredCapital: "",
      projectCapital: "",
      cooperatorSituation: "",
      remark: "",
    },
  ],

  // 9. 我方担保及股权融资情况
  equityFinancingAmount: "",
  equityFinancingCost: "",
  equityFinancingTerm: "",
  guaranteeAmount: "",
  projectGdxxs: [],

  // 10. 我方担保及债权融资情况 - 动态表格
  debtFinancingList: [
    { amount: "", financingCost: "", term: "", expectedLandingTime: "" },
  ],

  // 11. 项目内容及必要性
  constructionContent: "",
  projectNecessity: "",
  otherDescription: "",

  // 12. 风险管理 - 动态表格
  riskManagementList: [
    { riskType: "", riskDescription: "", responseMeasures: "" },
  ],

  // 13. 里程碑节点 - 动态表格 + 文件
  milestoneList: [
    {
      milestoneName: "",
      completionDescription: "",
      expectedCompletionTime: "",
    },
  ],
  milestoneApprovalFile: "",

  // 14. 投决申报材料 - 文件上传
  feasibilityStudyFile: "",
  economicIndicatorFile: "",
  supplementarySupportFile: "",
  otherSupportFile: "",
  meetingProposalFile: "",

  // 其他关联字段
  projectName: "",
  // ------------------ 财务评价
  jzymljsh: {},
});

// ========== 业务方法：获取项目列表 ==========
const getProjectData = (params = {}) => {
  proxy.$post({
    url: "/api/project/listProject",
    data: {
      page: 1,
      pagesize: 1000,
      attributes: [],
      menuType: "xmjc",
      ...params,
    },
    callback: (data) => {
      projectList.value = data.rows || [];
    },
    error: () => ElMessage.warning("获取项目列表失败"),
  });
};

// ========== 选择项目同步名称及相关信息 ==========
const changeProject = (val) => {
  proxy.$post({
    url: "/api/project/getProjectFinalInfo",
    data: { id: val },
    callback: (data) => {
      loading.value = false;
      // 回填基础字段（可根据实际接口返回扩展）
      formData.projectName = data.projectName || "";
      formData.projectCode = data.projectCode || "";
      formData.investmentSubject = data.investmentSubject || "";
    },
    error: () => {
      loading.value = false;
      ElMessage.error("获取项目详情失败");
    },
  });
  const selectItem = projectList.value.find((item) => item.id === val);
  if (selectItem) formData.projectName = selectItem.projectName;
};

// ========== 获取详情（编辑/预览） ==========
const getJsqtzjcDetail = () => {
  if (!rcCgqyglId.value) return;
  loading.value = true;
  proxy.$post({
    url: "/api/project/getTzjh",
    data: { id: rcCgqyglId.value },
    callback: async (data) => {
      loading.value = false;
      if (!data) return ElMessage.error("未查询到数据");
      Object.assign(formData, data);
      // 处理动态表格数据默认值
      formData.constructionScaleList = data.constructionScaleList || [
        { indicatorName: "", quantity: "", unit: "", supplement: "" },
      ];
      formData.shareholderList = data.shareholderList || [
        {
          shareholderType: "",
          shareholderName: "",
          shareholdingRatio: "",
          contributionAmount: "",
          registeredCapital: "",
          projectCapital: "",
          cooperatorSituation: "",
          remark: "",
        },
      ];
      formData.debtFinancingList = data.debtFinancingList || [
        { amount: "", financingCost: "", term: "", expectedLandingTime: "" },
      ];
      formData.riskManagementList = data.riskManagementList || [
        { riskType: "", riskDescription: "", responseMeasures: "" },
      ];
      formData.milestoneList = data.milestoneList || [
        {
          milestoneName: "",
          completionDescription: "",
          expectedCompletionTime: "",
        },
      ];
    },
    error: () => {
      loading.value = false;
      ElMessage.error("获取投资计划详情失败");
    },
  });
};

// ========== 保存表单 ==========
const saveClick = () => {
  if (!formData.projectId) return ElMessage.warning("请选择项目信息");
  loading.value = true;
  const url = rcCgqyglId.value
    ? "/api/project/updateTzjh"
    : "/api/project/createTzjh";

  // 组装提交数据
  const submitData = {
    ...formData,
    projectId: String(formData.projectId),
  };

  proxy.$post({
    url: url,
    data: submitData,
    callback: () => {
      loading.value = false;
      ElMessage.success(rcCgqyglId.value ? "编辑成功" : "新增成功");
      router.back(-1);
    },
    error: (err) => {
      loading.value = false;
      ElMessage.error(err.msg || "保存失败");
    },
  });
};

// ========== 辅助方法 ==========
const backClick = () => router.back(-1);
let initTableData = () => {
  Object.assign(formData, {
    jzymljsh: {
      // 指标列表
      indicatorList: [
        {
          name: "现金流入",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "现金流出",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "所得税前净现金流量",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "调整所得税",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "所得税后净现金流量",
          isTextRow: false,
          noTotal: false,
        },
      ],

      // 时间列表（月度）
      dynamicTimeList: [
        "2021",
        "2022",
        "2023",
        "2024",
        "2025",
        "2026",
        "2027",
        "2028",
        "2029",
        "2030",
        "2031",
        "2032",
        "2033",
        "2034",
        "2035",
        "2036",
        "2037",
        "2038",
        "2039",
        "2040",
        "2041",
        "2042",
        "2043",
        "2044",
        "2045",
      ],
      // 表格数据（子组件会自动初始化，父组件可传初始值）
      tableData: [],
    },
    tzze: {
      // 指标列表
      indicatorList: [
        {
          name: "项目造价构成",
          isTextRow: true,
          noTotal: true,
          serialNumber: "",
        },
        {
          name: "建安设备费",
          isTextRow: false,
          noTotal: false,
          serialNumber: "1",
        },
        {
          name: "其他费用",
          isTextRow: false,
          noTotal: false,
          serialNumber: "2",
        },
        {
          name: "其中：土地相关费用",
          isTextRow: false,
          noTotal: false,
          serialNumber: "2.1",
        },
        {
          name: "基本预备费",
          isTextRow: false,
          noTotal: false,
          serialNumber: "3",
        },
        {
          name: "建设期利息",
          isTextRow: false,
          noTotal: false,
          serialNumber: "4",
        },

        {
          name: "项目资金构成",
          isTextRow: false,
          noTotal: false,
          serialNumber: "",
        },
        {
          name: "项目资本金",
          isTextRow: false,
          noTotal: false,
          serialNumber: "1",
        },
        {
          name: "能建方出资",
          isTextRow: false,
          noTotal: false,
          serialNumber: "1.1",
        },
        {
          name: "外部股东",
          isTextRow: false,
          noTotal: false,
          serialNumber: "1.2",
        },
        {
          name: "贷款",
          isTextRow: false,
          noTotal: false,
          serialNumber: "2",
        },
        {
          name: "其中：非并表项目我方贷款/担保额",
          isTextRow: false,
          noTotal: false,
          serialNumber: "2.1",
        },
        {
          name: "其他出资",
          isTextRow: false,
          noTotal: false,
          serialNumber: "3",
        },
        {
          name: "其中：能建方出资",
          isTextRow: false,
          noTotal: false,
          serialNumber: "3.1",
        },
        {
          name: "单位工程造价",
          isTextRow: false,
          noTotal: false,
          serialNumber: "4",
        },
        {
          name: "批复总投资",
          isTextRow: false,
          noTotal: false,
          serialNumber: "",
        },
      ],

      // 时间列表（月度）
      dynamicTimeList: ["人民币计价"],
      // 表格数据（子组件会自动初始化，父组件可传初始值）
      tableData: [],
    },
    cwpjzb: {
      // 指标列表
      indicatorList: [
        {
          name: "项目投资内容部收益率（税前）",
          isTextRow: false,
          noTotal: false,
          serialNumber: "",
        },
        {
          name: "项目投资内容部收益率（税后）",
          isTextRow: false,
          noTotal: false,
          serialNumber: "1",
        },
        {
          name: "项目投资动态回收期（税前）",
          isTextRow: false,
          noTotal: false,
          serialNumber: "2",
        },
        {
          name: "能建方内部收益率",
          isTextRow: false,
          noTotal: false,
          serialNumber: "2.1",
        },
        {
          name: "净现金流首次回证年份",
          isTextRow: false,
          noTotal: false,
          serialNumber: "3",
        },
        {
          name: "净利润流首次回证年份",
          isTextRow: false,
          noTotal: false,
          serialNumber: "4",
        },

        {
          name: "可分配利润首次回证年份",
          isTextRow: false,
          noTotal: false,
          serialNumber: "",
        },
      ],

      // 时间列表（月度）
      dynamicTimeList: ["投资评估阶段批复值"],
      // 表格数据（子组件会自动初始化，父组件可传初始值）
      tableData: [],
    },
    economicFeasibility: {
      // 指标列表
      indicatorList: [
        {
          name: "项目投资内容部收益率（税前）",
          isTextRow: false,
          noTotal: false,
          serialNumber: "",
        },
        {
          name: "项目投资内容部收益率（税后）",
          isTextRow: false,
          noTotal: false,
          serialNumber: "1",
        },
        {
          name: "项目投资动态回收期（税前）",
          isTextRow: false,
          noTotal: false,
          serialNumber: "2",
        },
        {
          name: "能建方内部收益率",
          isTextRow: false,
          noTotal: false,
          serialNumber: "2.1",
        },
        {
          name: "净现金流首次回证年份",
          isTextRow: false,
          noTotal: false,
          serialNumber: "3",
        },
        {
          name: "净利润流首次回证年份",
          isTextRow: false,
          noTotal: false,
          serialNumber: "4",
        },

        {
          name: "可分配利润首次回证年份",
          isTextRow: false,
          noTotal: false,
          serialNumber: "",
        },
      ],

      // 时间列表（月度）
      dynamicTimeList: ["投资评估阶段批复值"],
      // 表格数据（子组件会自动初始化，父组件可传初始值）
      tableData: [],
    },
    cwpj: {
      // 指标列表

      indicatorList: [
        {
          name: "项目筹资(建设期投资)",
          level: 1,
          serialNumber: "1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "项目资本金（股权融资）",
          level: 2,
          serialNumber: "1.1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "能建方",
          level: 3,
          serialNumber: "1.1.1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "其他社会资本方",
          level: 3,
          serialNumber: "1.1.2",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "借款（债权融资）",
          level: 2,
          serialNumber: "1.2",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "银行贷款",
          level: 3,
          serialNumber: "1.2.1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "其中：非并表项目我方贷款/担保额",
          level: 4,
          serialNumber: "1.2.1.1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "其他出资",
          level: 2,
          serialNumber: "1.3",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "其中：能建方出资",
          level: 3,
          serialNumber: "1.3.1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "筹资总额",
          level: 1,
          serialNumber: " ",
          isTextRow: false,
          noTotal: false,
        },

        // 2. 经营情况 相关
        {
          name: "经营情况",
          level: 1,
          serialNumber: "2",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "营业总收入",
          level: 2,
          serialNumber: "2.1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "营业总成本",
          level: 2,
          serialNumber: "2.2",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "其中：营业成本",
          level: 3,
          serialNumber: "2.2.1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "其中：折旧及摊销",
          level: 3,
          serialNumber: "2.2.2",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "利润总额",
          level: 2,
          serialNumber: "2.3",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "所得税",
          level: 2,
          serialNumber: "2.4",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "净利润",
          level: 2,
          serialNumber: "2.5",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "能建方分红（税前）",
          level: 2,
          serialNumber: "2.6",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "能建方分红（税后）",
          level: 2,
          serialNumber: "2.7",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "未分配利润",
          level: 2,
          serialNumber: "2.8",
          isTextRow: false,
          noTotal: false,
        },

        // 3. 资金偿还 相关
        {
          name: "资金偿还",
          level: 1,
          serialNumber: "3",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "银行贷款",
          level: 2,
          serialNumber: "3.1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "项目贷",
          level: 3,
          serialNumber: "3.1.1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "项目贷利息",
          level: 3,
          serialNumber: "3.1.2",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "其他资金",
          level: 2,
          serialNumber: "3.2",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "其他资金本金",
          level: 3,
          serialNumber: "3.2.1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "其他资金利息（融资费用）",
          level: 3,
          serialNumber: "3.2.2",
          isTextRow: false,
          noTotal: false,
        },

        // 4. 项目公司其他财务指标 相关
        {
          name: "项目公司其他财务指标",
          level: 1,
          serialNumber: "4",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "资产总额（期末值）",
          level: 2,
          serialNumber: "4.1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "负债总额（期末值）",
          level: 2,
          serialNumber: "4.2",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "经营活动产生的现金流净额",
          level: 2,
          serialNumber: "4.3",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "经营活动产生的现金流入",
          level: 3,
          serialNumber: "4.3.1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "经营活动产生的现金流出",
          level: 3,
          serialNumber: "4.3.2",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "投资活动产生的现金流净额",
          level: 2,
          serialNumber: "4.4",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "投资活动产生的现金流入",
          level: 3,
          serialNumber: "4.4.1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "投资活动产生的现金流出",
          level: 3,
          serialNumber: "4.4.2",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "筹资活动产生的现金流净额",
          level: 2,
          serialNumber: "4.5",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "筹资活动产生的现金流入",
          level: 3,
          serialNumber: "4.5.1",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "筹资活动产生的现金流出",
          level: 3,
          serialNumber: "4.5.2",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "利息备付率",
          level: 2,
          serialNumber: "4.6",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "偿债备付率",
          level: 2,
          serialNumber: "4.7",
          isTextRow: false,
          noTotal: false,
        },
        {
          name: "投资回收额",
          level: 2,
          serialNumber: "4.8",
          isTextRow: false,
          noTotal: false,
        },
      ],

      // 时间列表（月度）
      dynamicTimeList: [
        "2021",
        "2022",
        "2023",
        "2024",
        "2025",
        "2026",
        "2027",
        "2028",
        "2029",
        "2030",
        "2031",
        "2032",
        "2033",
        "2034",
        "2035",
        "2036",
        "2037",
        "2038",
        "2039",
        "2040",
        "2041",
        "2042",
        "2043",
        "2044",
        "2045",
      ],
      // 表格数据（子组件会自动初始化，父组件可传初始值）
      tableData: [],
    },
  });
};

onMounted(() => {
  getProjectData();
  if (rcCgqyglId.value) {
    // 编辑/预览：拉取接口数据
    getJsqtzjcDetail();
  } else {
    initTableData();
  }
});
</script>
