From 42f17b759cc69f44a8d200934117daaaa703d87d Mon Sep 17 00:00:00 2001
From: wwl <xchao828@163.com>
Date: 星期三, 25 十二月 2024 17:59:53 +0800
Subject: [PATCH] his科室ID

---
 src/components/Packagese/index.vue |  135 +++++++++++++++++++++++++++-----------------
 1 files changed, 82 insertions(+), 53 deletions(-)

diff --git a/src/components/Packagese/index.vue b/src/components/Packagese/index.vue
index 298bcc9..ecf67a9 100644
--- a/src/components/Packagese/index.vue
+++ b/src/components/Packagese/index.vue
@@ -50,6 +50,7 @@
           >
         </el-form-item>
       </el-form>
+      
       <el-table
         :data="dataList"
         ref="elTable"
@@ -76,6 +77,7 @@
         <el-table-column label="鍐呭" align="center" prop="pacRemark" />
         <el-table-column label="澶囨敞" align="center" prop="price" />
       </el-table>
+
       <div class="pag">
         <div class="pag1">
           <pagination
@@ -87,6 +89,7 @@
           />
         </div>
       </div>
+
       <span slot="footer" class="dialog-footer">
         <el-button @click="open = false">鍙� 娑�</el-button>
         <el-button type="primary" @click="handleOk">纭� 瀹�</el-button>
@@ -94,30 +97,24 @@
     </el-dialog>
   </div>
 </template>
-  
+
 <script>
 import { getTjHyBgList } from "@/api/hosp/project";
+
 export default {
   name: "Packagese",
-  // props: {
-  //   pacCode: {
-  //         type: String,
-          
-  //     }
-
-  // },
+  props: {
+    selectedId: {
+      type: String,
+      default: "",  // 鐖剁粍浠朵紶閫掔殑閫変腑ID
+    },
+  },
   data() {
     return {
       open: false,
-      openone: false,
-      // 寮瑰嚭灞傛爣棰�
       title: "",
       dataList: [],
-      // 閬僵灞�
       loading: false,
-      form: {
-        desc: "",
-      },
       queryParams: {
         pid: "",
         pname: "",
@@ -126,73 +123,106 @@
         page: 1,
         pageSize: 10,
       },
+      total: 0,
       list: [],
-      fList: {},
     };
   },
+  
   watch: {
-    // 'row'(val, newVla) {
-    //     console.log(val,newVla)
-    //     this.fList = val
-    //     console.log(this.fList);
-    // }
-  },
-  mounted() {
-    // this.getList()
+    // 鐩戝惉鐖剁粍浠朵紶閫掔殑 selectedId
+    selectedId(newVal) {
+      // 濡傛灉 selectedId 涓虹┖锛屾竻绌烘墍鏈夐�変腑鐨勯」
+      if (!newVal) {
+        this.clearSelection();
+      } else {
+        this.handleSelectionEcho(newVal);
+      }
+    },
   },
 
-  created() {
-    // this.getList()
-  },
   methods: {
+    // 鑾峰彇鏁版嵁
     getAllList() {
       this.loading = true;
-      this.openone = true;
       getTjHyBgList(this.queryParams).then((res) => {
         this.dataList = res.data.list;
+        this.total = res.data.total;
         this.loading = false;
+        
+        // 鍦ㄨ幏鍙栨暟鎹悗鍥炴樉閫変腑椤�
+        this.handleSelectionEcho(this.selectedId);
       });
     },
-    // getList() {
-    //   this.loading = true;
-    //   this.openone = false;
-    //   Packagestlist(this.queryParams).then((res) => {
-    //     this.dataList = res.rows;
-    //     this.loading = false;
-    //   });
-    // },
-    handleQuery() {
-   
-      this.getAllList();
- 
+
+    // 鏍规嵁 selectedId 鏌ユ壘瀵瑰簲鐨勯」骞跺洖鏄鹃�夋嫨
+    handleSelectionEcho(selectedId) {
+      if (this.dataList.length > 0 && selectedId) {
+        const selectedItem = this.dataList.find(
+          (item) => item.pacCode === selectedId
+        );
+        if (selectedItem) {
+          this.$nextTick(() => {
+            this.$refs.elTable.clearSelection();  // 娓呴櫎涔嬪墠鐨勯�夋嫨
+            this.$refs.elTable.toggleRowSelection(selectedItem, true); // 閫変腑瀵瑰簲椤�
+            this.list = [selectedItem];  // 璁剧疆閫変腑鐨勯」
+          });
+        }
+      }
     },
+
+    // 娓呯┖鎵�鏈夐�変腑鐨勯」
+    clearSelection() {
+      this.$nextTick(() => {
+        this.$refs.elTable.clearSelection();  // 娓呯┖鎵�鏈夐�変腑鐨勯」
+        this.list = [];  // 娓呯┖閫変腑鐨勫垪琛�
+      });
+    },
+
+    // 澶勭悊閫夋嫨鍙樺寲
     handleSelectionChange(selection) {
       if (selection.length > 1) {
-        this.$refs.elTable.clearSelection(); // 娓呯┖鎵�鏈夐�夋嫨
-        this.$refs.elTable.toggleRowSelection(selection.pop()); // 璁剧疆閫夋嫨椤�
+        // 濡傛灉閫夋嫨浜嗗琛岋紝淇濈暀鏈�鍚庝竴琛�
+        this.$refs.elTable.clearSelection();  // 娓呯┖鎵�鏈夐�夋嫨
+        this.$refs.elTable.toggleRowSelection(selection[selection.length - 1]);  // 閲嶆柊閫夋嫨鏈�鍚庝竴椤�
       }
-      this.list = selection;
-      console.log(this.list);
+
+      // 鑾峰彇鏈�鍚庨�夋嫨鐨勮
+      this.list = [selection[selection.length - 1]];
     },
+
+    // 纭畾閫夋嫨
     handleOk() {
       this.open = false;
-   
-      if (this.list.length === 1) {
+      this.queryParams = {
+        pid: "",
+        pname: "",
+        pym: "",
+        checktype: "deptdict",
+        page: 1,
+        pageSize: 10,
+      };
+
+      if (this.list.length > 0) {
         const pac = [
-         {
-          pacCode: this.list[0].pacCode,
-          pacName: this.list[0].pacName
-         }
-      ];
+          {
+            pacCode: this.list[this.list.length - 1].pacCode,
+            pacName: this.list[this.list.length - 1].pacName,
+          },
+        ];
         this.$emit("add", pac);
       } else {
         this.$message.warning("璇烽�夋嫨涓�涓」鐩�");
       }
     },
+
+    // 瑙﹀彂鏌ヨ
+    handleQuery() {
+      this.getAllList();
+    },
   },
 };
 </script>
-  
+
 <style scoped>
 .pag {
   width: 100%;
@@ -201,7 +231,6 @@
 }
 
 .pag1 {
-  width: 30%;
+  width: 60%;
 }
 </style>
-  
\ No newline at end of file

--
Gitblit v1.8.0