273 lines
8.7 KiB
Vue
Raw Normal View History

2025-11-06 18:22:18 +08:00
<template>
2025-11-07 17:50:06 +08:00
<!-- 危急值特定判断条件 -->
2025-12-12 15:49:03 +08:00
<el-dialog title="危急值特定判断条件" width="700px" v-model="visible" :close-on-click-modal="false" :draggable="true"
@open="onOpen" @close="onClose">
2025-11-07 17:50:06 +08:00
<el-row class="row-up">
<div class="top-button">
<el-button type="primary" @click="bClickAdd">增加</el-button>
<el-button type="primary" @click="bClickDel">删除</el-button>
<el-button type="primary" @click="bClickSave">保存</el-button>
</div>
<CustomTable ref="tableRefs" :data="tableDataUp" :columns="columnsUp" :config="tableConfigUp"
2025-12-12 15:49:03 +08:00
@row-click="rowHandleUp" :enableColumnDrag="true" @column-drag-end="handleColumnDragEnd">
<template #samplecondition="{ row }">
<el-input v-model="row.samplecondition" class="full-width-input"></el-input>
</template>
<template #resultcondition="{ row }">
<el-input v-model="row.resultcondition" class="full-width-input"></el-input>
</template>
2025-11-07 17:50:06 +08:00
</CustomTable>
</el-row>
<el-row class="row-down">
<el-col :span="12">
2025-12-16 17:54:51 +08:00
<el-input v-model="searchKey" ref="searchInput" size="small" placeholder="快速搜索(支持简拼)" class="mb5" clearable
@clear="filterDataHandle" @input="filterDataHandle" />
2025-12-17 17:32:10 +08:00
<CustomVxeTable ref="tableRefs" :data="filterData" :columns="columnsDown" class="mytable-style"
2025-12-16 17:54:51 +08:00
:scrollYConfig="{ enabled: true, rSize: 30, height: '380', }" @current-change="rowHandleDown"
2025-12-12 15:49:03 +08:00
:enableColumnDrag="true" @column-drag-end="handleColumnDragEnd" />
2025-11-07 17:50:06 +08:00
</el-col>
<el-col :span="12" class="rigth-col">
<el-button type="primary" @click="bClickDept" size="small">科室</el-button>
<el-button type="primary" @click="bClickDiag" size="small">诊断</el-button>
<el-button type="primary" @click="bClickPre" size="small">初报</el-button>
<el-button type="primary" @click="bClickResult" size="small">结果</el-button>
<el-button type="primary" @click="bClickSample" size="small">样本状态</el-button>
2025-12-12 15:49:03 +08:00
<h4>1公式举例:科室诊断条件:[科室] = '血液科' or [诊断] ='白血病' 当前结果判断条件:[结果] &gt; 20 or [结果] &lt;2 or [结果] ='阳性'</h4>
<h4>2公式举例:科室诊断条件(其他项目代号如):[WBC] = '阳性' or [WBC] &gt; 20 or [WBC] &lt;20 当前结果判断条件: [结果] &gt; 20 or [结果] &lt;2
</h4>
<h4>3公式举例:只发一次危急值病人条件:[初报] = 'brdh' and [初报] = 'brxm' 当前结果判断条件:[结果] &gt; 20 or [结果] &lt;2 or [结果] ='阳性'</h4>
2025-11-07 17:50:06 +08:00
<h4>只要符合科室或诊断条件的,就不会再断默认的危机值标准了</h4>
<h4>注意科室用中文,结果如果是字符型用单引号引起来</h4>
</el-col>
</el-row>
</el-dialog>
2025-11-06 18:22:18 +08:00
</template>
<script setup lang="ts">
import CustomTable from '@/components/elTable/index.vue'
2025-12-17 17:32:10 +08:00
import CustomVxeTable from '@/components/vxeTable/index.vue'
2025-12-12 15:49:03 +08:00
import { queryXmInfoNew, queryXmAlarmdetailNew, addXmAlarmdetailNew, delXmAlarmdetailNew } from '@/api/liswork/labItem/labItemApi'
import { XmAlarmdetailNew } from '@/types'
import { ElMessageBox, ElMessage } from 'element-plus'
2025-12-16 17:54:51 +08:00
import { getFirstLetter } from '@/utils/pinyin';
2025-11-06 18:22:18 +08:00
const columnsUp = ref([
2025-12-12 15:49:03 +08:00
{ prop: 'seq', label: '序号', align: 'center', visible: true, width: 50 },
{ prop: 'samplecondition', label: '科室或诊断条件', align: 'center', visible: true, slot: 'samplecondition', width: 300 },
{ prop: 'resultcondition', label: '结果判断条件', align: 'center', visible: true, slot: 'resultcondition', width: 300 }
2025-11-06 18:22:18 +08:00
])
const columnsDown = ref([
2025-12-16 17:54:51 +08:00
{ field: 'xmdh', title: '项目代号', align: 'center', width: 100, resizable: true },
{ field: 'xmmc', title: '项目名称', resizable: true }
2025-11-06 18:22:18 +08:00
])
2025-12-16 17:54:51 +08:00
const currentIndex = ref(0)
const searchKey = ref('');
const filterData = ref<{ [key: string]: any; pinyinMap: Record<string, string> }[]>([]);
const tableData = ref()
const inputText = ref('')
const tableRefs = ref()
2025-11-07 17:50:06 +08:00
const tableDataUp = ref<Array<XmAlarmdetailNew>>([])
2025-12-16 17:54:51 +08:00
const tableDataDown = ref<{ [key: string]: any; pinyinMap: Record<string, string> }[]>([])
2025-12-12 15:49:03 +08:00
const selectRowUp = ref<XmAlarmdetailNew>({
xmid: 0,
seq: 0,
samplecondition: '',
resultcondition: ''
})
2025-11-07 17:50:06 +08:00
const visible = defineModel()
2025-12-12 15:49:03 +08:00
const props = defineProps({
formData: {
2025-11-07 17:50:06 +08:00
type: Object,
default: {}
}
})
2025-11-06 18:22:18 +08:00
// 表格配置
2025-11-07 17:50:06 +08:00
const tableConfigUp = ref(
{
// stripe: true, // 斑马纹
border: true, // 边框
height: '200', // 高度
highlightCurrentRow: true, // 高亮当前行
fit: true
}
)
2025-12-12 15:49:03 +08:00
2025-11-06 18:22:18 +08:00
2025-11-07 17:50:06 +08:00
//序号最大值
const maxXh = computed(() => {
return tableDataUp.value.length > 0 ? Math.max(...tableDataUp.value.map((item: { seq: number }) => item.seq)) : 0;
});
2025-11-06 18:22:18 +08:00
const handleColumnDragEnd = (newColumns: any) => {
columnsUp.value = newColumns.columns
2025-12-12 15:49:03 +08:00
columnsDown.value = newColumns.columns
2025-11-06 18:22:18 +08:00
}
2025-12-12 15:49:03 +08:00
const rowHandleUp = (row: any) => {
2025-11-07 17:50:06 +08:00
selectRowUp.value = row
}
2025-12-12 15:49:03 +08:00
const rowHandleDown = (row: any) => {
2025-11-07 17:50:06 +08:00
if (selectRowUp.value) {
selectRowUp.value.samplecondition += `[${row.xmdh}]`
}
}
const onOpen = async () => {
2025-12-12 15:49:03 +08:00
const res = await queryXmAlarmdetailNew(props.formData.xmid);
2025-11-07 17:50:06 +08:00
tableDataUp.value = res.data;
2025-12-12 15:49:03 +08:00
if (!tableDataDown.value.length) {
let res = await queryXmInfoNew(props.formData.xmgl);
2025-12-16 17:54:51 +08:00
tableDataDown.value = processTableData(res.data)
filterData.value = [...tableDataDown.value]
2025-12-12 15:49:03 +08:00
}
}
2025-12-16 17:54:51 +08:00
// 预处理数据:生成拼音信息
const processTableData = (data: object[]) => {
return data.map((item: any) => {
const pinyinMap: Record<string, string> = {};
// 处理label字段拼音
if (item.xmmc) {
pinyinMap.xmmc = getFirstLetter(item.xmmc).toLowerCase();
}
if (item.xmdh) {
pinyinMap.xmdh = getFirstLetter(item.xmdh).toLowerCase();
}
return { ...item, pinyinMap };
});
};
// 搜索过滤逻辑
const filterDataHandle = () => {
const key = searchKey.value.trim().toLowerCase();
if (!key) {
// 空搜索时显示全部预处理数据
filterData.value = [...tableDataDown.value];
return;
} else {
currentIndex.value = 0
}
filterData.value = tableDataDown.value.filter((item: any) => {
// 1. 原文本匹配
const matchLabel = item.xmmc?.toString().toLowerCase().includes(key);
const matchValue = item.xmdh?.toString().toLowerCase().includes(key);
// 2. 拼音匹配
const matchLabelPinyin = item.pinyinMap.xmmc?.includes(key);
const matchValuePinyin = item.pinyinMap.xmdh?.includes(key);
return matchLabel || matchValue || matchLabelPinyin || matchValuePinyin;
});
if (filterData.value.length > 0) {
tableRefs.value.setCurrentRow(filterData.value[0]);
}
};
2025-12-12 15:49:03 +08:00
const onClose = () => {
2025-12-16 17:54:51 +08:00
searchKey.value = ''
2025-12-12 15:49:03 +08:00
tableDataUp.value = []
selectRowUp.value = { xmid: 0, seq: 0, samplecondition: '', resultcondition: '' }
2025-11-07 17:50:06 +08:00
}
const bClickAdd = () => {
2025-12-12 15:49:03 +08:00
const newData: XmAlarmdetailNew = {
2025-11-07 17:50:06 +08:00
xmid: props.formData.xmid,
seq: maxXh.value + 1,
samplecondition: '',
resultcondition: ''
2025-12-12 15:49:03 +08:00
}
tableDataUp.value.push(newData);
2025-11-07 17:50:06 +08:00
}
2025-12-12 15:49:03 +08:00
const bClickDel = () => {
if (!selectRowUp.value.xmid) return ElMessage.warning('请选择要删除的行!')
ElMessageBox.confirm('是否要删除选中的数据?', '警告',
2025-11-07 17:50:06 +08:00
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
2025-12-12 15:49:03 +08:00
}).then(() => {
const xmid = selectRowUp.value.xmid
const seq = selectRowUp.value.seq
delXmAlarmdetailNew(xmid, seq).then((res: any) => {
if (res.code == 0) {
onOpen()
ElMessage.success('删除成功!')
}
})
})
2025-11-07 17:50:06 +08:00
}
2025-11-06 18:22:18 +08:00
2025-12-12 15:49:03 +08:00
const bClickSave = () => {
const flag = tableDataUp.value.every((item: XmAlarmdetailNew) => item.samplecondition && item.resultcondition)
if (!flag) return ElMessage.warning('请检查填写科室或诊断条件和结果判断条件!')
addXmAlarmdetailNew(tableDataUp.value).then((res: any) => {
if (res.code == 0) {
onOpen()
ElMessage.success('保存成功!')
}
})
2025-11-07 17:50:06 +08:00
}
const bClickDept = () => {
2025-12-12 15:49:03 +08:00
if (selectRowUp.value) {
2025-11-07 17:50:06 +08:00
selectRowUp.value.samplecondition += '[科室]'
}
}
const bClickDiag = () => {
2025-12-12 15:49:03 +08:00
if (selectRowUp.value) {
2025-11-07 17:50:06 +08:00
selectRowUp.value.samplecondition += '[诊断]'
}
2025-11-06 18:22:18 +08:00
}
2025-11-07 17:50:06 +08:00
const bClickPre = () => {
2025-12-12 15:49:03 +08:00
if (selectRowUp.value) {
2025-11-07 17:50:06 +08:00
selectRowUp.value.samplecondition += '[初报]'
}
}
2025-11-06 18:22:18 +08:00
2025-11-07 17:50:06 +08:00
//结果
const bClickResult = () => {
2025-12-12 15:49:03 +08:00
if (selectRowUp.value) {
2025-11-07 17:50:06 +08:00
selectRowUp.value.resultcondition += '[结果]'
}
2025-12-12 15:49:03 +08:00
2025-11-06 18:22:18 +08:00
}
2025-11-07 17:50:06 +08:00
const bClickSample = () => {
2025-12-12 15:49:03 +08:00
if (selectRowUp.value) {
2025-11-07 17:50:06 +08:00
selectRowUp.value.samplecondition += '[样本状态]'
}
}
2025-11-06 18:22:18 +08:00
</script>
<style scoped lang="scss">
2025-11-07 17:50:06 +08:00
.row-up {
margin-bottom: 5px;
}
.top-button {
margin-bottom: 5px;
}
.row-down {
.rigth-col {
padding-left: 10px;
}
}
2025-11-06 18:22:18 +08:00
</style>