From bbbc478129f72b26e2ec4a2e981ed8698a96880c Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 22 十月 2026 00:28:18 +0800
Subject: [PATCH] 当service_type=6时,需要根据传入的入院还是离院病区(病区)去后端查询

---
 src/views/outsideChainwtnew.vue |  233 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 217 insertions(+), 16 deletions(-)

diff --git a/src/views/outsideChainwtnew.vue b/src/views/outsideChainwtnew.vue
index 4d5e662..8b61ffa 100644
--- a/src/views/outsideChainwtnew.vue
+++ b/src/views/outsideChainwtnew.vue
@@ -1,5 +1,15 @@
 <template>
   <div class="questionnaire-optimized">
+    <!-- 鎻愪氦涓殑鍏ㄥ睆鍔犺浇閬僵锛堝ぇ瀛椾綋锛岄�傝�佸寲锛� -->
+    <div v-if="submitting" class="submit-loading-mask">
+      <div class="submit-loading-box">
+        <div class="submit-loading-spinner"></div>
+        <div class="submit-loading-title">闂嵎鎻愪氦涓�</div>
+        <div class="submit-loading-tip">璇风◢鍊欙紝姝e湪涓婁紶鎮ㄧ殑绛旀...</div>
+        <div class="submit-loading-warn">璇蜂笉瑕佸叧闂垨鍒锋柊椤甸潰</div>
+      </div>
+    </div>
+
     <div v-if="loading && !accomplish" class="loading-container">
       <div class="loading-content">
         <i class="el-icon-loading loading-icon"></i>
@@ -54,6 +64,7 @@
                       item.prompt &&
                       item.scriptResult &&
                       (item.scriptType !== 2 || item.scriptResult.length > 0),
+                    'required-error': item.requiredError,
                   }"
                 >
                   <!-- 棰樼洰棰樺共 -->
@@ -61,7 +72,11 @@
                     <span class="question-number"
                       >{{ getQuestionNumber(group, index) }}.</span
                     >
-                    <span class="question-text">{{ item.scriptContent }}</span>
+                    <span class="question-text"
+                      ><span v-if="isRequired(item)" class="required-star"
+                        >*</span
+                      >{{ item.scriptContent }}</span
+                    >
                     <span class="question-type-tag">
                       {{
                         item.scriptType == 1
@@ -191,6 +206,7 @@
                   item.prompt &&
                   item.scriptResult &&
                   (item.scriptType !== 2 || item.scriptResult.length > 0),
+                'required-error': item.requiredError,
               }"
             >
               <!-- 棰樼洰棰樺共 -->
@@ -198,7 +214,11 @@
                 <span class="question-number"
                   >{{ getVisibleQuestionIndex(index) }}.</span
                 >
-                <span class="question-text">{{ item.scriptContent }}</span>
+                <span class="question-text"
+                  ><span v-if="isRequired(item)" class="required-star"
+                    >*</span
+                  >{{ item.scriptContent }}</span
+                >
                 <span class="question-type-tag">
                   {{
                     item.scriptType == 1
@@ -317,8 +337,9 @@
               type="primary"
               @click="cache(true)"
               class="submit-button"
+              :loading="submitting"
             >
-              鎻愪氦闂嵎
+              {{ submitting ? "鎻愪氦涓�..." : "鎻愪氦闂嵎" }}
             </el-button>
           </div>
         </div>
@@ -372,6 +393,7 @@
       dialogVisible: false,
       Endornot: true,
       accomplish: false,
+      submitting: false, // 鎻愪氦涓殑鍔犺浇鐘舵��
       dimensionTypes: [
         {
           value: 1,
@@ -395,6 +417,12 @@
       // 鍚庣绉侀挜
       privateKey:
         " MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEAtDOpbUQhcEoYy77agRhIHmAzs7H+KHJhN56gTTI9fWq23j77nI055MFV3oQQziIrNUTNaPpEQhZXBpI0+f9K9QIDAQABAkB3n0fcWfrcoMN/FU3VnrnZOEF6CzFNxkgU9P8y36QECWKZ9JhYQkNpKrMC9oXlN3VSaRigV7B+L/I/a0Rs1W+tAiEA4jx7xcXJ4y4BNwAmVHt6NNiEkzIwWnwC/0qsEu8NsOsCIQDL6MMn1D2uznC6OuOWpxDCkBh1JL1NzZTZeH2G+hj7nwIgKGAC9tjFnvWm4dn0/T7MIIJDpsFeP8fCAS2iZ/6hwuECIAS/eLvWr1EAsZNEh8QcQ8GkBU3E+ztyjAK8UX/xFt/VAiBf79/1tDErX4/DChecM8w3c3DhbBcjuE3fHZn7p6/UKg==",
+      // 婊℃剰搴�/寤夋磥棰樼殑榛樿閫夐」锛堜粎鍦ㄩ鐩湭濉啓鏃剁敓鏁堬級
+      defaultAnswers: [
+        { keyword: "鎮ㄥ鍖绘姢浜哄憳鐨勬弧鎰忓害涓�", answer: "浼�" },
+        { keyword: "鎮ㄥ鍖婚櫌鐜銆佽鏂界瓑鏁翠綋鐨勬弧鎰忓害涓�", answer: "浼�" },
+        { keyword: "鏄惁鏈夊尰鎶や汉鍛樹富鍔ㄧ储瑕佺孩鍖呫�侀敠鏃楁垨琛ㄦ壃淇�", answer: "鏃�" },
+      ],
       formData: {
         question1: "",
         question2: "",
@@ -589,6 +617,8 @@
                   item.scriptResult = item.scriptResult.split("&");
                 }
               });
+              // 榛樿鍕鹃�夋弧鎰忓害/寤夋磥棰橈紙宸蹭綔绛旂殑涓嶄細琚鐩栵級
+              this.applyDefaultAnswers(this.questionList);
               this.loading = false;
 
               return;
@@ -622,12 +652,40 @@
                 item.scriptResult = [];
               }
             });
+            // 榛樿鍕鹃�夋弧鎰忓害/寤夋磥棰�
+            this.applyDefaultAnswers(this.questionList);
             this.loading = false;
           }
         })
         .finally(() => {
           this.loading = false;
         });
+    },
+    // 缁欐寚瀹氶鐩缃粯璁ら�夐」锛堜粎鍦ㄦ湭濉啓鏃剁敓鏁堬級
+    applyDefaultAnswers(list) {
+      if (!Array.isArray(list)) return;
+      list.forEach((item) => {
+        if (item.scriptType != 1) return;
+        // 宸叉湁绛旀鏃朵笉瑕嗙洊
+        if (
+          item.scriptResult !== undefined &&
+          item.scriptResult !== null &&
+          item.scriptResult !== ""
+        ) {
+          return;
+        }
+        const content = (item.scriptContent || "").trim();
+        const matched = this.defaultAnswers.find((d) =>
+          content.includes(d.keyword)
+        );
+        if (!matched) return;
+        const option = (item.svyTaskTemplateTargetoptions || []).find(
+          (o) => (o.optioncontent || "").trim() === matched.answer
+        );
+        if (option) {
+          item.scriptResult = option.optioncontent;
+        }
+      });
     },
     // 鍔犲瘑鍑芥暟
     encrypt(txt) {
@@ -662,19 +720,35 @@
       //   }
       // });
       form.serviceSubtaskDetailList = arr;
-      Submitaquestionnaire(form).then((res) => {
-        if (res.code == 200) {
-          if (this.jsy) {
-            this.dialogVisible = true;
+      Submitaquestionnaire(form)
+        .then((res) => {
+          this.submitting = false;
+          if (res.code == 200) {
+            if (this.jsy) {
+              this.dialogVisible = true;
+            }
+            this.accomplish = true;
+            this.$modal.msgSuccess("鎻愪氦鎴愬姛");
+          } else {
+            this.$modal.msgError(res.msg || "鎻愪氦澶辫触锛岃閲嶈瘯");
           }
-          this.accomplish = true;
-          this.$modal.msgSuccess("鎻愪氦鎴愬姛");
-        }
-      });
+        })
+        .catch(() => {
+          this.submitting = false;
+          this.$modal.msgError("鎻愪氦澶辫触锛岃閲嶈瘯");
+        });
     },
     // 缂撳瓨
     cache(subm) {
       console.log("杩涘叆缂撳瓨");
+      // 鎻愪氦鍦烘櫙锛氬厛鍋氬繀濉」鏍¢獙
+      if (subm === true && !this.validateRequired()) {
+        return;
+      }
+      // 鎻愪氦鍦烘櫙锛氬紑鍚姞杞界姸鎬侊紝闃叉閲嶅鐐瑰嚮
+      if (subm === true) {
+        this.submitting = true;
+      }
       let form = {
         param1: this.taskid,
         param2: this.patid,
@@ -720,13 +794,66 @@
       });
       form.svyTaskTemplateScriptVOS = arr;
       form.type = 2;
-      Cachequestionnaire(form).then((res) => {
-        if (res.code == 200) {
-          if (subm) {
-            this.submitForm();
+      Cachequestionnaire(form)
+        .then((res) => {
+          if (res.code == 200) {
+            if (subm) {
+              this.submitForm();
+            }
+          } else {
+            // 缂撳瓨澶辫触锛氭仮澶嶆彁浜ょ姸鎬�
+            if (subm) {
+              this.submitting = false;
+              this.$modal.msgError("鎻愪氦澶辫触锛岃閲嶈瘯");
+            }
           }
-        }
+        })
+        .catch(() => {
+          if (subm) {
+            this.submitting = false;
+            this.$modal.msgError("鎻愪氦澶辫触锛岃閲嶈瘯");
+          }
+        });
+    },
+    // 鏄惁蹇呭~锛�1蹇呭~ 2涓嶅繀濉級
+    isRequired(item) {
+      return item.ismandatory == 1 || item.ismandatory == "1";
+    },
+    // 鍒ゆ柇棰樼洰鏄惁鏈~鍐�
+    isQuestionEmpty(item) {
+      const val = item.scriptResult;
+      if (item.scriptType == 2) {
+        return !val || (Array.isArray(val) && val.length === 0);
+      }
+      return val === undefined || val === null || val === "";
+    },
+    // 淇濆瓨鍓嶅繀濉」鏍¢獙
+    validateRequired() {
+      const list = this.questionList || [];
+      list.forEach((item) => {
+        if (item.requiredError) this.$set(item, "requiredError", false);
       });
+      const unfilled = [];
+      list.forEach((item) => {
+        if (item.ishide) return;
+        if (!this.isRequired(item)) return;
+        if (this.isQuestionEmpty(item)) unfilled.push(item);
+      });
+      if (unfilled.length > 0) {
+        unfilled.forEach((item) => this.$set(item, "requiredError", true));
+        this.$modal.msgWarning(
+          `杩樻湁 ${unfilled.length} 閬撳繀濉鏈~鍐欙紝璇疯ˉ鍏呭悗鍐嶆彁浜
+        );
+        this.$nextTick(() => {
+          const idx = this.visibleQuestions.indexOf(unfilled[0]);
+          const els = this.$el.querySelectorAll(".question-item");
+          if (els[idx]) {
+            els[idx].scrollIntoView({ behavior: "smooth", block: "center" });
+          }
+        });
+        return false;
+      }
+      return true;
     },
     // 鑾峰彇鍙棰樼洰鐨勬纭簭鍙凤紙瑙e喅璺抽鍚庡簭鍙蜂笉杩炵画鐨勯棶棰橈級
     getVisibleQuestionIndex(index) {
@@ -1004,6 +1131,12 @@
     border-left: 4px solid #e6a23c;
   }
 
+  &.required-error {
+    border-color: #f56c6c;
+    border-left: 4px solid #f56c6c;
+    background: #fef0f0;
+  }
+
   &:last-child {
     margin-bottom: 0;
   }
@@ -1035,6 +1168,12 @@
   font-weight: 600;
   color: #175997;
   min-width: 16px;
+}
+
+.required-star {
+  color: #f56c6c;
+  margin-right: 2px;
+  font-weight: 600;
 }
 
 // .question-text {
@@ -1316,6 +1455,68 @@
   min-height: 70vh;
 }
 
+/* ===== 鎻愪氦涓細閫傝�佸寲鍏ㄥ睆鍔犺浇閬僵 ===== */
+.submit-loading-mask {
+  position: fixed;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  background: rgba(0, 0, 0, 0.55);
+  z-index: 3000;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  padding: 20px;
+}
+
+.submit-loading-box {
+  background: #ffffff;
+  border-radius: 20px;
+  padding: 48px 56px;
+  text-align: center;
+  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
+  max-width: 85vw;
+  box-sizing: border-box;
+}
+
+.submit-loading-spinner {
+  width: 72px;
+  height: 72px;
+  margin: 0 auto 24px;
+  border: 8px solid #e8eef5;
+  border-top-color: #175997;
+  border-right-color: #2a77c9;
+  border-radius: 50%;
+  animation: submit-spin 1s linear infinite;
+}
+
+@keyframes submit-spin {
+  to {
+    transform: rotate(360deg);
+  }
+}
+
+.submit-loading-title {
+  font-size: 28px;
+  font-weight: 700;
+  color: #175997;
+  margin-bottom: 14px;
+}
+
+.submit-loading-tip {
+  font-size: 20px;
+  color: #303a47;
+  line-height: 1.6;
+}
+
+.submit-loading-warn {
+  margin-top: 18px;
+  font-size: 17px;
+  color: #e6a23c;
+  font-weight: 500;
+}
+
 .loading-content {
   text-align: center;
   padding: 40px;

--
Gitblit v1.9.3