WXL (wul)
12 小时以前 055c1f8a3ff936b777e625dcb782edf2ccfb0f59
src/views/patient/patient/hospital.vue
@@ -121,6 +121,18 @@
          </el-col> -->
          <el-col :span="1.5">
            <el-button
              type="warning"
              plain
              icon="el-icon-plus"
              size="medium"
              :disabled="multiple"
              @click="handleBatchAddTask"
            >
              添加延续护理任务
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              plain
              icon="el-icon-delete"
@@ -323,7 +335,172 @@
        />
      </el-col>
    </el-row>
    <!-- 批量添加任务弹窗 -->
    <!-- 批量添加延续护理任务弹窗 -->
    <el-dialog
      title="批量添加延续护理"
      :visible.sync="batchTaskVisible"
      width="90%"
      append-to-body
      class="batch-dialog"
      :close-on-click-modal="false"
    >
      <el-row :gutter="20">
        <!-- 左侧:选中患者列表 -->
        <el-col :span="12">
          <div class="batch-patient-section">
            <div class="section-header">
              <h4>选中患者</h4>
              <span class="patient-count">{{ selectedPatients.length }}人</span>
            </div>
            <el-table
              :data="selectedPatients"
              border
              style="width: 100%"
              size="small"
              :row-class-name="tableRowClassName"
              :header-cell-style="{ background: '#F5F7FA', color: '#606266' }"
            >
              <el-table-column
                prop="patname"
                label="姓名"
                width="100"
                align="center"
              />
              <el-table-column
                prop="sex"
                label="性别"
                width="80"
                align="center"
              >
                <template slot-scope="scope">
                  <el-tag
                    size="small"
                    :type="scope.row.sex === 1 ? 'primary' : 'danger'"
                  >
                    {{ scope.row.sex === 1 ? "男" : "女" }}
                  </el-tag>
                </template>
              </el-table-column>
              <el-table-column
                label="入院时间"
                align="center"
                key="starttime"
                prop="starttime"
                width="120"
              >
                <template slot-scope="scope">
                  <span class="time-text">{{
                    formatTime(scope.row.starttime)
                  }}</span>
                </template>
              </el-table-column>
              <el-table-column
                prop="inhospno"
                label="住院号"
                width="120"
                align="center"
              />
              <el-table-column prop="deptname" label="科室" align="center" />
              <el-table-column
                prop="leavehospitaldistrictname"
                label="病区"
                align="center"
              />
            </el-table>
          </div>
        </el-col>
        <!-- 右侧:任务列表 -->
        <el-col :span="12">
          <div class="batch-task-section">
            <div class="section-header">
              <h4>延续护理任务</h4>
              <div v-if="selectedTask" class="task-selected-hint selected">
                <i class="el-icon-success"></i>
                <span>已选择:{{ selectedTask.taskName }}</span>
              </div>
              <div v-else class="task-selected-hint">
                <i class="el-icon-info"></i>
                <span>请点击选择一个任务</span>
              </div>
            </div>
            <el-table
              :data="taskList"
              border
               height="680"
              style="width: 100%"
              size="small"
              @current-change="handleTaskSelectionChange"
              highlight-current-row
              :row-class-name="taskRowClassName"
              :header-cell-style="{ background: '#F5F7FA', color: '#606266' }"
              :current-row-key="selectedTask ? selectedTask.taskid : ''"
            >
              <el-table-column
                label="任务名称"
                fixed
                align="center"
                key="taskName"
                prop="taskName"
                :show-overflow-tooltip="true"
                width="180"
              />
              <el-table-column
                label="服务项目"
                align="center"
                key="templatename"
                prop="templatename"
                :show-overflow-tooltip="true"
              />
              <el-table-column
                label="创建人"
                align="center"
                key="createBy"
                prop="createBy"
                :show-overflow-tooltip="true"
              />
              <el-table-column
                label="创建时间"
                sortable
                align="center"
                prop="createTime"
              >
                <template slot-scope="scope">
                  <span class="time-text">{{
                    formatTime(scope.row.createTime)
                  }}</span>
                </template>
              </el-table-column>
              <template #empty>
                <div class="empty-message">
                  <i class="el-icon-document"></i>
                  <span>暂无可用延续护理任务</span>
                  <span class="empty-tips">请联系管理员创建任务</span>
                </div>
              </template>
            </el-table>
          </div>
        </el-col>
      </el-row>
      <!-- 底部按钮 -->
      <div slot="footer" class="dialog-footer">
        <el-button @click="batchTaskVisible = false" :disabled="batchLoading"
          >取 消</el-button
        >
        <el-button
          type="primary"
          :loading="batchLoading"
          @click="submitBatchTask"
          :disabled="!selectedTask || batchLoading"
        >
          {{ batchLoading ? "创建中..." : "创建延续护理任务" }}
        </el-button>
      </div>
    </el-dialog>
    <!-- 用户导入对话框 -->
    <el-dialog
      :title="upload.title"
@@ -435,7 +612,7 @@
import Treeselect from "@riophae/vue-treeselect";
import { listDept } from "@/api/system/dept";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { query360PatInfo } from "@/api/AiCentre/index";
import { query360PatInfo, getTasklist, addSubtask } from "@/api/AiCentre/index";
import store from "@/store";
@@ -470,6 +647,12 @@
      // 默认密码
      initPassword: undefined,
      amendtag: false, //是否修改
      // 批量任务相关数据
      batchTaskVisible: false, // 弹窗可见性
      selectedPatients: [], // 选中的患者列表
      taskList: [], // 任务列表
      selectedTask: null, // 选中的任务
      batchLoading: false, // 批量提交加载状态
      // 日期范围
      dateRange: [],
      source: [
@@ -511,8 +694,8 @@
          YongHuXX: {
            XiTongID: "SUIFANGXT",
            XiTongMC: "随访系统",
            YongHuID: "1400466972205912064",
            YongHuXM: "JNRMYY",
            YongHuID: localStorage.getItem("YongHuID"),
            YongHuXM: localStorage.getItem("YongHuXM"),
            ZuZhiJGID: localStorage.getItem("orgid"),
            ZuZhiJGMC: localStorage.getItem("orgname"),
            idp: "lyra",
@@ -630,6 +813,9 @@
    this.queryParams.leaveldeptcodes = store.getters.belongDepts.map(
      (obj) => obj.deptCode
    );
    this.queryParams.leavehospitaldistrictcodes = store.getters.belongWards.map(
      (obj) => obj.districtCode
    );
    this.getList();
    // this.listDept();
    this.gettabList();
@@ -653,13 +839,10 @@
    },
    //患者360跳转
    gettoken360(sfzh, drcode, drname) {
      this.$modal.msgWarning('360功能暂未开通');
  return; // 阻止后续代码执行
      // this.$modal.msgWarning('360功能暂未开通');
      this.postData.YeWuXX.BingRenXX.ZhengJianHM = sfzh;
      if (this.postData.XiaoXiTou.ZuHuMC == "丽水市中医院") {
        this.postData.YeWuXX.YongHuXX.YongHuID = "1400398571877961728";
        this.postData.YeWuXX.YongHuXX.YongHuXM = "LSZYY";
      }
      query360PatInfo(this.postData).then((res) => {
        if (res.data.url) {
          window.open(res.data.url, "_blank");
@@ -668,6 +851,162 @@
          this.$modal.msgWarning("360查询无结果");
        }
      });
    },
    /** 批量添加任务按钮点击 */
    handleBatchAddTask() {
      // 校验是否选中患者
      if (this.ids.length === 0) {
        this.$modal.msgWarning("请至少选中1名患者");
        return;
      }
      // 获取选中患者的科室信息
      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.selectedPatients = this.userList.filter((item) =>
        this.ids.includes(item.patid)
      );
      // 显示弹窗
      this.batchTaskVisible = true;
      // 获取任务列表
      this.loadTaskList(deptcode);
    },
    /** 表格行样式 */
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 === 0) {
        return "even-row";
      } else {
        return "odd-row";
      }
    },
    /** 任务表格行样式 */
    taskRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 === 0) {
        return "task-even-row";
      } else {
        return "task-odd-row";
      }
    },
    /** 加载任务列表 */
    loadTaskList(deptcode) {
      this.batchLoading = true;
      let topqueryParams = {
        pageNum: 1,
        pageSize: 100, // 设置较大的分页获取更多任务
        type: 2, // 根据实际情况调整
      };
      getTasklist(topqueryParams)
        .then((response) => {
          this.taskList = response.rows;
          this.batchLoading = false;
          if (this.taskList.length === 0) {
            this.$modal.msgWarning("当前科室无可用任务");
          }
        })
        .catch((error) => {
          this.$modal.msgError("获取任务列表失败:" + error.message);
          this.batchLoading = false;
        });
    },
    /** 处理任务选择变化 */
    handleTaskSelectionChange(currentRow) {
      this.selectedTask = currentRow;
    },
    /** 批量提交任务 */
    async submitBatchTask() {
      // 校验是否选中任务
      if (!this.selectedTask) {
        this.$modal.msgWarning("请选择1个任务");
        return;
      }
      this.batchLoading = true;
      const successPatients = [];
      const failedPatients = [];
      const errorMessages = [];
      try {
        // 遍历选中的患者,逐个调用接口
        for (const patient of this.selectedPatients) {
          const params = {
            taskid: this.selectedTask.taskid,
            type: this.selectedTask.type,
            taskName: this.selectedTask.taskName,
            serviceType: 99,
            preachform: this.selectedTask.preachform,
            templateid: this.selectedTask.templateid,
            libtemplateid: this.selectedTask.libtemplateid,
            sendstate: 2,
            continueFlag: 2,
            ...patient,
            sendname: patient.patname,
            starttime: patient.starttime ? patient.starttime + " 00:00:00" : "",
            endtime: patient.endtime ? patient.endtime + " 00:00:00" : "",
            leavediagname: patient.leavediagname || patient.diagname || "",
            age: patient.age || "",
          };
          try {
            const response = await addSubtask(params);
            if (response.code === 200) {
              successPatients.push(patient.patname);
            } else {
              failedPatients.push(patient.patname);
              errorMessages.push(
                `${patient.patname}: ${response.msg || "添加失败"}`
              );
            }
          } catch (error) {
            failedPatients.push(patient.patname);
            errorMessages.push(
              `${patient.patname}: ${error.message || "网络错误"}`
            );
          }
        }
        // 显示处理结果
        if (failedPatients.length === 0) {
          this.$modal.msgSuccess(
            `成功为 ${successPatients.length} 名患者添加任务`
          );
        } else {
          this.$modal.msgWarning(
            `成功添加 ${successPatients.length} 人,失败 ${failedPatients.length} 人。` +
              (errorMessages.length > 0
                ? `失败原因:${errorMessages.join("; ")}`
                : "")
          );
        }
        this.batchTaskVisible = false;
        this.getList(); // 刷新患者列表
      } catch (error) {
        this.$modal.msgError("批量添加任务过程中出错:" + error.message);
      } finally {
        this.batchLoading = false;
      }
    },
    /** 格式化时间 */
    formatTime(time) {
      if (!time) return "";
      return time;
    },
    /** 查询标签列表 */
    gettabList() {
@@ -777,8 +1116,8 @@
        leavehospitaldistrictcodes: [],
      };
      this.queryParams.leaveldeptcodes = store.getters.belongDepts.map(
      (obj) => obj.deptCode
    );
        (obj) => obj.deptCode
      );
      this.handleQuery();
    },
    // 多选框选中数据
@@ -949,6 +1288,325 @@
  }
}
.button-textsc {
  color: #3664D9;
  color: #3664d9;
}
// 批量任务弹窗优化样式
.batch-dialog {
  .el-dialog__body {
    padding: 20px 20px 10px;
  }
  .el-dialog__header {
    background: linear-gradient(135deg, #5788fe, #7aa1ff);
    padding: 15px 20px;
    .el-dialog__title {
      color: white;
      font-weight: 600;
      font-size: 16px;
    }
    .el-dialog__headerbtn {
      .el-dialog__close {
        color: white;
        font-size: 18px;
        &:hover {
          color: #f0f0f0;
        }
      }
    }
  }
}
// 弹窗内容区域
.batch-patient-section,
.batch-task-section {
  h4 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
    padding-left: 8px;
    border-left: 4px solid #5788fe;
    display: flex;
    align-items: center;
    &::before {
      content: "";
      display: inline-block;
      width: 6px;
      height: 6px;
      background-color: #5788fe;
      border-radius: 50%;
      margin-right: 8px;
    }
  }
  .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    .patient-count {
      color: #5788fe;
      font-weight: 500;
      background: #f0f5ff;
      padding: 4px 12px;
      border-radius: 12px;
      font-size: 13px;
    }
  }
}
// 患者表格优化
.batch-patient-section {
  .el-table {
    border: 1px solid #e8eaec;
    border-radius: 6px;
    overflow: hidden;
    .el-table__header-wrapper {
      th {
        background-color: #f5f7fa;
        color: #606266;
        font-weight: 600;
        height: 40px;
      }
    }
    .el-table__body-wrapper {
      tr:hover > td {
        background-color: #f5f9ff;
      }
    }
  }
}
// 任务表格优化
.batch-task-section {
  .el-table {
    border: 1px solid #e8eaec;
    border-radius: 6px;
    overflow: hidden;
    .el-table__header-wrapper {
      th {
        background-color: #f5f7fa;
        color: #606266;
        font-weight: 600;
        height: 40px;
      }
    }
    .el-table__body-wrapper {
      tr {
        cursor: pointer;
        transition: all 0.3s;
        &:hover > td {
          background-color: #f5f9ff;
        }
        // 选中行样式
        &.current-row {
          td {
            background-color: #e8f1ff !important;
            border-left: 3px solid #5788fe;
            &:first-child {
              border-left: none;
            }
          }
        }
      }
      .selected-row {
        position: relative;
        &::after {
          content: "✓";
          position: absolute;
          right: 10px;
          top: 50%;
          transform: translateY(-50%);
          color: #5788fe;
          font-weight: bold;
          font-size: 16px;
        }
      }
    }
    .el-table__empty-block {
      min-height: 200px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
}
// 空状态优化
.empty-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  color: #909399;
  i {
    font-size: 48px;
    margin-bottom: 12px;
    color: #c0c4cc;
  }
  span {
    font-size: 14px;
    color: #c0c4cc;
  }
  .empty-tips {
    margin-top: 8px;
    font-size: 12px;
    color: #dcdfe6;
  }
}
// 底部按钮区域
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  padding: 20px 0 0;
  border-top: 1px solid #f0f0f0;
  margin-top: 20px;
  .el-button {
    min-width: 80px;
    height: 36px;
    border-radius: 4px;
    font-size: 14px;
    &.el-button--default {
      color: #666;
      border-color: #dcdfe6;
      &:hover {
        color: #5788fe;
        border-color: #5788fe;
        background-color: #f0f5ff;
      }
    }
    &.el-button--primary {
      background: linear-gradient(135deg, #5788fe, #7aa1ff);
      border-color: #5788fe;
      &:hover {
        background: linear-gradient(135deg, #4a7cfe, #6b94ff);
        border-color: #4a7cfe;
      }
      &:active {
        background: linear-gradient(135deg, #3d70fe, #5e87ff);
        border-color: #3d70fe;
      }
      &.is-loading {
        position: relative;
        pointer-events: none;
        &::after {
          content: "";
          position: absolute;
          right: 10px;
          top: 50%;
          transform: translateY(-50%);
          width: 16px;
          height: 16px;
          border: 2px solid transparent;
          border-top-color: white;
          border-radius: 50%;
          animation: loading-rotate 1s linear infinite;
        }
      }
    }
  }
}
// 加载动画
@keyframes loading-rotate {
  0% {
    transform: translateY(-50%) rotate(0deg);
  }
  100% {
    transform: translateY(-50%) rotate(360deg);
  }
}
// 响应式调整
@media screen and (max-width: 1200px) {
  .batch-patient-section,
  .batch-task-section {
    margin-bottom: 20px;
  }
  .el-row {
    flex-wrap: wrap;
  }
  .el-col-12 {
    width: 100%;
  }
}
// 任务列表选中提示
.task-selected-hint {
  margin-top: 8px;
  font-size: 12px;
  color: #5788fe;
  display: flex;
  align-items: center;
  i {
    margin-right: 4px;
    font-size: 14px;
  }
  &.selected {
    color: #67c23a;
  }
}
// 弹窗滚动优化
.el-dialog__wrapper {
  .el-dialog {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(87, 136, 254, 0.1);
    .el-dialog__body {
      max-height: 70vh;
      overflow-y: auto;
      &::-webkit-scrollbar {
        width: 6px;
      }
      &::-webkit-scrollbar-track {
        background: #f5f5f5;
        border-radius: 3px;
      }
      &::-webkit-scrollbar-thumb {
        background: #c0c4cc;
        border-radius: 3px;
        &:hover {
          background: #a0a4ab;
        }
      }
    }
  }
}
</style>