From a9929166ee6f4def812519684a739336c7202531 Mon Sep 17 00:00:00 2001
From: qx <1084500556@qq.com>
Date: 星期四, 12 六月 2025 16:53:07 +0800
Subject: [PATCH] Merge branch 'master' of http://101.42.27.146:5001/r/ltkj_peisweb_region

---
 src/components/jianqianwenzhen/index.vue |  124 ++++++++++++++++++++++++++++++----------
 1 files changed, 92 insertions(+), 32 deletions(-)

diff --git a/src/components/jianqianwenzhen/index.vue b/src/components/jianqianwenzhen/index.vue
index d297250..00a748e 100644
--- a/src/components/jianqianwenzhen/index.vue
+++ b/src/components/jianqianwenzhen/index.vue
@@ -79,12 +79,12 @@
             </el-form-item>
             <el-form-item
               label="鎺ヨЕ鏈夊鐗╁伐榫�"
-              prop="zgongLing"
+              prop="jhgl"
               label-width="150px"
             >
               <!-- <el-input v-model="form.cusName" placeholder="璇疯緭鍏ュ伐榫�" style="width: 150px" />骞� -->
               <el-input-number
-                v-model="form.zgongLing"
+                v-model="form.jhgl"
                 label="璇疯緭鍏ユ帴瑙︽湁瀹崇墿宸ラ緞"
               ></el-input-number
               >骞�
@@ -99,10 +99,10 @@
               <el-input @focus="change" type="textarea" rows="4" v-model="form.contactPoison" placeholder="璇疯緭鍏ユ帴瑙︽瘨鐗�"
                 style="width: 700px" />
             </el-form-item> -->
-            <el-form-item label="浣撴鍗卞鍥犵礌" prop="tjwhyx">
+            <el-form-item label="浣撴鍗卞鍥犵礌" prop="tjwhys">
               <el-select
                 filterable
-                v-model="form.tjwhyx"
+                v-model="form.tjwhys"
                 placeholder="璇烽�夋嫨浣撴鍗卞鍥犵礌"
                 clearable
                 style="width: 180px"
@@ -117,12 +117,12 @@
             </el-form-item>
             <el-form-item
               label="鎺ヨЕ鍗卞鍥犵礌"
-              prop="tcwhyx"
+              prop="jcwhys"
               style="margin-left: 30px"
             >
               <el-select
                 filterable
-                v-model="form.tcwhyx"
+                v-model="form.jcwhys"
                 placeholder="璇烽�夋嫨鎺ヨЕ鍗卞鍥犵礌"
                 clearable
                 style="width: 180px"
@@ -836,13 +836,15 @@
         dwmc: "",
         ygdw: "",
         gongLing: "",
-        zgongLing: "",
+        jhgl: "",
         yjsfyc: "", // 鏄惁寮傚父
         ycms: "", // 寮傚父鎻忚堪
         xiyan: "",
         xiyanpinlv: "",
         xiyanyear: "",
         yinjiu: "",
+        jcwhys: "",
+        tjwhys: "",
         yinjiupinlv: "",
         yinjiuyear: "",
         qita: "",
@@ -1044,33 +1046,49 @@
       }
       this.$forceUpdate();
     },
-
-    delezz() {
-      if (this.selectedZhiyezz && this.selectedZhiyezz.length > 0) {
-        const historyId = this.selectedZhiyezz.map((item) => item.diseaseId);
-        console.log(historyId, "鍑嗗鍒犻櫎鐨� diseaseId");
-
-        // 鍙戣姹�
-        removeAskHistorys(historyId).then((res) => {
-          console.log(res, "鍒犻櫎鎺ュ彛鍝嶅簲");
-
-          this.$message.success("鍒犻櫎鎴愬姛");
-
-          // 鎺ュ彛鎴愬姛鍚庡啀鏈湴鍒犻櫎
-          this.form.zhiyezzList = this.form.zhiyezzList.filter(
-            (item) =>
-              !this.selectedZhiyezz.some(
-                (selected) => selected.diseaseId === item.diseaseId
-              )
-          );
-
-          this.selectedZhiyezz = [];
-          this.$forceUpdate();
-        });
-      } else {
+    async delezz() {
+      if (!this.selectedZhiyezz?.length) {
         this.$message.warning("璇峰厛閫夋嫨瑕佸垹闄ょ殑椤�");
+        return;
       }
+
+      // 鎷嗗垎鈥滄湰鍦版暟鎹�濆拰鈥滄暟鎹簱鏁版嵁鈥�
+      const localItems = this.selectedZhiyezz.filter((item) => !item.diseaseId);
+      const dbItems = this.selectedZhiyezz.filter((item) => item.diseaseId);
+
+      // 鍏堝浠戒竴涓嬪綋鍓嶅垪琛紝鏂逛究鍑洪敊鏃舵仮澶�
+      const backupList = [...this.form.zhiyezzList];
+
+      // 鍒犻櫎鏈湴鏂板椤癸紙涓嶉渶瑕佽皟鎺ュ彛锛�
+      this.form.zhiyezzList = this.form.zhiyezzList.filter(
+        (item) => !localItems.includes(item)
+      );
+
+      try {
+        // 濡傛灉鏈夋暟鎹簱椤癸紝瑕佽皟鐢ㄦ帴鍙e垹闄�
+        if (dbItems.length) {
+          const deletedIds = dbItems.map((item) => item.diseaseId);
+          const res = await removeAskHistorys(deletedIds);
+          if (res?.code !== 200) throw new Error("鍒犻櫎澶辫触");
+
+          // 鎺ュ彛鎴愬姛锛屽啀浠庨〉闈㈢Щ闄ゆ暟鎹簱鏁版嵁
+          this.form.zhiyezzList = this.form.zhiyezzList.filter(
+            (item) => !dbItems.includes(item)
+          );
+          this.$message.success("鍒犻櫎鎴愬姛");
+        }
+      } catch (err) {
+        // 鍒犻櫎澶辫触
+        this.form.zhiyezzList = backupList;
+        this.$message.error("鍒犻櫎澶辫触");
+        console.error(err);
+      }
+
+      // 娓呯┖閫変腑
+      this.selectedZhiyezz = [];
+      this.$forceUpdate();
     },
+
     // 鏂板琛�
     addmembers() {
       if (this.form.cusName) {
@@ -1252,6 +1270,48 @@
       }
     },
     delemembers() {
+      if (!this.bingshiall || this.bingshiall.length === 0) {
+        this.$message.warning("璇峰厛閫夋嫨瑕佸垹闄ょ殑椤�");
+        return;
+      }
+
+      // 鍖哄垎鏂板椤瑰拰鏁版嵁搴撻」
+      const localItems = this.bingshiall.filter((item) => !item.diseaseId); // 鏂板鐨�
+      const dbItems = this.bingshiall.filter((item) => item.diseaseId); // 鏁版嵁搴撳凡鏈夌殑
+
+      // 鍏堝垹闄ゆ柊澧炵殑锛堟湰鍦扮洿鎺ュ垹锛�
+      if (localItems.length > 0) {
+        this.form.tjAskHistorysList = this.form.tjAskHistorysList.filter(
+          (item) => !localItems.includes(item)
+        );
+      }
+
+      if (dbItems.length === 0) {
+        // 鍙湁鏂板椤癸紝鏃犻渶璋冪敤鎺ュ彛锛岀洿鎺ユ竻绌洪�変腑锛岄��鍑�
+        this.bingshiall = [];
+        this.$forceUpdate();
+        return;
+      }
+
+      // 璋冩帴鍙e垹闄ゆ暟鎹簱椤�
+      const historyId = dbItems.map((item) => item.diseaseId);
+      removeAskHistorys(historyId)
+        .then((res) => {
+          this.$message.success("鍒犻櫎鎴愬姛");
+          // 鎺ュ彛鎴愬姛鍚庡垹闄ゆ暟鎹簱椤�
+          this.form.tjAskHistorysList = this.form.tjAskHistorysList.filter(
+            (item) =>
+              !dbItems.some((selected) => selected.diseaseId === item.diseaseId)
+          );
+          this.bingshiall = [];
+          this.$forceUpdate();
+        })
+        .catch(() => {
+          this.$message.warning("鍒犻櫎澶辫触");
+        });
+    },
+
+    /* delemembers() {
       if (this.bingshiall && this.bingshiall.length > 0) {
         const historyId = this.bingshiall.map((item) => item.diseaseId);
 
@@ -1275,7 +1335,7 @@
       } else {
         this.$message.warning("璇峰厛閫夋嫨瑕佸垹闄ょ殑椤�");
       }
-    },
+    }, */
     handlebingChange(selection) {
       this.bingshiall = [];
       this.bingshiall = selection;

--
Gitblit v1.8.0