yxh
4 天以前 45d4fe24016c03fcccbe7c9798533ca97e2e7aea
src/views/project/fund/applyDetail/index.vue
@@ -304,7 +304,7 @@
                <i class="el-icon-warning-outline" />
                当前为查看模式,不能上传附件
              </div>
              <el-table ref="annexTable" :data="fileListto" :row-class-name="annexRowClass" @row-click="downFile" style="width: 100%" height="400">
              <el-table ref="annexTable" :data="fileListto" :row-class-name="annexRowClass" @row-click="previewInline" @row-dblclick="downFile" style="width: 100%" height="400">
                <el-table-column prop="name" :show-overflow-tooltip="true" label="名称">
                  <template slot-scope="scope">
                    <i style="color:#409EFF" class=" el-icon-s-order" />{{
@@ -616,7 +616,7 @@
                <i class="el-icon-warning-outline" />
                当前为查看模式,不能上传附件
              </div>
                <el-table ref="annexTable2" :data="fileListto" :row-class-name="annexRowClass" @row-click="downFile" style="width: 100%" height="400">
                <el-table ref="annexTable2" :data="fileListto" :row-class-name="annexRowClass" @row-click="previewInline" @row-dblclick="downFile" style="width: 100%" height="400">
                  <el-table-column prop="name" :show-overflow-tooltip="true" label="名称">
                    <template slot-scope="scope">
                      <i style="color:#409EFF" class=" el-icon-s-order" />
@@ -664,7 +664,7 @@
                <i class="el-icon-warning-outline" />
                当前为查看模式,不能上传附件
              </div>
                <el-table ref="invoiceTable" :data="invoicefileListto" :row-class-name="invoiceRowClass" @row-click="downFile" style="width: 100%" height="400">
                <el-table ref="invoiceTable" :data="invoicefileListto" :row-class-name="invoiceRowClass" @row-click="previewInline" @row-dblclick="downFile" style="width: 100%" height="400">
                  <el-table-column prop="name" :show-overflow-tooltip="true" label="名称">
                    <template slot-scope="scope">
                      <i style="color:#409EFF" class=" el-icon-s-order" />
@@ -1144,6 +1144,7 @@
      flashInvoiceName: "",
      invoicepdfimg: "",
      invoicepdfimgsrcList: [],
      previewToken: 0,
      invoDatatop: [],
      activeName: "invoice", //文件类型:默认发票文件
      //上传附件路径
@@ -2521,6 +2522,10 @@
            addorupdateFund(this.form).then(response => {
              if (response.code === 200) {
                // 2026-11-23:后端剔除了无效(blob:/data:)附件地址时给出提示
                if (response.attachWarn) {
                  this.$modal.msgWarning(response.attachWarn);
                }
                this.$modal.msgSuccess("申请单保存成功!");
                // 非提醒状态下执行审批解决异步调用延迟问题
                if (!this.Savereminder) {
@@ -2803,6 +2808,9 @@
      } else {
        this.rbDetails.splice(rowIndex + 1, 0, rowData);
      }
      // 2026-11-30:新增行后把当前操作行切到新行,并清空上一次的预览态
      this.atpresent = this.rbDetails.indexOf(rowData);
      this.resetPreviewState();
      this.Reminderquantity++;
      this.totalquantity++;
      for (let i = 0; i < this.rbDetails.length; i++) {
@@ -3072,13 +3080,33 @@
    },
    remove(file, fileList) {
      const rbDetails = [...this.rbDetails];
      // 2026-11-23:不再用"预览用临时列表"(blob: URL) 整表覆盖附件字段,
      // 改为按文件名精确删除,避免 blob: 地址被保存进 annexfiles / invoicefiles。
      const name =
        (file && (file.name || (file.raw && file.raw.name))) || "";
      if (!this.rbDetails[this.atpresent]) {
        return;
      }
      if (this.activeName == "common") {
        this.fileListto.splice(this.fileListto.indexOf(file), 1);
        rbDetails[this.atpresent].annexfilesList = this.fileListto;
        this.spliceByName(this.fileListto, name);
        this.spliceByName(this.rbDetails[this.atpresent].annexfilesList, name);
      } else {
        this.invoicefileListto.splice(this.invoicefileListto.indexOf(file), 1);
        rbDetails[this.atpresent].invoicefilesList = this.invoicefileListto;
        this.spliceByName(this.invoicefileListto, name);
        this.spliceByName(
          this.rbDetails[this.atpresent].invoicefilesList,
          name
        );
      }
    },
    /** 按文件名从列表中删除一项(找不到则不做任何事) */
    spliceByName(list, name) {
      if (!list || !name) {
        return;
      }
      const idx = list.findIndex(item => item && item.name === name);
      if (idx > -1) {
        list.splice(idx, 1);
      }
    },
@@ -3150,9 +3178,11 @@
            type: /\.pdf$/i.test(file.name) ? "pdf" : "image"
          };
          this.pdfimgsrcList.push(localUrl);
          // 2026-11-23:url 存服务端路径(权威值),previewUrl 只用于本地预览
          this.fileListto.push({
            name: file.name,
            url: localUrl
            url: response.fileName,
            previewUrl: localUrl
          });
          this.$modal.msgSuccess(response.msg);
@@ -3185,9 +3215,11 @@
            type: /\.pdf$/i.test(file.name) ? "pdf" : "image"
          };
          this.invoicepdfimgsrcList.push(localUrl);
          // 2026-11-23:url 存服务端路径(权威值),previewUrl 只用于本地预览
          this.invoicefileListto.push({
            name: file.name,
            url: localUrl
            url: response.fileName,
            previewUrl: localUrl
          });
          this.$modal.msgSuccess(response.msg);
@@ -3211,18 +3243,33 @@
    },
    // 点击票据
    /**
     * 2026-11-30:清空票据弹窗的预览状态。
     * 原实现漏清 embeddedFile / invoiceEmbeddedFile,导致再次打开弹窗时
     * 预览组件仍显示上一次选择的发票图片。
     */
    resetPreviewState() {
      this.fileListto = [];
      this.invoicefileListto = [];
      this.pdfimg = "";
      this.invoicepdfimg = "";
      this.pdfimgsrcList = [];
      this.invoicepdfimgsrcList = [];
      this.embeddedFile = null;
      this.invoiceEmbeddedFile = null;
      this.pdftitle = "";
      // 递增令牌:让上一行尚未返回的 fetch 结果失效,避免异步回写覆盖
      this.previewToken = (this.previewToken || 0) + 1;
    },
    Filepopup(index, rows, row) {
      const config = {
        headers: { Authorization: "Bearer " + this.ICDtoken }
      };
      this.tableDatatop = [];
      this.fileListto = [];
      this.invoicefileListto = [];
      this.pdfimg = "";
      this.invoicepdfimg = [];
      this.pdfimgsrcList = [];
      this.invoicepdfimgsrcList = [];
      this.resetPreviewState();
      const previewToken = ++this.previewToken;
      this.tableDatatop.push(row);
      this.atpresent = index;
      this.pdfVisible = true;
@@ -3257,7 +3304,9 @@
              .then(blob => {
                return {
                  name: value.name,
                  url: URL.createObjectURL(blob)
                  // 2026-11-23:权威地址仍是服务端路径,blob 只放 previewUrl
                  url: value.url,
                  previewUrl: URL.createObjectURL(blob)
                };
              })
              .catch(error => {
@@ -3268,10 +3317,16 @@
        );
        Promise.all(fetchPromises).then(fileListto => {
          // 2026-11-30:切换行后旧请求返回,丢弃过期结果,避免覆盖当前行预览
          if (previewToken !== this.previewToken) {
            return;
          }
          this.fileListto = fileListto.filter(item => item !== null);
          this.pdfimg = this.fileListto[0].url;
          this.pdfimg =
            this.fileListto.length > 0 ? this.fileListto[0].previewUrl : "";
          console.log(this.pdfimg, "pdfimg");
          this.pdfimgsrcList = this.fileListto.map(item => item.url);
          this.pdfimgsrcList = this.fileListto.map(item => item.previewUrl);
        });
        this.previewpdf = true;
@@ -3290,7 +3345,9 @@
              .then(blob => {
                return {
                  name: value.name,
                  url: URL.createObjectURL(blob)
                  // 2026-11-23:权威地址仍是服务端路径,blob 只放 previewUrl
                  url: value.url,
                  previewUrl: URL.createObjectURL(blob)
                };
              })
              .catch(error => {
@@ -3301,13 +3358,21 @@
        );
        Promise.all(fetchPromises).then(invoicefileListto => {
          // 2026-11-30:切换行后旧请求返回,丢弃过期结果,避免覆盖当前行预览
          if (previewToken !== this.previewToken) {
            return;
          }
          this.invoicefileListto = invoicefileListto.filter(
            item => item !== null
          );
          this.invoicepdfimg = this.invoicefileListto[0].url;
          this.invoicepdfimg =
            this.invoicefileListto.length > 0
              ? this.invoicefileListto[0].previewUrl
              : "";
          console.log(this.invoicepdfimg, "invoicepdfimg");
          this.invoicepdfimgsrcList = this.invoicefileListto.map(
            item => item.url
            item => item.previewUrl
          );
        });
@@ -3328,13 +3393,42 @@
    },
    // 费用报销:附件统一使用独立 FilePreview(录入、审批、详情一致)
    /**
     * 2026-11-30:单击列表项 → 在本页预览(右侧 preview-pane)。
     * 双击才打开独立的预览页面(downFile → $previewFile)。
     */
    previewInline(row) {
      if (!row) {
        return;
      }
      const url = row.previewUrl || row.url;
      if (!url) {
        return;
      }
      const file = {
        name: row.name || "",
        url,
        type: /\.pdf$/i.test(row.name || "") ? "pdf" : "image"
      };
      if (this.activeName == "common") {
        this.embeddedFile = file;
      } else {
        this.invoiceEmbeddedFile = file;
      }
    },
    downFile(item) {
      const source =
        this.activeName == "common" ? this.fileListto : this.invoicefileListto;
      let list = (source || []).map(f => ({ name: f.name, url: f.url }));
      let index = list.findIndex(f => f.url === item.url);
      if (index < 0 && item && item.url) {
        list = [{ name: item.name, url: item.url }];
      // 2026-11-23:预览优先用本地 blob(previewUrl),没有则退回服务端路径
      let list = (source || []).map(f => ({
        name: f.name,
        url: f.previewUrl || f.url
      }));
      const target = item && (item.previewUrl || item.url);
      let index = list.findIndex(f => f.url === target);
      if (index < 0 && target) {
        list = [{ name: item.name, url: target }];
        index = 0;
      }
      this.$previewFile(list, index > -1 ? index : 0);
@@ -3355,7 +3449,10 @@
      console.log(row);
      let indexvalue = "";
      if (this.activeName == "common") {
        const indexlist = this.getIndexInArray(this.pdfimgsrcList, row.url);
        const indexlist = this.getIndexInArray(
          this.pdfimgsrcList,
          row.previewUrl || row.url
        );
        this.pdfimgsrcList.splice(indexlist, 1);
        const index = this.getIndexInArray(this.fileListto, row);
        this.fileListto.splice(index, 1);
@@ -3364,11 +3461,13 @@
          item => item.name == row.name
        );
        console.log(indexvalue, "删除索引");
        this.rbDetails[this.atpresent].annexfilesList.splice(indexvalue, 1);
        if (indexvalue > -1) {
          this.rbDetails[this.atpresent].annexfilesList.splice(indexvalue, 1);
        }
      } else {
        const indexlist = this.getIndexInArray(
          this.invoicepdfimgsrcList,
          row.url
          row.previewUrl || row.url
        );
        this.invoicepdfimgsrcList.splice(indexlist, 1);
        const index = this.getIndexInArray(this.invoicefileListto, row);
@@ -3378,7 +3477,9 @@
          item => item.name == row.name
        );
        console.log(indexvalue, "删除索引");
        this.rbDetails[this.atpresent].invoicefilesList.splice(indexvalue, 1);
        if (indexvalue > -1) {
          this.rbDetails[this.atpresent].invoicefilesList.splice(indexvalue, 1);
        }
      }
    },
    // 点击上移
@@ -3431,7 +3532,17 @@
      // console.log(this.rbDetails[this.atpresent].invoicefilesList,'invoicefilesList');
    },
    Downloadfile(row) {
      window.location.href = row.url;
      // 2026-11-23:优先用本地 blob 下载;没有则拼服务端地址
      const target = (row && (row.previewUrl || row.url)) || "";
      if (!target) {
        return;
      }
      if (/^(blob:|data:|https?:)/i.test(target)) {
        window.location.href = target;
      } else {
        window.location.href =
          this.Networkheader + process.env.VUE_APP_BASE_API + target;
      }
    },
    //专家/医疗机构/费用报销机构选择