From b4fe2c16274a91fee4fb26d91374f95fbe2dbcec Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期一, 09 十一月 2026 15:28:21 +0800
Subject: [PATCH] 测试完成

---
 src/views/patient/patient/behospitalized.vue |  160 +++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 136 insertions(+), 24 deletions(-)

diff --git a/src/views/patient/patient/behospitalized.vue b/src/views/patient/patient/behospitalized.vue
index f1f22c6..b92d1e1 100644
--- a/src/views/patient/patient/behospitalized.vue
+++ b/src/views/patient/patient/behospitalized.vue
@@ -122,6 +122,20 @@
               娣诲姞寤剁画鎶ょ悊浠诲姟
             </el-button>
           </el-col>
+          <!-- 璇煶鏈嶅姟杞汉宸ユ寜閽� -->
+          <el-col :span="1.5">
+            <el-button
+              type="primary"
+              plain
+              icon="el-icon-refresh-right"
+              size="medium"
+              :disabled="multiple"
+              v-if="orgname === '绗竴浜烘皯鍖婚櫌婀栨花闄㈠尯'||orgname === '绗竴浜烘皯鍖婚櫌鍚村北闄㈠尯'||orgname === '绗竴浜烘皯鍖婚櫌鍩庝笢闄㈠尯'"
+              @click="handleManualVisit"
+            >
+              璇煶鏈嶅姟杞汉宸�
+            </el-button>
+          </el-col>
           <!-- <el-col :span="1.5">
             <el-button
               type="success"
@@ -314,7 +328,7 @@
     <!-- 鎵归噺娣诲姞寤剁画鎶ょ悊浠诲姟寮圭獥 -->
     <!-- 鎵归噺娣诲姞寤剁画鎶ょ悊浠诲姟寮圭獥 -->
     <el-dialog
-      title="鎵归噺娣诲姞寤剁画鎶ょ悊"
+      :title="batchMode === 'manual' ? '璇煶鏈嶅姟杞汉宸�' : '鎵归噺娣诲姞寤剁画鎶ょ悊'"
       :visible.sync="batchTaskVisible"
       width="90%"
       append-to-body
@@ -391,7 +405,9 @@
         <el-col :span="12">
           <div class="batch-task-section">
             <div class="section-header">
-              <h4>寤剁画鎶ょ悊浠诲姟</h4>
+              <h4>
+                {{ batchMode === "manual" ? "浜哄伐闅忚浠诲姟" : "寤剁画鎶ょ悊浠诲姟" }}
+              </h4>
               <div v-if="selectedTask" class="task-selected-hint selected">
                 <i class="el-icon-success"></i>
                 <span>宸查�夋嫨锛歿{ selectedTask.taskName }}</span>
@@ -453,7 +469,11 @@
               <template #empty>
                 <div class="empty-message">
                   <i class="el-icon-document"></i>
-                  <span>鏆傛棤鍙敤寤剁画鎶ょ悊浠诲姟</span>
+                  <span>{{
+                    batchMode === "manual"
+                      ? "鏆傛棤鍙敤浜哄伐闅忚浠诲姟"
+                      : "鏆傛棤鍙敤寤剁画鎶ょ悊浠诲姟"
+                  }}</span>
                   <span class="empty-tips">璇疯仈绯荤鐞嗗憳鍒涘缓浠诲姟</span>
                 </div>
               </template>
@@ -473,7 +493,15 @@
           @click="submitBatchTask"
           :disabled="!selectedTask || batchLoading"
         >
-          {{ batchLoading ? "鍒涘缓涓�..." : "鍒涘缓寤剁画鎶ょ悊浠诲姟" }}
+          {{
+            batchLoading
+              ? batchMode === "manual"
+                ? "杞崲涓�..."
+                : "鍒涘缓涓�..."
+              : batchMode === "manual"
+              ? "纭杞汉宸�"
+              : "鍒涘缓寤剁画鎶ょ悊浠诲姟"
+          }}
         </el-button>
       </div>
     </el-dialog>
@@ -581,7 +609,7 @@
 import { delUser } from "@/api/system/user";
 import formatTime from "@/filters/index";
 
-import { listpatient } from "@/api/patient/record";
+import { listpatient, addManualVisit } from "@/api/patient/record";
 import {
   messagelistpatient,
   alterpatient,
@@ -639,6 +667,7 @@
       initPassword: undefined,
       amendtag: false, //鏄惁淇敼
       // 鎵归噺浠诲姟鐩稿叧鏁版嵁
+      batchMode: "continue", // 寮圭獥妯″紡锛歝ontinue 寤剁画鎶ょ悊 / manual 璇煶鏈嶅姟杞汉宸�
       batchTaskVisible: false, // 寮圭獥鍙鎬�
       selectedPatients: [], // 閫変腑鐨勬偅鑰呭垪琛�
       taskList: [], // 浠诲姟鍒楄〃
@@ -669,7 +698,7 @@
           label: "鐥呭尯鎮h��",
         },
       ],
-      orgName: localStorage.getItem("orgname"),
+      orgname: localStorage.getItem("orgname"),
 
       postData: {
         XiaoXiTou: {
@@ -811,6 +840,8 @@
     this.queryParams.leavehospitaldistrictcodes = store.getters.belongWards.map(
       (obj) => obj.districtCode
     );
+    console.log(this.orgname);
+
     this.getList();
     // this.listDept();
     this.gettabList();
@@ -929,37 +960,52 @@
         return;
       }
 
-      // 鑾峰彇閫変腑鎮h�呯殑绉戝淇℃伅
-      const patientDepts = new Set();
-      let deptcode = "";
-      this.ids.forEach((patId) => {
-        const patient = this.userList.find((item) => item.patid === patId);
-        if (patient) {
-          patientDepts.add(patient.deptname);
-          deptcode = patient.deptcode;
-        }
-      });
-
+      this.batchMode = "continue";
       // 鑾峰彇閫変腑鎮h�呭垪琛�
       this.selectedPatients = this.userList.filter((item) =>
         this.ids.includes(item.patid)
       );
+      this.selectedTask = null;
 
       // 鏄剧ず寮圭獥
       this.batchTaskVisible = true;
 
       // 鑾峰彇浠诲姟鍒楄〃
-      this.loadTaskList(deptcode);
+      this.loadTaskList();
+    },
+
+    /** 璇煶鏈嶅姟杞汉宸ユ寜閽偣鍑� */
+    handleManualVisit() {
+      // 鏍¢獙鏄惁閫変腑鎮h��
+      if (this.ids.length === 0) {
+        this.$modal.msgWarning("璇疯嚦灏戦�変腑1鍚嶆偅鑰�");
+        return;
+      }
+
+      this.batchMode = "manual";
+      // 鑾峰彇閫変腑鎮h�呭垪琛�
+      this.selectedPatients = this.userList.filter((item) =>
+        this.ids.includes(item.patid)
+      );
+      this.selectedTask = null;
+
+      // 鏄剧ず寮圭獥
+      this.batchTaskVisible = true;
+
+      // 鑾峰彇浠诲姟鍒楄〃
+      this.loadTaskList();
     },
 
     /** 鍔犺浇浠诲姟鍒楄〃 */
-    loadTaskList(deptcode) {
+    loadTaskList() {
       this.batchLoading = true;
       let topqueryParams = {
         pageNum: 1,
-        pageSize: 100, // 璁剧疆杈冨ぇ鐨勫垎椤佃幏鍙栨洿澶氫换鍔�
-        type: 2, // 寤剁画鎶ょ悊浠诲姟绫诲瀷
+        pageSize: 1000, // 璁剧疆杈冨ぇ鐨勫垎椤佃幏鍙栨洿澶氫换鍔�
       };
+      if (this.batchMode !== "manual") {
+        topqueryParams.type = 2; // 寤剁画鎶ょ悊浠诲姟绫诲瀷
+      }
       topqueryParams.deptcodes = store.getters.belongDepts.map(
         (obj) => obj.deptCode
       );
@@ -968,11 +1014,21 @@
       );
       getTasklist(topqueryParams)
         .then((response) => {
-          this.taskList = response.rows;
+          this.taskList = response.rows || [];
+          if (this.batchMode === "manual") {
+            // 鍙繚鐣欍�屼汉宸ャ�嶄换鍔″舰寮忥紙preachform 鍚� 1锛�
+            this.taskList = this.taskList.filter((task) =>
+              this.isManualTask(task)
+            );
+          }
           this.batchLoading = false;
 
           if (this.taskList.length === 0) {
-            this.$modal.msgWarning("褰撳墠绉戝鏃犲彲鐢ㄥ欢缁姢鐞嗕换鍔�");
+            this.$modal.msgWarning(
+              this.batchMode === "manual"
+                ? "褰撳墠绉戝鏃犲彲鐢ㄤ汉宸ラ殢璁夸换鍔�"
+                : "褰撳墠绉戝鏃犲彲鐢ㄥ欢缁姢鐞嗕换鍔�"
+            );
           }
         })
         .catch((error) => {
@@ -981,16 +1037,38 @@
         });
     },
 
+    /** 鍒ゆ柇鏄惁涓恒�屼汉宸ャ�嶄换鍔″舰寮忥紙preachform 鍚� 1锛� */
+    isManualTask(task) {
+      if (task.preachform != null && task.preachform !== "") {
+        const forms = String(task.preachform)
+          .split(",")
+          .map((s) => s.trim());
+        if (forms.includes("1")) return true;
+      }
+      if (Array.isArray(task.preachformList)) {
+        return task.preachformList.some(
+          (item) => String(item.preachform) === "1"
+        );
+      }
+      return false;
+    },
+
     /** 澶勭悊浠诲姟閫夋嫨鍙樺寲 */
     handleTaskSelectionChange(currentRow) {
       this.selectedTask = currentRow;
     },
 
-    /** 鎵归噺鎻愪氦寤剁画鎶ょ悊浠诲姟 */
+    /** 鎵归噺鎻愪氦锛堝欢缁姢鐞� / 璇煶鏈嶅姟杞汉宸ワ級 */
     async submitBatchTask() {
       // 鏍¢獙鏄惁閫変腑浠诲姟
       if (!this.selectedTask) {
         this.$modal.msgWarning("璇烽�夋嫨1涓换鍔�");
+        return;
+      }
+
+      // 璇煶鏈嶅姟杞汉宸ワ細璧版柊鎺ュ彛
+      if (this.batchMode === "manual") {
+        this.submitManualVisit();
         return;
       }
 
@@ -1066,6 +1144,40 @@
       }
     },
 
+    /** 璇煶鏈嶅姟杞汉宸ワ細鍒犻櫎鏈畬鎴愰殢璁夸换鍔″苟閲嶆柊鐢熸垚浜哄伐闅忚浠诲姟 */
+    async submitManualVisit() {
+      this.batchLoading = true;
+      try {
+        const params = {
+          patids: this.selectedPatients.map((item) => item.patid),
+          taskid: this.selectedTask.taskid,
+        };
+        const response = await addManualVisit(params);
+        if (response.code === 200) {
+          const data = response.data || {};
+          const generated = data.generatedCount || 0;
+          const noDischarge = (data.noDischargeRecordPatids || []).length;
+          const noArchive = (data.noArchivePatids || []).length;
+          const failed = (data.generateFailedPatids || []).length;
+          let msg = `鎴愬姛鐢熸垚 ${generated} 涓汉宸ラ殢璁夸换鍔;
+          if (noDischarge) msg += `锛�${noDischarge} 浜烘棤鍑洪櫌璁板綍`;
+          if (noArchive) msg += `锛�${noArchive} 浜烘棤鎮h�呮。妗坄;
+          if (failed) msg += `锛�${failed} 浜虹敓鎴愬け璐;
+          this.$modal.msgSuccess(msg);
+          this.batchTaskVisible = false;
+          this.getList(); // 鍒锋柊鎮h�呭垪琛�
+        } else {
+          this.$modal.msgError(response.msg || "璇煶鏈嶅姟杞汉宸ュけ璐�");
+        }
+      } catch (error) {
+        this.$modal.msgError(
+          "璇煶鏈嶅姟杞汉宸ュけ璐ワ細" + (error.message || "缃戠粶閿欒")
+        );
+      } finally {
+        this.batchLoading = false;
+      }
+    },
+
     /** 璁$畻闅忚缁撴潫鏃堕棿锛堝湪闄㈡偅鑰咃細鍑洪櫌鍚�7澶╋級 */
     getFollowUpEndTime(admitDate) {
       if (!admitDate) return "";

--
Gitblit v1.9.3