WXL (wul)
4 天以前 5f4d48e663c47eb7390e4a1784d773d6814889ff
src/views/patient/patient/outpatient.vue
@@ -67,16 +67,16 @@
            ></el-cascader>
          </el-form-item>
          <el-form-item label="就诊日期">
              <el-date-picker
                v-model="dateRange"
                style="width: 240px"
                value-format="yyyy-MM-dd"
                type="daterange"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              ></el-date-picker>
              <!-- <el-date-picker
            <el-date-picker
              v-model="dateRange"
              style="width: 240px"
              value-format="yyyy-MM-dd"
              type="daterange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker>
            <!-- <el-date-picker
                v-model="dateRange"
                type="datetimerange"
                value-format="yyyy-MM-dd HH:mm:ss"
@@ -85,7 +85,7 @@
                :default-time="['12:00:00']"
              >
              </el-date-picker> -->
            </el-form-item>
          </el-form-item>
          <el-row>
            <!-- <el-form-item label=" 就诊日期 " prop="admitdate">
              <el-date-picker
@@ -150,6 +150,18 @@
              @click="handleDelete"
              v-hasPermi="['system:user:remove']"
              >删除</el-button
            >
          </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="19">
@@ -228,7 +240,13 @@
              <el-button
                size="medium"
                type="text"
                @click="gettoken360(scope.row.idcardno,scope.row.drcode,scope.row.drname)"
                @click="
                  gettoken360(
                    scope.row.idcardno,
                    scope.row.drcode,
                    scope.row.drname
                  )
                "
                ><span class="button-textsc">{{
                  scope.row.patname
                }}</span></el-button
@@ -337,7 +355,107 @@
        />
      </el-col>
    </el-row>
    <el-dialog
      title="批量添加任务"
      :visible.sync="batchTaskVisible"
      width="90%"
      append-to-body
    >
      <el-row :gutter="20">
        <!-- 左侧:选中患者列表 -->
        <el-col :span="12">
          <div class="batch-patient-section">
            <h4>选中患者({{ selectedPatients.length }}人)</h4>
            <el-table
              :data="selectedPatients"
              border
              style="width: 100%"
              size="small"
            >
              <el-table-column prop="patname" label="姓名" width="100" />
              <el-table-column prop="sex" label="性别" width="80">
                <template slot-scope="scope">
                  {{ scope.row.sex === 1 ? "男" : "女" }}
                </template>
              </el-table-column>
              <el-table-column
                label="就诊时间"
                align="center"
                key="admitdate"
                prop="admitdate"
              >
                <template slot-scope="scope">
                  <span>{{ formatTime(scope.row.admitdate) }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="outhospno" label="病案号" />
              <el-table-column prop="deptname" label="科室" />
            </el-table>
          </div>
        </el-col>
        <!-- 右侧:任务列表 -->
        <el-col :span="12">
          <div class="batch-task-section">
            <h4>任务列表(请选择1个任务)</h4>
            <el-table
              :data="taskList"
              border
              style="width: 100%"
              size="small"
              @current-change="handleTaskSelectionChange"
              highlight-current-row
            >
              <el-table-column
                label="任务名称"
                fixed
                align="center"
                key="taskName"
                prop="taskName"
                :show-overflow-tooltip="true"
              />
              <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>{{ formatTime(scope.row.createTime) }}</span>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-col>
      </el-row>
      <!-- 底部按钮 -->
      <div slot="footer" class="dialog-footer">
        <el-button @click="batchTaskVisible = false">取 消</el-button>
        <el-button
          type="primary"
          :loading="batchLoading"
          @click="submitBatchTask"
          >创建任务</el-button
        >
      </div>
    </el-dialog>
    <!-- 用户导入对话框 -->
    <el-dialog
      :title="upload.title"
@@ -383,6 +501,7 @@
          </div>
        </el-upload>
      </div>
      <!-- 导入检查 -->
      <div class="uploading" v-else-if="dractive == 2">
        <el-table :data="uploadingData" style="width: 100%">
@@ -446,7 +565,7 @@
import { getToken } from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
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";
@@ -509,6 +628,12 @@
      Labelchange: false, //修改新增弹窗
      propss: { multiple: true },
      optionstag: [], //标签列表
      batchTaskVisible: false, // 弹窗可见性
      selectedPatients: [], // 选中的患者列表
      taskList: [], // 任务列表
      selectedTask: null, // 选中的任务列表
      batchLoading: false, // 批量提交加载状态
      deptcode: "",
      Patientrange: [
        {
          name: "全部",
@@ -680,9 +805,9 @@
      if (this.dateRange) {
        this.queryParams.beginTime = this.dateRange[0];
        this.queryParams.endTime = this.dateRange[1];
      }else{
        this.queryParams.beginTime = '';
        this.queryParams.endTime = '';
      } else {
        this.queryParams.beginTime = "";
        this.queryParams.endTime = "";
      }
      listPatouthosp(this.queryParams).then((response) => {
        this.userList = response.rows;
@@ -733,11 +858,11 @@
      });
    },
    //患者360跳转
    gettoken360(sfzh,drcode,drname) {
    gettoken360(sfzh, drcode, drname) {
      this.postData.YeWuXX.BingRenXX.ZhengJianHM = sfzh;
      if (this.postData.XiaoXiTou.ZuHuMC=='丽水市中医院') {
        this.postData.YeWuXX.YongHuXX.YongHuID = '1400398571877961728';
        this.postData.YeWuXX.YongHuXX.YongHuXM = 'LSZYY';
      if (this.postData.XiaoXiTou.ZuHuMC == "丽水市中医院") {
        this.postData.YeWuXX.YongHuXX.YongHuID = "1400398571877961728";
        this.postData.YeWuXX.YongHuXX.YongHuXM = "LSZYY";
      }
      query360PatInfo(this.postData).then((res) => {
@@ -796,7 +921,7 @@
        leaveldeptcodes: [],
        leavehospitaldistrictcodes: [],
      };
        this.handleQuery();
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
@@ -913,6 +1038,113 @@
      this.upload.open = false;
      this.dractive = 1;
    },
    /** 批量添加任务按钮点击 */
    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;
        }
      });
      // 校验是否同一科室
      if (patientDepts.size > 1) {
        this.$modal.msgError("选中的患者不属于同一科室,无法批量添加任务");
        return;
      }
      // 获取选中患者列表
      this.selectedPatients = this.userList.filter((item) =>
        this.ids.includes(item.patid)
      );
      // 显示弹窗
      this.batchTaskVisible = true;
      // 获取任务列表
      this.loadTaskList(deptcode);
    },
    /** 加载任务列表 */
    loadTaskList(deptcode) {
      this.batchLoading = true;
      let topqueryParams = {
        pageNum: 1,
        pageSize: 10,
        serviceType: 3,
        type: 2,
        deptcode: deptcode,
      };
      getTasklist(topqueryParams).then((response) => {
        this.taskList = response.rows;
        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 = [];
      try {
        // 遍历选中的患者,逐个调用接口
        for (const patient of this.selectedPatients) {
          const params = {
            taskId: this.selectedTask.taskId,
            taskName: this.selectedTask.taskName,
            serviceType: this.selectedTask.serviceType,
            ...patient,
            age: "",
          };
          try {
            await addSubtask(params);
            successPatients.push(patient.patname);
          } catch (error) {
            failedPatients.push(patient.patname);
          }
        }
        // 显示处理结果
        let message = `成功为 ${successPatients.length} 名患者添加任务`;
        if (failedPatients.length > 0) {
          message += `,${failedPatients.length} 名患者添加失败`;
        }
        this.$modal.msgSuccess(message);
        this.batchTaskVisible = false;
        this.getList(); // 刷新患者列表
      } catch (error) {
        this.$modal.msgError("批量添加任务过程中出错");
      } finally {
        this.batchLoading = false;
      }
    },
    /** 批量添加患者任务接口 */
    batchAddPatientTask(params) {},
  },
};
</script>
@@ -963,4 +1195,41 @@
.button-textsc {
  color: #28cfe6;
}
.batch-patient-section,
.batch-task-section {
  padding: 15px;
  border: 1px solid #ebeef5;
  border-radius: 4px;
  margin-bottom: 15px;
}
.el-table--enable-row-hover .el-table__body tr:hover > td {
  background-color: #f5f7fa;
}
.el-table__body tr.current-row > td {
  background-color: #e6f7ff;
}
/* 禁用状态下按钮样式 */
.el-button.is-disabled {
  cursor: not-allowed;
}
.batch-patient-section h4,
.batch-task-section h4 {
  margin-top: 0;
  margin-bottom: 15px;
  color: #303133;
  font-size: 16px;
}
/* 表格样式优化 */
.el-table {
  margin-bottom: 10px;
}
/* 弹窗底部按钮间距 */
.dialog-footer {
  text-align: right;
  padding: 10px 20px 20px;
}
</style>