Newer
Older
Nanping_sponge_GCGL / src / views / project / contractManagement / contractManagement.vue
@liyingjing liyingjing on 25 Oct 2023 39 KB 海绵工程管理
<template>
  <div class="app-container">
    <!-- 项目合同管理 -->
    <!-- 搜索栏 -->
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
    >
    <el-form-item v-for="i in queryClouns" :label="i.label" :prop="i.prop">
          <el-select
          v-if="i.prop == 'contractType'"
          v-model="queryParams.contractType"
          placeholder="请选择合同类型"
          clearable
        >
          <el-option
            v-for="dict in contract_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
        <el-select
        v-else-if="i.prop == 'contractStatus'"
          v-model="queryParams.contractStatus"
          placeholder="请选择合同状态"
          clearable
        >
          <el-option
            v-for="dict in contract_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
        <el-date-picker
        style="width: 260px"
          v-model="queryParams.timer"
          type="daterange"
          unlink-panels
           v-else-if="i.prop == 'timer'"
          placeholder="请选择签约日期"
          range-separator="至"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          format="YYYY-MM-DD"
          value-format="YYYY-MM-DD"
        />
          <el-input
            v-else
            clearable
            @keyup.enter="handleQuery"
            v-model="queryParams[i.prop]"
            :placeholder="i.placeholder"
            style="width: 200px"
          ></el-input>
          </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- 操作栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['system:post:add']"
          >新增</el-button
        >
      </el-col>
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <!-- 表格 -->
    <el-table
      v-loading="loading"
      :data="postList"
      @selection-change="handleSelectionChange"
      max-height="500"

    >
      <el-table-column label="序号" type="index" width="60" align="center" />
      <el-table-column
        :label="i.label"
        align="center"
        :prop="i.props"
        show-overflow-tooltip
        v-for="i in contractManagementCloum"
      >
        <template #default="{ row }" v-if="i.props == 'contractType'">
          <dict-tag :options="contract_type" :value="row.contractType" />
        </template>
        <template #default="{ row }" v-if="i.props == 'money'">
          {{ row.money ||0}}(万元)
        </template>
        <template #default="{ row }" v-if="i.props == 'paidMoney'">
          {{ row.paidMoney ||0}}(万元)
        </template>
        <template #default="{ row }" v-if="i.props == 'notPaidMoney'">
          {{ row.notPaidMoney ||0}}(万元)
        </template>
        <template #default="{ row }" v-if="i.props == 'ratio'">
          {{ row.ratio ||0  }}%
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        width="280"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template #default="scope">
          <el-button
            link
            type="primary"
            icon="View"
            @click="handleDetails(scope.row,2)"
            >详情</el-button
          >
          <el-button
            link
            type="warning"
            icon="Edit"
            @click="handleUpdate(scope.row,2)"
            v-hasPermi="['system:post:edit']"
            >修改</el-button
          >
          <el-button
            link
            type="danger"
            icon="Delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:post:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 添加或修改合同对话框 -->
    <el-dialog :title="title" v-model="open" width="68%">
      <el-form
        ref="postRef"
        :model="form"
        :rules="contractManagementRules"
        label-width="120px"
        :inline="true"
      >
        <el-divider content-position="left">基本信息</el-divider>
        <el-form-item label="合同编号:" prop="contractNo" style="width: 45%">
          <el-input v-model="form.contractNo" placeholder="请输入合同编号" />
        </el-form-item>
        <el-form-item label="项目名称:" prop="projectNo" style="width: 45%">
          <el-select
            v-model="form.projectNo"
            placeholder="请选择项目名称"
            style="width: 100%"
            @change="ProjectChange"
          >
            <el-option
              v-for="dict in ProjectListData"
              :key="dict.projectNo"
              :label="dict.projectName"
              :value="dict.projectNo"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="合同名称:" style="width: 45%">
          <el-input v-model="form.contractName" placeholder="请输入合同名称" />
        </el-form-item>
        <el-form-item label="投标编号:" style="width: 45%">
          <el-select
            v-model="form.tenderExaminationId"
            placeholder="请选择投标编号"
            style="width: 100%"
            @change="tenderExaminationChange"
          >
            <el-option
              v-for="dict in tenderExaminationData"
              :key="dict.id"
              :label="dict.tenderNumber"
              :value="dict.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="签约日期:" style="width: 45%" prop="signTime">
          <el-date-picker
            style="width: 100%"
            v-model="form.signTime"
            type="date"
            placeholder="请选择签约日期"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD"
          />
        </el-form-item>
        <el-form-item label="合同类型:" style="width: 45%">
          <el-select
            v-model="form.contractType"
            placeholder="请选择合同类型"
            style="width: 100%"
          >
            <el-option
              v-for="dict in contract_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="甲方:" style="width: 45%">
          <el-select
            v-model="form.firstParty"
            placeholder="请选择甲方"
            style="width: 100%"
            @change="firstPartyChange"
          >
            <el-option
              v-for="dict in JiaFangList"
              :key="dict.id"
              :label="dict.unitName"
              :value="dict.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="乙方:" style="width: 45%">
          <el-input
            v-model="form.secondParty"
            placeholder="请选择乙方"
           disabled
          />
        </el-form-item>
        <el-form-item label="通讯地址一:" style="width: 45%">
          <el-input
            v-model="form.firstPartyAddress"
            placeholder="请输入通讯地址一"
           disabled
          />
        </el-form-item>
        <el-form-item label="通讯地址二:" style="width: 45%">
          <el-input
            v-model="form.secondPartyAddress"
            placeholder="请输入通讯地址二"
           disabled
          />
        </el-form-item>
        <el-form-item label="主要负责人一:" style="width: 45%">
          <el-input
            v-model="form.firstPartyPrimaryPerson"
            placeholder="请输入主要负责人一"
           disabled
          />
        </el-form-item>
        <el-form-item label="主要负责人二:" style="width: 45%">
          <el-input
            v-model="form.secondPartyPrimaryPerson"
            placeholder="请输入主要负责人二"
           disabled
          />
        </el-form-item>
        <el-form-item label="电话一:" style="width: 45%">
          <el-input
            v-model="form.firstPartyTelephone"
            placeholder="请输入电话一"
           disabled
          />
        </el-form-item>
        <el-form-item label="电话二:" style="width: 45%">
          <el-input
            v-model="form.secondPartyTelephone"
            placeholder="请输入电话二"
           disabled
          />
        </el-form-item>
        <el-form-item label="手机一:" style="width: 45%">
          <el-input
            v-model="form.firstPartyPhone"
            placeholder="请输入手机一"
           disabled
          />
        </el-form-item>
        <el-form-item label="手机二:" style="width: 45%">
          <el-input
            v-model="form.secondPartyPhone"
            placeholder="请输入手机二"
           disabled
          />
        </el-form-item>
        <el-form-item label="邮箱一:" style="width: 45%">
          <el-input
            v-model="form.firstPartyEmail"
            placeholder="请输入邮箱一"
           disabled
          />
        </el-form-item>
        <el-form-item label="邮箱二:" style="width: 45%">
          <el-input
            v-model="form.secondPartyEmail"
            placeholder="请输入邮箱二"
           disabled
          />
        </el-form-item>
        <el-form-item label="金额:" style="width: 45%" prop="money">
          <el-input v-model="form.money" placeholder="请输入金额" style="width: 100%">
            <template #append>万元</template>
          </el-input>
        </el-form-item>
        <el-form-item
          label="业务负责人:"
          style="width: 45%"
          prop="businessPrimaryPerson"
        >
          <el-input
            v-model="form.businessPrimaryPerson"
            placeholder="请输入业务负责人"
          />
        </el-form-item>
        <el-form-item label="合同状态:" style="width: 45%">
          <el-select
            v-model="form.contractStatus"
            placeholder="请选择合同状态"
            clearable
            style="width: 100%"
          >
            <el-option
              v-for="dict in contract_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="合同有效期:" style="width: 45%">
          <el-date-picker
            style="width: 100%"
            v-model="form.contractLimited"
            type="date"
            placeholder="请选择合同有效期"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD"
          />
        </el-form-item>
        <el-form-item label="主要条款:" style="width: 93%">
          <el-input
            v-model="form.mainClause"
            placeholder="请输入主要条款"
            :autosize="{ minRows: 5, maxRows: 7 }"
            type="textarea"
          />
        </el-form-item>
        <el-form-item label="备注:" style="width: 93%">
          <el-input
            v-model="form.remark"
            placeholder="请输入备注"
            :autosize="{ minRows: 5, maxRows: 7 }"
            type="textarea"
          />
        </el-form-item>
        <el-form-item label="附件:" style="width: 93%">
          <el-upload
            v-model:file-list="fileList1"
            class="upload-demo"
            action="/prod-api/system/upload"
            :headers="uploadHeader"
            multiple
            :on-preview="handlePreview"
            style="width: 100%"
            :before-remove="beforeRemove"
          >
            <el-button type="primary">选择文件</el-button>
            <template #tip>
              <div class="el-upload__tip">支持CSV格式,可一次性上传多个文件</div>
            </template>
          </el-upload>
        </el-form-item>
      </el-form>
      <div class="biaoti">
          支付计划
          <el-button
            type="primary"
            plain
            style="float: right"
            @click="FenJieMoney"
            >按比例分解</el-button
          >
        </div>
        <div class="JiHuaHeader">
          <div class="HeaderListDiv">期次</div>
          <div class="HeaderListDiv">金额(元)</div>
          <div class="HeaderListDiv">备注</div>
        </div>
        <div
          v-for="(row, index) in form.projectContractPayPlanList"
          :key="index"
          class="JiHuaHeader"
        >
          <div class="HeaderListDiv">{{ index + 1 }}</div>
          <div class="HeaderListDiv">{{ row.currentMoney }}</div>
          <div class="HeaderListDiv">
            <el-input
              v-model="row.remark"
              class="EditInput"
              placeholder="点击添加备注信息"
            />
          </div>
        </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">保 存</el-button>
          <el-button @click="cancel">关 闭</el-button>
        </div>
      </template>
      <!-- 分解计划数据 -->
      <el-dialog
        width="800px"
        title="按比例分解回款计划"
        v-model="open3"
        append-to-body
        align-center
        top="30%"
      >
        <div class="HTMoney">
          合同金额: {{ form.money * 10000 }} 元
          <el-button type="primary" plain style="float: right" @click="AddJh"
            >添加计划</el-button
          >
        </div>
        <div class="JiHuaHeader">
          <div class="HeaderListDiv HeaderListDiv2">期次</div>
          <div class="HeaderListDiv HeaderListDiv2">比例(%)</div>
          <div class="HeaderListDiv HeaderListDiv2">金额(元)</div>
          <div class="HeaderListDiv HeaderListDiv2">操作</div>
        </div>
        <div
          v-for="(row, index) in FenJieJiHuaData"
          :key="index"
          class="JiHuaHeader"
        >
          <div class="HeaderListDiv HeaderListDiv2">{{ index + 1 }}</div>
          <div class="HeaderListDiv HeaderListDiv2">
            <el-input-number
              v-model="row.paymentRatio"
              :min="1"
              :max="100"
              @change="BiLiChange(row, index)"
            />
          </div>
          <div class="HeaderListDiv HeaderListDiv2">
            {{ row.currentMoney }}
          </div>
          <div class="HeaderListDiv HeaderListDiv2">
            <el-button type="danger" link @click="ZhiFuDel2(index)"
              >删除数据</el-button
            >
          </div>
        </div>
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" @click="submitForm2">确 定</el-button>
            <el-button @click="open3 = false">取 消</el-button>
          </div>
        </template>
      </el-dialog>
    </el-dialog>
    <!-- 详情对话框 -->
    <el-dialog
      title="项目合同管理详情"
      v-model="open2"
      width="1400px"
      id="DiaLogBox"
    >
      <!-- 顶部切换 -->
      <div class="TabsTop">
        <div
          class="TabsList"
          :class="{ TabsListActive: tabsNum == 1 }"
          @click="tabsNum = 1"
        >
          基础信息
        </div>
        <div
          class="TabsList"
          :class="{ TabsListActive: tabsNum == 2 }"
          @click="tabsNum = 2"
        >
          支付情况
        </div>
      </div>
      <!-- 内容 -->
      <div class="TabBody" v-show="tabsNum == 1">
        <!-- 基础信息 -->
        <div class="LeftBox1">
          <el-progress
            type="circle"
            :percentage="DetailData.ratio"
            :width="200"
            style="margin: 100px 80px 20px 70px"
            :stroke-width="20"
            striped
            striped-flow
          />
          <p class="HTNo">{{ DetailData.contractNo }}</p>
          <div class="HTMoney1">
            <div class="JENum">{{ DetailData.money }}(万元)</div>
            <div class="JEName">合同金额</div>
          </div>
          <div class="HTMoney1">
            <div class="JENum">
              {{ DetailData.paidMoney ? DetailData.paidMoney : "--" }}(万元)
            </div>
            <div class="JEName">已支付金额</div>
          </div>
        </div>
        <div class="LeftBox2">
          <div class="InfoList">
            <div class="InfoListLable">合同编号</div>
            <div class="InfoListvalue">{{ DetailData.contractNo }}</div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">项目名称</div>
            <div class="InfoListvalue">{{ DetailData.projectName }}</div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">合同名称</div>
            <div class="InfoListvalue">{{ DetailData.contractName }}</div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">投标编号</div>
            <div class="InfoListvalue">{{ DetailData.tenderNumber }}</div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">签约日期</div>
            <div class="InfoListvalue">{{ DetailData.signTime }}</div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">合同类型</div>
            <div class="InfoListvalue">
              {{ selectDictLabel(contract_type, DetailData.contractType) }}
            </div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">甲方</div>
            <div class="InfoListvalue">{{ DetailData.firstParty }}</div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">乙方</div>
            <div class="InfoListvalue">{{ DetailData.secondParty }}</div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">通讯地址</div>
            <div class="InfoListvalue">{{ DetailData.firstPartyAddress }}</div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">通讯地址</div>
            <div class="InfoListvalue">{{ DetailData.secondPartyAddress }}</div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">主要负责人</div>
            <div class="InfoListvalue">
              {{ DetailData.firstPartyPrimaryPerson }}
            </div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">主要负责人</div>
            <div class="InfoListvalue">
              {{ DetailData.secondPartyPrimaryPerson }}
            </div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">电话</div>
            <div class="InfoListvalue">
              {{ DetailData.firstPartyTelephone }}
            </div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">电话</div>
            <div class="InfoListvalue">
              {{ DetailData.secondPartyTelephone }}
            </div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">手机</div>
            <div class="InfoListvalue">{{ DetailData.firstPartyPhone }}</div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">手机</div>
            <div class="InfoListvalue">{{ DetailData.secondPartyPhone }}</div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">邮箱</div>
            <div class="InfoListvalue">{{ DetailData.firstPartyEmail }}</div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">邮箱</div>
            <div class="InfoListvalue">{{ DetailData.secondPartyEmail }}</div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">金额</div>
            <div class="InfoListvalue">{{ DetailData.money }} 万元</div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">业务负责人</div>
            <div class="InfoListvalue">
              {{ DetailData.businessPrimaryPerson }}
            </div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">合同状态</div>
            <div class="InfoListvalue">
              {{ selectDictLabel(contract_status, DetailData.contractStatus) }}
            </div>
          </div>
          <div class="InfoList">
            <div class="InfoListLable">合同有效期</div>
            <div class="InfoListvalue">{{ DetailData.contractLimited }}</div>
          </div>
          <div class="InfoList InfoList2">
            <div class="InfoListLable">主要条款</div>
            <div class="InfoListvalue">{{ DetailData.mainClause }}</div>
          </div>
          <div class="InfoList InfoList2">
            <div class="InfoListLable">备注</div>
            <div class="InfoListvalue">{{ DetailData.remark }}</div>
          </div>
          <div class="InfoList3">
            <div class="InfoListLable">附件</div>
            <div class="InfoListvalue">
              <el-upload
                v-model:file-list="fileList1"
                class="upload-demo"
                action="/prod-api/system/upload"
                disabled
                multiple
                :on-preview="handlePreview"
              >
              </el-upload>
            </div>
          </div>
        </div>
      </div>
      <div class="TabBody" v-show="tabsNum == 2">
        <!-- 支付信息 -->
        <p class="ProjectInfoTitle">支付计划</p>
        <div class="JiHuaHeader">
          <div class="HeaderListDiv">期次</div>
          <div class="HeaderListDiv">金额(元)</div>
          <div class="HeaderListDiv">备注</div>
        </div>
        <div
          v-for="(row, index) in DetailData.projectContractPayPlanList"
          :key="index"
          class="JiHuaHeader"
        >
          <div class="HeaderListDiv">{{ index + 1 }}</div>
          <div class="HeaderListDiv">{{ row.currentMoney }}</div>
          <div class="HeaderListDiv">
            {{ row.remark ? row.remark : "无" }}
          </div>
        </div>

        <p class="ProjectInfoTitle">支付记录</p>
        <PaymentRecords
          v-if="tabsNum == 2"
          :contractId="contractId"
          :PiCiData="DetailData"
        ></PaymentRecords>
      </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="open2 = false">关 闭</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>
<script setup name="Post">
import { ElMessage, ElMessageBox } from "element-plus";
import {
  projectContractPage,
  projectContractAdd,
  projectContractIDS,
  projectContractDetail,
  projectContractEdit,
  projectInfoList,
  projectTenderResultList,
  projectCompanyID,
  projectCompanyList,
  FileSystemList,
  projectContractCalculateByRatio,
} from "@/api/project/tenderReview";
import { getToken } from "@/utils/auth";
import PaymentRecords from "./components/PaymentRecords.vue";
import {contractManagementRules} from '@/utils/rules'
import { contractManagementCloum } from "@/utils/cloums";
const { proxy } = getCurrentInstance();
const { contract_type, contract_status } = proxy.useDict(
  "contract_type",
  "contract_status"
);

const postList = ref([]);
const open = ref(false);
const open2 = ref(false);
const open3 = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const tabsNum = ref(1);
const contractId = ref("");
const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    postCode: undefined,
    postName: undefined,
    status: undefined,
    timer: "",
  },

  DetailData: {},
  FenJieJiHuaData: [],
});
const { queryParams, form, DetailData, FenJieJiHuaData } = toRefs(data);
const ProjectListData = ref([]);
const tenderExaminationData = ref([]);
const JiaFangList = ref([]);
const queryClouns = [
  { label: "项目名称", prop: "projectName", placeholder: "请输入项目名称" },
  {
    label: "合同类型",
    prop: "contractType",
    placeholder: "请选择合同类型",
  },
  {
    label: "合同状态",
    prop: "contractStatus",
    placeholder: "请选择合同状态",
  },
  { label: "合同名称", prop: "contractName", placeholder: "请输入合同名称" },
  { label: "签约日期", prop: "timer", placeholder: "请选择签约日期" },
];
const uploadHeader = ref({
  Authorization: "Bearer " + getToken(),
});
/** 文件上传 */
const fileList1 = ref([]);
function handlePreview(file) {
  console.log(file);
  return ElMessageBox.confirm(`下载此文件: ${file.name}?`).then(
    () => window.open(file.url),
    () => false
  );
}
function beforeRemove(file) {
  return true
}
/** 查询合同列表 */
function getList() {
  loading.value = true;
  if (queryParams.value.timer?.length > 0) {
    queryParams.value.signEndTime = queryParams.value.timer[1];
    queryParams.value.signStartTime = queryParams.value.timer[0];
  }else{
    queryParams.value.signEndTime = ''
    queryParams.value.signStartTime = ''
  }
  projectContractPage(queryParams.value).then((response) => {
    postList.value = response.data;
    total.value = response.total;
    loading.value = false;
  });
}
/** 取消按钮 */
function cancel() {
  open.value = false;
  reset();
}
/** 表单重置 */
function reset() {
  form.value = {
    id: undefined,
    contractNo: undefined,
    projectNo: undefined,
    contractName: undefined,
    tenderExaminationId: undefined,
    signTime: undefined,
    contractType: undefined,
    firstParty: undefined,
    secondParty: undefined,
    firstCompanyId: undefined,
    secondCompanyId: undefined,
    firstPartyAddress: undefined,
    secondPartyAddress: undefined,
    firstPartyPrimaryPerson: undefined,
    secondPartyPrimaryPerson: undefined,
    firstPartyTelephone: undefined,
    secondPartyTelephone: undefined,
    firstPartyPhone: undefined,
    secondPartyPhone: undefined,
    firstPartyEmail: undefined,
    secondPartyEmail: undefined,
    money: undefined,
    businessPrimaryPerson: undefined,
    contractStatus: undefined,
    contractLimited: undefined,
    mainClause: undefined,
    remark: undefined,
    projectContractPayPlanList: [],
    fileSaveRequestList: [],
  };
  fileList1.value = [];
  proxy.resetForm("postRef");
}
/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}
/** 重置按钮操作 */
function resetQuery() {
  // proxy.resetForm("queryRef");
  queryParams.value = { pageNum: 1, pageSize: 10 };
  handleQuery();
}
/** 多选框选中数据 */
function handleSelectionChange(selection) {
  ids.value = selection.map((item) => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}
/** 新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  title.value = "合同添加";
}
/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const id = row.id || ids.value;
  projectContractDetail(id).then((response) => {
    form.value = response.data;
    ProjectChange(DetailData.value.projectNo);
    open.value = true;
    title.value = "项目合同管理修改";
    form.value.fileSaveRequestList = [];
  });
  // 获取文件列表
  FileSystemList({
    refId: id,
    refType: "proProjectContract",
  }).then((response) => {
    response.data.forEach((element) => {
      fileList1.value.push(element);
    });
  });
}
/**详情按钮 */
// let idss=ref()
function handleDetails(row,t) {
  reset();
  const id = row.id || ids.value;
  // idss.value=id
  projectContractDetail(id).then((response) => {
    DetailData.value = response.data;
    DetailData.value.type = t
    tabsNum.value = 1;
    open2.value = true;
    contractId.value = DetailData.value.id;
  });
  form.value.fileSaveRequestList = [];
  // 获取文件列表
  FileSystemList({
    refId: id,
    refType: "proProjectContract",
  }).then((response) => {
    response.data.forEach((element) => {
      fileList1.value.push(element);
    });
  });
}
/** 提交按钮 */
function submitForm() {
  console.log("FenJieJiHuaData", FenJieJiHuaData.value.length)
  proxy.$refs["postRef"].validate((valid) => {
    if (valid) {
      if(form.value?.projectContractPayPlanList?.length==0){
        ElMessage({
      message: "请先添加支付计划",
      type: "warning",
    });
  }else{
    fileList1.value.forEach((element) => {
        if (element.hasOwnProperty("response")) {
          element.response.data.refType = "proProjectContract";
          form.value.fileSaveRequestList.push(element.response.data);
        } else {
          form.value.fileSaveRequestList.push(element);
        }
      });
      if (form.value.id != undefined) {
        projectContractEdit(form.value).then((response) => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
      } else {
        projectContractAdd(form.value).then((response) => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
      }
    }
  }

  });
}
/** 删除按钮操作 */
function handleDelete(row) {
  const ids = row.id || ids.value;
  proxy.$modal
    .confirm('是否确认删除合同编号为"' + ids + '"的数据项?')
    .then(function () {
      return projectContractIDS(ids);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => {});
}
/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    "system/post/export",
    {
      ...queryParams.value,
    },
    `post_${new Date().getTime()}.xlsx`
  );
}
/**获取所有的项目数据 */
function loadProjerctListData() {
  projectInfoList().then((response) => {
    ProjectListData.value = response.data;
  });
}
/**项目下拉框事件 */
function ProjectChange(val) {
  console.log(val);

  // 清空部分数据
  form.value.secondCompanyId = undefined;
  form.value.secondParty = undefined;
  form.value.secondPartyAddress = undefined;
  form.value.secondPartyPrimaryPerson = undefined;
  form.value.secondPartyTelephone = undefined;
  form.value.secondPartyPhone = undefined;
  form.value.secondPartyEmail = undefined;
  projectTenderResultList({
    projectNo: val,
  }).then((response) => {
    tenderExaminationData.value = response.data;
    if (form.value.tenderExaminationId != undefined) {
      tenderExaminationChange(form.value.tenderExaminationId);
    }
  });
}

/** 投标id下拉框事件*/
function tenderExaminationChange(val) {
  // 选择一个投标编号
  // 清空部分数据
  form.value.secondCompanyId = undefined;
  form.value.secondParty = undefined;
  form.value.secondPartyAddress = undefined;
  form.value.secondPartyPrimaryPerson = undefined;
  form.value.secondPartyTelephone = undefined;
  form.value.secondPartyPhone = undefined;
  form.value.secondPartyEmail = undefined;
  // 通过标书id获取公司信息
  let companyId = "";
  tenderExaminationData.value.forEach((element) => {
    if (element.id == val) {
      companyId = element.companyId;
      // 获取乙方详情信息
      projectCompanyID(companyId).then((response) => {
        form.value.secondCompanyId = response.data.id;
        form.value.secondParty = response.data.unitName;
        form.value.secondPartyAddress = response.data.unitAddress;
        form.value.secondPartyPrimaryPerson =
          response.data.primaryConcatPersonName;
        form.value.secondPartyTelephone =
          response.data.primaryConcatPersonTelephone;
        form.value.secondPartyPhone =
          response.data.primaryConcatPersonInformation;
        form.value.secondPartyEmail = response.data.primaryConcatPersonEmail;
      });
    }
  });
}

/**甲方下拉框选择 */
function firstPartyChange(val) {
  JiaFangList.value.forEach((element) => {
    if (element.id == val) {
      form.value.firstCompanyId = element.id;
      form.value.firstParty = element.unitName;
      form.value.firstPartyAddress = element.unitAddress;
      form.value.firstPartyPrimaryPerson = element.primaryConcatPersonName;
      form.value.firstPartyTelephone = element.primaryConcatPersonTelephone;
      form.value.firstPartyPhone = element.primaryConcatPersonInformation;
      form.value.firstPartyEmail = element.primaryConcatPersonEmail;
    }
  });
}
/**获取所有公司的列表信息 */
function loadAllGongSiData(params) {
  projectCompanyList().then((response) => {
    JiaFangList.value = response.data;
  });
}
/**点击分解金额 */
function FenJieMoney() {
  if (form.value.money == undefined) {
    ElMessage({
      message: "请先填写合同金额",
      type: "warning",
    });
  } else {
    open3.value = true;
    FenJieJiHuaData.value = JSON.parse(
      JSON.stringify(form.value.projectContractPayPlanList)
    );
  }
}
/**点击添加计划 */
function AddJh() {
  let lengthNum = FenJieJiHuaData.value.length;
  // if (lengthNum > 0) {
  FenJieJiHuaData.value.push({
    currentMoney: form.value.money * 100,
    paymentRatio: 1,
  });
  // FenJieJiHuaData.value.splice(lengthNum - 1, 0, {
  //     currentMoney: form.value.money * 100,
  //     paymentRatio: 1,
  // });
  // }
}
/**比例变化获取金额 */
function BiLiChange(params, index) {
  let querys = {
    money: form.value.money,
    paymentHistoryRequestList: [],
    ratio: params.paymentRatio,
  };
  FenJieJiHuaData.value.forEach((element, index2) => {
    // 获取请求金额的参数
    if (index != index2) {
      querys.paymentHistoryRequestList.push({
        money: Number(element.currentMoney),
        ratio: Number(element.paymentRatio),
      });
    }
  });

  projectContractCalculateByRatio(querys).then((response) => {
    params.currentMoney = response.data;
  });
}
/**分解回款计划完成 */
function submitForm2() {
  // 判断当前回款比例是否为100%
  let AllRatio = 0;
  FenJieJiHuaData.value.forEach((element, index2) => {
    // 判断当前值是否超过了100
    AllRatio += element.paymentRatio;
  });
  console.log(AllRatio);
  if (AllRatio == 100) {
    FenJieJiHuaData.value.forEach((i, index) => {
      i.currentBatch = index + 1;
    });
    form.value.projectContractPayPlanList = JSON.parse(
      JSON.stringify(FenJieJiHuaData.value)
    );
    open3.value = false;
  } else {
    ElMessage({
      message: "请保证所有期次的比例之和为100%",
      type: "warning",
    });
  }
}

/**删除分解支付计划 */
function ZhiFuDel2(index) {
  FenJieJiHuaData.value.splice(index, 1);
}

getList();
loadProjerctListData();
loadAllGongSiData();
</script>
<style scoped lang="scss">
.biaoti {
  font-weight: 900;
  font-size: 18px;
  margin: 10px 0;
  width: 100%;
  height: 40px;
  line-height: 40px;
}

:deep(.el-dialog__body) {
  // padding: 0px !important;
  background-color: #eef1fb;
  height: 750px;
  overflow: auto;
}
.HTMoney {
  width: 100%;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
}

.JiHuaHeader {
  width: 100%;
  height: 40px;

  .HeaderListDiv {
    width: 33%;
    text-align: center;
    float: left;
    height: 40px;
    line-height: 40px;
    border: 1px solid #ccc;
    color: black;
    font-weight: 600;

    .EditInput {
      border: none !important;

      :deep(.el-input__wrapper) {
        background: #f0f0f000 !important;
        border: none !important;
        box-shadow: none !important;
      }
    }
  }

  .HeaderListDiv2 {
    width: 25%;
  }
}

#DiaLogBox {
  .TabsTop {
    width: 100%;
    height: 36px;
    margin-bottom: 14px;

    .TabsList {
      width: 120px;
      text-align: center;
      height: 36px;
      line-height: 34px;
      float: left;
      box-sizing: border-box;
      border: 1px solid #409eff;
      color: #409eff;
      cursor: pointer;

      &:nth-child(1) {
        border-top-left-radius: 5px;
        border-bottom-left-radius: 5px;
      }

      &:nth-child(2) {
        border-top-right-radius: 5px;
        border-bottom-right-radius: 5px;
      }
    }

    .TabsListActive {
      background-color: #409eff;
      color: white;
    }
  }

  .TabBody {
    width: 100%;
    height: calc(100% - 50px);

    // 基础信息
    .LeftBox1 {
      width: 360px;
      height: 100%;
      float: left;

      .HTNo {
        width: 340px;
        text-align: center;
        font-size: 16px;
      }

      .HTMoney1 {
        width: 170px;
        height: 80px;
        float: left;
        text-align: center;

        .JENum {
          width: 100%;
          height: 40px;
          font-size: 26px;
          font-weight: 400;
          color: #409eff;
        }

        .JEName {
          width: 100%;
          height: 40px;
          font-size: 16px;
          color: black;
        }
      }
    }

    .LeftBox2 {
      width: calc(100% - 360px);
      height: 100%;
      float: left;
      background: white;
      overflow: auto;
      font-size: 0;

      .InfoList {
        display: inline-block;
        width: 50%;
        height: 42px;
        border: 1px solid #d8ddef;
        box-sizing: border-box;
        // margin-left: 1%;

        .InfoListLable {
          height: 40px;
          line-height: 40px;
          width: 100px;
          float: left;
          background-color: #f3f7ff;
          box-sizing: border-box;
          font-size: 14px;
          font-family: Source Han Sans CN;
          font-weight: 500;
          color: #666666;
          text-align: center;
        }

        .InfoListvalue {
          width: calc(100% - 100px);
          height: 40px;
          line-height: 40px;
          float: left;
          font-size: 14px;
          font-family: Source Han Sans CN;
          font-weight: bold;
          color: #333333;
          text-align: right;
          padding-right: 10px;
        }
      }

      .InfoList2 {
        width: 100%;
        height: 82px;

        .InfoListLable {
          height: 100%;
          height: 80px;
          line-height: 80px;
        }

        .InfoListvalue {
          height: 100%;
          height: 80px;
        }
      }

      .InfoList3 {
        width: 100%;
        min-height: 60px;
        height: auto;
        overflow: auto;

        .InfoListLable {
          width: 100px;
          float: left;
          font-size: 14px;
          font-family: Source Han Sans CN;
          font-weight: 500;
          color: #000000;
          text-align: center;
          line-height: 60px;
        }

        .InfoListvalue {
          float: left;
          width: calc(100% - 100px);
          height: auto;
        }
      }
    }

    // 支付信息
    .ProjectInfoTitle {
      width: 100%;
      height: 50px;
      line-height: 50px;
      box-sizing: border-box;
      padding-left: 24px;
      font-size: 16px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      color: #333333;
      margin: 0;
    }
  }
}
</style>