yxh
2026-09-30 d21d7dd23f15a0ca395a4c9d1b3bb31330ff56c0
src/views/project/travelexpenseapply/travelexpensedetail/index.vue
@@ -2538,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,
@@ -2549,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;
@@ -2592,7 +2597,8 @@
      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
@@ -2619,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;
@@ -3251,6 +3263,45 @@
        });
    },
    /**
     * 状态类字段转字符串(接口可能返回 null)。
     *
     * 背景:checkstatus、recordstatus 等在库中可空,早期直接调用 .toString()
     * 会抛 TypeError 并中断其后的取数逻辑,表现为“接口已有数据但明细区空白”。
     *
     * @param {*} value 原始状态值
     * @param {string} fallback 为空时的兜底值
     * @returns {string}
     */
    toStatusText(value, fallback) {
      if (value === null || value === undefined || value === "") {
        return fallback;
      }
      return String(value);
    },
    /**
     * 统一从明细接口响应中取出数组。
     *
     * 正常为 AjaxResult 的 data 数组;若后端改为分页结构(total + rows),
     * res.data 将不是数组,直接绑定到 el-table 会导致“有数据但不显示”。
     *
     * @param {Object} res 接口原始响应
     * @returns {Array} 明细数组(异常时为空数组,不会让表格拿到非数组)
     */
    normalizeDetailList(res) {
      if (!res) {
        return [];
      }
      if (Array.isArray(res.data)) {
        return res.data;
      }
      if (Array.isArray(res.rows)) {
        return res.rows;
      }
      return [];
    },
    //计算一行合计
    //计算当前行报销内容费用合计(金额一律走精确运算)
    sumRowFee(row) {