From fb34ba28cb908bd328cf6690ab0b19a56428f4e2 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期五, 13 十一月 2026 10:56:55 +0800
Subject: [PATCH] 测试完成

---
 src/views/patient/patient/behospitalized.vue |  260 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 231 insertions(+), 29 deletions(-)

diff --git a/src/views/patient/patient/behospitalized.vue b/src/views/patient/patient/behospitalized.vue
index f17a2ee..bb0eb64 100644
--- a/src/views/patient/patient/behospitalized.vue
+++ b/src/views/patient/patient/behospitalized.vue
@@ -49,6 +49,8 @@
               v-model="queryParams.scopetype"
               placeholder="榛樿鍏ㄩ儴绉戝"
               :options="sourcetype"
+              filterable
+              clearable
               :props="{ expandTrigger: 'hover' }"
               @change="handleChange"
             ></el-cascader>
@@ -63,6 +65,17 @@
               start-placeholder="寮�濮嬫棩鏈�"
               end-placeholder="缁撴潫鏃ユ湡"
             ></el-date-picker>
+          </el-form-item>
+          <el-form-item label="搴婂彿鎺掑簭" prop="bedSort">
+            <el-select
+              v-model="queryParams.bedSort"
+              placeholder="涓嶆寜搴婂彿鎺掑簭"
+              style="width: 160px"
+            >
+              <el-option label="涓嶆寜搴婂彿鎺掑簭" :value="null"></el-option>
+              <el-option label="鎸夊簥鍙锋搴�" :value="1"></el-option>
+              <el-option label="鎸夊簥鍙峰�掑簭" :value="2"></el-option>
+            </el-select>
           </el-form-item>
 
           <el-row>
@@ -109,6 +122,32 @@
               娣诲姞寤剁画鎶ょ悊浠诲姟
             </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"
+              plain
+              icon="el-icon-folder-add"
+              size="medium"
+              :disabled="multiple"
+              @click="handleCreateArchive"
+            >
+              鎮h�呭缓妗�</el-button
+            >
+          </el-col> -->
           <el-col :span="1.5">
             <el-button
               type="danger"
@@ -174,7 +213,7 @@
                     scope.row.idcardno,
                     scope.row.drcode,
                     scope.row.drname,
-                    scope.row.patid,
+                    scope.row.patid
                   )
                 "
                 ><span class="button-textsc">{{
@@ -289,7 +328,7 @@
     <!-- 鎵归噺娣诲姞寤剁画鎶ょ悊浠诲姟寮圭獥 -->
     <!-- 鎵归噺娣诲姞寤剁画鎶ょ悊浠诲姟寮圭獥 -->
     <el-dialog
-      title="鎵归噺娣诲姞寤剁画鎶ょ悊"
+      :title="batchMode === 'manual' ? '璇煶鏈嶅姟杞汉宸�' : '鎵归噺娣诲姞寤剁画鎶ょ悊'"
       :visible.sync="batchTaskVisible"
       width="90%"
       append-to-body
@@ -366,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>
@@ -428,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>
@@ -448,7 +493,15 @@
           @click="submitBatchTask"
           :disabled="!selectedTask || batchLoading"
         >
-          {{ batchLoading ? "鍒涘缓涓�..." : "鍒涘缓寤剁画鎶ょ悊浠诲姟" }}
+          {{
+            batchLoading
+              ? batchMode === "manual"
+                ? "杞崲涓�..."
+                : "鍒涘缓涓�..."
+              : batchMode === "manual"
+              ? "纭杞汉宸�"
+              : "鍒涘缓寤剁画鎶ょ悊浠诲姟"
+          }}
         </el-button>
       </div>
     </el-dialog>
@@ -542,6 +595,13 @@
         <el-button @click="submitclose">鍙� 娑�</el-button>
       </div>
     </el-dialog>
+
+    <!-- 鎮h�呭缓妗e脊绐� -->
+    <ArchiveDialog
+      :visible.sync="archiveDialogVisible"
+      :patients="archivePatients"
+      source-page="inpatient"
+    />
   </div>
 </template>
 
@@ -549,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,
@@ -565,14 +625,20 @@
 import Treeselect from "@riophae/vue-treeselect";
 import { listDept } from "@/api/system/dept";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
-import { query360PatInfo,query360PatInfonh, getTasklist, addSubtask } from "@/api/AiCentre/index";
+import {
+  query360PatInfo,
+  query360PatInfonh,
+  getTasklist,
+  addSubtask,
+} from "@/api/AiCentre/index";
 
 import store from "@/store";
+import ArchiveDialog from "@/views/patient/archives/components/ArchiveDialog.vue";
 
 export default {
   name: "behospitalized",
   dicts: ["sys_normal_disable", "sys_user_sex", "nursinggrade"],
-  components: { Treeselect },
+  components: { Treeselect, ArchiveDialog },
   data() {
     return {
       // 閬僵灞�
@@ -601,11 +667,15 @@
       initPassword: undefined,
       amendtag: false, //鏄惁淇敼
       // 鎵归噺浠诲姟鐩稿叧鏁版嵁
+      batchMode: "continue", // 寮圭獥妯″紡锛歝ontinue 寤剁画鎶ょ悊 / manual 璇煶鏈嶅姟杞汉宸�
       batchTaskVisible: false, // 寮圭獥鍙鎬�
       selectedPatients: [], // 閫変腑鐨勬偅鑰呭垪琛�
       taskList: [], // 浠诲姟鍒楄〃
       selectedTask: null, // 閫変腑鐨勪换鍔�
       batchLoading: false, // 鎵归噺鎻愪氦鍔犺浇鐘舵��
+      // 鎮h�呭缓妗�
+      archiveDialogVisible: false,
+      archivePatients: [],
       // 鏃ユ湡鑼冨洿
       dateRange: [],
       paperstypes: [
@@ -628,6 +698,8 @@
           label: "鐥呭尯鎮h��",
         },
       ],
+      orgname: localStorage.getItem("orgname"),
+
       postData: {
         XiaoXiTou: {
           FaSongFCSJC: "ZJHES",
@@ -735,6 +807,7 @@
         pageNum: 1,
         pageSize: 10,
         cry: 0,
+        bedSort: null,
         searchscope: 3,
         scopetype: [],
         leaveldeptcodes: [],
@@ -767,6 +840,8 @@
     this.queryParams.leavehospitaldistrictcodes = store.getters.belongWards.map(
       (obj) => obj.districtCode
     );
+    console.log(this.orgname);
+
     this.getList();
     // this.listDept();
     this.gettabList();
@@ -775,12 +850,33 @@
     /** 鏌ヨ鎮h�呭垪琛� */
     getList() {
       this.loading = true;
-      listpatient(this.queryParams).then((response) => {
+      listpatient(this.buildListQueryParams()).then((response) => {
         console.log(response);
         this.userList = response.rows;
         this.total = response.total;
         this.loading = false;
       });
+    },
+    /**
+     * 缁勮 listpatient 鍏ュ弬锛�
+     * cry = 0 涓旂櫥褰曟満鏋勪负銆岀渷绔嬪悓寰风繝鑻戦櫌鍖� / 鍗楀崕澶у闄勫睘绗竴鍖婚櫌銆嶆椂锛�
+     * 绉戝/鐥呭尯瀛楁 leaveldeptcodes銆乴eavehospitaldistrictcodes 闇�鎹㈡垚
+     * deptcodeList銆乭ospitaldistrictcodeList銆�
+     */
+    buildListQueryParams() {
+      const params = { ...this.queryParams };
+      const orgname = localStorage.getItem("orgname");
+      const needRename =
+        params.cry === 0 &&
+        (orgname === "鐪佺珛鍚屽痉缈犺嫅闄㈠尯" ||
+          orgname === "鍗楀崕澶у闄勫睘绗竴鍖婚櫌");
+      if (needRename) {
+        params.deptcodeList = params.leaveldeptcodes;
+        params.hospitaldistrictcodeList = params.leavehospitaldistrictcodes;
+        delete params.leaveldeptcodes;
+        delete params.leavehospitaldistrictcodes;
+      }
+      return params;
     },
     /** 琛ㄦ牸琛屾牱寮� */
     tableRowClassName({ row, rowIndex }) {
@@ -816,6 +912,10 @@
         this.queryParams.leaveldeptcodes.push(code);
         this.queryParams.leavehospitaldistrictcodes = [];
         this.queryParams.searchscope = 1;
+      } else if (type == 2) {
+        this.queryParams.leavehospitaldistrictcodes.push(code);
+        this.queryParams.leaveldeptcodes = [];
+        this.queryParams.searchscope = 2;
       } else if (type == 3) {
         this.queryParams.leaveldeptcodes = store.getters.belongDepts.map(
           (obj) => obj.deptCode
@@ -860,45 +960,75 @@
         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
+      );
+      topqueryParams.hospitaldistrictcodes = store.getters.belongWards.map(
+        (obj) => obj.districtCode
+      );
       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) => {
@@ -907,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;
       }
 
@@ -937,7 +1089,8 @@
             templateid: this.selectedTask.templateid,
             libtemplateid: this.selectedTask.libtemplateid,
             sendstate: 2, // 鍙戦�佺姸鎬�
-            continueFlag: 1, // 寤剁画鎶ょ悊鏍囧織锛堝湪闄㈡偅鑰咃級
+            continueFlag: 2, // 寤剁画鎶ょ悊鏍囧織锛堝湪闄㈡偅鑰咃級
+            hospType: 6, // 鎮h�呯被鍨嬶細6=浣忛櫌
             ...patient,
             sendname: patient.patname,
             // 鍦ㄩ櫌鎮h�呬娇鐢ㄥ綋鍓嶆椂闂翠綔涓轰换鍔″紑濮嬫椂闂�
@@ -981,9 +1134,46 @@
         }
 
         this.batchTaskVisible = false;
+        this.$router.push({
+          path: "/followvisit/Continue",
+        });
         this.getList(); // 鍒锋柊鎮h�呭垪琛�
       } catch (error) {
         this.$modal.msgError("鎵归噺娣诲姞浠诲姟杩囩▼涓嚭閿欙細" + error.message);
+      } finally {
+        this.batchLoading = false;
+      }
+    },
+
+    /** 璇煶鏈嶅姟杞汉宸ワ細鍒犻櫎鏈畬鎴愰殢璁夸换鍔″苟閲嶆柊鐢熸垚浜哄伐闅忚浠诲姟 */
+    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;
       }
@@ -1078,6 +1268,7 @@
         pageNum: 1,
         pageSize: 10,
         cry: 0,
+        bedSort: null,
         searchscope: 3,
         scopetype: [],
         leaveldeptcodes: [],
@@ -1208,6 +1399,17 @@
       this.upload.open = false;
       this.dractive = 1;
     },
+    /** 鎮h�呭缓妗� */
+    handleCreateArchive() {
+      if (this.ids.length === 0) {
+        this.$modal.msgWarning("璇疯嚦灏戦�変腑1鍚嶆偅鑰�");
+        return;
+      }
+      this.archivePatients = this.userList.filter((item) =>
+        this.ids.includes(item.patid)
+      );
+      this.archiveDialogVisible = true;
+    },
   },
 };
 </script>

--
Gitblit v1.9.3