提交merge1.3
This commit is contained in:
@@ -1,148 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<div>
|
||||
<el-input placeholder="住院号/姓名">
|
||||
<template #append>
|
||||
<el-button icon="Search" @click="getPatientList" />
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
<el-tree
|
||||
ref="treeRef"
|
||||
:load="loadNode"
|
||||
lazy
|
||||
show-checkbox
|
||||
node-key="id"
|
||||
default-expand-all
|
||||
:props="{ label: 'name', children: 'children' }"
|
||||
@node-click="handleNodeClick"
|
||||
@check="handleCheckChange"
|
||||
@node-expand="onNodeExpand"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<div class="custom-tree-node" v-if="node.level === 2">
|
||||
<span>{{ data.bedName + ' / ' + node.label }}</span>
|
||||
<span class="tree-node-actions">
|
||||
{{ data.genderEnum_enumText + ' / ' + data.age }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-tree>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { getPatientList, getWardList } from './api';
|
||||
import { updatePatientInfoList } from '../store/patient';
|
||||
import { nextTick, onMounted } from 'vue';
|
||||
|
||||
const treeRef = ref(null);
|
||||
const allNodesLoaded = ref(false);
|
||||
// 树节点加载完成后的回调
|
||||
function onTreeLoaded() {
|
||||
if (!allNodesLoaded.value && treeRef.value) {
|
||||
// 等待DOM更新后设置全选
|
||||
nextTick(() => {
|
||||
// 获取所有节点并设置为选中状态
|
||||
const allNodes = getAllNodes(treeRef.value.store.root.childNodes);
|
||||
const allKeys = allNodes.map((node) => node.key);
|
||||
|
||||
treeRef.value.setCheckedKeys(allKeys, true); // 第二个参数设为true表示级联选中
|
||||
allNodesLoaded.value = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 递归获取所有节点
|
||||
function getAllNodes(nodes) {
|
||||
let result = [];
|
||||
if (nodes && nodes.length > 0) {
|
||||
nodes.forEach((node) => {
|
||||
result.push(node);
|
||||
if (node.childNodes && node.childNodes.length > 0) {
|
||||
result = result.concat(getAllNodes(node.childNodes));
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function loadNode(node, resolve) {
|
||||
// 初始加载:获取所有病区(父级节点)
|
||||
if (node.level === 0) {
|
||||
getWardList().then((res) => {
|
||||
// 确保病区节点不是叶子节点
|
||||
const wards = res.map((ward) => ({
|
||||
...ward,
|
||||
leaf: false,
|
||||
}));
|
||||
return resolve(wards);
|
||||
});
|
||||
}
|
||||
// 展开病区节点时:获取该病区下的患者列表
|
||||
else if (node.level === 1) {
|
||||
const wardId = node.data.id;
|
||||
getPatientList({ wardId: wardId }).then((res) => {
|
||||
let children = res.data.records.map((item) => {
|
||||
return {
|
||||
leaf: true, // 患者节点为叶子节点
|
||||
...item,
|
||||
name: item.patientName,
|
||||
};
|
||||
});
|
||||
return resolve(children);
|
||||
});
|
||||
}
|
||||
// 更深层级直接返回空数组
|
||||
else {
|
||||
return resolve([]);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取所有选中的子节点(叶子节点)
|
||||
function getCheckedLeafNodes() {
|
||||
if (!treeRef.value) return [];
|
||||
|
||||
// 获取所有选中的节点key
|
||||
const checkedKeys = treeRef.value.getCheckedKeys();
|
||||
// 获取所有半选中的节点key(父节点)
|
||||
const halfCheckedKeys = treeRef.value.getHalfCheckedKeys();
|
||||
|
||||
// 获取所有选中的节点数据
|
||||
const checkedNodes = treeRef.value.getCheckedNodes();
|
||||
|
||||
// 只返回叶子节点(患者节点)
|
||||
return checkedNodes.filter((node) => node.leaf === true);
|
||||
}
|
||||
|
||||
// 处理节点选中状态变化
|
||||
function handleCheckChange(data, checked) {
|
||||
// 可以在这里处理选中状态变化的逻辑
|
||||
let list = getCheckedLeafNodes();
|
||||
console.log(list, '2345678');
|
||||
|
||||
updatePatientInfoList(list);
|
||||
handleGetPrescription()
|
||||
}
|
||||
const handleGetPrescription = inject('handleGetPrescription')
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.custom-tree-node {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tree-node-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
:deep(.el-tree-node__content) {
|
||||
height: 35px;
|
||||
}
|
||||
</style>
|
||||
@@ -29,6 +29,15 @@
|
||||
</el-button>
|
||||
</div>
|
||||
<div>
|
||||
<span class="descriptions-item-label">实际执行时间:</span>
|
||||
<el-date-picker
|
||||
v-model="exeDate"
|
||||
type="datetime"
|
||||
format="YYYY/MM/DD HH:mm:ss"
|
||||
value-format="YYYY/MM/DD HH:mm:ss"
|
||||
:clearable="false"
|
||||
@change="handleGetPrescription"
|
||||
/>
|
||||
<span class="descriptions-item-label">全选:</span>
|
||||
<el-switch v-model="chooseAll" @change="handelSwicthChange" />
|
||||
<el-button
|
||||
@@ -139,6 +148,8 @@
|
||||
border
|
||||
:ref="'tableRef' + index"
|
||||
:header-cell-style="{ background: '#eef9fd !important' }"
|
||||
@select="(selection, row) => handleRowSelect(selection, row, index)"
|
||||
@select-all="(selection) => handleSelectAll(selection, index)"
|
||||
>
|
||||
<el-table-column type="selection" align="center" width="50" />
|
||||
<el-table-column label="类型" align="center" prop="therapyEnum_enumText" width="80">
|
||||
@@ -173,7 +184,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="开始/终止" prop="requestTime" width="200" />
|
||||
<el-table-column label="预计执行" prop="times">
|
||||
<el-table-column :label="props.exeStatus == 1 ? '预计执行' : '执行时间'" prop="times">
|
||||
<template #default="scope">
|
||||
<div
|
||||
v-for="(item, timeIndex) in scope.row.times"
|
||||
@@ -215,13 +226,19 @@
|
||||
|
||||
<script setup>
|
||||
import { getPrescriptionList, adviceExecute, adviceCancel, adviceNoExecute } from './api';
|
||||
<<<<<<< HEAD
|
||||
import { patientInfoList } from '../store/patient.js';
|
||||
=======
|
||||
import { patientInfoList } from '../../components/store/patient.js';
|
||||
import { lotNumberMatch } from '@/api/public';
|
||||
>>>>>>> v1.3
|
||||
import { formatDate, formatDateStr } from '@/utils/index';
|
||||
import { ref, getCurrentInstance } from 'vue';
|
||||
import { ref, getCurrentInstance, nextTick } from 'vue';
|
||||
|
||||
const activeNames = ref([]);
|
||||
const prescriptionList = ref([]);
|
||||
const deadline = ref(formatDateStr(new Date(), 'YYYY-MM-DD') + ' 23:59:59');
|
||||
const exeDate = ref(formatDateStr(new Date(), 'YYYY-MM-DD') + ' 23:59:59');
|
||||
const therapyEnum = ref(undefined);
|
||||
const { proxy } = getCurrentInstance();
|
||||
const loading = ref(false);
|
||||
@@ -392,6 +409,10 @@ function handleGetPrescription() {
|
||||
// 将分组结果转换为数组形式
|
||||
prescriptionList.value = Object.values(groupedPrescriptions);
|
||||
loading.value = false;
|
||||
// 默认选中全部行
|
||||
nextTick(() => {
|
||||
defaultSelectAllRows();
|
||||
});
|
||||
// } catch {
|
||||
// loading.value = false;
|
||||
// }
|
||||
@@ -406,6 +427,7 @@ function handleGetPrescription() {
|
||||
// 执行
|
||||
function handleExecute() {
|
||||
let list = getSelectRows();
|
||||
let encounterIds = patientInfoList.value.map((i) => i.encounterId).join(',');
|
||||
list = list.map((item) => {
|
||||
return {
|
||||
requestId: item.requestId,
|
||||
@@ -415,13 +437,35 @@ function handleExecute() {
|
||||
};
|
||||
});
|
||||
console.log(list, 'list');
|
||||
adviceExecute({ adviceExecuteDetailList: list }).then((res) => {
|
||||
adviceExecute({ exeDate: exeDate.value, adviceExecuteDetailList: list }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
handleGetPrescription();
|
||||
lotNumberMatch({ encounterIdList: encounterIds });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 不执行
|
||||
function handleNoExecute() {
|
||||
let list = getSelectRows();
|
||||
list = list.map((item) => {
|
||||
return {
|
||||
requestId: item.requestId,
|
||||
encounterId: item.encounterId,
|
||||
patientId: item.patientId,
|
||||
adviceTable: item.adviceTable,
|
||||
executeTimes: item.executeTimes,
|
||||
};
|
||||
});
|
||||
console.log(list, 'list');
|
||||
adviceNoExecute({ adviceExecuteDetailList: list }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
handleGetPrescription();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
// 不执行
|
||||
function handleNoExecute() {
|
||||
let list = getSelectRows();
|
||||
@@ -456,6 +500,22 @@ function handleCancel() {
|
||||
})
|
||||
);
|
||||
});
|
||||
=======
|
||||
// 取消执行
|
||||
function handleCancel() {
|
||||
let list = getSelectRows();
|
||||
let producerIds = [];
|
||||
list.forEach((item) => {
|
||||
producerIds.push(
|
||||
...item.procedureIds.map((value) => {
|
||||
return {
|
||||
procedureId: value,
|
||||
therapyEnum: item.therapyEnum,
|
||||
};
|
||||
})
|
||||
);
|
||||
});
|
||||
>>>>>>> v1.3
|
||||
adviceCancel({ adviceExecuteDetailList: producerIds }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
handleGetPrescription();
|
||||
@@ -504,6 +564,7 @@ function getDateRange(startDate, endDate) {
|
||||
|
||||
function handleRateChange(value, date, time, row, rateItem) {
|
||||
// 拼接当前选中时间
|
||||
<<<<<<< HEAD
|
||||
let tiemStr = row.year + '-' + date + ' ' + time + ':00';
|
||||
let index = row.executeTimes.indexOf(tiemStr);
|
||||
debugger;
|
||||
@@ -514,14 +575,215 @@ function handleRateChange(value, date, time, row, rateItem) {
|
||||
row.executeTimes.splice(row.executeTimes.indexOf(tiemStr), 1);
|
||||
row.procedureIds.splice(row.executeTimes.indexOf(rateItem.producerId), 1);
|
||||
}
|
||||
=======
|
||||
let timeStr = row.year + '-' + date + ' ' + time + ':00';
|
||||
let timeIndex = row.executeTimes.indexOf(timeStr);
|
||||
|
||||
if (value) {
|
||||
// 选中checkbox:如果时间不在执行时间列表中,则添加
|
||||
if (timeIndex === -1) {
|
||||
row.executeTimes.push(timeStr);
|
||||
}
|
||||
// 如果有procedureId,添加到列表中
|
||||
if (rateItem.procedureId && !row.procedureIds.includes(rateItem.procedureId)) {
|
||||
row.procedureIds.push(rateItem.procedureId);
|
||||
}
|
||||
} else {
|
||||
// 取消选中checkbox:从执行时间列表中移除
|
||||
if (timeIndex !== -1) {
|
||||
row.executeTimes.splice(timeIndex, 1);
|
||||
}
|
||||
// 移除对应的procedureId
|
||||
if (rateItem.procedureId) {
|
||||
const procedureIndex = row.procedureIds.indexOf(rateItem.procedureId);
|
||||
if (procedureIndex !== -1) {
|
||||
row.procedureIds.splice(procedureIndex, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查该行所有checkbox是否全部选中,联动表格行选中状态
|
||||
nextTick(() => {
|
||||
checkAndToggleRowSelection(row);
|
||||
});
|
||||
>>>>>>> v1.3
|
||||
}
|
||||
|
||||
function handelSwicthChange(value) {
|
||||
prescriptionList.value.forEach((item, index) => {
|
||||
proxy.$refs['tableRef' + index][0].toggleAllSelection();
|
||||
const tableRef = proxy.$refs['tableRef' + index];
|
||||
if (tableRef && tableRef[0]) {
|
||||
if (value) {
|
||||
// 全选:选中所有行并联动checkbox
|
||||
item.forEach((row) => {
|
||||
tableRef[0].toggleRowSelection(row, true);
|
||||
selectAllCheckboxesInRow(row);
|
||||
});
|
||||
} else {
|
||||
// 取消全选:取消选中所有行并联动checkbox
|
||||
item.forEach((row) => {
|
||||
tableRef[0].toggleRowSelection(row, false);
|
||||
unselectAllCheckboxesInRow(row);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 默认选中全部行
|
||||
function defaultSelectAllRows() {
|
||||
prescriptionList.value.forEach((item, index) => {
|
||||
const tableRef = proxy.$refs['tableRef' + index];
|
||||
if (tableRef && tableRef[0]) {
|
||||
// 选中该表格的所有行
|
||||
item.forEach((row) => {
|
||||
tableRef[0].toggleRowSelection(row, true);
|
||||
// 同时选中该行内部的所有checkbox
|
||||
selectAllCheckboxesInRow(row);
|
||||
});
|
||||
}
|
||||
});
|
||||
// 更新全选开关状态
|
||||
chooseAll.value = true;
|
||||
}
|
||||
|
||||
// 选中行内部的所有checkbox
|
||||
function selectAllCheckboxesInRow(row) {
|
||||
if (!row.times || !row.rate) return;
|
||||
|
||||
// 遍历所有时间点,选中所有checkbox
|
||||
row.times.forEach((time, timeIndex) => {
|
||||
const rateItems = row.rate[time] || [];
|
||||
if (rateItems.length > 0) {
|
||||
// 获取该时间点的所有rate值
|
||||
const allRates = rateItems.map((item) => item.rate);
|
||||
// 设置为全选
|
||||
row.checkedRates[timeIndex] = [...allRates];
|
||||
|
||||
// 更新执行时间列表
|
||||
allRates.forEach((rate) => {
|
||||
const timeStr = row.year + '-' + time + ' ' + rate + ':00';
|
||||
if (!row.executeTimes.includes(timeStr)) {
|
||||
row.executeTimes.push(timeStr);
|
||||
}
|
||||
// 添加procedureId
|
||||
const rateItem = rateItems.find((item) => item.rate === rate);
|
||||
if (rateItem && rateItem.procedureId && !row.procedureIds.includes(rateItem.procedureId)) {
|
||||
row.procedureIds.push(rateItem.procedureId);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 取消选中行内部的所有checkbox
|
||||
function unselectAllCheckboxesInRow(row) {
|
||||
if (!row.times) return;
|
||||
|
||||
// 清空所有checkbox选中状态
|
||||
row.times.forEach((time, timeIndex) => {
|
||||
row.checkedRates[timeIndex] = [];
|
||||
});
|
||||
|
||||
// 清空执行时间列表和procedureIds
|
||||
row.executeTimes = [];
|
||||
row.procedureIds = [];
|
||||
}
|
||||
|
||||
// 检查行内部所有checkbox是否全部选中
|
||||
function isAllCheckboxesSelected(row) {
|
||||
if (!row.times || !row.rate) return false;
|
||||
|
||||
// 遍历所有时间点,检查是否全部选中
|
||||
for (let timeIndex = 0; timeIndex < row.times.length; timeIndex++) {
|
||||
const time = row.times[timeIndex];
|
||||
const rateItems = row.rate[time] || [];
|
||||
const checkedRates = row.checkedRates[timeIndex] || [];
|
||||
|
||||
// 如果该时间点的checkbox没有全部选中,返回false
|
||||
if (rateItems.length > 0 && checkedRates.length !== rateItems.length) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 检查并联动表格行选中状态
|
||||
function checkAndToggleRowSelection(row) {
|
||||
prescriptionList.value.forEach((item, tableIndex) => {
|
||||
const rowIndex = item.findIndex((r) => r.requestId === row.requestId);
|
||||
if (rowIndex !== -1) {
|
||||
const tableRef = proxy.$refs['tableRef' + tableIndex];
|
||||
if (tableRef && tableRef[0]) {
|
||||
const isAllSelected = isAllCheckboxesSelected(row);
|
||||
const selectedRows = tableRef[0].getSelectionRows();
|
||||
const isCurrentlySelected = selectedRows.some((r) => r.requestId === row.requestId);
|
||||
|
||||
// 根据checkbox状态更新表格行选中状态
|
||||
if (isAllSelected && !isCurrentlySelected) {
|
||||
tableRef[0].toggleRowSelection(row, true);
|
||||
} else if (!isAllSelected && isCurrentlySelected) {
|
||||
tableRef[0].toggleRowSelection(row, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 处理表格行选中事件
|
||||
function handleRowSelect(selection, row, tableIndex) {
|
||||
const isSelected = selection.some((item) => item.requestId === row.requestId);
|
||||
|
||||
if (isSelected) {
|
||||
// 选中行时,选中该行内部的所有checkbox
|
||||
selectAllCheckboxesInRow(row);
|
||||
} else {
|
||||
// 取消选中行时,取消选中该行内部的所有checkbox
|
||||
unselectAllCheckboxesInRow(row);
|
||||
}
|
||||
|
||||
// 更新全选开关状态
|
||||
updateChooseAllStatus();
|
||||
}
|
||||
|
||||
// 处理表格全选事件
|
||||
function handleSelectAll(selection, tableIndex) {
|
||||
const tableData = prescriptionList.value[tableIndex];
|
||||
if (!tableData) return;
|
||||
|
||||
if (selection.length > 0) {
|
||||
// 全选时,选中所有行内部的所有checkbox
|
||||
tableData.forEach((row) => {
|
||||
selectAllCheckboxesInRow(row);
|
||||
});
|
||||
} else {
|
||||
// 取消全选时,取消选中所有行内部的所有checkbox
|
||||
tableData.forEach((row) => {
|
||||
unselectAllCheckboxesInRow(row);
|
||||
});
|
||||
}
|
||||
|
||||
// 更新全选开关状态
|
||||
updateChooseAllStatus();
|
||||
}
|
||||
|
||||
// 更新全选开关状态
|
||||
function updateChooseAllStatus() {
|
||||
let allSelected = true;
|
||||
prescriptionList.value.forEach((item, index) => {
|
||||
const tableRef = proxy.$refs['tableRef' + index];
|
||||
if (tableRef && tableRef[0]) {
|
||||
const selectedRows = tableRef[0].getSelectionRows();
|
||||
if (selectedRows.length !== item.length) {
|
||||
allSelected = false;
|
||||
}
|
||||
} else {
|
||||
allSelected = false;
|
||||
}
|
||||
});
|
||||
chooseAll.value = allSelected;
|
||||
}
|
||||
|
||||
// 处理后端返回的时间集合
|
||||
function handleTime() {}
|
||||
|
||||
|
||||
@@ -22,9 +22,11 @@
|
||||
<el-tab-pane label="在科" name="first" style="padding: 15px 10px">
|
||||
<PatientList />
|
||||
</el-tab-pane>
|
||||
<!-- 隐藏转科tab
|
||||
<el-tab-pane label="转科" name="second" style="padding: 0 10px">
|
||||
<PatientList />
|
||||
</el-tab-pane>
|
||||
-->
|
||||
</el-tabs>
|
||||
</div>
|
||||
<div style="width: 100%">
|
||||
@@ -50,7 +52,7 @@
|
||||
|
||||
<script setup>
|
||||
import { getCurrentInstance } from 'vue';
|
||||
import PatientList from './components/patientList.vue';
|
||||
import PatientList from '../components/patientList.vue';
|
||||
import PrescriptionList from './components/prescriptionList.vue';
|
||||
|
||||
const activeName = ref('preparation');
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
// 选择患者信息
|
||||
export const patientInfo = ref()
|
||||
export function updatePatientInfo(info) {
|
||||
patientInfo.value = info
|
||||
}
|
||||
|
||||
// 多选患者
|
||||
export const patientInfoList = ref([])
|
||||
export function updatePatientInfoList(info) {
|
||||
patientInfoList.value = info
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user