<template>
  <div class="add-project-container">
    <div class="add-project-content" v-loading="loading">
      <routerBack />

      <div class="tabs-content">
        <div class="project-tab-content">
          <div class="tab-content">
            <el-form :model="formData" label-width="150" :disabled="isPreview">
              <el-collapse v-model="activeCollapse">
                <!-- 基本信息 -->
                <el-collapse-item title="基本信息" name="基本信息">
                  <el-row :gutter="20">
                    <el-col :span="6">
                      <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.key"
                            :label="item.projectName"
                            :value="item.id"
                          ></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="境内/外">
                        <el-select
                          v-model="formData.jnw"
                          placeholder="请选择境内/外"
                        >
                          <el-option label="境内" value="境内"></el-option>
                          <el-option label="境外" value="境外"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="省(境)内/洲(境)外">
                        <el-input
                          v-model="formData.sqnzw"
                          placeholder="请输入省(境)内/洲(境)外"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="项目名称">
                        <el-input
                          v-model="formData.xmmc"
                          placeholder="请输入项目名称"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="6">
                      <el-form-item label="项目编号">
                        <el-input
                          v-model="formData.xmbh"
                          placeholder="请输入项目编号"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="区县(境)内/国家(境)外">
                        <el-input
                          v-model="formData.qxnzwgw"
                          placeholder="请输入区县(境)内/国家(境)外"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="申报单位">
                        <el-input
                          v-model="formData.sbdw"
                          placeholder="请输入申报单位"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="所属二级单位">
                        <el-input
                          v-model="formData.ssejdw"
                          placeholder="请输入所属二级单位"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="6">
                      <el-form-item label="是否境外企业">
                        <el-select
                          v-model="formData.sfjwqy"
                          placeholder="请选择是否境外企业"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="形成参股原因">
                        <el-select
                          v-model="formData.xccgyy"
                          placeholder="请选择形成参股原因"
                        >
                          <el-option
                            label="合资设立"
                            value="合资设立"
                          ></el-option>
                          <el-option
                            label="股权受让"
                            value="股权受让"
                          ></el-option>
                          <el-option
                            label="增资扩股"
                            value="增资扩股"
                          ></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="其他参股原因">
                        <el-input
                          v-model="formData.qtcgyy"
                          placeholder="请输入其他参股原因"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="参股分类">
                        <el-select
                          v-model="formData.cgfl"
                          placeholder="请选择参股分类"
                        >
                          <el-option
                            label="绝对控股"
                            value="绝对控股"
                          ></el-option>
                          <el-option
                            label="相对控股"
                            value="相对控股"
                          ></el-option>
                          <el-option label="参股" value="参股"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="6">
                      <el-form-item label="项目状态">
                        <el-input
                          v-model="formData.xmzt"
                          placeholder="请输入项目状态"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="是否集团主业">
                        <el-select
                          v-model="formData.sfjtzy"
                          placeholder="请选择是否集团主业"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="是否属主业关联产业">
                        <el-select
                          v-model="formData.sfzyglcy"
                          placeholder="请选择是否属主业关联产业"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="是否属于战略性持有或有培育期">
                        <el-select
                          v-model="formData.sfgzxccyypyq"
                          placeholder="请选择"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="6">
                      <el-form-item label="所属行业">
                        <el-input
                          v-model="formData.sshy"
                          placeholder="请输入所属行业"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="是否为民营企业">
                        <el-select
                          v-model="formData.sfwmqy"
                          placeholder="请选择是否为民营企业"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="是否上市公司">
                        <el-select
                          v-model="formData.sfssgs"
                          placeholder="请选择是否上市公司"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="是否为问题整改项目">
                        <el-select
                          v-model="formData.sfwtzgxm"
                          placeholder="请选择是否为问题整改项目"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="6">
                      <el-form-item label="是否民营企业实际运营">
                        <el-select
                          v-model="formData.sfmqysjyy"
                          placeholder="请选择是否民营企业实际运营"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="是否整改完成">
                        <el-select
                          v-model="formData.sfzgwc"
                          placeholder="请选择是否整改完成"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="是否落号">
                        <el-select
                          v-model="formData.sflh"
                          placeholder="请选择是否落号"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="决策批复时间">
                        <el-date-picker
                          v-model="formData.jcpfsj"
                          type="date"
                          placeholder="请选择决策批复时间"
                          format="YYYY-MM-DD"
                          value-format="YYYY-MM-DD"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="6">
                      <el-form-item label="参股形成时间">
                        <el-date-picker
                          v-model="formData.cgxcjsj"
                          type="date"
                          placeholder="请选择参股形成时间"
                          format="YYYY-MM-DD"
                          value-format="YYYY-MM-DD"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="计划退出年份">
                        <el-input
                          v-model="formData.jhtcnf"
                          placeholder="请输入计划退出年份"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="风险金额(万元)">
                        <el-input-number
                          precision="2"
                          v-model="formData.fxje"
                          placeholder="请输入风险金额(万元)"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="是否我方控股非并表企业">
                        <el-select
                          v-model="formData.sfwfkgfbbqy"
                          placeholder="请选择是否我方控股非并表企业"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="24">
                      <el-form-item label="主营业务">
                        <el-input
                          v-model="formData.zyyw"
                          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="6">
                      <el-form-item label="十二大业务板块">
                        <el-select
                          v-model="formData.sehybk"
                          placeholder="请选择十二大业务板块"
                        >
                          <el-option
                            label="E综合交通"
                            value="E综合交通"
                          ></el-option>
                          <el-option label="F城建" value="F城建"></el-option>
                          <el-option label="G能源" value="G能源"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="指标名称">
                        <el-input
                          v-model="formData.zbmc"
                          placeholder="请输入指标名称"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="数量">
                        <el-input-number
                          precision="2"
                          v-model="formData.sl"
                          placeholder="请输入数量"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="单位">
                        <el-input
                          v-model="formData.dwdw"
                          placeholder="请输入单位"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="8">
                      <el-form-item label="批复文件">
                        <el-button type="primary">上传</el-button>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="营业执照">
                        <el-button type="primary">上传</el-button>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="合作协议">
                        <el-button type="primary">上传</el-button>
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-collapse-item>

                <!-- 股东信息 -->
                <el-collapse-item title="股东信息" name="股东信息">
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="是否无实际控制人">
                        <el-select
                          v-model="formData.sfwjskzr"
                          placeholder="请选择是否无实际控制人"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="是否平股">
                        <el-select
                          v-model="formData.sfpg"
                          placeholder="请选择是否平股"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="股东名称">
                        <el-input
                          v-model="formData.gdmc"
                          placeholder="请输入股东名称"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="股比(%)">
                        <el-input-number
                          precision="2"
                          v-model="formData.gbl"
                          placeholder="请输入股比(%)"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="8">
                      <el-form-item label="国有股东合计股比(%)">
                        <el-input-number
                          precision="2"
                          v-model="formData.gdgdhjgbl"
                          placeholder="请输入国有股东合计股比(%)"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="新建参股合计(%)">
                        <el-input-number
                          precision="2"
                          v-model="formData.xjcghj"
                          placeholder="请输入新建参股合计(%)"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="一致行动人股比合计(%)">
                        <el-input-number
                          precision="2"
                          v-model="formData.yzxdrhjhj"
                          placeholder="请输入一致行动人股比合计(%)"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="24">
                      <el-form-item label="一致行动人单位名称">
                        <el-input
                          v-model="formData.yzxdrdwmc"
                          placeholder="请输入一致行动人单位名称"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>

                  <!-- 股东信息表格 -->
                  <div class="tab-handle">
                    <el-button type="primary" @click="addGdxx">新增</el-button>
                    <el-button type="primary">章程：上传</el-button>
                  </div>
                  <el-table
                    :data="gdxxList"
                    style="width: 100%"
                    empty-text="暂无数据"
                    border
                    show-summary
                    :summary-method="sumGdxxColumns"
                  >
                    <el-table-column type="index" width="60" label="序号" />
                    <el-table-column prop="gdmc" label="股东名称">
                      <template #default="scope">
                        <el-input
                          v-model="scope.row.gdmc"
                          placeholder="请输入股东名称"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column prop="gdxz" label="股东性质">
                      <template #default="scope">
                        <el-select
                          v-model="scope.row.gdxz"
                          placeholder="请选择股东性质"
                        >
                          <el-option
                            label="中央企业"
                            value="中央企业"
                          ></el-option>
                          <el-option
                            label="地方国有企业"
                            value="地方国有企业"
                          ></el-option>
                          <el-option label="其他" value="其他"></el-option>
                        </el-select>
                      </template>
                    </el-table-column>
                    <el-table-column prop="gbl" label="股比(%)">
                      <template #default="scope">
                        <el-input-number
                          precision="2"
                          v-model="scope.row.gbl"
                          placeholder="请输入股比(%)"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column prop="sfkgdg" label="是否控股股东">
                      <template #default="scope">
                        <el-select
                          v-model="scope.row.sfkgdg"
                          placeholder="请选择"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </template>
                    </el-table-column>
                    <el-table-column prop="sfjtcydw" label="是否集团内成员单位">
                      <template #default="scope">
                        <el-select
                          v-model="scope.row.sfjtcydw"
                          placeholder="请选择"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </template>
                    </el-table-column>
                    <el-table-column prop="sfskdw" label="是否实控单位">
                      <template #default="scope">
                        <el-select
                          v-model="scope.row.sfskdw"
                          placeholder="请选择"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </template>
                    </el-table-column>
                    <el-table-column prop="sfyzxdr" label="是否一致行动人">
                      <template #default="scope">
                        <el-select
                          v-model="scope.row.sfyzxdr"
                          placeholder="请选择"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </template>
                    </el-table-column>
                    <el-table-column label="操作" width="80">
                      <template #default="scope">
                        <el-button
                          link
                          type="danger"
                          size="small"
                          @click="deleteGdxx(scope.$index)"
                          >删除</el-button
                        >
                      </template>
                    </el-table-column>
                  </el-table>
                </el-collapse-item>

                <!-- 企业工商注册资本金 -->
                <el-collapse-item
                  title="企业工商注册资本金"
                  name="企业工商注册资本金"
                >
                  <el-row :gutter="20">
                    <el-col :span="6">
                      <el-form-item label="企业工商注册资本金（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.qygszczij"
                          placeholder="请输入企业工商注册资本金（万元）"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="我方参数比例（%）">
                        <el-input-number
                          precision="2"
                          v-model="formData.wfcgbl"
                          placeholder="请输入我方参数比例（%）"
                        />
                      </el-form-item>
                    </el-col>

                    <el-col :span="6">
                      <el-form-item label="我方认缴企业工商注册资本金（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.wfrjqygszczij"
                          placeholder="请输入我方认缴企业工商注册资本金（万元）"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item
                        label="工商注册资本金我方实际已出资金额（万元）"
                      >
                        <el-input-number
                          precision="2"
                          v-model="formData.gszczijwfysjczje"
                          placeholder="请输入工商注册资本金我方实际已出资金额（万元）"
                        />
                      </el-form-item>
                    </el-col>

                    <el-col :span="6">
                      <el-form-item label="企业工商注册资本金我方首次出资时间">
                        <el-date-picker
                          v-model="formData.qygszczijwfscczsj"
                          type="date"
                          placeholder="请选择企业工商注册资本金我方首次出资时间"
                          format="YYYY-MM-DD"
                          value-format="YYYY-MM-DD"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="能建合计认缴工商注册资本金比例（%）">
                        <el-input-number
                          precision="2"
                          v-model="formData.njhjrjqygszczijbl"
                          placeholder="请输入能建合计认缴工商注册资本金比例（%）"
                        />
                      </el-form-item>
                    </el-col>

                    <el-col :span="6">
                      <el-form-item label="能建合计认缴工商注册资本金（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.njhjrjqygszczij"
                          placeholder="请输入能建合计认缴工商注册资本金（万元）"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="能建合计实缴工商注册资本金（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.njhjsjqygszczij"
                          placeholder="请输入能建合计实缴工商注册资本金（万元）"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-collapse-item>

                <!-- 项目资本金 -->
                <el-collapse-item title="项目资本金" name="项目资本金">
                  <el-row :gutter="20">
                    <el-col :span="6">
                      <el-form-item label="项目资本金（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.xmzbj"
                          placeholder="请输入项目资本金（万元）"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="我方认缴项目资本金比例（%）">
                        <el-input-number
                          precision="2"
                          v-model="formData.wfrjxmzbjbl"
                          placeholder="请输入我方认缴项目资本金比例（%）"
                        />
                      </el-form-item>
                    </el-col>

                    <el-col :span="6">
                      <el-form-item label="我方认缴项目资本金（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.wfrjxmzbj"
                          placeholder="请输入我方认缴项目资本金（万元）"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="我方实缴项目资本金（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.wfsjxmzbj"
                          placeholder="请输入我方实缴项目资本金（万元）"
                        />
                      </el-form-item>
                    </el-col>

                    <el-col :span="6">
                      <el-form-item label="项目资本金能建合计持股比例（%）">
                        <el-input-number
                          precision="2"
                          v-model="formData.xmzbjnjhjcgbll"
                          placeholder="请输入项目资本金能建合计持股比例（%）"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="能建合计认缴项目资本金（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.njhjrjxmzbj"
                          placeholder="请输入能建合计认缴项目资本金（万元）"
                        />
                      </el-form-item>
                    </el-col>

                    <el-col :span="6">
                      <el-form-item label="能建合计实缴项目资本金（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.njhjsjxmzbj"
                          placeholder="请输入能建合计实缴项目资本金（万元）"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <el-form-item label="出资文件">
                        <el-button type="primary">上传</el-button>
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-collapse-item>

                <!-- 财务经营信息 -->
                <el-collapse-item title="财务经营信息" name="财务经营信息">
                  <div class="tab-handle">
                    <el-button type="primary" @click="addCwxx">新增</el-button>
                  </div>
                  <el-table
                    :data="cwxxList"
                    style="width: 100%"
                    empty-text="暂无数据"
                    border
                  >
                    <el-table-column type="index" width="60" label="序号" />
                    <el-table-column prop="nd" label="年度" width="100">
                      <template #default="scope">
                        <el-input
                          v-model="scope.row.nd"
                          placeholder="请输入年度"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="zzc"
                      label="总资产（万元）"
                      width="140"
                    >
                      <template #default="scope">
                        <el-input-number
                          precision="2"
                          v-model="scope.row.zzc"
                          placeholder="请输入"
                          :controls="false"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="jzc"
                      label="净资产（审计后）（万元）"
                      width="180"
                    >
                      <template #default="scope">
                        <el-input-number
                          precision="2"
                          v-model="scope.row.jzc"
                          placeholder="请输入"
                          :controls="false"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="gsnjfznc"
                      label="归属能建方净资产（万元）"
                      width="180"
                    >
                      <template #default="scope">
                        <el-input-number
                          precision="2"
                          v-model="scope.row.gsnjfznc"
                          placeholder="请输入"
                          :controls="false"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="yysr"
                      label="营业收入（万元）"
                      width="140"
                    >
                      <template #default="scope">
                        <el-input-number
                          precision="2"
                          v-model="scope.row.yysr"
                          placeholder="请输入"
                          :controls="false"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="jlr"
                      label="净利润（万元）"
                      width="140"
                    >
                      <template #default="scope">
                        <el-input-number
                          precision="2"
                          v-model="scope.row.jlr"
                          placeholder="请输入"
                          :controls="false"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="gsnjfndjdfh"
                      label="归属能建方年度决策分红（万元）"
                      width="220"
                    >
                      <template #default="scope">
                        <el-input-number
                          precision="2"
                          v-model="scope.row.gsnjfndjdfh"
                          placeholder="请输入"
                          :controls="false"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="gdhjcdffhsj"
                      label="股东会决策分红时间"
                      width="160"
                    >
                      <template #default="scope">
                        <el-date-picker
                          v-model="scope.row.gdhjcdffhsj"
                          type="date"
                          placeholder="请选择"
                          format="YYYY-MM-DD"
                          value-format="YYYY-MM-DD"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="gsnjfndysdfh"
                      label="归属能建方年度已收到分红（万元）"
                      width="240"
                    >
                      <template #default="scope">
                        <el-input-number
                          precision="2"
                          v-model="scope.row.gsnjfndysdfh"
                          placeholder="请输入"
                          :controls="false"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="sjsdfhsj"
                      label="实际收到分红时间"
                      width="160"
                    >
                      <template #default="scope">
                        <el-date-picker
                          v-model="scope.row.sjsdfhsj"
                          type="date"
                          placeholder="请选择"
                          format="YYYY-MM-DD"
                          value-format="YYYY-MM-DD"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="bndjtnzyjtzttzrb"
                      label="本年度与集团内投资主体关联交易收入占该被投资企业营业收入比例（%）"
                      width="360"
                    >
                      <template #default="scope">
                        <el-input-number
                          precision="2"
                          v-model="scope.row.bndjtnzyjtzttzrb"
                          placeholder="请输入"
                          :controls="false"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column label="操作" width="80" fixed="right">
                      <template #default="scope">
                        <el-button
                          link
                          type="danger"
                          size="small"
                          @click="deleteCwxx(scope.$index)"
                          >删除</el-button
                        >
                      </template>
                    </el-table-column>
                  </el-table>
                </el-collapse-item>

                <!-- 分红与投资情况 -->
                <el-collapse-item title="分红与投资情况" name="分红与投资情况">
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="2020年以前累计分红金额（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.enyqljfhje"
                          placeholder="请输入2020年以前累计分红金额（万元）"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="2019年以前累计收到分红金额（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.esnqljsdfhje"
                          placeholder="请输入2019年以前累计收到分红金额（万元）"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="历年累计收到分红金额（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.lnljsdfhje"
                          placeholder="请输入历年累计收到分红金额（万元）"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="累计参股投资回报率（%）">
                        <el-input-number
                          precision="2"
                          v-model="formData.ljcgtzhibl"
                          placeholder="请输入累计参股投资回报率（%）"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="归属集团内投资主体所有权益（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.gsjtntzztzsuyq"
                          placeholder="请输入归属集团内投资主体所有权益（万元）"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="总体参股投资保值增值率（%）">
                        <el-input-number
                          precision="2"
                          v-model="formData.ztcgtzbzzzl"
                          placeholder="请输入总体参股投资保值增值率（%）"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="拉动营收">
                        <el-input-number
                          precision="2"
                          v-model="formData.ldys"
                          placeholder="请输入拉动营收"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="拉动利润">
                        <el-input-number
                          precision="2"
                          v-model="formData.ldlr"
                          placeholder="请输入拉动利润"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="当前持有股数">
                        <el-input-number
                          precision="2"
                          v-model="formData.dqcygs"
                          placeholder="请输入当前持有股数"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="是否能够及时掌握财务数据和经营情况">
                        <el-select
                          v-model="formData.sfnkjzwsjyjjyqk"
                          placeholder="请选择是否能够及时掌握财务数据和经营情况"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="是否满5年未分红">
                        <el-select
                          v-model="formData.sfmwnwfkh"
                          placeholder="请选择是否满5年未分红"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="是否连续5年长期亏损">
                        <el-select
                          v-model="formData.sflxwnlcqks"
                          placeholder="请选择是否连续5年长期亏损"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="是否非持续经营">
                        <el-select
                          v-model="formData.sffcxjy"
                          placeholder="请选择是否非持续经营"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="是否属于低效无效资产">
                        <el-select
                          v-model="formData.sfdydwxzc"
                          placeholder="请选择是否属于低效无效资产"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="财务报表文件">
                        <el-button type="primary">上传</el-button>
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-collapse-item>

                <!-- 法人治理 -->
                <el-collapse-item title="法人治理" name="法人治理">
                  <div class="tab-handle">
                    <el-button type="primary" @click="addFrzl">新增</el-button>
                  </div>
                  <el-table
                    :data="frzlList"
                    style="width: 100%"
                    empty-text="暂无数据"
                    border
                  >
                    <el-table-column type="index" width="60" label="序号" />
                    <el-table-column
                      prop="zcypcdrdbprs"
                      label="章程约定派出股东代表人数"
                      width="200"
                    >
                      <template #default="scope">
                        <el-input-number
                          v-model="scope.row.zcypcdrdbprs"
                          placeholder="请输入"
                          :controls="false"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="sjpccrdbprs"
                      label="实际派出股东代表人数"
                      width="200"
                    >
                      <template #default="scope">
                        <el-input-number
                          v-model="scope.row.sjpccrdbprs"
                          placeholder="请输入"
                          :controls="false"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="zcypxpcsjqksqk"
                      label="章程约定选派董事、监事或重要岗位人员情况"
                      width="280"
                    >
                      <template #default="scope">
                        <el-checkbox-group v-model="scope.row.zcypxpcsjqksqk">
                          <el-checkbox label="国有股东代表"></el-checkbox>
                          <el-checkbox label="董事"></el-checkbox>
                          <el-checkbox label="监事"></el-checkbox>
                          <el-checkbox label="重要岗位"></el-checkbox>
                          <el-checkbox label="其他高级管理人员"></el-checkbox>
                        </el-checkbox-group>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="sjxpcsjqksqk"
                      label="实际选派董事、监事或重要岗位人员情况"
                      width="280"
                    >
                      <template #default="scope">
                        <el-checkbox-group v-model="scope.row.sjxpcsjqksqk">
                          <el-checkbox label="国有股东代表"></el-checkbox>
                          <el-checkbox label="董事"></el-checkbox>
                          <el-checkbox label="监事"></el-checkbox>
                          <el-checkbox label="重要岗位"></el-checkbox>
                          <el-checkbox label="其他高级管理人员"></el-checkbox>
                        </el-checkbox-group>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="sfytdtsfjq"
                      label="是否有特定事项否决权"
                      width="150"
                    >
                      <template #default="scope">
                        <el-select
                          v-model="scope.row.sfytdtsfjq"
                          placeholder="请选择"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="fjqnr"
                      label="否决权内容"
                      width="200"
                    >
                      <template #default="scope">
                        <el-input
                          v-model="scope.row.fjqnr"
                          placeholder="请输入否决权内容"
                        />
                      </template>
                    </el-table-column>
                    <el-table-column label="操作" width="80" fixed="right">
                      <template #default="scope">
                        <el-button
                          link
                          type="danger"
                          size="small"
                          @click="deleteFrzl(scope.$index)"
                          >删除</el-button
                        >
                      </template>
                    </el-table-column>
                  </el-table>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item
                        label="2020年自查整改至今新增或调整参股企业董事监事及重要岗位人员人数"
                      >
                        <el-input-number
                          precision="0"
                          v-model="formData.ezjzccjtgqdsjcyjsryrs"
                          placeholder="请输入人数"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item
                        label="2020年自查整改至今新增或修订参股企业公司章程条款"
                      >
                        <el-input-number
                          precision="0"
                          v-model="formData.ezjzccjtqsgszxtk"
                          placeholder="请输入条数"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="是否建立党的组织">
                        <el-select
                          v-model="formData.sfjldjzz"
                          placeholder="请选择是否建立党的组织"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="2020年自查整改至今是否开展党的活动">
                        <el-select
                          v-model="formData.ezjzccsfkzdhd"
                          placeholder="请选择是否开展党的活动"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item
                        label="2020年自查整改至今是否开展党的活动次数"
                      >
                        <el-input-number
                          precision="0"
                          v-model="formData.ezjzccsfkzdhdcs"
                          placeholder="请输入次数"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="8">
                      <el-form-item label="董监高任命文件">
                        <el-button type="primary">上传</el-button>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="股东会文件">
                        <el-button type="primary">上传</el-button>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="董事会决议文件">
                        <el-button type="primary">上传</el-button>
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-collapse-item>

                <!-- 集团内投资主体相关信息 -->
                <el-collapse-item
                  title="集团内投资主体相关信息"
                  name="集团内投资主体相关信息"
                >
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item
                        label="是否使用集团内投资主体字号、经营资质"
                      >
                        <el-select
                          v-model="formData.sfssytzztzzhjyzz"
                          placeholder="请选择"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="字号及经营资质名称">
                        <el-input
                          v-model="formData.zhjyzzmc"
                          placeholder="请输入字号及经营资质名称"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="是否使用集团内投资主体产品注册商标">
                        <el-select
                          v-model="formData.sfsytzztzcptzcsh"
                          placeholder="请选择"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="是否采取公允价格">
                        <el-select
                          v-model="formData.sfcqgyjg"
                          placeholder="请选择"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="集团内投资主体实际担保">
                        <el-select
                          v-model="formData.sftzztjcsjdb"
                          placeholder="请选择"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="担保金额（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.dbje"
                          placeholder="请输入担保金额（万元）"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="其中：超股权比例担保金额">
                        <el-input-number
                          precision="2"
                          v-model="formData.cgqblcjedbje"
                          placeholder="请输入超股权比例担保金额"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="是否办理国有产权登记">
                        <el-select
                          v-model="formData.sfblgqcqdj"
                          placeholder="请选择"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-collapse-item>

                <!-- 股权退出信息 -->
                <el-collapse-item title="股权退出信息" name="股权退出信息">
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="股权是否退出" required>
                        <el-select
                          v-model="formData.gqsfct"
                          placeholder="请选择股权是否退出"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="股权退出收回资金（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.gqcthszj"
                          placeholder="请输入股权退出收回资金（万元）"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="股权退出时间">
                        <el-date-picker
                          v-model="formData.gqctsj"
                          type="date"
                          placeholder="请选择股权退出时间"
                          format="YYYY-MM-DD"
                          value-format="YYYY-MM-DD"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="股权退出收回资金到账金额（万元）">
                        <el-input-number
                          precision="2"
                          v-model="formData.gqcthszjdzje"
                          placeholder="请输入股权退出收回资金到账金额（万元）"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="股权退出收回资金到账时间">
                        <el-date-picker
                          v-model="formData.gqcthszjdzsj"
                          type="date"
                          placeholder="请选择股权退出收回资金到账时间"
                          format="YYYY-MM-DD"
                          value-format="YYYY-MM-DD"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="退出文件">
                        <el-button type="primary">上传</el-button>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="24">
                      <el-form-item label="股权退出原因">
                        <el-input
                          v-model="formData.gqctyy"
                          type="textarea"
                          :rows="3"
                          placeholder="请输入股权退出原因"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-collapse-item>

                <!-- 自查问题整改信息 -->
                <el-collapse-item
                  title="自查问题整改信息"
                  name="自查问题整改信息"
                >
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="自查是否发现问题" required>
                        <el-select
                          v-model="formData.zcsffjwt"
                          placeholder="请选择自查是否发现问题"
                        >
                          <el-option label="是" value="是"></el-option>
                          <el-option label="否" value="否"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="24">
                      <el-form-item label="自查发现的主要问题及整改计划">
                        <el-input
                          v-model="formData.zcfxdzzywtjzgjh"
                          type="textarea"
                          :rows="4"
                          placeholder="请输入自查发现的主要问题及整改计划"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="20">
                    <el-col :span="24">
                      <el-form-item label="备注">
                        <el-input
                          v-model="formData.bz"
                          type="textarea"
                          :rows="4"
                          placeholder="请输入备注"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-collapse-item>
              </el-collapse>
            </el-form>
          </div>
        </div>
      </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, h, computed } from "vue";
import { useRouter, useRoute } from "vue-router";
import { ElMessage, ElMessageBox } from "element-plus";
import routerBack from "@/components/common/routerBack.vue";

const router = useRouter();
const route = useRoute();
const { proxy } = getCurrentInstance();

// 折叠面板默认展开项
const activeCollapse = ref([
  "基本信息",
  "规模指标及额度",
  "股东信息",
  "企业工商注册资本金",
  "项目资本金",
  "财务经营信息",
  "分红与投资情况",
  "法人治理",
  "集团内投资主体相关信息",
  "股权退出信息",
  "自查问题整改信息",
]);

// 表单数据
const formData = reactive({
  projectId: "",
  jnw: "",
  sqnzw: "",
  xmmc: "",
  xmbh: "",
  qxnzwgw: "",
  sbdw: "",
  ssejdw: "",
  sfjwqy: "",
  xccgyy: "",
  qtcgyy: "",
  cgfl: "",
  xmzt: "",
  sfjtzy: "",
  sfzyglcy: "",
  sfgzxccyypyq: "",
  sshy: "",
  sfwmqy: "",
  sfssgs: "",
  sfwtzgxm: "",
  sfmqysjyy: "",
  sfzgwc: "",
  sflh: "",
  jcpfsj: "",
  cgxcjsj: "",
  jhtcnf: "",
  fxje: null,
  sfwfkgfbbqy: "",
  zyyw: "",
  sehybk: "",
  zbmc: "",
  sl: null,
  dwdw: "",
  sfwjskzr: "",
  sfpg: "",
  gdmc: "",
  gbl: null,
  gdgdhjgbl: null,
  xjcghj: null,
  yzxdrhjhj: null,
  yzxdrdwmc: "",
  qygszczij: null,
  wfcgbl: null,
  wfrjqygszczij: null,
  gszczijwfysjczje: null,
  qygszczijwfscczsj: "",
  njhjrjqygszczijbl: null,
  njhjrjqygszczij: null,
  njhjsjqygszczij: null,
  xmzbj: null,
  wfrjxmzbjbl: null,
  wfrjxmzbj: null,
  wfsjxmzbj: null,
  xmzbjnjhjcgbll: null,
  njhjrjxmzbj: null,
  njhjsjxmzbj: null,
  enyqljfhje: null,
  esnqljsdfhje: null,
  lnljsdfhje: null,
  ljcgtzhibl: null,
  gsjtntzztzsuyq: null,
  ztcgtzbzzzl: null,
  ldys: null,
  ldlr: null,
  dqcygs: null,
  sfnkjzwsjyjjyqk: "",
  sfmwnwfkh: "",
  sflxwnlcqks: "",
  sffcxjy: "",
  sfdydwxzc: "",
  ezjzccjtgqdsjcyjsryrs: null,
  ezjzccjtqsgszxtk: null,
  sfjldjzz: "",
  ezjzccsfkzdhd: "",
  ezjzccsfkzdhdcs: null,
  sfssytzztzzhjyzz: "",
  zhjyzzmc: "",
  sfsytzztzcptzcsh: "",
  sfcqgyjg: "",
  sftzztjcsjdb: "",
  dbje: null,
  cgqblcjedbje: null,
  sfblgqcqdj: "",
  gqsfct: "",
  gqcthszj: null,
  gqctsj: "",
  gqcthszjdzje: null,
  gqcthszjdzsj: "",
  gqctyy: "",
  zcsffjwt: "",
  zcfxdzzywtjzgjh: "",
  bz: "",
});

// 股东信息列表
const gdxxList = ref([]);

// 财务信息列表
const cwxxList = ref([]);

// 法人治理列表
const frzlList = ref([]);

// 新增股东信息
const addGdxx = () => {
  gdxxList.value.push({
    gdmc: "",
    gdxz: "",
    gbl: null,
    sfkgdg: "",
    sfjtcydw: "",
    sfskdw: "",
    sfyzxdr: "",
  });
};

// 删除股东信息
const deleteGdxx = (index) => {
  ElMessageBox.confirm("确认删除该项？", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  }).then(() => {
    gdxxList.value.splice(index, 1);
  });
};

// 股东信息表格合计
const sumGdxxColumns = (param) => {
  const { columns, data } = param;
  const sums = [];
  columns.forEach((column, index) => {
    if (index === 0) {
      sums[index] = h("div", "合计");
      return;
    }
    if (column.property === "gbl") {
      const values = data.map((item) => Number(item.gbl) || 0);
      const total = values.reduce((prev, curr) => prev + curr, 0);
      sums[index] = total.toFixed(2) + "%";
      return;
    }
    sums[index] = "";
  });
  return sums;
};

// 新增财务信息
const addCwxx = () => {
  cwxxList.value.push({
    nd: "",
    zzc: null,
    jzc: null,
    gsnjfznc: null,
    yysr: null,
    jlr: null,
    gsnjfndjdfh: null,
    gdhjcdffhsj: "",
    gsnjfndysdfh: null,
    sjsdfhsj: "",
    bndjtnzyjtzttzrb: null,
  });
};

// 删除财务信息
const deleteCwxx = (index) => {
  ElMessageBox.confirm("确认删除该项？", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  }).then(() => {
    cwxxList.value.splice(index, 1);
  });
};

// 新增法人治理
const addFrzl = () => {
  frzlList.value.push({
    zcypcdrdbprs: null,
    sjpccrdbprs: null,
    zcypxpcsjqksqk: [],
    sjxpcsjqksqk: [],
    sfytdtsfjq: "",
    fjqnr: "",
  });
};

// 删除法人治理
const deleteFrzl = (index) => {
  ElMessageBox.confirm("确认删除该项？", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  }).then(() => {
    frzlList.value.splice(index, 1);
  });
};

// 加载状态
const loading = ref(false);
// 是否预览模式
const isPreview = ref(!!route.query.isPreview);
// 项目列表数据
const projectList = ref([]);
// 当前编辑的记录ID
const rcCgqyglId = ref(route.query.id || "");

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

// 选择项目后同步项目名称
const changeProject = (val) => {
  const selectItem = projectList.value.find((item) => item.id === val);
  if (selectItem) {
    formData.projectName = selectItem.projectName;
  }
};

// 获取单条记录详情（编辑/预览）
const getRcCgqyglDetail = () => {
  if (!rcCgqyglId.value) return;

  loading.value = true;
  proxy.$post({
    url: "/api/project/getCgqygl",
    data: { id: rcCgqyglId.value },
    callback: (data) => {
      loading.value = false;
      Object.assign(formData, data);

      // 处理股东信息列表
      if (data.gdxxList) {
        gdxxList.value = data.gdxxList;
      }

      // 处理财务信息列表
      if (data.cwxxList) {
        cwxxList.value = data.cwxxList;
      }

      // 处理法人治理列表
      if (data.frzlList) {
        frzlList.value = data.frzlList;
      }
    },
  });
};

const backClick = () => {
  router.back(-1);
};

// 保存/提交表单
const saveClick = () => {
  // 基础校验
  if (!formData.projectId) {
    ElMessage.warning("请选择项目信息");
    return;
  }

  loading.value = true;
  // 区分新增/编辑
  const url = rcCgqyglId.value
    ? "/api/project/updateCgqygl"
    : "/api/project/createCgqygl";

  // 组装提交数据
  const submitData = {
    ...formData,
    projectId: formData.projectId + "",
    gdxxList: gdxxList.value,
    cwxxList: cwxxList.value,
    frzlList: frzlList.value,
  };

  proxy.$post({
    url: url,
    data: submitData,
    callback: (res) => {
      loading.value = false;
      ElMessage.success(rcCgqyglId.value ? "编辑成功" : "新增成功");
      router.back(-1);
    },
  });
};

// 页面初始化
onMounted(() => {
  // 获取项目列表
  getProjectData();
  // 如果有ID则加载详情
  if (rcCgqyglId.value) {
    getRcCgqyglDetail();
  }
});
</script>

<style scoped lang="less">
.tab-handle {
  margin-bottom: 10px;
}
</style>
