<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="180" :disabled="isPreview">
              <el-collapse v-model="ndActiveCollapse">
                <!-- 基本信息 -->
                <el-collapse-item title="基本信息" name="基本信息">
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="项目名称">
                        <el-input v-model="formData.nd_xmxx_projectName" />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="决策主体">
                        <el-input v-model="formData.nd_xmxx_jczt" />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="监管单位">
                        <el-select
                          v-model="formData.nd_xmxx_jgdw"
                          placeholder="请选择"
                          clearable
                        >
                          <el-option
                            v-for="item in jgdwList"
                            :key="item.key"
                            :label="item.name"
                            :value="item.key"
                          />
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="签订单位">
                        <el-select
                          v-model="formData.nd_xmxx_qddw"
                          placeholder="请选择"
                          clearable
                        >
                          <el-option
                            v-for="item in qddwList"
                            :key="item.key"
                            :label="item.name"
                            :value="item.key"
                          />
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="投资主体">
                        <el-input v-model="formData.nd_xmxx_tzzt" />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="项目地点">
                        <el-input v-model="formData.nd_xmxx_xmdd" />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="建设期(月份)">
                        <el-input-number
                          v-model="formData.nd_xmxx_jsq"
                          :min="0"
                          controls-position="right"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="项目投产时间">
                        <el-date-picker
                          v-model="formData.nd_xmxx_xmccsj"
                          type="date"
                          placeholder="请选择"
                          value-format="YYYY-MM-DD"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="运营期">
                        <el-input-number
                          v-model="formData.nd_xmxx_yyq"
                          :min="0"
                          controls-position="right"
                        />
                        <span style="margin-left: 5px">年</span>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="计划竣工时间">
                        <el-date-picker
                          v-model="formData.nd_xmxx_jhgcsj"
                          type="date"
                          placeholder="请选择"
                          value-format="YYYY-MM-DD"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="决策时间">
                        <el-date-picker
                          v-model="formData.nd_xmxx_jcsj"
                          type="date"
                          placeholder="请选择"
                          value-format="YYYY-MM-DD"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="24">
                      <el-form-item label="项目内容">
                        <el-input
                          v-model="formData.nd_xmxx_xmnr"
                          type="textarea"
                          :autosize="{ minRows: 3, maxRows: 6 }"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="24">
                      <el-form-item label="项目主要方案内容">
                        <el-input
                          v-model="formData.nd_xmxx_xmzyfanr"
                          type="textarea"
                          :autosize="{ minRows: 2, maxRows: 5 }"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="全投资财务内部收益率%（税前）">
                        <el-input-number
                          v-model="formData.nd_xmxx_qtzwsyln"
                          :min="0"
                          :max="100"
                          :precision="2"
                          controls-position="right"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="资本金财务内部收益率%（税后）">
                        <el-input-number
                          v-model="formData.nd_xmxx_zjbwsylh"
                          :min="0"
                          :max="100"
                          :precision="2"
                          controls-position="right"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="签订日期">
                        <el-date-picker
                          v-model="formData.nd_xmxx_qdrq"
                          type="date"
                          placeholder="请选择"
                          value-format="YYYY-MM-DD"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="填报人">
                        <el-input v-model="formData.nd_xmxx_tbr" />
                      </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-number
                          v-model="formData.xmztz"
                          :min="0"
                          :precision="2"
                          controls-position="right"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="建安费(万元)">
                        <el-input-number
                          v-model="formData.jaf"
                          :min="0"
                          :precision="2"
                          controls-position="right"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="设备及工具购置费(万元)">
                        <el-input-number
                          v-model="formData.sbjgjgzf"
                          :min="0"
                          :precision="2"
                          controls-position="right"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="土地相关费用(万元)">
                        <el-input-number
                          v-model="formData.tdxgfy"
                          :min="0"
                          :precision="2"
                          controls-position="right"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="建设单位管理费(万元)">
                        <el-input-number
                          v-model="formData.jsdwglf"
                          :min="0"
                          :precision="2"
                          controls-position="right"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="其他建设项目管理费(万元)">
                        <el-input-number
                          v-model="formData.qtjsxmglf"
                          :min="0"
                          :precision="2"
                          controls-position="right"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="其他费用(万元)">
                        <el-input-number
                          v-model="formData.qtfy"
                          :min="0"
                          :precision="2"
                          controls-position="right"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="能建方建安费(万元)">
                        <el-input-number
                          v-model="formData.njfjaf"
                          :min="0"
                          :precision="2"
                          controls-position="right"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="建设期利息(万元)">
                        <el-input-number
                          v-model="formData.jsqlx"
                          :min="0"
                          :precision="2"
                          controls-position="right"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-collapse-item>

                <el-collapse-item
                  title="投融资与运营指标（万元）"
                  name="投融资与运营指标（万元）"
                >
                  <DynamicTable
                    :columns="transferColumns1"
                    :disabled="isPreview"
                    v-model="formData.trzyyyzb"
                  />
                </el-collapse-item>

                <el-collapse-item
                  title="颠覆性影响的边界条件"
                  name="颠覆性影响的边界条件"
                >
                  <DynamicTable
                    :columns="transferColumns2"
                    :disabled="isPreview"
                    v-model="formData.qtdxmjcyssydfxyxdbj"
                  />
                </el-collapse-item>

                <el-collapse-item
                  title="市场开拓相关指标"
                  name="市场开拓相关指标"
                >
                  <DynamicTable
                    :columns="transferColumns2"
                    :disabled="isPreview"
                    v-model="formData.xmssgczqttgxmtzsylhddgsscktqk"
                  />
                </el-collapse-item>
                <!-- 签订信息 -->
                <el-collapse-item title="签订信息" name="签订信息">
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <el-form-item label="签订状态">
                        <el-input v-model="formData.qdzt" />

                        <!-- <el-select
                              v-model="formData.qdzt"
                              placeholder="请选择"
                              clearable
                            >
                              <el-option
                                v-for="item in qdztList"
                                :key="item.key"
                                :label="item.name"
                                :value="item.key"
                              />
                            </el-select> -->
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="是否按时签订">
                        <CommonSelector
                          v-model="formData.sfasqd"
                          :radio="true"
                          dictName="sf"
                        ></CommonSelector>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="签订单位">
                        <el-input v-model="formData.qddw" />
                      </el-form-item>
                    </el-col>
                    <el-col :span="24">
                      <el-form-item label="已盖章签字的运营阶段目标责任书附件">
                        <FileUploader
                          v-model="formData.ygzqzdyyjdmbzrsfj"
                        ></FileUploader>
                      </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, watch } from "vue";
import { useRouter, useRoute } from "vue-router";
import { ElMessage, ElMessageBox } from "element-plus";
import { useUserStore } from "@/stores/user.js";
const userStore = useUserStore();
const router = useRouter();
const route = useRoute();
const { proxy } = getCurrentInstance();
import FileUploader from "@/components/FileUploader/index.vue";
import DynamicTable from "@/components/FormDynamicTable/index.vue";
const transferColumns1 = ref([
  {
    prop: "njfcgbl",
    label: "指标名称",
    type: "input",
    placeholder: "请填写指标名称",
  },
  {
    prop: "njfcgb2",
    label: "是否考核",
    type: "select",
    optionKey: "sf",
  },
  {
    prop: "njfcgb3",
    label: "责任目标值",
    type: "number",
    placeholder: "请填写责任目标值",
  },
  {
    prop: "njfcgb4",
    label: "考核基准分",
    type: "number",
    placeholder: "请填写考核基准分",
  },

  {
    prop: "njfcgb5",
    label: "计分细责",
    type: "input",
    placeholder: "请填写计分细责",
  },
]);
const transferColumns2 = ref([
  {
    prop: "njfcgbl",
    label: "指标名称",
    type: "input",
    placeholder: "请填写指标名称",
  },

  {
    prop: "njfcgb2",
    label: "考核基准分",
    type: "number",

    placeholder: "请填写考核基准分",
  },

  {
    prop: "njfcgb3",
    label: "计分细责",
    type: "input",
    placeholder: "请填写计分细责",
  },
]);

// 表单数据

const pageActiveName = ref("全生命周期责任书");
let token = ref("");
token.value = userStore.authToken || sessionStorage.getItem("authToken") || "";
import routerBack from "@/components/common/routerBack.vue";

const activeCollapse = reactive([
  "责任书基本信息",
  "责任书具体指标",
  "批复意见落实情况",
]);
const ndActiveCollapse = reactive([
  "基本信息",

  "投融资与运营指标（万元）",
  "市场开拓相关指标",
  "颠覆性影响的边界条件",
  "造价信息",
  "签订信息",
]);
let formData = reactive({
  qtdxmjcyssydfxyxdbj: [],
  xmssgczqttgxmtzsylhddgsscktqk: [],
  trzyyyzb: [],
});
let loading = ref(false);
// 责任书类型
let zrslxList = reactive([]);
let zrslxProps = {
  label: "name",
};
let selectedFullPath = ref(""); //已选项的全路径名称
watch(
  () => formData.zrslx,
  (newVal) => {
    if (newVal) {
      selectedFullPath.value = getFullPathById(newVal);
    } else {
      selectedFullPath.value = "";
    }
  },
);
// 构建节点映射表
const nodeMap = new Map();
const getFullPathById = (id) => {
  const node = nodeMap.get(id);
  if (!node) return "";

  const path = [];
  let current = node;

  while (current) {
    path.unshift(current.name);
    current = current.parent;
  }

  return path.join(" / ");
};
// 项目列表
let projectList = ref([]);
const getProjectData = (params = {}) => {
  proxy.$post({
    url: "/api/project/listProject",
    data: {
      page: 1,
      pagesize: 1000,
      attributes: [],
      menuType: "xmjc",
      ...params,
    },
    callback: (data) => {
      projectList.value = data.rows;
    },
  });
};
// 批复意见落实情况
let pfyjlxList = reactive([]);
let lsqkList = reactive([]);
let pfyjlsqkData = ref([]);
// 年度经营管理责任书相关数据
let jgdwList = reactive([]);
let qddwList = reactive([]);
let qdztList = reactive([]);
let qdfjData = ref([]);
let qdfjSelectIds = ref([]);
const addPfyjlsqk = () => {
  pfyjlsqkData.value.push({});
};
const deletePfyjlsqk = (index) => {
  ElMessageBox.confirm("确认删除该项？", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  }).then(() => {
    pfyjlsqkData.value.splice(index, 1);
  });
};

let isPreview = !!route.query.isPreview;
let statementId = route.query.statementId;
// 查看编辑详情
const getStatementInfo = () => {
  loading.value = true;
  proxy.$post({
    url: "/api/project/getTzmbzrsInfo",
    data: {
      id: statementId,
    },
    callback: (res) => {
      loading.value = false;
      Object.assign(formData, res);
      Object.assign(zrsData.value, res.zrswj);
      Object.assign(
        zrsjtzbData.value,
        res.tzmbzrsZbs.map((item) => {
          return {
            ...item,
            sfsy: item.sfsy && item.sfsy.toString(),
          };
        }),
      );
      Object.assign(chwjData.value, res.chwj);
      Object.assign(pfyjlsqkData.value, res.tzmbzrsPfyjs);
      Object.assign(qdfjData.value, res.ndQdfj || []);
    },
  });
};
onMounted(() => {
  getProjectData();
  let resourceData = JSON.parse(sessionStorage.getItem("resourceData"));
  zrslxList = resourceData.level;
  pfyjlxList = resourceData.ssjd;
  lsqkList = resourceData.lszxqk;
  // 年度经营管理责任书相关字典
  jgdwList = resourceData.jgdw || [];
  qddwList = resourceData.qddw || [];
  qdztList = resourceData.qdzt || [];

  statementId && getStatementInfo();
  // 构建节点映射
  const buildNodeMap = (nodes, parent = null) => {
    nodes.forEach((node) => {
      node.parent = parent;
      nodeMap.set(node.key, node);
      if (node.children && node.children.length > 0) {
        buildNodeMap(node.children, node);
      }
    });
  };
  buildNodeMap(zrslxList);
});
// 选择关联项目，同步相关字段信息
const changeProject = (val) => {
  let selectData = projectList.value.filter((item) => item.id === val)[0];
  if (selectData) {
    formData.projectName = selectData.projectName;
    formData.tzzt = selectData.tzzt;
  }
};

// 责任书文件
let zrsData = ref([]);
const addZrsFile = (res, file) => {
  zrsData.value.push(res.data);
};
const deleteZrs = (index) => {
  ElMessageBox.confirm("确认删除该项？", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      zrsData.value.splice(index, 1);
    })
    .catch(() => {});
};
let zrsSelectIds = ref([]);
const zrsSelectionChange = (datas) => {
  zrsSelectIds.value = datas.map((item) => item.id);
};
const multiDeleteZrs = () => {
  ElMessageBox.confirm("确认删除选中数据？", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      zrsData.value = zrsData.value.filter(
        (item) => !zrsSelectIds.value.includes(item.id),
      );
    })
    .catch(() => {});
};
// 责任书具体指标
let zrsjtzbData = ref([
  {
    xh: "1",
    zbmc: "项目总投资(亿元)",
  },
  {
    xh: "1.1",
    zbmc: "建安费用(亿元)",
  },
  {
    xh: "2",
    zbmc: "项目带动工程收益(亿元)",
  },
]);
let qsmzqZrs = [
  {
    xh: "1",
    zbmc: "项目总投资(亿元)",
  },
  {
    xh: "1.1",
    zbmc: "建安费用(亿元)",
  },
  {
    xh: "2",
    zbmc: "项目带动工程收益(亿元)",
  },
  {
    xh: "2.1",
    zbmc: "工程收益率(%)",
  },
  {
    xh: "3",
    zbmc: "政府补助资金到位(亿元)",
  },
  {
    xh: "4",
    zbmc: "我方资本金投入(亿元)",
  },
  {
    xh: "5",
    zbmc: "我方负责引入的股权融资(亿元)",
  },
  {
    xh: "6",
    zbmc: "项目融资额(亿元)",
  },
  {
    xh: "6.1",
    zbmc: "融资利率(%)",
  },
  {
    xh: "7",
    zbmc: "项目实现营业收入累计(亿元)",
  },
  {
    xh: "8",
    zbmc: "项目经营净现金流累计(亿元)",
  },
  {
    xh: "9",
    zbmc: "项目全投资财务内部收益率（税前）(%)",
  },
  {
    xh: "10",
    zbmc: "项目资本金财务内部收益率(%)",
  },
  {
    xh: "11",
    zbmc: "项目竣工投产时间(年月)",
  },
];
let jsqZrs = [
  {
    xh: "1",
    zbmc: "项目总投资 (亿元)",
  },
  {
    xh: "1.1",
    zbmc: "建安费用(亿元)",
  },
  {
    xh: "2",
    zbmc: "项目带动工程收益 (亿元)",
  },
  {
    xh: "2.1",
    zbmc: "工程收益率(%)",
  },
  {
    xh: "3",
    zbmc: "建设期政府补助资金(亿元)",
  },
  {
    xh: "4",
    zbmc: "我方资本金投入(亿元)",
  },
  {
    xh: "5",
    zbmc: "我方负责引入的股权融资(亿元)",
  },
  {
    xh: "5.1",
    zbmc: "股权融资成本(%)",
  },
  {
    xh: "6",
    zbmc: "项目建设期融资额(亿元)",
  },
  {
    xh: "6.1",
    zbmc: "融资利率(%)",
  },
  {
    xh: "7",
    zbmc: "项目全投资财务内部收益率（税前）(%)",
  },
  {
    xh: "8",
    zbmc: "项目资本金财务内部收益率(%)",
  },
  {
    xh: "9",
    zbmc: "项目竣工投产时间(年月)",
  },
];
let yyqZrs = [
  {
    xh: "1",
    zbmc: "运营期政府补助资金到位(亿元)",
  },
  {
    xh: "2",
    zbmc: "项目运营期融资额(亿元)",
  },
  {
    xh: "2.1",
    zbmc: "融资利率(%)",
  },
  {
    xh: "3",
    zbmc: "项目实现营业收入累计(亿元)",
  },
  {
    xh: "3.1",
    zbmc: "利润总额累计(亿元)",
  },
  {
    xh: "4",
    zbmc: "项目经营净现金流累计(亿元)",
  },
  {
    xh: "5",
    zbmc: "项目全投资财务内部收益率（税前）(%)",
  },
  {
    xh: "6",
    zbmc: "项目资本金财务内部收益率(%)",
  },
];
let ndZrs = [
  {
    xh: "1",
    zbmc: "本年度完成投资(亿元)",
  },
  {
    xh: "1.1",
    zbmc: "建安费用(亿元)",
  },
  {
    xh: "1.2",
    zbmc: "项目征地拆迁费(亿元)",
  },
  {
    xh: "2",
    zbmc: "本年度工程收益(亿元)",
  },
  {
    xh: "2.1",
    zbmc: "工程收益率(%)",
  },
  {
    xh: "3",
    zbmc: "本年度政府补助资金(亿元)",
  },
  {
    xh: "4",
    zbmc: "本年度我方资本金投入(亿元)",
  },
  {
    xh: "5",
    zbmc: "本年度我方负责引入的股权融资(亿元)",
  },
  {
    xh: "5.1",
    zbmc: "股权融资成本(%)",
  },
  {
    xh: "6",
    zbmc: "本年度项目融资额(亿元)",
  },
  {
    xh: "6.1",
    zbmc: "融资利率(%)",
  },
  {
    xh: "7",
    zbmc: "本年度投资项目实现营业收入(亿元)",
  },
  {
    xh: "8",
    zbmc: "本年度项目经营净现金流(亿元)",
  },
  {
    xh: "9",
    zbmc: "项目全投资财务内部收益率（税前）(%)",
  },
  {
    xh: "10",
    zbmc: "项目资本金财务内部收益率(%)",
  },
];
// 选择责任书类型，同步切换责任书具体指标数据
const changeZrslx = (data) => {
  if (!data.children || !data.children.length) {
    // 点击到最内层子节点
    if (data.name.indexOf("年度") != -1) {
      zrsjtzbData.value = ndZrs;
    } else if (data.name.indexOf("建设") != -1) {
      zrsjtzbData.value = jsqZrs;
    } else if (data.name.indexOf("运营") != -1) {
      zrsjtzbData.value = yyqZrs;
    } else {
      zrsjtzbData.value = qsmzqZrs;
    }
  }
};
const getSummaries = (param) => {
  const { columns, data } = param;
  let sums = [];
  columns.forEach((column, index) => {
    if (index === 0) {
      sums[0] = h("div", "合计");
      return;
    }
    const values = data.map((item) => Number(item[column.property]));
    if (["khjzf"].includes(column.property)) {
      sums[index] = `${values.reduce((prev, curr) => {
        const value = Number(curr);
        if (!Number.isNaN(value)) {
          return prev + curr;
        } else {
          return prev;
        }
      }, 0)}`;
    } else {
      sums[index] = "";
    }
  });
  return sums;
};
// 策划文件
let chwjData = ref([]);
const addChwjFile = (res, file) => {
  chwjData.value.push(res.data);
};
const deleteChwj = (index) => {
  ElMessageBox.confirm("确认删除该项？", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      chwjData.value.splice(index, 1);
    })
    .catch(() => {});
};
let chwjSelectIds = ref([]);
const chwjSelectionChange = (datas) => {
  chwjSelectIds.value = datas.map((item) => item.id);
};
const multiDeleteChwj = () => {
  ElMessageBox.confirm("确认删除选中数据？", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      chwjData.value = chwjData.value.filter(
        (item) => !chwjSelectIds.value.includes(item.id),
      );
    })
    .catch(() => {});
};

// 签订附件
const addQdfjFile = (res, file) => {
  qdfjData.value.push(res.data);
};
const deleteQdfj = (index) => {
  ElMessageBox.confirm("确认删除该项？", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      qdfjData.value.splice(index, 1);
    })
    .catch(() => {});
};
const qdfjSelectionChange = (datas) => {
  qdfjSelectIds.value = datas.map((item) => item.id);
};
const multiDeleteQdfj = () => {
  ElMessageBox.confirm("确认删除选中数据？", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      qdfjData.value = qdfjData.value.filter(
        (item) => !qdfjSelectIds.value.includes(item.id),
      );
    })
    .catch(() => {});
};

// 下载已上传文件
const downloadFile = (data) => {
  let a = document.createElement("a");
  a.href = `${proxy.windowConfig.baseUrl}/api/file/download/${data.id}`;
  a.download = data.originalname;
  document.body.appendChild(a);
  a.click();
  a.remove();
};

const backClick = () => {
  router.back(-1);
};
const saveClick = () => {
  if (formData.projectId) {
    let url = formData.id ? "updateTzmbzrs" : "createTzmbzrs";
    proxy.$post({
      url: "/api/project/" + url,
      data: {
        ...formData,
        zrswj: zrsData.value,
        tzmbzrsZbs: zrsjtzbData.value,
        chwj: chwjData.value,
        tzmbzrsPfyjs: pfyjlsqkData.value,
        ndQdfj: qdfjData.value,
      },
      callback: (data) => {
        router.back(-1);
      },
    });
  } else {
    ElMessage.warning("请选择项目信息");
  }
};
</script>

<style lang="less">
.add-project-header {
  margin-bottom: 10px;
}
.collapse-title {
  font-size: 14px;
  font-weight: bold;
  color: #303133;
  margin-bottom: 10px;
  padding-left: 10px;
  border-left: 3px solid #409eff;
}
.always-click {
  color: #409eff;
  cursor: pointer;
  margin-right: 10px;
  &:hover {
    text-decoration: underline;
  }
}
.tab-handle {
  margin-bottom: 10px;
  display: flex;
  justify-content: flex-end;
}
</style>
