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/QuestionnaireTask.vue |  146 ++++++++++++++++++++++++++++++++----------------
 1 files changed, 96 insertions(+), 50 deletions(-)

diff --git a/src/views/patient/propaganda/QuestionnaireTask.vue b/src/views/patient/propaganda/QuestionnaireTask.vue
index 47284f1..6c4256a 100644
--- a/src/views/patient/propaganda/QuestionnaireTask.vue
+++ b/src/views/patient/propaganda/QuestionnaireTask.vue
@@ -428,7 +428,6 @@
                       placeholder="璇风偣鍑诲彸渚ч�夋嫨"
                     />
                     <el-button
-                      v-if="form.templateid"
                       style="margin-left: 10px"
                       type="primary"
                       icon="el-icon-edit"
@@ -1504,13 +1503,16 @@
       if (this.submitLoading) {
         return;
       }
-      // 绗簩姝ワ細寮�鍚姞杞界姸鎬侊紝绂佺敤鎸夐挳
+
+      // 寮�鍚姞杞界姸鎬�
       this.submitLoading = true;
       console.log(this.submitLoading);
 
       try {
-        if (this.time4 && this.form.sendType == 3)
+        // 鏃堕棿澶勭悊
+        if (this.time4 && this.form.sendType == 3) {
           this.form.showTimeMorn = this.time4;
+        }
         this.form.sendTimeslot = [
           {
             begantime: this.time4,
@@ -1518,8 +1520,8 @@
             xh: 1,
           },
         ];
-        console.log(1);
 
+        // 鏍规嵁搴旂敤绫诲瀷娓呯悊瀛楁
         if (this.form.appltype == 1) {
           this.leavehospitaldistrictcodes = [];
           this.form.oplevelcode = null;
@@ -1537,75 +1539,90 @@
           this.illnesscodes = [];
           this.leavehospitaldistrictcodes = [];
         }
+
+        // 鏍¢獙锛氭湇鍔$被鍨�
         if (this.checkList) {
           this.form.preachform = this.checkList.join(",");
           this.form.preachformList = this.selectedOrder;
         } else {
           this.$modal.msgError("璇烽�夋嫨鏈嶅姟绫诲瀷");
           this.submitLoading = false;
-
           return;
         }
-        console.log(2);
 
-        if (
+        // 鏍¢獙锛氱柧鐥呭叧鑱旂瀹ゆ垨鐥呭尯
+        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;
+          }
+        }
+
+        // 鏍¢獙锛氫换鍔″叧鑱旀潯浠�
+        const hasCondition =
           this.deptcodesWards[0] ||
           this.leavehospitaldistrictcodes[0] ||
           this.diagglist[0] ||
           this.form.oplevelcode ||
           this.form.longTask == 2 ||
-          this.serviceType == 3
-        ) {
-        } else {
+          this.serviceType == 3;
+
+        if (!hasCondition) {
           this.$modal.msgError("璇烽�夋嫨浠诲姟鍏宠仈鏉′欢");
           this.submitLoading = false;
           return;
         }
-        //鏆傚仠浠诲姟鎮h�呴檺鍒�
-        // if (!this.form.patTaskRelevances[0] && !this.form.longTask) {
-        //   this.$modal.msgError("璇烽�夋嫨鐥呬汉");
-        //   return;
-        // }
-        console.log(3);
 
+        // 鏍¢獙锛氭ā鏉�
         if (!this.form.templatename && !this.templateor) {
           this.$modal.msgError("鏈�夋嫨妯℃澘");
           this.submitLoading = false;
-
           return;
         }
 
-        if (
+        // 鏍¢獙锛氭椂闂翠俊鎭�
+        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.form.longTask;
+
+        if (!isValidTime) {
           this.submitLoading = false;
-          return this.$modal.msgError("鏃堕棿淇℃伅缂哄け");
+          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;
         }
-        console.log(4);
+
+        // 缁勮鎻愪氦鏁版嵁
         this.form.serviceType = this.serviceType;
         this.form.deptcode = this.deptcodesWards.join(",");
         this.form.leavehospitaldistrictcode =
           this.leavehospitaldistrictcodes.join(",");
-        // this.form.opcode = this.operationcodes.join(",");
+
+        // 鐤剧梾鍏宠仈鐨勭瀹�/鐥呭尯
         if (this.form.appltype == 3) {
           if (this.diseaseDept) {
             this.form.deptcode = this.diseaseDept.deptCode;
@@ -1618,30 +1635,46 @@
           }
         }
 
+        // 璇婃柇淇℃伅
         this.form.icd10code = this.diagglist
           .map((item) => item.icdcode)
           .join(",");
         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.$router.push({
+                path: "/followvisit/tasklist",
+                query: { tasktopic: this.form.serviceType },
+              });
             } else {
-              this.$modal.msgSuccess("鏂板鎴愬姛");
+              // 鉁� 鎺ュ彛杩斿洖閿欒鐮佹椂鐨勫鐞�
+              this.$modal.msgError(res.msg || "鎿嶄綔澶辫触");
             }
-            this.$router.push({
-              path: "/followvisit/tasklist",
-              query: { tasktopic: this.form.serviceType },
-            });
+          })
+          .catch((error) => {
+            // 鉁� 鎹曡幏鎺ュ彛璇锋眰寮傚父
+            console.error("鎻愪氦澶辫触:", error);
+            this.$modal.msgError(error.message || "缃戠粶寮傚父锛岃绋嶅悗閲嶈瘯");
+          })
+          .finally(() => {
+            // 鉁� 鏃犺鎴愬姛鎴栧け璐ワ紝鏈�缁堥兘鍏抽棴鍔犺浇鐘舵��
             this.submitLoading = false;
-          }
-        });
+          });
       } catch (error) {
+        // 鉁� 鎹曡幏鍚屾浠g爜寮傚父
+        console.error("琛ㄥ崟鎻愪氦寮傚父:", error);
+        this.$modal.msgError(error.message || "琛ㄥ崟鎻愪氦寮傚父");
         this.submitLoading = false;
-      } finally {
-        // 绗洓姝ワ細鏃犺鎴愬姛鎴栧け璐ワ紝鏈�缁堥兘鍏抽棴鍔犺浇鐘舵��
       }
     },
     handleDiseaseDeptChange(dept) {
@@ -2103,6 +2136,14 @@
             this.form.patTaskRelevances = this.form.patTaskRelevances
               ? this.form.patTaskRelevances
               : [];
+            this.diseaseDept = {
+              deptCode: this.form.deptcode,
+              deptName: this.form.deptname,
+            };
+            this.diseaseWard = {
+              districtCode: this.form.leavehospitaldistrictcode,
+              districtName: this.form.leavehospitaldistrictname,
+            };
             this.overallCase = this.form.patTaskRelevances.concat();
             this.checkList = this.form.preachform.split(",");
             this.selectedOrder = this.form.preachformList;
@@ -2371,19 +2412,24 @@
 
       this.objyl.isoperation = 1;
       this.objyl.taskid = this.form.taskid;
-
+      this.objyl.svyTemplateLibScripts.forEach((item) => {
+        item.qremark = [];
+        item.svyTaskTemplateTargetoptions = item.svyLibTemplateTargetoptions;
+      });
+      this.objyl.svyTaskTemplateScriptVOS = this.objyl.svyTemplateLibScripts;
       if (this.objyl.id) {
         deleteTaskQuestioncomit(this.objyl.id).then((res) => {
           if (res.code == 200) {
-            (this.objyl.id = null),
-              TaskQuestioncomit(this.objyl).then((response) => {
-                this.previewtf = false;
-                this.form.libtemplateid = this.objyl.svyid;
-                this.form.libtemplatename = this.objyl.svyname;
-                this.form.templateid = response.data;
-                this.form.templatename = this.objyl.svyname;
-                this.$modal.msgSuccess("閫夋嫨妯℃澘鎴愬姛");
-              });
+            this.objyl.id = null;
+
+            TaskQuestioncomit(this.objyl).then((response) => {
+              this.previewtf = false;
+              this.form.libtemplateid = this.objyl.svyid;
+              this.form.libtemplatename = this.objyl.svyname;
+              this.form.templateid = response.data;
+              this.form.templatename = this.objyl.svyname;
+              this.$modal.msgSuccess("閫夋嫨妯℃澘鎴愬姛");
+            });
           }
         });
       } else {

--
Gitblit v1.9.3