From d90b45d7e9e38e34c044b772006004f2a4cb8b8e Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期五, 26 六月 2026 13:51:50 +0800
Subject: [PATCH] 测试完成
---
src/components/OptionalForm/index.vue | 125 +++++++++++++++++++++++++++++------------
1 files changed, 87 insertions(+), 38 deletions(-)
diff --git a/src/components/OptionalForm/index.vue b/src/components/OptionalForm/index.vue
index c00251a..4fa2ac1 100644
--- a/src/components/OptionalForm/index.vue
+++ b/src/components/OptionalForm/index.vue
@@ -66,9 +66,16 @@
:data="donorchargeList"
tooltip-effect="dark"
style="width: 100%"
+ @select="handleSelect"
+ @select-all="handleSelectAll"
@selection-change="handleSelectionChange"
>
- <el-table-column class="checkall" type="selection" width="55">
+ <el-table-column
+ class="checkall"
+ type="selection"
+ width="55"
+ :selectable="checkSelectable"
+ >
</el-table-column>
<el-table-column
prop="icdid"
@@ -121,6 +128,8 @@
},
donorchargeList: [],
donorchargeanlList: [], //妗堜緥鍒楄〃
+ // 鏂板锛氭槸鍚︽鍦ㄥ鐞嗗叏閫夋搷浣滅殑鏍囧織
+ isSelectAllProcessing: false,
};
},
@@ -199,51 +208,86 @@
getillnesslist(this.patientqueryParams).then((res) => {
this.donorchargeList = res.rows;
this.patienttotal = res.total;
- console.log(this.$refs.multipleTable, "22");
this.Restorecheck();
});
},
- // 澶氶�夋閫変腑鏁版嵁
- handleSelectionChange(selection) {
- if (this.decision) return;
- // 鍒ゆ柇鏄惁鏈夊垹闄�
- if (this.multipleSelection.length <= selection.length) {
- this.multipleSelection = selection;
+
+ // 鏂板锛氬鐞嗗崟涓�夋嫨
+ handleSelect(selection, row) {
+ if (this.isSelectAllProcessing) return;
+
+ const isSelected = selection.includes(row);
+ this.handleItemSelection(row, isSelected);
+ },
+
+ // 鏂板锛氬鐞嗗叏閫�/鍏ㄤ笉閫�
+ handleSelectAll(selection) {
+ this.isSelectAllProcessing = true;
+
+ if (selection.length === 0) {
+ // 鍏ㄤ笉閫夛細绉婚櫎褰撳墠椤垫墍鏈夋暟鎹�
+ this.donorchargeList.forEach(item => {
+ this.removeFromSelections(item);
+ });
} else {
- console.log(selection, "selection");
- console.log(this.multipleSelection, "this.multipleSelection");
- this.multipleSelection.forEach((item) => {
- if (selection.includes(item)) {
- } else {
- if (this.multipleSelection.length == 1) {
- this.multipleSelection = [];
- } else {
- this.multipleSelection.splice(
- this.multipleSelection.indexOf(item),
- 1
- );
- }
- if (this.overallCase.length == 1) {
- this.overallCase = [];
- } else {
- this.overallCase.splice(this.overallCase.indexOf(item), 1);
- }
- }
+ // 鍏ㄩ�夛細娣诲姞褰撳墠椤垫墍鏈夋暟鎹�
+ this.donorchargeList.forEach(item => {
+ this.addToSelections(item);
});
}
- // 璧嬪�肩粰鏁翠綋閫変腑鏁扮粍
- console.log(this.overallCase);
- this.multipleSelection.forEach((item) => {
- console.log(
- this.overallCase.every((obj) => obj.icdname != item.icdname)
- );
- if (this.overallCase.every((obj) => obj.icdname != item.icdname)) {
- this.overallCase.push(item);
- }
+ this.$nextTick(() => {
+ this.isSelectAllProcessing = false;
});
- console.log(this.multipleSelection, "瑙﹀彂閫夋嫨鍚巑ultipleSelection");
},
+
+ // 鏂板锛氬鐞嗗崟涓」鐩殑閫夋嫨/鍙栨秷閫夋嫨
+ handleItemSelection(row, isSelected) {
+ if (isSelected) {
+ this.addToSelections(row);
+ } else {
+ this.removeFromSelections(row);
+ }
+ },
+
+ // 鏂板锛氭坊鍔犲埌閫変腑鍒楄〃
+ addToSelections(row) {
+ // 濡傛灉宸茬粡鍦ㄥ閫夋暟缁勪腑锛屼笉鍐嶆坊鍔�
+ if (this.multipleSelection.some(item => item.icdid === row.icdid)) {
+ return;
+ }
+
+ this.multipleSelection.push(row);
+
+ // 娣诲姞鍒版�绘暟缁�
+ if (this.overallCase.every(item => item.icdid !== row.icdid)) {
+ this.overallCase.push({...row});
+ }
+ },
+
+ // 鏂板锛氫粠閫変腑鍒楄〃绉婚櫎
+ removeFromSelections(row) {
+ const index = this.multipleSelection.findIndex(item => item.icdid === row.icdid);
+ if (index > -1) {
+ this.multipleSelection.splice(index, 1);
+ }
+
+ // 浠庢�绘暟缁勪腑绉婚櫎
+ const overallIndex = this.overallCase.findIndex(item => item.icdid === row.icdid);
+ if (overallIndex > -1) {
+ this.overallCase.splice(overallIndex, 1);
+ }
+ },
+
+ // 淇濈暀鍘熸湁鐨剆election-change浜嬩欢澶勭悊锛屼絾绠�鍖栭�昏緫
+ handleSelectionChange(selection) {
+ // 濡傛灉姝e湪澶勭悊鍏ㄩ�夋搷浣滐紝涓嶆墽琛岃繖閲岀殑閫昏緫
+ if (this.isSelectAllProcessing) return;
+
+ // 鍘熸湁鐨勫鏉傞�昏緫鍙互淇濈暀锛屼絾涓轰簡娓呮櫚锛屽缓璁娇鐢ㄤ笂闈㈢殑鏂版柟娉�
+ console.log('selection changed:', selection.length);
+ },
+
// 鍒囨崲椤靛悗鎭㈠閫変腑
Restorecheck() {
console.log(this.overallCase, "this.overallCase");
@@ -275,6 +319,11 @@
AddDispatchpatients() {
this.$emit("addoption");
},
+
+ // 鏂板锛氭鏌ユ槸鍚﹀彲浠ラ�夋嫨锛堝彲閫夛紝鐢ㄤ簬鎺у埗鏌愪簺琛屼笉鍙�夛級
+ checkSelectable(row, index) {
+ return true; // 鎵�鏈夎閮藉彲閫�
+ }
},
};
</script>
@@ -323,7 +372,7 @@
}
}
::v-deep.el-table .el-table__header th:first-child .el-checkbox {
- display: none;
+ display: inline-block; /* 淇敼杩欓噷锛屾樉绀哄叏閫夊閫夋 */
}
.el-tag + .el-tag {
margin-left: 10px;
--
Gitblit v1.9.3