From 505af13b112589445b39cb2bf448d8531790dd1f Mon Sep 17 00:00:00 2001 From: lkk <364857242@qq.com> Date: 星期二, 10 六月 2025 16:37:51 +0800 Subject: [PATCH] 1 --- src/components/jianqianwenzhen/index.vue | 98 +++++++++++++++++++++++++++++++++++-------------- 1 files changed, 70 insertions(+), 28 deletions(-) diff --git a/src/components/jianqianwenzhen/index.vue b/src/components/jianqianwenzhen/index.vue index b3c5140..eb496c5 100644 --- a/src/components/jianqianwenzhen/index.vue +++ b/src/components/jianqianwenzhen/index.vue @@ -1020,7 +1020,6 @@ } this.form.tjAskHistorysList = response.data.tjAskHistorysList; this.form.zhiyezzList = response.data.zhiyezzList; - console.log(response.data.tjAskHistorysList, 123456); // this.isdisabled= true }); @@ -1107,7 +1106,7 @@ }); }, - addzj() { + /* addzj() { if (this.form.cusName) { if (!this.form.zhiyezzList) { this.form.zhiyezzList = []; @@ -1134,36 +1133,79 @@ }); } } else { - Message.warning("璇峰厛濉啓瀹㈡埛鍚�"); + this.$message.warning("璇峰厛濉啓瀹㈡埛鍚�"); } this.$forceUpdate(); + }, */ + + addzj() { + if (!this.form.cusName) { + this.$message.warning("璇峰厛濉啓瀹㈡埛鍚�"); + return; + } + + if (!this.form.zhiyezzList) { + this.form.zhiyezzList = []; + } + + this.form.zhiyezzList.push({ + id: Date.now(), // 鐢ㄦ椂闂存埑褰撴湰鍦板敮涓� id + diseaseId: null, // 鍏抽敭锛佹槑纭爣璇嗏�滆繕娌″瓨杩涙暟鎹簱鈥� + isLocal: true, // 鍙�夛紝渚夸簬鍚庣画澶勭悊 + diseaseName: "", + diseaseData: "", + diseaseCompany: "", + isOk: "", + remark: "", + icdId: "", + type: "", + }); + + 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(); }, // 鏂板琛� @@ -1355,9 +1397,9 @@ }, submitForm() { - console.log("鎻愪氦鍓� form:", JSON.parse(JSON.stringify(this.form))); + // console.log("鎻愪氦鍓� form:", JSON.parse(JSON.stringify(this.form))); this.$refs.form.validate((valid) => { - console.log("鏍¢獙鍚� form:", JSON.parse(JSON.stringify(this.form))); + // console.log("鏍¢獙鍚� form:", JSON.parse(JSON.stringify(this.form))); if (valid) { this.$emit("submitLoading", true); @@ -1372,7 +1414,7 @@ id: match ? match.id : "", }; }); - console.log(this.form, 1236); + // console.log(this.form, 1236); updateHistory(this.form) .then((response) => { -- Gitblit v1.8.0