WXL
3 天以前 5e093dcc9f4177bfd5f9ab2927914d2bf852770b
src/views/project/travelexpenseapply/travelexpensedetail/index.vue
@@ -30,6 +30,7 @@
              >
                <el-option
                  v-for="item in personsList"
                  :key="item.reportNo"
                  :label="item.reportName"
                  :value="item.reportName"
                >
@@ -64,6 +65,7 @@
              >
                <el-option
                  v-for="dict in dict.type.sys_travelexpensebelong"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
@@ -74,12 +76,11 @@
            <el-form-item
              label="捐献者"
              prop="infoid"
              v-show="form.costtype == 4"
              v-show="form.costtype == 3 || form.costtype == 4"
            >
              <el-select
                v-model="form.infoid"
                @change="selectbaseinfo"
                @clear="clearDonatorInfo"
                clearable
                filterable
                placeholder="请选择捐献者"
@@ -333,12 +334,11 @@
                  allow-create
                  default-first-option
                  placeholder="请选择"
                  @focus1="getPersons(scope.row)"
                >
                  <el-option
                    v-for="(item, index) in personsSel"
                    :key="`${item.reportNo}_${index}`"
                    :label="item.reportName"
                    v-for="item in personsSel"
                    :key="item.id"
                    :label="item.reportNameDesc"
                    :value="item.reportName"
                  >
                  </el-option>
@@ -786,10 +786,10 @@
                  @change="getAccountinfo2(scope.row, scope.row.persontype)"
                >
                  <el-option
                    v-for="(item, index) in personsSel"
                    :key="`${item.reportNo}_${index}`"
                    :label="item.reportName"
                    :value="item.reportName"
                    v-for="item in personsSel"
                    :key="item.id"
                    :label="item.reportNameDesc"
                    :value="item.id"
                  >
                  </el-option>
                </el-select>
@@ -924,9 +924,9 @@
          <el-col :span="12">
            <el-form-item label="预审材料" prop="infoid">
              <el-radio-group v-model="form.checkstatus" align="left">
                <el-radio label="1">待申请材料</el-radio>
                <el-radio label="2">审核通过等待邮寄纸质材料</el-radio>
                <el-radio label="3">已收到报销材料</el-radio>
                <el-radio label="1">待申请</el-radio>
                <el-radio label="2">审核通过等待纸质材料</el-radio>
                <el-radio label="3">已收到纸质材料</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
@@ -1263,6 +1263,7 @@
<script>
import pdf from "vue-pdf";
import Decimal from 'decimal.js';
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { listDonatebaseinfo } from "@/api/project/donatebaseinfo";
@@ -1281,7 +1282,8 @@
  exportReimbursement,
  getdownload,
  checkfund,
  fundSubmit
  fundSubmit,
  listbypowerone
} from "@/api/project/reimbursement";
import {
  addReimbursementdetail,
@@ -1443,15 +1445,15 @@
      baselisttages: [
        {
          id: 1,
          name: "待申请材料"
          name: "待申请"
        },
        {
          id: 2,
          name: "审核通过等待邮寄纸质材料"
          name: "预审通过等待纸质材料"
        },
        {
          id: 3,
          name: "已收到报销材料"
          name: "已收到纸质材料"
        }
      ],
      baselist: [],
@@ -1491,6 +1493,8 @@
        flowconclusion: null,
        fundid: null
      },
      //连续审批:待审批列表
      pendingList: [],
      jurisdiction: false,
      //保存按钮控制
@@ -1583,7 +1587,7 @@
      if (
        (JSON.stringify(this.form) == sessionStorage.getItem("apiform") &&
          JSON.stringify(this.rbDetails) ==
            sessionStorage.getItem("apifunddetail")) ||
          sessionStorage.getItem("apifunddetail")) ||
        !sessionStorage.getItem("apifunddetail")
      ) {
      } else {
@@ -1646,7 +1650,7 @@
    handleImageLoad() {
      console.log("图片加载成功");
    },
    handleUploadError() {},
    handleUploadError() { },
    // 获取请求头
    Getnetworkheader() {
      console.log(window.location.href);
@@ -2062,6 +2066,11 @@
      } else if (row.persontype == "管理人员") {
        this.personsSel = this.personsManager;
      }
      if (this.personsSel && this.personsSel.length) {
        this.personsList.forEach(item => {
          item.reportNameDesc = `${item.reportName}(${item.unitname})`;
        });
      }
    },
    //获取设置人员账号信息
@@ -2091,7 +2100,8 @@
      }
      for (let m = 0; m < dataArr.length; m++) {
        if (dataArr[m].reportName == row.personname) {
        if (dataArr[m].id == row.personname) {
          row.personname = dataArr[m].reportName;
          row.bankname = dataArr[m].depositbank;
          row.bankcardno = dataArr[m].bankcardno;
        }
@@ -2110,7 +2120,7 @@
        row.days = (
          Math.floor(
            Math.abs(Date.parse(row.starttime) - Date.parse(row.endtime)) /
              (1000 * 3600 * 24)
            (1000 * 3600 * 24)
          ) + 1
        ).toString();
      } else {
@@ -2453,13 +2463,13 @@
        this.fileListto = this.form.annexfiles
          ? this.form.annexfiles
              .split(",")
              .map(item => ({ url: item, name: item }))
            .split(",")
            .map(item => ({ url: item, name: item }))
          : [];
        this.invoicefileListto = this.form.invoicefilesList
          ? this.form.invoicefilesList
              .split(",")
              .map(item => ({ url: item, name: item }))
            .split(",")
            .map(item => ({ url: item, name: item }))
          : [];
        this.form.recordstatus = response.data.recordstatus + "";
        sessionStorage.removeItem("apiform");
@@ -2518,13 +2528,13 @@
        //票据
        this.fileListto = this.form.annexfiles
          ? this.form.annexfiles
              .split(",")
              .map(item => ({ url: item, name: item }))
            .split(",")
            .map(item => ({ url: item, name: item }))
          : [];
        this.invoicefileListto = this.form.invoicefilesList
          ? this.form.invoicefilesList
              .split(",")
              .map(item => ({ url: item, name: item }))
            .split(",")
            .map(item => ({ url: item, name: item }))
          : [];
        //审核状态
        this.form.recordstatus = response.data.recordstatus + "";
@@ -2568,7 +2578,15 @@
      this.reset();
      this.open = true;
      const id = ids || this.ids;
      this.checkObj.fundid = id;
      // 重置审批信息,避免上一单的审批结果带入下一单
      this.checkObj = {
        flowlevelone: null,
        flowconclusion: null,
        fundid: id
      };
      // 连续审批:加载当前用户的待审批列表
      this.getPendingList();
      getReimbursement(id).then(response => {
        this.form = response.data;
@@ -2578,13 +2596,13 @@
        //票据
        this.fileListto = this.form.annexfiles
          ? this.form.annexfiles
              .split(",")
              .map(item => ({ url: item, name: item }))
            .split(",")
            .map(item => ({ url: item, name: item }))
          : [];
        this.invoicefileListto = this.form.invoicefilesList
          ? this.form.invoicefilesList
              .split(",")
              .map(item => ({ url: item, name: item }))
            .split(",")
            .map(item => ({ url: item, name: item }))
          : [];
        //审核状态
@@ -2658,9 +2676,8 @@
        if (res.code == 200) {
          this.$modal.closeLoading();
          this.$modal.msgSuccess("提交审核成功!");
          // 关闭窗口
          this.$store.dispatch("tagsView/delView", this.$route);
          this.$router.go(-1);
          // 连续审批:询问是否继续审批下一单
          this.continueOrExit();
        } else {
          this.$modal.closeLoading();
          if (res.msg) {
@@ -2672,29 +2689,101 @@
      });
    },
    // 获取当前用户待审批列表(用于连续审批)
    getPendingList() {
      listbypowerone({
        pageNum: 1,
        pageSize: 1000,
        CHECKFLAG: 1
      })
        .then(res => {
          this.pendingList = res.rows || [];
        })
        .catch(() => {
          this.pendingList = [];
        });
    },
    // 审批完成后:询问是否继续审批下一单
    continueOrExit() {
      const list = this.pendingList || [];
      const curId = String(this.checkObj.fundid);
      const idx = list.findIndex(item => String(item.id) === curId);
      let next = null;
      if (idx > -1 && idx + 1 < list.length) {
        next = list[idx + 1];
      } else {
        // 当前已是末位(或从中间开始),取剩余列表中第一条非当前单据
        next = list.find(item => String(item.id) !== curId) || null;
      }
      if (next) {
        this.$confirm("审批已完成,是否继续审批下一张待审批单据?", "提示", {
          confirmButtonText: "继续审批",
          cancelButtonText: "返回列表",
          type: "info"
        })
          .then(() => {
            // 直接在当前页面加载下一张待审批单据
            this.handleCheck(next.id);
            // 同步更新地址栏,避免刷新后回到上一单
            this.$router
              .replace({
                path: this.$route.path,
                query: { id: next.id, pos: 4 }
              })
              .catch(() => {});
          })
          .catch(() => {
            this.exitToPage();
          });
      } else {
        this.$modal.msgSuccess("已无待审批单据,返回列表");
        this.exitToPage();
      }
    },
    // 返回列表页
    exitToPage() {
      this.$store.dispatch("tagsView/delView", this.$route);
      this.$router.go(-1);
    },
    /** 提交保存按钮 */
    submitForm: debounce(function(data) {
    submitForm: debounce(function (data) {
      this.$refs["form"].validate(valid => {
        if (valid) {
          //票据文件处理
          const addnumber = this.rbPayees.reduce(
            (amount, item) => amount + Number(item.amount),
            0
          );
          // const addnumber = new Decimal(this.rbPayees.reduce((amount, item) => amount + Number(item.amount), 0 ));
          // console.log(this.form.amountrequested,addnumber);
          // //校验请款金额合计是否等于报销单金额
          // if (this.form.amountrequested != addnumber) {
          //   this.$message({
          //     message:
          //       "报销请款表中合计金额不等于报销单的报销金额,请更正后再保存!!",
          //     type: "warning"
          //   });
          //   return;
          // }
          // 保留2位小数后进行比较
          const requestedAmount = Number(this.form.amountrequested);
          const calculatedAmount = Number(addnumber);
          // 1. 在 reduce 累加时,直接传入字符串给 Decimal,并使用 .plus() 方法进行累加
          // 初始值设为 new Decimal(0),确保全程高精度运算
          const addnumber = this.rbPayees.reduce((amount, item) => {
            return amount.plus(new Decimal(item.amount.toString()));
          }, new Decimal(0));
          // 使用toFixed保留2位小数
          if (requestedAmount.toFixed(2) !== calculatedAmount.toFixed(2)) {
          console.log(this.form.amountrequested, addnumber.toString());
          // 2. 使用 Decimal 的 .eq() 方法进行严格相等比较
          // 这样既解决了精度问题,也解决了类型转换比较的问题
          if (!addnumber.eq(this.form.amountrequested)) {
            this.$message({
              message:
                "报销请款表中合计金额不等于报销单的报销金额,请更正后再保存!",
              message: "报销请款表中合计金额不等于报销单的报销金额,请更正后再保存!!",
              type: "warning"
            });
            return;
          }
          const rbDetails = [...this.rbDetails];
          const rbPayees = [...this.rbPayees];
@@ -2705,8 +2794,8 @@
            if (!tempDetail.persontype) {
              this.$modal.msgWarning(
                "明细表中,第" +
                  (k + 1).toString() +
                  "行的人员类别未选择,请先选择人员类别后再提交保存!"
                (k + 1).toString() +
                "行的人员类别未选择,请先选择人员类别后再提交保存!"
              );
              return;
            }
@@ -2714,8 +2803,8 @@
            if (!tempDetail.personname) {
              this.$modal.msgWarning(
                "明细表中,第" +
                  (k + 1).toString() +
                  "行的费用人员未选择,请选择费用人员后再提交保存!"
                (k + 1).toString() +
                "行的费用人员未选择,请选择费用人员后再提交保存!"
              );
              return;
            }
@@ -2723,8 +2812,8 @@
            if (!tempDetail.starttime) {
              this.$modal.msgWarning(
                "明细表中,第" +
                  (k + 1).toString() +
                  "行的开始日期未选择,请选择开始日期后再提交保存!"
                (k + 1).toString() +
                "行的开始日期未选择,请选择开始日期后再提交保存!"
              );
              return;
            }
@@ -2732,8 +2821,8 @@
            if (!tempDetail.endtime) {
              this.$modal.msgWarning(
                "明细表中,第" +
                  (k + 1).toString() +
                  "行的结束日期姓名为选择,请选择结束日期后再提交保存!"
                (k + 1).toString() +
                "行的结束日期姓名为选择,请选择结束日期后再提交保存!"
              );
              return;
            }
@@ -2745,12 +2834,12 @@
            //保存明细
            for (let i = 0; i < rbDetails.length; i++) {
              if (rbDetails[i].rbid != null) {
                if (rbDetails[i].persontype == "家属") {
                if (rbDetails[i].persontype == "家属"||rbDetails[i].persontype == "专家") {
                  if (this.form.infoid) {
                    updateReimbursementdetail(rbDetails[i]);
                  } else {
                    return this.$message.error(
                      `因家属分配要求,请选择捐献者信息`
                      "因财务核算的要求,家属或专家的报销,需要选择对应的捐献者!"
                    );
                  }
                } else {
@@ -2764,7 +2853,7 @@
                    addReimbursementdetail(rbDetails[i]);
                  } else {
                    return this.$message.error(
                      `因家属分配要求,请选择捐献者信息`
                      "因财务核算的要求,家属或专家的报销,需要选择对应的捐献者!"
                    );
                  }
                } else {
@@ -2851,7 +2940,7 @@
      const ids = row.id || this.ids;
      this.$modal
        .confirm("是否确认删除该条记录?")
        .then(function() {
        .then(function () {
          // 删除details内的数据
          return delReimbursement(ids);
        })
@@ -2860,7 +2949,7 @@
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
        .catch(() => { });
    },
    /** 导出按钮操作 */
@@ -2876,7 +2965,7 @@
          this.$download.name(response.msg);
          this.exportLoading = false;
        })
        .catch(() => {});
        .catch(() => { });
    },
    // 取消提醒
    unsave() {
@@ -2892,7 +2981,6 @@
        (amount, item) => amount + Number(item.amount),
        0
      );
      console.log(addnumber, "addnumber");
      this.$refs["form"].validate(valid => {
        if (valid) {
          //票据文件处理
@@ -2900,7 +2988,7 @@
          if (this.form.amountrequested != addnumber) {
            this.$message({
              message:
                "报销请款表中合计金额不等于报销单的报销金额,请更正后再保存!",
                "报销请款表中合计金额不等于报销单的报销金额,请更正后再保存!!!",
              type: "warning"
            });
            return;
@@ -3265,7 +3353,7 @@
        this.form.amountrequested = allSum.toFixed(2);
        this.form.bigstrmoney = this.convertCurrency(this.form.amountrequested);
      } catch {}
      } catch { }
    },
    //金额数字转换成大写