wwl
1 天以前 5821664d8e34973ec0e0123228c3591da51cdd2f
全选问题,动态url
3个文件已修改
122 ■■■■ 已修改文件
src/main.js 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/doctor/inspectCheck/index.vue 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
vue.config.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.js
@@ -17,7 +17,7 @@
import "./assets/icons";
import "./permission";
import { getDicts } from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config";
import { getConfigKey,yidu } from "@/api/system/config";
import {
  parseTime,
  resetForm,
@@ -36,7 +36,7 @@
import DictData from "@/components/DictData";
import * as echarts from "echarts";
import VueBarcode from "vue-barcode";
// import { initWebSocket, closeWebSocket } from "@/utils/websocket";
import { initWebSocket, closeWebSocket } from "@/utils/websocket";
import RightToolbar from "@/components/RightToolbar"
// 注册全局组件
@@ -63,7 +63,7 @@
Vue.prototype.$echarts = echarts;
// 通知管理:跟踪当前通知和偏移量
/* const notificationManager = {
const notificationManager = {
  notifications: [], // 存储当前显示的通知实例
  baseOffset: 50, // 基础偏移量
  notificationHeight: 80, // 每个通知的估计高度(包括间距)
@@ -94,10 +94,10 @@
      notification.customClass = notification.customClass.replace(/notification-\d+/, `notification-${index + 1}`);
    });
  }
}; */
};
// 全局通知方法,添加“已读”按钮
/* Vue.prototype.$showNotification = function (type, title, message, onClick, noticeId) {
 Vue.prototype.$showNotification = function (type, title, message, onClick, noticeId) {
  console.log('触发通知:', { type, title, message, noticeId, noticeIdType: typeof noticeId }); // 调试:记录 noticeId 和类型
  const h = this.$createElement;
  const notification = this.$notify({
@@ -134,7 +134,8 @@
    appendTo: document.body
  });
  notificationManager.addNotification(notification); // 添加到通知管理
}; */
};
// 监听路由变化
router.afterEach(() => {
@@ -142,14 +143,14 @@
});
// 定义 WebSocket 初始化标志,防止重复连接
// let isWebSocketInitialized = false;
let isWebSocketInitialized = false;
const app = new Vue({
  el: "#app",
  router,
  store,
  render: (h) => h(App),
  /* mounted() {
 mounted() {
    const token = store.state.user.token || Cookies.get('token') || '';
    if (token && !isWebSocketInitialized) {
      console.log('初始化 WebSocket,Token:', token);
@@ -207,7 +208,7 @@
      isWebSocketInitialized = false;
      console.log('Vue 实例销毁,WebSocket 已清理');
    }
  } */
  }
});
// 注册插件
src/views/doctor/inspectCheck/index.vue
@@ -22,7 +22,8 @@
      <div class="table-header">检验记录</div>
      <div>
        <el-table :data="exaLists" border style="width: 100%" @selection-change="handleSelectionChange"
          :header-cell-style="{ background: '#aad8df', fontSize: '14px', color: '#333' }" height="350" ref="firstTable">
          @select-all="handleSelectAll" :header-cell-style="{ background: '#aad8df', fontSize: '14px', color: '#333' }"
          height="350" ref="firstTable">
          <el-table-column fixed type="selection" align="center" label="选择" width="50" />
          <el-table-column label="姓名" align="center" prop="name" width="80" />
          <el-table-column label="性别" align="center" prop="gender" width="80" />
@@ -89,7 +90,6 @@
    </el-table>
  </div>
</template>
<script>
import { getlisList, getJyTjList, asyncPacs } from "@/api/doctor/pacsCheck";
import { getOrderList } from "@/api/hosp/order";
@@ -145,57 +145,59 @@
      this.exaLists = [];
      this.checkList = [];
      this.infoList = {};
      this.selectedFirstTable = [];
      this.selectedSecondTable = [];
    },
    handleSelectionChange(selected) {
    // ✅ 分组多选稳固版
    handleSelectionChange(selection) {
      if (this.isProcessingSelection) return;
      this.isProcessingSelection = true;
      // 找到用户刚操作的那一条(对比之前和现在的差异)
      const old = this.selectedFirstTable;
      let changedRow = null;
      // 计算所有被选中的分组 brid
      const allBrids = new Set();
      selection.forEach(row => allBrids.add(row.brid));
      if (selected.length > old.length) {
        // 新增:找出新增的
        changedRow = selected.find(row => !old.includes(row));
      } else {
        // 删除:找出删除的
        changedRow = old.find(row => !selected.includes(row));
      }
      // 清空后重选
      this.$refs.firstTable.clearSelection();
      this.$nextTick(() => {
        const newSelection = this.exaLists.filter(row => allBrids.has(row.brid));
        newSelection.forEach(row => {
          this.$refs.firstTable.toggleRowSelection(row, true);
        });
        this.selectedFirstTable = newSelection;
        this.isProcessingSelection = false;
        this.fetchRightTableData();
      });
    },
      if (changedRow) {
        const group = this.exaLists.filter(r => r.brid === changedRow.brid);
        const isAdding = selected.length > old.length;
    handleSelectAll(selection) {
      if (this.isProcessingSelection) return;
      this.isProcessingSelection = true;
      if (selection.length === 0) {
        // 取消全选
        this.$refs.firstTable.clearSelection();
        if (isAdding) {
          // 添加,整个组选上 + 原有选的 brid 也选上
          const allBrids = new Set();
          selected.forEach(row => allBrids.add(row.brid));
          allBrids.add(changedRow.brid);
        this.selectedFirstTable = [];
        this.isProcessingSelection = false;
        this.fetchRightTableData();
      } else {
        // 全选所有分组
        const allBrids = new Set(this.exaLists.map(row => row.brid));
        this.$refs.firstTable.clearSelection();
        this.$nextTick(() => {
          const newSelection = this.exaLists.filter(row => allBrids.has(row.brid));
          newSelection.forEach(row => {
            this.$refs.firstTable.toggleRowSelection(row, true);
          });
          this.selectedFirstTable = newSelection;
        } else {
          // 删除,整个组取消,再把剩下 brid 分组补回去
          const remaining = old.filter(row => row.brid !== changedRow.brid);
          const remainBrids = [...new Set(remaining.map(r => r.brid))];
          const newSelection = this.exaLists.filter(row => remainBrids.includes(row.brid));
          newSelection.forEach(row => {
            this.$refs.firstTable.toggleRowSelection(row, true);
          });
          this.selectedFirstTable = newSelection;
        }
      } else {
        this.selectedFirstTable = selected;
          this.isProcessingSelection = false;
          this.fetchRightTableData();
        });
      }
      this.fetchRightTableData();
      this.isProcessingSelection = false;
    },
    // 第二个表格只允许单选
    handleSelectionChangeSecond(selected) {
      this.selectedSecondTable = selected.slice(0, 1);
    },
@@ -215,16 +217,24 @@
    tongbu() {
      this.$modal.loading("正在同步,请稍候...");
      const requestData = {
        lis: this.selectedFirstTable ? this.selectedFirstTable.map((item) => ({
          ...item,
          tjNum: this.queryParams.tjNum,
        })) : [],
        jcxmid: this.selectedFirstTable && this.selectedFirstTable.length > 0 ? this.selectedFirstTable[0].jcxmid : null,
        shys: this.selectedFirstTable && this.selectedFirstTable.length > 0 ? this.selectedFirstTable[0].shys : null,
        lis: this.selectedFirstTable
          ? this.selectedFirstTable.map(item => ({
              ...item,
              tjNum: this.queryParams.tjNum,
            }))
          : [],
        jcxmid:
          this.selectedFirstTable && this.selectedFirstTable.length > 0
            ? this.selectedFirstTable[0].jcxmid
            : null,
        shys:
          this.selectedFirstTable && this.selectedFirstTable.length > 0
            ? this.selectedFirstTable[0].shys
            : null,
        tj: this.selectedSecondTable[0],
      };
      asyncPacs(requestData)
        .then((res) => {
        .then(res => {
          if (res.code === 200) {
            this.fetchRightTableData();
            clearInterval(this.clearTimeSet);
@@ -235,7 +245,7 @@
            this.$message.error(res.message || "同步失败,请稍后重试");
          }
        })
        .catch((error) => {
        .catch(() => {
          clearInterval(this.clearTimeSet);
          this.clearTimeSet = null;
          this.$modal.closeLoading();
@@ -245,6 +255,7 @@
};
</script>
<style lang="scss" scoped>
.app-container {
  padding: 20px;
vue.config.js
@@ -54,7 +54,7 @@
      [process.env.VUE_APP_BASE_API]: {
        // target: `https://ltpeis.xaltjdkj.cn:5801/`,
        // target: `http://192.168.1.99:5012`,
        target: `http://192.168.1.113:5011`,
        target: `http://192.168.1.244:5011`,
        // target: `http://192.168.1.244:5011`,
        // // target: `http://192.168.0.99:8080/ltkj-admin`,
        // target: `https://ltpeis.xaltjdkj.cn:5011/ltkj-admin`,