From b06a903d08d6f5432105d12686ccaf074b45323a Mon Sep 17 00:00:00 2001
From: lkk <364857242@qq.com>
Date: 星期四, 24 十月 2024 08:58:35 +0800
Subject: [PATCH] lkk 10.24

---
 src/views/doctor/checkAll/index.vue |  209 ++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 168 insertions(+), 41 deletions(-)

diff --git a/src/views/doctor/checkAll/index.vue b/src/views/doctor/checkAll/index.vue
index b01db8c..ef48f09 100644
--- a/src/views/doctor/checkAll/index.vue
+++ b/src/views/doctor/checkAll/index.vue
@@ -493,9 +493,7 @@
               </div>
               <div v-else>
                 <table style="width: 100%" v-if="tjproject != '1'">
-                  <tr
-                    style="border: 1px solid #dfe6ec; "
-                  >
+                  <tr style="border: 1px solid #dfe6ec">
                     <td
                       style="
                         border: 1px solid #dfe6ec;
@@ -506,7 +504,10 @@
                     >
                       妫�鏌ユ墍瑙侊細
                     </td>
-                    <td style="border: 1px solid #dfe6ec; height: 52px;" colspan="2">
+                    <td
+                      style="border: 1px solid #dfe6ec; height: 52px"
+                      colspan="2"
+                    >
                       <textarea
                         placeholder="璇疯緭鍏ュ唴瀹�"
                         :autosize="{ minRows: 3, maxRows: 4 }"
@@ -1151,6 +1152,9 @@
   name: "checkAll",
   data() {
     return {
+      // 鏇存柊鎬绘寤鸿
+      initialTotalCheckAdvice: "",
+      initialState: "",
       preObj: {},
       baogao: [],
       flags: false,
@@ -1698,6 +1702,21 @@
       }
     },
 
+    /*  changRed(row) {
+      if (row.label === "鈫�") {
+        return {
+          color: "green", // 璁剧疆涓婄澶翠负缁胯壊
+        };
+      } else if (row.label === "鈫�") {
+        return {
+          color: "red", // 璁剧疆涓嬬澶翠负绾㈣壊
+        };
+      }
+      // 榛樿棰滆壊
+      return {
+        color: "black",
+      };
+    }, */
     handleCurrentChange(val) {
       if (val != null) {
         this.handleClick(val);
@@ -1709,15 +1728,7 @@
       this.$refs.Pre.open = false;
       this.tableAll = row;
       this.tjproject = "0";
-      // if (this.tableAll.cusSex === 0) {
-      //   this.tableAll.cusSex = "鐢�";
-      // }
-      // if (this.tableAll.cusSex === 1) {
-      //   this.tableAll.cusSex = "濂�";
-      // }
-      // if (this.tableAll.cusSex === 2) {
-      //   this.tableAll.cusSex = "鏈煡";
-      // }
+
       this.tjNumber = this.tableAll.tjNumber;
       getState(this.tjNumber).then((res) => {
         this.status = res.data;
@@ -1737,8 +1748,17 @@
                   this.changedate = response.data;
                   if (this.changedate) {
                     this.changedate.forEach((item) => {
-                      this.textarea1 = item.checkAdvice;
+                      this.textarea1 = item.checkAdvice || "";
                     });
+
+                    // 杩欓噷璁剧疆鍒濆鍊�
+                    this.initialTotalCheckAdvice = this.textarea1; // 淇濆瓨鎬绘寤鸿
+
+                    // 淇濆瓨鍒濆鐘舵��
+                    this.initialState = JSON.parse(
+                      JSON.stringify(this.changedate)
+                    );
+
                     for (let i = 0; i < this.changedate.length; i++) {
                       this.remark = this.changedate[i].remark;
                     }
@@ -1791,8 +1811,12 @@
                         for (let i = 0; i < this.changedate.length; i++) {
                           this.remark = this.changedate[i].remark;
                         }
+                        this.initialState = JSON.parse(
+                          JSON.stringify(this.changedate)
+                        );
+
                         this.changedate.forEach((item) => {
-                          this.textarea1 = item.checkAdvice;
+                          this.textarea1 = item.checkAdvice || "";
 
                           // this.remark = item.remark;
                           // item.sons.forEach((item3) => {
@@ -1805,6 +1829,11 @@
                           // });
                           // item.remark = "";
                         });
+
+                        // 淇濆瓨鎬绘寤鸿
+                        this.totalCheckAdvice = this.changedate.map(
+                          (item) => item.totalCheckAdvice
+                        );
                       } else {
                         this.$message({
                           type: "warning ",
@@ -1855,29 +1884,44 @@
       if (this.loading) {
         return;
       }
-      this.$confirm("纭畾瑕佹彁浜ゅ悧锛�")
-        .then((_) => {
-          this.loading = true;
-          this.timer = setTimeout(() => {
-            done();
-            this.determine();
-            // 鍔ㄧ敾鍏抽棴闇�瑕佷竴瀹氱殑鏃堕棿
-            setTimeout(() => {
-              this.loading = false;
-            }, 400);
-          }, 2000);
-        })
-        .catch((_) => {
-          this.drawer = false;
-          let data = {
-            userId: this.userId,
-            tjNumber: this.tjNumber,
-            state: 1,
-            id: this.MsgId,
-          };
-          getfiedState(data).then((res) => {});
-          this.submitForm();
-        });
+
+      // 妫�鏌ユ槸鍚︽湁淇敼
+      let isModified =
+        JSON.stringify(this.changedate) !== JSON.stringify(this.initialState) ||
+        (this.textarea1 !== this.initialTotalCheckAdvice &&
+          this.textarea1 !== null);
+      console.log("Initial Total Check Advice:", this.initialTotalCheckAdvice);
+
+      console.log("Current textarea1:", this.textarea1);
+      if (isModified) {
+        // 濡傛灉鏈変慨鏀癸紝寮瑰嚭纭妗�
+        this.$confirm("妫�娴嬪唴瀹规湁淇敼锛岀‘瀹氳鎻愪氦鍚楋紵")
+          .then(() => {
+            this.loading = true;
+            this.timer = setTimeout(() => {
+              done();
+              this.determine();
+              setTimeout(() => {
+                this.loading = false;
+              }, 400);
+            }, 2000);
+          })
+          .catch(() => {
+            // 鐢ㄦ埛鍙栨秷鎿嶄綔
+            this.drawer = false;
+            let data = {
+              userId: this.userId,
+              tjNumber: this.tjNumber,
+              state: 1,
+              id: this.MsgId,
+            };
+            getfiedState(data).then((res) => {});
+            this.submitForm();
+          });
+      } else {
+        // 濡傛灉娌℃湁淇敼锛岀洿鎺ュ叧闂�
+        done();
+      }
     },
     handleClose1() {
       this.jianqians = false;
@@ -1904,7 +1948,7 @@
     //   }
     // },
     change(vale) {},
-    determine() {
+   /*  determine() {
       let tjNumber = this.tableAll.tjNumber;
       let advice = this.textarea1;
       let data = {
@@ -1912,6 +1956,7 @@
         advice,
         checkStatus: 1,
       };
+      this.loading = true;
       getTjdetailList(data).then((response) => {
         if (response.code === 200) {
           this.$modal.msgSuccess("鎻愪氦鎴愬姛");
@@ -1930,7 +1975,7 @@
               this.$modal.msgError(
                 "鎵撳嵃鎶ュ憡澶辫触锛岃鍓嶅線鎶ュ憡鎵撳嵃椤甸潰琛ユ墦鎶ュ憡锛�"
               );
-            });
+            })
           getfiedState(data).then((res) => {
             this.drawer = false;
           });
@@ -1938,7 +1983,6 @@
           this.queryParams.pageSize = 10;
           this.submitForm();
           this.$forceUpdate();
-        }
       });
 
       for (let i = 0; i < this.changedate.length; i++) {
@@ -1958,6 +2002,89 @@
       //   this.proIds = item.parentId;
       //   // this.remark = item.remark;
       // });
+    }, */
+    determine() {
+      let tjNumber = this.tableAll.tjNumber;
+      let advice = this.textarea1;
+      let data = {
+        tjNumber,
+        advice,
+        checkStatus: 1,
+      };
+
+      // 寮�濮嬪姞杞�
+      this.loading = true;
+
+      // 鎻愪氦鏁版嵁
+      getTjdetailList(data)
+        .then((response) => {
+          if (response.code === 200) {
+            this.$modal.msgSuccess("鎻愪氦鎴愬姛");
+
+            // 鍑嗗鐢熸垚鎶ュ憡鐨勮姹傛暟鎹�
+            let reportData = {
+              userId: this.userId,
+              tjNumber: tjNumber,
+              state: 1,
+              id: this.MsgId,
+            };
+
+            // 鐢熸垚鎶ュ憡骞朵繚鎸� loading 鎵撳紑
+            const reportPromise = gettoPdf(tjNumber)
+              .then((res) => {
+                this.$modal.msgSuccess("宸茬敓鎴愭姤鍛婏紒璇峰墠寰�鎶ュ憡鏍告敹椤甸潰纭锛�");
+              })
+              .catch((error) => {
+                this.$modal.msgError(
+                  "鎵撳嵃鎶ュ憡澶辫触锛岃鍓嶅線鎶ュ憡鎵撳嵃椤甸潰琛ユ墦鎶ュ憡锛�"
+                );
+              });
+
+            // 鏇存柊鐘舵�佸苟鎻愪氦淇敼璇锋眰
+            const statePromise = getfiedState(reportData).then((res) => {
+              this.drawer = false;
+            });
+
+            // 澶勭悊鍏朵粬淇敼鎿嶄綔
+            const updatePromises = this.changedate.map((item) => {
+              this.proIds = item.parentId;
+              let remarks = item.remark;
+              let updateOrderRemarkVos = [
+                {
+                  tjNumber,
+                  proId: this.proIds.toString(),
+                  remarks,
+                },
+              ];
+              return getModified(updateOrderRemarkVos); // 杩斿洖 Promise
+            });
+
+            // 绛夊緟鎵�鏈夎姹傚畬鎴�
+            Promise.all([reportPromise, statePromise, ...updatePromises])
+              .then(() => {
+                // 鎵�鏈夎姹傚畬鎴愶紝鍏抽棴 loading
+                this.loading = false;
+                // 鏇存柊鍒嗛〉淇℃伅
+                this.queryParams.page = 1;
+                this.queryParams.pageSize = 10;
+                this.submitForm();
+                this.$forceUpdate();
+              })
+              .catch((error) => {
+                // 澶勭悊閿欒鎯呭喌
+                this.loading = false;
+                console.error("鍙戠敓閿欒:", error);
+              });
+          } else {
+            // 鎻愪氦澶辫触锛屽叧闂� loading
+            this.loading = false;
+          }
+        })
+        .catch((error) => {
+          // 鎻愪氦璇锋眰澶辫触锛屽叧闂� loading
+          this.loading = false;
+          console.error("鎻愪氦璇锋眰澶辫触:", error);
+        });
     },
   },
 };

--
Gitblit v1.8.0