yxh
3 天以前 5743e533414c608a12f9323f17a7c86721c7f54c
src/views/project/donationdetails/index.vue
@@ -2511,6 +2511,7 @@
      :title="pdftitle"
      :visible.sync="pdfVisible"
      width="68%"
      custom-class="pdf-resize-dialog"
    >
      <!-- <el-tabs style="margin-top: 20px;" v-model="activeName" type="card">
        <el-tab-pane :label="activetele" name="1"> </el-tab-pane>
@@ -2811,18 +2812,6 @@
        contacttime: "",
        reporttime: ""
      },
      organOrder: [
        "肝脏",
        "左肾",
        "右肾",
        "心脏",
        "左肺",
        "右肺",
        "胰腺",
        "小肠",
        "左眼角膜",
        "右眼角膜"
      ], // 指定的器官顺序
      isSorting: false, // 标志位,表示是否正在排序
      tableKey: 0,
      istb: false,
@@ -3182,7 +3171,8 @@
    // 监听 procureddata 的变化,数据更新后重新排序
    procureddata: {
      handler(newVal) {
        if (this.procureddata[0].organgettime) {
        // 判空:取消最后一个器官时数组会变成空,直接取 [0] 会抛 TypeError
        if (this.procureddata[0] && this.procureddata[0].organgettime) {
          this.organgettimetrue = true;
        }
        if (this.isSorting) {
@@ -3342,7 +3332,8 @@
        listDonateorgan(searchParam).then(res => {
          if (res.code == 200) {
            if (res.rows[0]) {
              this.allocateddata = res.rows;
              // 2026-10-23:按器官排队序号排序后再渲染
              this.allocateddata = this.sortOrganRows(res.rows);
              console.log("this.allocateddata", this.allocateddata);
              this.allocateddataform.allocateddata = this.allocateddata;
            }
@@ -3383,6 +3374,8 @@
              });
              // this.procureddata.infoid = this.infoid;
            }
            // 2026-10-23:按器官排队序号排序后再渲染
            this.procureddata = this.sortOrganRows(this.procureddata);
            this.organList.organprocured = [];
            for (let i = 0; i < this.procureddata.length; i++) {
              this.organList.organprocured.push(this.procureddata[i].organno);
@@ -3437,6 +3430,8 @@
              this.transplantdata.infoid = this.infoid;
            }
            // 2026-10-23:按器官排队序号排序后再渲染
            this.transplantdata = this.sortOrganRows(this.transplantdata);
            for (let i = 0; i < this.transplantdata.length; i++) {
              this.organList.organtransplant.push(
                this.transplantdata[i].organno
@@ -3703,6 +3698,8 @@
              item.transplanthospitalname = objs.organizationname;
            }
          });
          // 2026-10-23:提交前按器官排队序号排序,保证入库顺序与展示一致
          this.sortOrganRows(this.allocateddata);
          saveDonateorgan(this.allocateddata).then(res => {
            // 回填主键:后端已按"同一案例同一器官"做 upsert,回填后前端不会再误判为新增
            if (res && res.data && res.data.length === this.allocateddata.length) {
@@ -3757,6 +3754,8 @@
                  }
                });
                //保存器官获取表数据
                // 2026-10-23:提交前按器官排队序号排序
                this.sortOrganRows(this.procureddata);
                saveDonationwitnessorgan(this.procureddata).then(res => {
                  if (res && res.data && res.data.length === this.procureddata.length) {
                    res.data.forEach((row, i) => {
@@ -3793,6 +3792,8 @@
                    this.Processvalidation();
                  });
                  //保存器官获取表数据
                  // 2026-10-23:提交前按器官排队序号排序
                  this.sortOrganRows(this.procureddata);
                  saveDonationwitnessorgan(this.procureddata).then(res => {
                    if (res && res.data && res.data.length === this.procureddata.length) {
                      res.data.forEach((row, i) => {
@@ -3833,6 +3834,8 @@
            if (this.accomplishform.id) {
              updateDonatecompletioninfo(this.accomplishform).then(response => {
                this.$modal.msgSuccess("完成登记信息修改成功");
                // 2026-10-23:提交前按器官排队序号排序
                this.sortOrganRows(this.transplantdata);
                saveDonatecomporgan(this.transplantdata).then(res => {
                  if (res && res.data && res.data.length === this.transplantdata.length) {
                    res.data.forEach((row, i) => {
@@ -3854,6 +3857,8 @@
                  this.accomplishform.id = response.data.id;
                }
                this.$modal.msgSuccess("完成登记成功");
                // 2026-10-23:提交前按器官排队序号排序
                this.sortOrganRows(this.transplantdata);
                saveDonatecomporgan(this.transplantdata).then(res => {
                  if (res && res.data && res.data.length === this.transplantdata.length) {
                    res.data.forEach((row, i) => {
@@ -3886,35 +3891,48 @@
      }
    },
    customOrganSort() {
      console.log("调用");
    /**
     * 取器官的排队序号:字典 sys_Organ 的 dict_sort 原值
     * 字典里没有该器官时返回 null(排序时排最后)
     */
    getOrganSort(organno) {
      const list =
        (this.dict && this.dict.type && this.dict.type.sys_Organ) || [];
      const item = list.find(d => d.value === organno);
      if (item && item.raw) {
        const s = item.raw.dictSort;
        if (s !== null && s !== undefined && s !== "") {
          return Number(s);
        }
      }
      return null;
    },
    /**
     * 按器官排队序号升序排序(原地)
     * sort 为空/0 视为未知,排最后;相同序号按 id 兜底,保证顺序稳定
     */
    sortOrganRows(rows) {
      if (!rows || !rows.length) {
        return rows;
      }
      const weight = r => {
        const s = Number(r.sort);
        if (r.sort === null || r.sort === undefined || isNaN(s) || s === 0) {
          return 999999;
        }
        return s;
      };
      rows.sort((a, b) => weight(a) - weight(b) || (a.id || 0) - (b.id || 0));
      return rows;
    },
    customOrganSort() {
      // 1. 加锁,阻止监听器执行
      this.isSorting = true;
      this.loading = true;
      // 自定义排序函数
      this.procureddata.sort((a, b) => {
        const indexA = this.organOrder.indexOf(a.organname);
        const indexB = this.organOrder.indexOf(b.organname);
        // 如果两个都在列表中,按列表中的顺序排序
        if (indexA !== -1 && indexB !== -1) {
          return indexA - indexB;
        }
        // 如果 a 在列表中,b 不在,a 排前面
        if (indexA !== -1) {
          return -1;
        }
        // 如果 b 在列表中,a 不在,b 排前面
        if (indexB !== -1) {
          return 1;
        }
        // 两个都不在列表中,保持原顺序(或按其他规则,比如按字母排序,这里按原始顺序)
        return 0;
      });
      console.log(this.procureddata, "顺序");
      this.sortOrganRows(this.procureddata);
      this.tableKey += 1; // 改变 key 迫使表格重新渲染
      // 你可以使用 this.$forceUpdate() 或者重新赋值数组来触发更新
      this.procureddata = [...this.procureddata];
      this.$nextTick(() => {
        this.isSorting = false;
@@ -3922,33 +3940,10 @@
      });
    },
    allocateddataSort() {
      console.log("调用");
      // 1. 加锁,阻止监听器执行
      this.isSorting = true;
      // 自定义排序函数
      this.allocateddata.sort((a, b) => {
        const indexA = this.organOrder.indexOf(a.organname);
        const indexB = this.organOrder.indexOf(b.organname);
        // 如果两个都在列表中,按列表中的顺序排序
        if (indexA !== -1 && indexB !== -1) {
          return indexA - indexB;
        }
        // 如果 a 在列表中,b 不在,a 排前面
        if (indexA !== -1) {
          return -1;
        }
        // 如果 b 在列表中,a 不在,b 排前面
        if (indexB !== -1) {
          return 1;
        }
        // 两个都不在列表中,保持原顺序(或按其他规则,比如按字母排序,这里按原始顺序)
        return 0;
      });
      console.log(this.allocateddata, "顺序");
      this.sortOrganRows(this.allocateddata);
      this.tableKey += 1; // 改变 key 迫使表格重新渲染
      // 你可以使用 this.$forceUpdate() 或者重新赋值数组来触发更新
      this.allocateddata = [...this.allocateddata];
      this.$nextTick(() => {
        this.isSorting = false;
@@ -4028,6 +4023,8 @@
            this.allocateddata.push({
              organname: temporganname,
              organno: value,
              // 2026-10-23:写入器官排队序号(字典 dict_sort)
              sort: this.getOrganSort(value),
              id: null,
              infoid: this.infoid,
              donorno: this.form.donorno,
@@ -4098,6 +4095,8 @@
            this.procureddata.push({
              organname: temporganname,
              organno: value,
              // 2026-10-23:写入器官排队序号(字典 dict_sort)
              sort: this.getOrganSort(value),
              id: null,
              infoid: this.infoid,
              donorno: this.form.donorno,
@@ -4174,12 +4173,17 @@
            this.transplantdata.push({
              organname: temporganname,
              organno: value,
              // 2026-10-23:写入器官排队序号(字典 dict_sort)
              sort: this.getOrganSort(value),
              id: null,
              infoid: this.infoid,
              donorno: this.form.donorno,
              organstate: 1,
              transplantstate: 1
            });
            // 2026-10-23:完成登记原先没有 watch,新增器官会停在表格最后;
            // 这里立即按排队序号归位(原地排序后必须重新赋值,否则表格不重渲染)
            this.transplantdata = this.sortOrganRows([...this.transplantdata]);
          }
        } else {
          this.$modal.msgWarning("该器官已经选择,请勿重复选择!");
@@ -4279,14 +4283,8 @@
    },
    // 获取请求头
    Getnetworkheader() {
      let string = window.location.href;
      if (string.includes("9091")) {
        const index = string.indexOf("9091");
        this.Networkheader = string.slice(0, index + 4); // 截取9091及其前部字符
      } else {
        const index = string.indexOf("8032");
        this.Networkheader = string.slice(0, index + 4); // 截取8032及其前部字符
      }
      // 以当前页面 origin 为准,兼容 80/8032/9091 及后续端口调整
      this.Networkheader = window.location.origin;
    },
    // 获取附件数据并分类二级列
@@ -4334,7 +4332,7 @@
      const config = {
        headers: { Authorization: "Bearer " + this.ICDtoken }
      };
      const pdfimg = this.Networkheader + "/prod-api" + response.fileName;
      const pdfimg = this.Networkheader + process.env.VUE_APP_BASE_API + response.fileName;
      console.log(this.Networkheader);
      //获取票据信息位置
      if (response.code == 200) {
@@ -4395,7 +4393,7 @@
      this.pdfVisible = true;
      if (this.annexfilesList.length) {
        this.annexfilesList.forEach((value, indexson) => {
          const pdfimg = this.Networkheader + "/prod-api" + value.annexurl;
          const pdfimg = this.Networkheader + process.env.VUE_APP_BASE_API + value.annexurl;
          fetch(pdfimg, config)
            .then(response => response.blob())
            .then(blob => {
@@ -4430,18 +4428,13 @@
      console.log(item, "点击文件拿item");
      this.pdftitle =
        "共" + this.donatelist.length + "项,当前选中" + item.annexname;
      let name = item.annexname.split(".");
      if (name[1] == "pdf") {
        this.$modal.msgWarning("当前文件暂不支持预览");
        this.previewpdf = false;
        this.hintitle = "当前文件暂不支持预览";
      } else if (name[1] == "jpg" || "png") {
        this.previewpdf = true;
        if (item.annexurl) {
          this.pdfimg = item.annexurl;
        } else {
          this.pdfimg = "";
        }
      const ext = String(item.annexname || "pdf").toLowerCase().split(".").pop();
      if (ext === "pdf") {
        this.$previewFile([{ name: item.annexname, url: item.annexurl }]);
        return;
      } else if (["jpg", "jpeg", "png", "gif", "bmp", "webp"].includes(ext)) {
        this.$previewFile([{ name: item.annexname, url: item.annexurl }]);
        return;
      } else {
        this.hintitle = "当前文件暂不支持预览";
        this.$modal.msgWarning("当前文件暂不支持预览");
@@ -4539,16 +4532,16 @@
  overflow: hidden;
  transition: all 0.3s ease;
  // 左侧工作进程栏
  // 左侧工作进程栏(2026-10-22:去掉底色,只留一条分隔线;标题文字改品牌青)
  .left-course {
    background: #fff;
    background: transparent;
    width: 220px;
    min-width: 220px;
    text-align: center;
    margin: 0;
    padding: 0;
    height: 100%;
    box-shadow: 2px 0 8px rgba(16, 24, 40, 0.08);
    border-right: 1px solid var(--opo-border-base, #e5e7eb);
    transition: all 0.3s ease;
    position: relative;
    z-index: 100;
@@ -4583,10 +4576,10 @@
      flex-direction: column;
      .title {
        background: var(--opo-primary, #0e768f);
        background: transparent;
        margin-bottom: 0;
        padding: 15px 10px;
        color: #fff;
        color: var(--opo-primary, #0e768f);
        font-size: 16px;
        font-weight: 600;
        display: flex;
@@ -4596,11 +4589,13 @@
        transition: all 0.3s ease;
        min-height: 54px; // 确保标题区域有固定高度
        box-sizing: border-box;
        border-bottom: 1px solid var(--opo-border-base, #e5e7eb);
        .collapse-btn {
          background: rgba(255, 255, 255, 0.2);
          border: none;
          color: #fff;
          // 标题底色去掉后,按钮改为浅青描边风格,避免白底白字看不见
          background: var(--opo-primary-light-9, #e7f1f4);
          border: 1px solid var(--opo-primary-light-7, #b7d6dd);
          color: var(--opo-primary, #0e768f);
          width: 32px; // 稍微增大确保可点击区域
          height: 32px;
          padding: 0;
@@ -4612,7 +4607,8 @@
          flex-shrink: 0; // 防止按钮被压缩
          &:hover {
            background: rgba(255, 255, 255, 0.3);
            background: var(--opo-primary-light-7, #b7d6dd);
            border-color: var(--opo-primary, #0e768f);
            transform: scale(1.1);
          }