@@ -0,0 +1,146 @@
|
||||
<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>
|
||||
@@ -21,7 +21,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<span class="descriptions-item-label">全选:</span>
|
||||
<el-switch v-model="chooseAll" @change="handelSwitchChange" />
|
||||
<el-switch v-model="chooseAll" @change="handelSwicthChange" />
|
||||
<el-button class="ml20" type="primary" @click="handleCheck"> 核对通过 </el-button>
|
||||
<el-button class="ml20 mr20" type="danger" @click="handleCancel"> 退回 </el-button>
|
||||
</div>
|
||||
@@ -107,10 +107,8 @@
|
||||
border
|
||||
:ref="'tableRef' + index"
|
||||
:header-cell-style="{ background: '#eef9fd !important' }"
|
||||
@select="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" align="center" width="50" />
|
||||
<el-table-column label="组" align="center" width="60" prop="groupIcon" />
|
||||
<el-table-column label="类型" align="center" prop="therapyEnum_enumText" width="80">
|
||||
<template #default="scope">
|
||||
<span :style="scope.row.therapyEnum == '1' ? 'color: #a6745c' : 'color: #3787a5'">
|
||||
@@ -153,7 +151,7 @@
|
||||
</template>
|
||||
<script setup>
|
||||
import { getPrescriptionList, adviceVerify, cancel } from './api';
|
||||
import { patientInfoList } from '../../components/store/patient.js';
|
||||
import { patientInfoList } from '../store/patient.js';
|
||||
import { formatDateStr } from '@/utils/index';
|
||||
|
||||
const activeNames = ref([]);
|
||||
@@ -201,9 +199,7 @@ function handleGetPrescription() {
|
||||
// 将分组结果转换为数组形式
|
||||
prescriptionList.value = Object.values(groupedPrescriptions);
|
||||
console.log(prescriptionList.value, '1111');
|
||||
console.log('@@@@@=======>', JSON.stringify(prescriptionList.value));
|
||||
loading.value = false;
|
||||
getGroupMarkers();
|
||||
});
|
||||
chooseAll.value = false;
|
||||
} else {
|
||||
@@ -211,58 +207,6 @@ function handleGetPrescription() {
|
||||
}
|
||||
}
|
||||
|
||||
// 分组标记处理
|
||||
function getGroupMarkers() {
|
||||
// 初始化所有行的 groupIcon 为 null
|
||||
prescriptionList.value.forEach((item) => {
|
||||
item.forEach((prescription) => {
|
||||
prescription.groupIcon = null;
|
||||
});
|
||||
});
|
||||
console.log('prescriptionList====>', JSON.stringify(prescriptionList.value));
|
||||
// 创建一个映射来存储每个 groupId 对应的行索引
|
||||
const groupMap = {};
|
||||
|
||||
// 遍历处方列表,按 groupId 分组(忽略无 groupId 的项)
|
||||
prescriptionList.value.forEach((item, index) => {
|
||||
item.forEach((prescription, idnexNum) => {
|
||||
if (prescription.groupId) {
|
||||
if (!groupMap[prescription.groupId]) {
|
||||
groupMap[prescription.groupId] = [];
|
||||
}
|
||||
groupMap[prescription.groupId].push(idnexNum);
|
||||
}
|
||||
});
|
||||
});
|
||||
// 为每个组设置 groupIcon
|
||||
Object.values(groupMap).forEach((indices) => {
|
||||
// 只有当组内元素大于1个时才需要显示分组标记
|
||||
if (indices.length > 1) {
|
||||
let iconArrayIndex = 0;
|
||||
indices.forEach((index, i) => {
|
||||
prescriptionList.value.forEach((itemArray, index1) => {
|
||||
itemArray.forEach((item, index2) => {
|
||||
if (index2 === index) {
|
||||
iconArrayIndex++;
|
||||
if (iconArrayIndex == 1) {
|
||||
item.groupIcon = '┏';
|
||||
} else if (iconArrayIndex == indices.length) {
|
||||
item.groupIcon = '┗';
|
||||
} else {
|
||||
item.groupIcon = '┃';
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
console.log('prescriptionList====>', JSON.stringify(prescriptionList.value));
|
||||
}
|
||||
|
||||
// 选择框改变时的处理
|
||||
function handleSelectionChange(selection, row) {}
|
||||
|
||||
/**
|
||||
* 核对通过
|
||||
*/
|
||||
@@ -313,7 +257,7 @@ function getSelectRows() {
|
||||
});
|
||||
}
|
||||
|
||||
function handelSwitchChange(value) {
|
||||
function handelSwicthChange(value) {
|
||||
prescriptionList.value.forEach((item, index) => {
|
||||
proxy.$refs['tableRef' + index][0].toggleAllSelection();
|
||||
});
|
||||
@@ -374,4 +318,4 @@ defineExpose({
|
||||
:deep(.el-table__row:hover > td) {
|
||||
background-color: #eef9fd !important;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -18,19 +18,17 @@
|
||||
<Refresh />
|
||||
</el-icon>
|
||||
</div>
|
||||
<el-tabs v-model="active" class="centered-tabs tab-header" @tab-click="handleClick">
|
||||
<el-tabs v-model="active" class="demo-tabs centered-tabs tab-header" @tab-click="handleClick">
|
||||
<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%">
|
||||
<el-tabs v-model="activeName" class="centered-tabs" @tab-change="handleTabClick">
|
||||
<el-tabs v-model="activeName" class="demo-tabs centered-tabs" @tab-change="handleTabClick">
|
||||
<el-tab-pane
|
||||
v-for="tab in prescriptionTabs"
|
||||
:key="tab.name"
|
||||
@@ -50,7 +48,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import PatientList from '../components/patientList.vue';
|
||||
import PatientList from './components/patientList.vue';
|
||||
import PrescriptionList from './components/prescriptionList.vue';
|
||||
|
||||
const activeName = ref('unverified');
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// 选择患者信息
|
||||
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