yxh
2026-10-12 0e10e10157b90002b99996914eaf1e5574924ddf
src/views/project/travelexpenseapply/travelexpensedetail/index.vue
@@ -9,8 +9,8 @@
              <el-date-picker
                style="width: 100%"
                v-model="form.applyTime"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                type="date" format="yyyy-MM-dd"
                value-format="yyyy-MM-dd"
                placeholder="申请日期"
                :disabled="true"
              >
@@ -369,8 +369,8 @@
                  size="small"
                  style="width: 100%"
                  v-model="scope.row.starttime"
                  type="date"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  type="date" format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                  placeholder="开始日期"
                  @blur="getdays(scope.row)"
                >
@@ -401,8 +401,8 @@
                  size="small"
                  style="width: 100%"
                  v-model="scope.row.endtime"
                  type="date"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  type="date" format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                  placeholder="结束日期"
                  @blur="getdays(scope.row)"
                >
@@ -848,8 +848,8 @@
            <!--
            <el-table-column prop="paiddate" slot="" label="打款日期" fixed align="center" width="150">
              <template slot-scope="scope">
                <el-date-picker clearable size="small" style="width: 100%" v-model="scope.row.paiddate" type="date"
                  value-format="yyyy-MM-dd HH:mm:ss" placeholder="打款日期" :disabled="true">
                <el-date-picker clearable size="small" style="width: 100%" v-model="scope.row.paiddate" type="date" format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd" placeholder="打款日期" :disabled="true">
                </el-date-picker>
              </template>
            </el-table-column>-->
@@ -1116,8 +1116,8 @@
              <!-- <el-image
                style="width: 95%; height: 90%"
                :src="pdfimg"
                :preview-src-list="pdfimgsrcList" -->
              >
                :preview-src-list="pdfimgsrcList"
              > -->
              <el-image
                ref="imagePreview"
                style="width: 95%; height: 90%"
@@ -1282,7 +1282,8 @@
  exportReimbursement,
  getdownload,
  checkfund,
  fundSubmit
  fundSubmit,
  listbypowerone
} from "@/api/project/reimbursement";
import {
  addReimbursementdetail,
@@ -1304,6 +1305,7 @@
import { listReportname, listUser } from "@/api/project/organization";
import { getToken } from "@/utils/auth";
import debounce from "lodash/debounce";
import { moneySum, moneyAdd, moneyRound } from "@/utils/money";
export default {
  components: {
    Treeselect,
@@ -1492,6 +1494,8 @@
        flowconclusion: null,
        fundid: null
      },
      //连续审批:待审批列表
      pendingList: [],
      jurisdiction: false,
      //保存按钮控制
@@ -2143,9 +2147,9 @@
          if (tempStr == "杭州") {
            row.otherexpense = "";
          } else if (
            tempStr == "杭州-桐庐" ||
            tempStr == "杭州-建德" ||
            tempStr == "杭州-淳安"
            tempStr.includes("桐庐") ||
          tempStr.includes("建德") ||
          tempStr.includes("淳安")
          ) {
            row.otherexpense = (parseInt(row.days) * 60).toString();
          } else {
@@ -2534,7 +2538,7 @@
            .map(item => ({ url: item, name: item }))
          : [];
        //审核状态
        this.form.recordstatus = response.data.recordstatus + "";
        this.form.recordstatus = this.toStatusText(response.data.recordstatus, "-1");
        let ids = response.data.id;
        let listFundflowparams = {
          fundid: ids,
@@ -2545,14 +2549,19 @@
        });
        //报销明细
        getReimbursementdetaillist(ids).then(res => {
          this.rbDetails = res.data;
          //合计费用
          // if (this.rbDetails.length > 0) this.sumTotalFee();
          for (let i = 0; i < this.rbDetails.length; i++) {
            this.sumRowFee(this.rbDetails[i]);
          }
        });
        getReimbursementdetaillist(ids)
          .then(res => {
            this.rbDetails = this.normalizeDetailList(res);
            //合计费用
            // if (this.rbDetails.length > 0) this.sumTotalFee();
            for (let i = 0; i < this.rbDetails.length; i++) {
              this.sumRowFee(this.rbDetails[i]);
            }
          })
          .catch(err => {
            this.rbDetails = [];
            console.error("获取报销明细失败,id=" + ids, err);
          });
        //付款信息
        this.queryParamsPayee.rbid = ids;
@@ -2575,12 +2584,21 @@
      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;
        console.log(this.form.checkstatus, "checkstatus");
        this.form.checkstatus = this.form.checkstatus.toString();
        // checkstatus 在库中可为空(预审状态尚未产生时),直接 toString 会抛 TypeError 中断后续取数
        this.form.checkstatus = this.toStatusText(this.form.checkstatus, "-1");
        //票据
        this.fileListto = this.form.annexfiles
@@ -2607,16 +2625,22 @@
        });
        //报销明细
        getReimbursementdetaillist(ids).then(res => {
          this.rbDetails = res.data;
          console.log(this.rbDetails);
        getReimbursementdetaillist(ids)
          .then(res => {
            this.rbDetails = this.normalizeDetailList(res);
            console.log("报销明细行数:", this.rbDetails.length, this.rbDetails);
          //合计费用
          // if (this.rbDetails.length > 0) this.sumTotalFee();
          for (let i = 0; i < this.rbDetails.length; i++) {
            this.sumRowFee(this.rbDetails[i]);
          }
        });
            //合计费用
            // if (this.rbDetails.length > 0) this.sumTotalFee();
            for (let i = 0; i < this.rbDetails.length; i++) {
              this.sumRowFee(this.rbDetails[i]);
            }
          })
          .catch(err => {
            // 取数失败时不再静默:置空并打出原因,避免“接口有数据但页面空白”无从排查
            this.rbDetails = [];
            console.error("获取报销明细失败,id=" + ids, err);
          });
        //付款信息
        this.queryParamsPayee.rbid = ids;
@@ -2665,18 +2689,73 @@
        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) {
            this.$modal.msgError("操作失误");
          } else {
            this.$modal.msgError(res.msg);
          }
          this.$modal.msgError(res.msg || "操作失败");
        }
      });
    },
    // 获取当前用户待审批列表(用于连续审批)
    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);
    },
    /** 提交保存按钮 */
@@ -3180,108 +3259,71 @@
        });
    },
    //计算一行合计
    //计算当前行报销内容费用合计
    sumRowFee(row) {
      let totalFee = 0;
      if (!isNaN(parseFloat(row.trafficexpense))) {
        totalFee += parseFloat(row.trafficexpense);
    /**
     * 状态类字段转字符串(接口可能返回 null)。
     *
     * 背景:checkstatus、recordstatus 等在库中可空,早期直接调用 .toString()
     * 会抛 TypeError 并中断其后的取数逻辑,表现为“接口已有数据但明细区空白”。
     *
     * @param {*} value 原始状态值
     * @param {string} fallback 为空时的兜底值
     * @returns {string}
     */
    toStatusText(value, fallback) {
      if (value === null || value === undefined || value === "") {
        return fallback;
      }
      if (!isNaN(parseFloat(row.cityfee))) {
        totalFee += parseFloat(row.cityfee);
      }
      if (!isNaN(parseFloat(row.hotelexpense))) {
        totalFee += parseFloat(row.hotelexpense);
      }
      if (!isNaN(parseFloat(row.otherexpense))) {
        totalFee += parseFloat(row.otherexpense);
      }
      if (!isNaN(parseFloat(row.foodexpenses))) {
        totalFee += parseFloat(row.foodexpenses);
      }
      if (!isNaN(parseFloat(row.foodallowance))) {
        totalFee += parseFloat(row.foodallowance);
      }
      if (!isNaN(parseFloat(row.otherfeeamount))) {
        totalFee += parseFloat(row.otherfeeamount);
      }
      row.total = totalFee.toFixed(2);
      return String(value);
    },
      /*
      if (!isNaN(parseFloat(this.rbDetails[rowIndex].trafficexpense))) {
        totalFee += parseFloat(this.rbDetails[rowIndex].trafficexpense);
    /**
     * 统一从明细接口响应中取出数组。
     *
     * 正常为 AjaxResult 的 data 数组;若后端改为分页结构(total + rows),
     * res.data 将不是数组,直接绑定到 el-table 会导致“有数据但不显示”。
     *
     * @param {Object} res 接口原始响应
     * @returns {Array} 明细数组(异常时为空数组,不会让表格拿到非数组)
     */
    normalizeDetailList(res) {
      if (!res) {
        return [];
      }
      if (!isNaN(parseFloat(this.rbDetails[rowIndex].cityfee))) {
        totalFee += parseFloat(this.rbDetails[rowIndex].cityfee);
      if (Array.isArray(res.data)) {
        return res.data;
      }
      if (!isNaN(parseFloat(this.rbDetails[rowIndex].hotelexpense))) {
        totalFee += parseFloat(this.rbDetails[rowIndex].hotelexpense);
      if (Array.isArray(res.rows)) {
        return res.rows;
      }
      if (!isNaN(parseFloat(this.rbDetails[rowIndex].otherexpense))) {
        totalFee += parseFloat(this.rbDetails[rowIndex].otherexpense);
      }
      if (!isNaN(parseFloat(this.rbDetails[rowIndex].foodexpenses))) {
        totalFee += parseFloat(this.rbDetails[rowIndex].foodexpenses);
      }
      if (!isNaN(parseFloat(this.rbDetails[rowIndex].foodallowance))) {
        totalFee += parseFloat(this.rbDetails[rowIndex].foodallowance);
      }
      if (!isNaN(parseFloat(this.rbDetails[rowIndex].otherfeeamount))) {
        totalFee += parseFloat(this.rbDetails[rowIndex].otherfeeamount);
      }
      this.rbDetails[rowIndex].total = parseFloat(totalFee).toFixed(2);
      this.$set(this.rbDetails, rowIndex, this.rbDetails[rowIndex]);
      */
      return [];
    },
    //计算一行合计
    //计算当前行报销内容费用合计(金额一律走精确运算)
    sumRowFee(row) {
      const totalFee = moneySum([
        row.trafficexpense,
        row.cityfee,
        row.hotelexpense,
        row.otherexpense,
        row.foodexpenses,
        row.foodallowance,
        row.otherfeeamount
      ]);
      row.total = moneyRound(totalFee).toFixed(2);
      //重新计算整个报销单的合计
      this.sumTotalFee();
    },
    //计算费用合计
    sumTotalFee() {
      let allSum = 0;
      //捐献者家属费用
      if (!isNaN(parseFloat(this.form.donoramount))) {
        allSum += parseFloat(this.form.donoramount);
      }
      //报销明细费用
      try {
        for (let i = 0; i < this.rbDetails.length; i++) {
          /*
          let totalFee = 0;
          //计算当前报销内容费用合计
          if (!isNaN(parseFloat(this.rbDetails[i].total))) {
            totalFee += parseFloat(this.rbDetails[i].total);
          }
          if (!isNaN(parseFloat(this.rbDetails[i].cityfee))) {
            totalFee += parseFloat(this.rbDetails[i].cityfee);
          }
          if (!isNaN(parseFloat(this.rbDetails[i].hotelexpense))) {
            totalFee += parseFloat(this.rbDetails[i].hotelexpense);
          }
          if (!isNaN(parseFloat(this.rbDetails[i].otherexpense))) {
            totalFee += parseFloat(this.rbDetails[i].otherexpense);
          }
          if (!isNaN(parseFloat(this.rbDetails[i].foodexpenses))) {
            totalFee += parseFloat(this.rbDetails[i].foodexpenses);
          }
          if (!isNaN(parseFloat(this.rbDetails[i].foodallowance))) {
            totalFee += parseFloat(this.rbDetails[i].foodallowance);
          }
          if (!isNaN(parseFloat(this.rbDetails[i].otherfeeamount))) {
            totalFee += parseFloat(this.rbDetails[i].otherfeeamount);
          }
          this.rbDetails[i].total = parseFloat(totalFee).toFixed(2);
          this.$set(this.rbDetails, i, this.rbDetails[i]);
          */
          if (!isNaN(parseFloat(this.rbDetails[i].total))) {
            allSum += parseFloat(this.rbDetails[i].total);
          }
        }
        this.form.amountrequested = allSum.toFixed(2);
        this.form.amountrequested = moneyAdd(
          moneySum(this.rbDetails, "total"),
          this.form.donoramount
        ).toFixed(2);
        this.form.bigstrmoney = this.convertCurrency(this.form.amountrequested);
      } catch { }
    },