From 741805d8daa2d2baa0b6b75bc1724488baf9c6bc Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期一, 15 六月 2026 14:55:10 +0800
Subject: [PATCH] 测试完成

---
 src/views/patient/propaganda/particty.vue |  135 +++++++++++++++++++++++++++++++-------------
 1 files changed, 95 insertions(+), 40 deletions(-)

diff --git a/src/views/patient/propaganda/particty.vue b/src/views/patient/propaganda/particty.vue
index 3be475e..2d36270 100644
--- a/src/views/patient/propaganda/particty.vue
+++ b/src/views/patient/propaganda/particty.vue
@@ -449,10 +449,7 @@
                       placeholder="璇风偣鍑诲彸渚ч�夋嫨"
                     />
                     <el-button
-                      v-if="
-                        (form.templateid && form.sendState == 1) ||
-                        !form.templateid
-                      "
+                      v-if="form.templateid"
                       style="margin-left: 10px"
                       type="primary"
                       icon="el-icon-edit"
@@ -1533,15 +1530,24 @@
     },
     // 淇濆瓨
     submitForm(type) {
+      // 闃叉閲嶅鎻愪氦
       if (this.submitLoading) {
         return;
       }
-      // 绗簩姝ワ細寮�鍚姞杞界姸鎬侊紝绂佺敤鎸夐挳
+
+      // 寮�鍚姞杞界姸鎬�
       this.submitLoading = true;
+
       try {
-        if (this.templateor && type) this.templateor = false;
-        if (this.time4 && this.form.sendType == 3)
+        // 妯℃澘鐩稿叧澶勭悊
+        if (this.templateor && type) {
+          this.templateor = false;
+        }
+
+        // 鏃堕棿澶勭悊
+        if (this.time4 && this.form.sendType == 3) {
           this.form.showTimeMorn = this.time4;
+        }
         this.form.sendTimeslot = [
           {
             begantime: this.time4,
@@ -1549,6 +1555,8 @@
             xh: 1,
           },
         ];
+
+        // 鏍规嵁搴旂敤绫诲瀷娓呯悊瀛楁
         if (this.form.appltype == 1) {
           this.leavehospitaldistrictcodes = [];
           this.operationcodes = [];
@@ -1566,68 +1574,88 @@
           this.illnesscodes = [];
           this.leavehospitaldistrictcodes = [];
         }
+
+        // ===== 琛ㄥ崟鏍¢獙 =====
+
+        // 1. 鏈嶅姟绫诲瀷鏍¢獙
         if (this.checkList) {
           this.form.preachform = this.checkList.join(",") || [];
           this.form.preachformList = this.selectedOrder || [];
         } else {
           this.$modal.msgError("璇烽�夋嫨鏈嶅姟绫诲瀷");
           this.submitLoading = false;
-
           return;
         }
 
-        if (
+        // 2. 鐤剧梾鍏宠仈绉戝鎴栫梾鍖烘牎楠�
+        if (this.form.appltype == 3) {
+          const hasDept = this.diseaseDept?.deptCode;
+          const hasWard = this.diseaseWard?.districtCode;
+
+          if (!hasDept && !hasWard) {
+            this.$modal.msgError("褰撳墠鐤剧梾闇�鍏宠仈绉戝鎴栫梾鍖�");
+            this.submitLoading = false;
+            return;
+          }
+        }
+
+        // 3. 浠诲姟鍏宠仈鏉′欢鏍¢獙
+        const hasCondition =
           this.deptcodesWards[0] ||
           this.leavehospitaldistrictcodes[0] ||
           this.diagglist[0] ||
           this.operationcodes[0] ||
           this.form.longTask == 2 ||
-          this.serviceType == 3
-        ) {
-        } else {
+          this.serviceType == 3;
+
+        if (!hasCondition) {
           this.$modal.msgError("璇烽�夋嫨浠诲姟鍏宠仈鏉′欢");
           this.submitLoading = false;
-
           return;
         }
-        // if (!this.form.patTaskRelevances[0] && !this.form.longTask) {
-        //   this.$modal.msgError("璇烽�夋嫨鐥呬汉");
-        //   return;
-        // }
 
+        // 4. 妯℃澘鏍¢獙
         if (!this.form.templatename && !this.templateor) {
           this.$modal.msgError("鏈�夋嫨妯℃澘");
           this.submitLoading = false;
-
           return;
         }
 
-        if (
+        // 5. 鏃堕棿淇℃伅鏍¢獙
+        const isValidTime =
           (this.form.sendType == 1 && this.time1) ||
-          this.form.sendType == 2
-        ) {
-        } else if (
+          this.form.sendType == 2 ||
           (this.form.sendType == 3 && this.time4) ||
-          this.form.longTask
-        ) {
-        } else {
-          this.submitLoading = false;
+          this.form.longTask;
 
-          return this.$modal.msgError("鏃堕棿淇℃伅缂哄け");
+        if (!isValidTime) {
+          this.submitLoading = false;
+          this.$modal.msgError("鏃堕棿淇℃伅缂哄け");
+          return;
         }
+
+        // ===== 鏁版嵁澶勭悊 =====
+
+        // 杩囨护鏂囨湰鍙傛暟
         const filteredArray = this.variableList.filter(
           (item) =>
             item.name !== "濮撳悕" && item.name !== "鐢佃瘽" && item.name !== "鍦板潃"
         );
         this.form.textParam = this.convertFormat2ToFormat1(filteredArray);
+
+        // 璁剧疆鎿嶄綔绫诲瀷
         if (this.form.taskid) {
           this.form.isoperation = 2;
         } else {
           this.form.isoperation = 1;
         }
+
+        // 璁剧疆绫诲瀷
         if (!this.form.type) {
           this.form.type = this.$route.query.type;
         }
+
+        // 鐤剧梾鍏宠仈鐨勭瀹�/鐥呭尯
         if (this.form.appltype == 3) {
           if (this.diseaseDept) {
             this.form.deptcode = this.diseaseDept.deptCode;
@@ -1639,6 +1667,8 @@
             this.form.leavehospitaldistrictname = this.diseaseWard.districtName;
           }
         }
+
+        // 缁勮鎻愪氦鏁版嵁
         this.form.serviceType = this.serviceType;
         this.form.deptcode = this.deptcodesWards.join(",");
         this.form.leavehospitaldistrictcode =
@@ -1650,24 +1680,39 @@
         this.form.icd10name = this.diagglist
           .map((item) => item.icdname)
           .join(",");
-        Editsingletask(this.form).then((res) => {
-          if (res.code == 200) {
-            if (this.form.taskid) {
-              this.$modal.msgSuccess("淇敼鎴愬姛");
+
+        // ===== 鎻愪氦鎺ュ彛 =====
+        Editsingletask(this.form)
+          .then((res) => {
+            if (res.code == 200) {
+              // 鉁� 鎴愬姛
+              if (this.form.taskid) {
+                this.$modal.msgSuccess("淇敼鎴愬姛");
+              } else {
+                this.$modal.msgSuccess("鏂板鎴愬姛");
+              }
+              this.submitLoading = false;
+              this.$router.push({
+                path: "/followvisit/tasklist",
+                query: { tasktopic: this.form.serviceType },
+              });
             } else {
-              this.$modal.msgSuccess("鏂板鎴愬姛");
+              // 鉁� 鎺ュ彛杩斿洖閿欒鐮�
+              this.$modal.msgError(res.msg || "鎿嶄綔澶辫触");
+              this.submitLoading = false;
             }
+          })
+          .catch((error) => {
+            // 鉁� 鎹曡幏鎺ュ彛璇锋眰寮傚父
+            console.error("鎻愪氦澶辫触:", error);
+            this.$modal.msgError(error.message || "缃戠粶寮傚父锛岃绋嶅悗閲嶈瘯");
             this.submitLoading = false;
-            this.$router.push({
-              path: "/followvisit/tasklist",
-              query: { tasktopic: this.form.serviceType },
-            });
-          }
-        });
+          });
       } catch (error) {
+        // 鉁� 鎹曡幏鍚屾浠g爜寮傚父
+        console.error("琛ㄥ崟鎻愪氦寮傚父:", error);
+        this.$modal.msgError(error.message || "琛ㄥ崟鎻愪氦寮傚父");
         this.submitLoading = false;
-      } finally {
-        // 绗洓姝ワ細鏃犺鎴愬姛鎴栧け璐ワ紝鏈�缁堥兘鍏抽棴鍔犺浇鐘舵��
       }
     },
     handleDiseaseDeptChange(dept) {
@@ -2044,6 +2089,16 @@
           let filteredArray = "";
           if (res.code == 200) {
             this.form = res.data;
+            this.diseaseDept = {
+              deptCode: this.form.deptcode,
+              deptName: this.form.deptname,
+            };
+            this.diseaseWard = {
+              districtCode: this.form.leavehospitaldistrictcode,
+              districtName: this.form.leavehospitaldistrictname,
+            };
+            console.log(this.diseaseWard, this.diseaseDept);
+
             this.form.serviceType = this.serviceType;
             this.form.patTaskRelevances = this.form.patTaskRelevances
               ? this.form.patTaskRelevances

--
Gitblit v1.9.3