From 5821664d8e34973ec0e0123228c3591da51cdd2f Mon Sep 17 00:00:00 2001 From: wwl <xchao828@163.com> Date: 星期一, 28 七月 2025 17:38:00 +0800 Subject: [PATCH] 全选问题,动态url --- vue.config.js | 2 src/views/doctor/inspectCheck/index.vue | 101 ++++++++++++++++++--------------- src/main.js | 19 +++--- 3 files changed, 67 insertions(+), 55 deletions(-) diff --git a/src/main.js b/src/main.js index 6aee2e6..e85e3f5 100644 --- a/src/main.js +++ b/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锛孴oken:', token); @@ -207,7 +208,7 @@ isWebSocketInitialized = false; console.log('Vue 瀹炰緥閿�姣侊紝WebSocket 宸叉竻鐞�'); } - } */ + } }); // 娉ㄥ唽鎻掍欢 diff --git a/src/views/doctor/inspectCheck/index.vue b/src/views/doctor/inspectCheck/index.vue index 943887e..10bcf44 100644 --- a/src/views/doctor/inspectCheck/index.vue +++ b/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; - // 鎵惧埌鐢ㄦ埛鍒氭搷浣滅殑閭d竴鏉★紙瀵规瘮涔嬪墠鍜岀幇鍦ㄧ殑宸紓锛� - 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("姝e湪鍚屾锛岃绋嶅��..."); 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; diff --git a/vue.config.js b/vue.config.js index 1759202..f031a59 100644 --- a/vue.config.js +++ b/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`, -- Gitblit v1.8.0