2025-12-11 18:03:51 +08:00

1074 lines
34 KiB
Vue

<template>
<div>
<div>
<el-button class="btn_green btns_box" :size="autoSize" v-if="labPat.jgbz != 2"
@click="handleCheck(2)">审核</el-button>
<el-button class="btns_box" :size="autoSize" v-if="labPat.jgbz == 2" @click="handleCheck(3)">取消审核</el-button>
<el-button class="btns_box" type="primary" :size="autoSize" plain :disabled="labPat.jgbz == 2"
@click="openItemDictDialog">新增</el-button>
<el-button class="btns_box" type="danger" :size="autoSize" :disabled="labPat.jgbz == 2" plain
@click="handleBatchDelete">删除</el-button>
<el-button class="btn_green btns_box" :size="autoSize" :disabled="labPat.jgbz == 2"
@click="zhHandel">组合项目</el-button>
</div>
<ContextMenu :items="contextMenuItems" @select="handleMenuSelect">
<CustomTable ref="tableRef" :data="tableData" :columns="columns" :config="tableConfig" :enable-column-drag="true"
@column-drag-end="handleColumnDragEnd" @row-click="rowHandle">
<template #xmdh="{ column }">
细菌/结果({{ tableData.length }})项
</template>
<template #od="{ row }">
<el-input v-model="row.od" v-if="labPat.jgbz != 2" size="small" class="full-width-input foucs-input"
@change="handleCsjgEnter(row)" />
<span v-else>{{ row.od }}</span>
</template>
<template #csjg="{ row }">
<el-input v-model="row.csjg" v-if="labPat.jgbz != 2" size="small" class="full-width-input"
@change="handleCsjgEnter(row)" @dblclick="handleInputFocus(row)" />
<span v-else>{{ row.csjg }}</span>
</template>
<template #jgbz="{ row }">
<el-select v-model="row.jgbz" class="full-width-input" v-if="labPat.jgbz != 2" placeholder=""
@change="handleCsjgEnter(row)">
<el-option label="阳性" value="P" />
<el-option label="阴性" value="N" />
</el-select>
<span v-else> {{ formatJgbz(row.jgbz) }}</span>
</template>
<template #cutoff="{ row }">
<el-input v-model="row.cutoff" v-if="labPat.jgbz != 2" size="small" class="full-width-input"
@change="handleCsjgEnter(row)" />
<span v-else>{{ row.cutoff }}</span>
</template>
<template #alarm_flag="{ row }">
<el-select v-model="row.alarm_flag" class="full-width-input" v-if="labPat.jgbz != 2" placeholder=""
@change="handleCsjgEnter(row)">
<el-option label="危急值" value="H" />
<el-option label="无" value="" />
</el-select>
<span v-else> {{ row.alarm_flag == 'H' ? '危急值' : '' }}</span>
</template>
<template #germclass="{ row }">
{{ formatDict(row.germclass, 'germclass') }}
</template>
</CustomTable>
</ContextMenu>
<div class="tabs_btns">
<el-tabs v-model="activeName2" type="card" class="tabs_box" :size="autoSize">
<el-tab-pane label="药敏结果" name="first">
<CustomTable ref="ymTableRef" :data="ymTableData" :columns="ymColumns" :config="ymTableConfig"
:enable-column-drag="true" @row-click="ymRowHandle" @column-drag-end="ymHandleColumnDragEnd">
<template #ywdhHead="{ column }">
抗生素({{ ymTableData.length }})项
</template>
<template #mic="{ row }">
<el-input v-model="row.mic" v-if="labPat.jgbz != 2" size="small" class="ymFoucs full-width-input"
@change="ymHandleEnter(row)" />
<span v-else>{{ row.mic }}</span>
</template>
<template #rad="{ row }">
<el-input v-model="row.rad" v-if="labPat.jgbz != 2" size="small" class="full-width-input"
@change="ymHandleEnter(row)" />
<span v-else>{{ row.rad }}</span>
</template>
<template #csjg="{ row }">
<el-input v-model="row.csjg" v-if="labPat.jgbz != 2" size="small" class="full-width-input"
@change="ymHandleEnter(row)" />
<span v-else>{{ row.csjg }}</span>
</template>
<template #jgbz="{ row }">
<el-radio-group v-model="row.jgbz" :disabled="labPat.jgbz != 2 ? false : true"
@change="(val: string) => { jgbzHandle(val, row) }">
<el-radio value="R">R</el-radio>
<el-radio value="I">I</el-radio>
<el-radio value="S">S</el-radio>
<el-radio value="N">N</el-radio>
<el-radio value="D">SDD</el-radio>
</el-radio-group>
</template>
<template #bz="{ row }">
<el-input v-model="row.bz" v-if="labPat.jgbz != 2" size="small" class="full-width-input"
@change="ymHandleEnter(row)" />
<span v-else>{{ row.bz }}</span>
</template>
<template #txtresult="{ row }">
<el-input v-model="row.txtresult" v-if="labPat.jgbz != 2" size="small" class="full-width-input"
@change="ymHandleEnter(row)" />
<span v-else>{{ row.txtresult }}</span>
</template>
<template #cp_bz="{ row }">
<el-input v-model="row.cp_bz" v-if="labPat.jgbz != 2" size="small" class="full-width-input"
@change="ymHandleEnter(row)" />
<span v-else>{{ row.cp_bz }}</span>
</template>
</CustomTable>
</el-tab-pane>
<el-tab-pane label="专家评语" name="second">
<el-input v-model="textarea" style="width: 100%" :rows="20" type="textarea" />
</el-tab-pane>
</el-tabs>
<div class="btns anchor">
<template v-if="activeName2 == 'first'">
<el-button class="btns_box" type="primary" :size="autoSize" plain :disabled="labPat.jgbz == 2"
@click="addMed">新增</el-button>
<el-button class="btns_box" type="danger" :size="autoSize" :disabled="labPat.jgbz == 2" plain
@click="delMed">删除</el-button>
<el-button type="primary" class="btns_box" plain :size="autoSize" :disabled="labPat.jgbz == 2"
@click="changeKss">更换抗生素组</el-button>
<el-button type="primary" class="btns_box" plain :size="autoSize" :disabled="labPat.jgbz == 2"
@click="addKss">添加抗生素组</el-button>
</template>
<template v-if="activeName2 == 'second'">
<el-button class="btns_box" type="primary" :size="autoSize" plain :disabled="labPat.jgbz == 2"
@click="pyMb">评语模板</el-button>
<el-button type="primary" class="btns_box" plain :size="autoSize" :disabled="labPat.jgbz == 2"
@click="handleTextarea">保存</el-button>
<el-button type="primary" class="btns_box" plain :size="autoSize" :disabled="labPat.jgbz == 2"
@click="textarea = ''">清除</el-button>
</template>
</div>
</div>
<!-- 专家评语 -->
<CommentDialog ref="commentRef" @update:text="handleCommentConfirm" />
<!-- 新增明细 -->
<ProjectDetails ref="itemDictRef" :dialog-title="'选择检验项目'" :tableKey="labPatKey" @select="handleItemSelect" />
<!-- 测试结果项目常用结果选择 -->
<projectsJg ref="csjgRef" :tableData='csjgTableData' :dialog-title="'项目常用结果选择'" @selectItem="selectItem"
label="qz" />
<!-- 组合项目 -->
<Combined ref="combinedRef" :queryParams="labPatKey" @dbMbHandle="combinedHandel" />
<!-- 药敏字典 -->
<Meddict ref="medDictRef" :dialog-title="'抗生素选择'" :tableKey="labPatKey" @select="medSelect" />
<!-- 抗生素组模板 -->
<kssMb ref="kssMbRef" :dialog-title="'抗生素组选择'" :tableKey="labPatKey" @select="kssSelect" />
<!-- 校验用户 -->
<CheckUser ref="checkUserRef" :title="checktitle" @onConfirm="handleCheckUserConfirm" />
<!-- 取消审核操作原因 -->
<Unconfirmlog ref="unconfirmlogRef" :reasonText="reasonText" :tableKey="labPatKey" @onConfirm="unShHandle" />
<!-- 危急值结果上报 -->
<UploadWarning ref="uploadwarningRef" :warningMsgdata="warningMsgdata" :tableKey="labPatKey"
@onupload="shHandleCheck" />
<!-- 用户校验 -->
<userVerification ref="formRef" :title="verTitle" :userList="userList" @confirm="handleConfirm" />
<!-- 合并当前病人其他结果 -->
<MergeResults ref="mergeRef" :tableKey="{ ...labPatKey, jyrq: labPat.jyrq }" :dictData="dictData" />
<!-- 查看备份数据 -->
<ViewBackup ref="backRef" :tableKey="{ ...labPatKey, jyrq: labPat.jyrq }" :userList="userList"
:dictData="dictData" />
<!-- 双工流水线 -->
<DlDialog ref="dlRef" :tableKey="{ ...labPatKey, jyrq: labPat.jyrq }" :dictData="dictData" />
<!-- 未建项目结果 -->
<BuiltDialog ref="builtRef" :tableKey="{ ...labPatKey, jyrq: labPat.jyrq }" @clearPro="clearProHandle" />
</div>
</template>
<script setup lang="ts">
import CustomTable from "@/components/elTable/index.vue";
import { classCom } from "@/utils/classCom";
import {
getresultmedList, savetestResult, changeresult, saveresult, newresult, getmeddictList, savemedresult,
savemedresultall, deletemedresult, getmedgroupMbList
} from '@/api/liswork/micro/index';
import {
check2, uncheck2, unconfirmlog, checkuser, deleteresult, queryXmVal, setinputmdl, clearPrintflag,
clearnotComplete, emrquery, allPatquery, lockSample, unLockSample,
printListwork,
} from "@/api/liswork/work/LisWork";
import { useCommonStore } from "@/store/modules/commonStore";
import CheckUser from "../../work/components/CheckUser.vue";
import Unconfirmlog from "../../work/components/unconfirmlog.vue";
import UploadWarning from "../../work/components/uploadwarning.vue";
// @ts-ignore
import ProjectDetails from "@/components/projectDetails/index.vue";
import projectsJg from "@/components/projectsjg/index.vue";
// @ts-ignore
import kssMb from "./components/kssMb.vue";
import Combined from "./components/combinedDialog.vue";
// @ts-ignore
import Meddict from "./components/meddict.vue";
import { ElMessage, ElMessageBox } from "element-plus";
import emitter from "@/utils/mitt";
const autoSize = classCom.useAutoSize();
import { LabResultItem, ymTableDataItem } from '@/types/index';
import ContextMenu from "@/components/contextMenu/index.vue";
import { ContextMenuItem } from '@/types/index'
import BuiltDialog from "../../work/components/builtDialog.vue"
import ViewBackup from "../../work/components/viewBackup.vue"
import userVerification from "@/components/userVerification/index.vue";
import DlDialog from "../../work/components/dlDialog.vue";
import MergeResults from "../../work/components/mergeResults.vue";
import CommentDialog from "./components/commentDialog.vue";
const props = defineProps({
labPat: {
type: Object,
required: true
},
//结果主键
labPatKey: {
type: Object,
default: () => { }
},
labResutsData: {
type: Array as PropType<LabResultItem[]>,
default: () => []
},
dictData: {
type: Object,
default: () => { }
},
userList: {
type: Array as PropType<any[]>,
default: () => []
}
});
const { labPat, labPatKey, labResutsData, dictData } = toRefs(props);
// 事件定义
const emits = defineEmits([
'fetchLabResults',
'changeStatus',
'previewHandle',
'update:labPatKey'
]);
const activeName2 = ref('first')
const textarea = ref('')
const columns = ref([
{ label: "细菌/结果", prop: "zhxmdh", visible: true, headerSlot: 'xmdh', width: 150 },
{ label: "菌落计数", prop: "od", align: 'center', visible: true, slot: 'od' },
{ label: "检验结果", prop: "csjg", align: 'center', visible: true, slot: 'csjg' },
{ label: "阴阳性", prop: "jgbz", align: 'center', visible: true, slot: 'jgbz', showOverflowTooltip: false },
{ label: "危急值", prop: "alarm_flag", align: 'center', visible: true, slot: 'alarm_flag', showOverflowTooltip: false },
{ label: "菌属", prop: "germclass", align: 'center', visible: true, slot: 'germclass' },
{ label: "鉴定率", prop: "cutoff", align: 'center', visible: true, slot: 'cutoff' },
{ label: "抗生素组", prop: "bz1", align: 'center', visible: true, width: 120 },
])
const CellStyleHd = ({ row, column, rowIndex, columnIndex }: {
row: any;
column: any;
rowIndex: number;
columnIndex: number;
}) => {
if (column.label == "细菌/结果" && row.alarm_flag) {
return { background: '#f00 !important', color: '#FFF' };
}
if (column.label == "危急值" && row.alarm_flag) {
return { background: '#f00 !important', color: '#FFF' };
}
if (column.label == "检验结果" && row.jgbz == "H") {
return { background: '#ffc0c0 !important', color: '#606266' };
}
if (column.label == "检验结果" && row.jgbz == "L") {
return { background: '#8080ff !important', color: '#fff' };
}
if (column.label == "检验结果" && row.jgbz == "P") {
return { background: '#ffc0c0 !important', color: '#606266' };
}
if (column.label == "检验结果" && row.jgbz == "Q") {
return { background: '#ffff80 !important', color: '#606266' };
}
if (column.label == "阴阳性" && row.jgbz == "H") {
return { background: '#ffc0c0 !important', color: '#606266' };
}
if (column.label == "阴阳性" && row.jgbz == "L") {
return { background: '#8080ff !important', color: '#fff' };
}
if (column.label == "阴阳性" && row.jgbz == "P") {
return { background: '#ffc0c0 !important', color: '#606266' };
}
if (column.label == "阴阳性" && row.jgbz == "Q") {
return { background: '#ffff80 !important', color: '#606266' };
}
};
const tableConfig = ref({
height: '24vh',
border: true,
highlightCurrentRow: true,
cellStyle: CellStyleHd
});
const handleColumnDragEnd = (data: any) => {
columns.value = data.columns;
}
// 右键菜单配置
const contextMenuItems = computed<ContextMenuItem[]>(() => [
{ label: '打印预览', action: 'view', shortcut: 'V', },
{ label: 'PDF报告预览', action: 'bgyl', shortcut: 'P', },
{ label: '合并病人当前其他结果', action: 'merge', shortcut: 'B', },
{ type: 'divider' },
{ label: '锁定报告', action: 'Lock', shortcut: 'L', },
{ label: '解除报告锁定', action: 'lift', shortcut: 'W', },
{ type: 'divider' },
// { label: '删除记录', action: 'delete', danger: true, shortcut: 'd', },
{ label: '查看电子病历', action: 'emrquery', shortcut: 'E', },
{ label: '查看360全景视图', action: 'patquery', shortcut: 'Y', },
{ label: '查看备份数据', action: 'viewbackup', shortcut: 'P', },
{ label: '双工流水线', action: 'datalink', shortcut: 'F', },
{ type: 'divider' },
{ label: '解除审核', action: 'unblock', shortcut: 'C', },
{ label: '清除打印标志', action: 'clearPrint', shortcut: 'U', },
{ label: '清除所有未做项目', action: 'clearPro', shortcut: 'T', },
{ type: 'divider' },
{ label: '未建项目结果', action: 'unbuilt', shortcut: 'N', },
]);
// 处理菜单选择
const handleMenuSelect = (item: any) => {
switch (item.action) {
case 'view':
previewHandle(1) //打印预览
break;
case 'bgyl':
previewHandle(2) //PDF报告预览
break;
case 'merge':
mergeHandle()
// alert(`合并病人当前其他结果`);
break;
case 'Lock':
lockHandle(); //锁定
break;
case 'lift':
unlockHandle() //解锁
break;
case 'emrquery':
emrqueryHandle() //电子病历查询
break;
case 'patquery':
patqueryHandle() //360视图
break;
case 'viewbackup':
viewbackupHandle() //查看备份数据
break;
case 'datalink':
datalinkHandle() //流水线
break;
case 'unblock':
handleCheck(3) //解除审核
break;
case 'clearPrint':
clearPrintHandle() //清除打印标志
break;
case 'clearPro':
clearProHandle() //清除所有未做项目
break;
case 'unbuilt':
unbuiltHandle() //未建项目结果
break;
case 'delete':
if (confirm(`确定要删除患者的记录吗?`)) {
}
break;
}
};
const previewHandle = (type: number) => { //1 打印预览 2 PDF报告预览
const data = {
jyrq: labPat.value.jyrq,
yq: labPat.value.yq,
ybh: labPat.value.ybh,
sqh: labPat.value.sqh
}
printListwork(data).then((res: any) => {
if (res.code == 0) {
if (type == 1) {
classCom.printBase64PDF(res.data)
} else {
emits('previewHandle', res.data);
}
}
})
};
const mergeRef = ref()
const mergeHandle = () => {
mergeRef.value.open()
};
const formRef = ref();
const verTitle = ref('请输入锁定人员账号密码')
const lockType = ref(1)
// 锁定报告
const lockHandle = () => {
if (props.labPat.jgbz != 0) return ElMessage.warning('样本已审核,不能锁定!')
lockType.value = 1
formRef.value.open()
verTitle.value = '请输入锁定人员账号密码'
}
// 解除锁定报告
const unlockHandle = () => {
if (props.labPat.jgbz != 5) return ElMessage.warning('目标标本未锁定,不可解除锁定!')
lockType.value = 2
verTitle.value = '请输入解除锁定人员账号密码'
formRef.value.open()
}
// 锁定样本
const handleConfirm = (data: { yhdh: string, userName: string, mm: string }) => {
const obj = {
...labPatKey.value,
jyrq: labPat.value.jyrq,
yhdh: data.yhdh,
}
emits('update:labPatKey', {
...labPatKey.value,
yhdh: data.yhdh,
});
if (lockType.value == 1) {
lockSample(obj).then((res: any) => {
if (res.code == 0) {
formRef.value?.cancel()
ElMessage.success(res.msg)
emits('changeStatus', labPat.value)
}
});
} else {
unLockSample(obj).then((res: any) => {
if (res.code == 0) {
formRef.value?.cancel()
ElMessage.success(res.msg)
emits('changeStatus', labPat.value)
}
});
}
}
const emrqueryHandle = () => {
emrquery({ ...labPatKey.value, jyrq: labPat.value.jyrq }).then((res: any) => {
if (res.data) {
window.open(res.data)
}
})
};
const patqueryHandle = () => {
allPatquery({ ...labPatKey.value, jyrq: labPat.value.jyrq }).then((res: any) => {
if (res.data) {
window.open(res.data)
}
})
};
const dlRef = ref()
const datalinkHandle = () => {
dlRef.value.open()
};
const backRef = ref()
const viewbackupHandle = () => {
backRef.value.openDialog()
};
const builtRef = ref()
const unbuiltHandle = () => {
builtRef.value.open()
};
const clearPrintHandle = () => {
clearPrintflag({ ...labPatKey.value, jyrq: labPat.value.jyrq }).then((res: any) => {
if (res.code == 0) {
emits('changeStatus', labPat.value)
}
})
};
const clearProHandle = () => {
clearnotComplete({ ...labPatKey.value, jyrq: labPat.value.jyrq }).then((res: any) => {
if (res.code == 0) {
emits('fetchLabResults')
}
})
};
const reasonText = ref('');
const warningMsgdata = ref('');
const checktitle = ref('');
const checkUserRef = ref();
const runnextstepname = ref(-1); // 审核类型
const handleCheck = (checkType: number) => {
runnextstepname.value = checkType
labPatKey.value.problemId = 0;
if (!labPatKey.value.yhdh) {
checktitle.value = '审核人工号密码验证'
checkUserRef.value.open()
} else {
proceedCheck(checkType)
}
};
const handleCheckUserConfirm = (info: { yhdh: string, mm: string }) => {
checkuser({ yhdh: info.yhdh, mm: info.mm }).then((response: any) => {
if (response.code == 0) {
emits('update:labPatKey', {
...labPatKey.value,
yhdh: info.yhdh
});
// 异步处理 等待yhdh数据更新
setTimeout(() => {
proceedCheck(runnextstepname.value)
}, 100);
}
})
}
const proceedCheck = (type: number) => {
switch (type) {
case 2: // 审核
labPatKey.value.problemId = 0
shHandleCheck()
break;
case 3: // 取消审核
labPatKey.value.problemId = 0
unShHandle()
break;
default:
break;
}
}
const uploadwarningRef = ref();
const shHandleCheck = () => {
check2({ ...labPatKey.value, jyrq: labPat.value.jyrq }).then((res: any) => {
emits("changeStatus", props.labPat);
if (res.code == "4" && res.problemId === 4) {
labPatKey.value.problemId = res.problemId;
warningMsgdata.value = res.msg;
uploadwarningRef.value.open();
}
})
};
const unconfirmlogRef = ref();
const unShHandle = () => {
uncheck2({ ...labPatKey.value, jyrq: labPat.value.jyrq }).then((res: any) => {
if (res.code == "4") {
labPatKey.value.problemId = res.problemId;
reasonText.value = res.msg;
unconfirmlogRef.value.open();
}
emits("changeStatus", props.labPat);
})
};
const itemDictRef = ref();
const openItemDictDialog = () => {
itemDictRef.value.openDictSelector();
};
const handleItemSelect = async (selectedItem: any) => {
// 1. 构造新增行数据
const newRow = {
id: `temp_${Date.now()}_${Math.random().toString(36).substr(2, 8)}`,
xmdh: selectedItem.value,
xmmc: selectedItem.label,
dw: selectedItem.dw || "",
refs: selectedItem.refs || "",
jyrq: labPatKey.value.jyrq,
yq: labPatKey.value.yq,
ybh: labPatKey.value.ybh,
};
addRowFromDict(newRow);
// ElMessage.success(`已新增项目:${newRow.xmmc}`);
};
const selectedRows: any = ref([])
const tableRef = ref()
// 新增行核心方法:接收父组件传递的项目数据
const addRowFromDict = async (rowData: any) => {
if (!rowData.xmdh) return ElMessage.error("新增失败:项目编码不能为空");
const isDuplicate = tableData.value.some((item: any) => item.xmdh === rowData.xmdh);
if (isDuplicate) return ElMessage.warning(`项目【${rowData.xmmc}】已存在`);
const newRow = {
...rowData,
od: '',
csjg: "",
jgbz: "",
alarm_flag: '',
cutoff: '',
};
tableData.value.push(newRow);
newresult({ ...newRow, ybh: labPat.value.ybh, jyrq: labPat.value.jyrq, yq: labPat.value.yq })
// 5. 自动聚焦
nextTick(() => {
selectedRows.value = [newRow];
tableRef.value.setCurrentRow(newRow);
tableRef.value.setScrollTo(tableData.value.length - 1)
// 聚焦到新行的输入框
const inputs = Array.from(document.querySelectorAll('.foucs-input .el-input__inner'))
.filter(el => el instanceof HTMLElement) as HTMLElement[];
if (inputs.length > 0) {
inputs[inputs.length - 1].focus();
}
});
};
const handleBatchDelete = () => {
if (selectedRows.value.length === 0) return ElMessage.warning("请先选择要删除的记录");
const arr = selectedRows.value.filter((row: any) => !row.id);
ElMessageBox.confirm(
`确定要删除选中的 ${selectedRows.value.length} 条记录吗?`,
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
if (arr.length == 0) {
const index = tableData.value.findIndex((item: any) => item.xmdh === selectedRows.value[0].xmdh);
if (index > -1) tableData.value.splice(index, 1);
selectedRows.value = [];
} else {
deleteresult(arr).then((res: any) => {
if (res.code == 0) {
ElMessage.success('删除成功');
emits('fetchLabResults');
}
})
}
}).catch(() => {
});
};
const mbStore = useCommonStore();
const tableData: any = ref([])
watch(labResutsData, (newVal: any) => {
if (newVal.length) {
tableData.value = newVal.map((item: any) => {
return {
...item,
zhxmdh: item.xmdh + ' ' + item.xmmc,
}
})
rowHandle(newVal[0])
textarea.value = newVal[0]?.textresult
} else {
textarea.value = ''
rowInfo.value = {}
tableData.value = []
selectedRows.value = []
ymTableData.value = []
ymselectedRows.value = []
}
if (labPat.value.jgbz == 2) return;
// console.log('mbStore==>', mbStore.lxsrs);
if (mbStore.lxsrs.length > 0) {
mbStore.lxsrs.forEach((mbmc) => {
const data = {
...labPatKey.value,
mbmc: mbmc,
}
setinputmdl(data).then((res: any) => {
if (res.code == 0) {
const existingNames = new Set(tableData.value.map((item: any) => item.xmdh))
res.data?.forEach((item: any) => {
if (!existingNames.has(item.xmdh)) {
tableData.value.push({ ...item, jyrq: labPat.value.jyrq, zhxmdh: item.xmdh + ' ' + item.xmmc })
existingNames.add(item.xmdh)
}
})
emitter.emit('clearLxsrList')
}
});
});
}
})
const handleTextarea = () => {
if (!rowInfo.value.xmdh) return
savetestResult({ ...rowInfo.value, textresult: textarea.value }).then((res: any) => {
if (res.code == 0) {
ElMessage.success('保存成功');
}
});
};
const rowInfo: any = ref({})
const rowHandle = (row: any) => {
selectedRows.value = [row];
emitter.emitWithCache('refreshClinical', row);
rowInfo.value = row
textarea.value = row.textresult
const data = {
ybh: row.ybh,
yq: row.yq,
jyrq: row.jyrq,
xmdh: row.xmdh
}
getresultmedList(data).then((res: any) => {
if (res.code == 0) {
ymTableData.value = res.data.map((item: any) => {
return {
...item,
zhywdh: item.ywdh + ' ' + item.ywmc
}
})
}
})
}
// 项目结果保存
const handleCsjgEnter = async (row: any) => {
// 判断数据中包含模板新增的数据 flag
if (tableData.value.length == 0) return
const flag = tableData.value.some((item: any) => item.changeflag == 2)
if (flag) {
saveresult(tableData.value).then((res: any) => {
if (res.code == 0) {
emitter.emit('wswSaveResult');
}
})
} else {
if (!row) return
if (row && row.id) {
emitter.emit('wswSaveResult');
newresult({ ...row, ybh: labPat.value.ybh, jyrq: labPat.value.jyrq, yq: labPat.value.yq }).then((response: any) => {
ElMessage.success("结果保存成功");
emits('fetchLabResults');
}).catch((error: any) => {
emits('fetchLabResults');
});
} else {
changeresult(row).then((response: any) => {
ElMessage.success("结果保存成功");
emits('fetchLabResults');
}).catch((error: any) => {
emits('fetchLabResults');
});
}
// nextTick(() => {
// const input = document.activeElement;
// if (input?.tagName === "INPUT") input?.blur();
// });
}
};
const csjgRef = ref()
const csjgTableData = ref([])
const handleInputFocus = (row: any) => {
// dbRow.value = row
queryXmVal({ yq: labPatKey.value.yq, xmdh: row.xmdh }).then((res: any) => {
if (res.code == 0) {
csjgTableData.value = res.data
}
nextTick(() => {
csjgRef.value.open()
})
})
};
const selectItem = (row: any) => {
// 查找修改行
const index = tableData.value.findIndex((item: any) => item.xmdh == row.xmdh)
tableData.value[index].csjg = row.qz
handleCsjgEnter(tableData.value[index])
};
// 组合项目
const combinedRef = ref()
const zhHandel = () => {
combinedRef.value.open()
};
const combinedHandel = (row: any) => {
if (props.labPat.jgbz != null && props.labPat.jgbz != 0 && props.labPat.jgbz != 'C') return ElMessage.warning('已审核结果不可添加模板项目');
const data = {
...labPatKey.value,
mbmc: row.mbmc,
}
setinputmdl(data).then((res: any) => {
if (res.code == 0) {
const existingNames = new Set(tableData.value.map((item: any) => item.xmdh))
res.data?.forEach((item: any) => {
if (!existingNames.has(item.xmdh)) {
tableData.value.push({ ...item, jyrq: labPat.value.jyrq, zhxmdh: item.xmdh + ' ' + item.xmmc })
existingNames.add(item.xmdh)
}
})
handleCsjgEnter(null)
emitter.emit('clearLxsrList')
}
});
};
const ymTableRef = ref()
const ymTableData = ref<ymTableDataItem[]>([]);
const ymColumns = ref([
{ label: "抗生素", prop: "zhywdh", visible: true, width: 120, headerSlot: 'ywdhHead' },
{ label: "Mic", prop: "mic", align: 'center', visible: true, width: 60, slot: 'mic' },
{ label: "KB", prop: "rad", align: 'center', visible: true, width: 50, slot: 'rad' },
{ label: "结果", prop: "csjg", align: 'center', visible: true, width: 60, slot: 'csjg' },
{ label: "结果标志", prop: "jgbz", align: 'center', visible: true, slot: 'jgbz', width: 180, showOverflowTooltip: false },
{ label: "折点", prop: "ckz", align: 'center', visible: true, },
{ label: "分组", prop: "bz", align: 'center', visible: true, slot: 'bz' },
{ label: "专家值", prop: "txtresult", align: 'center', visible: true, slot: 'txtresult' },
{ label: "引用说明", prop: "cp_bz", align: 'center', visible: true, slot: 'cp_bz' },
])
const ymCellStyleHd = ({ row, column, rowIndex, columnIndex }: {
row: any;
column: any;
rowIndex: number;
columnIndex: number;
}) => {
if (column.label == "结果" && row.jgbz == "R") {
return { background: '#ffc0c0 !important', color: '#606266' };
}
if (column.label == "结果" && row.jgbz == "I") {
return { background: '#ffff80 !important', color: '#606266' };
}
}
const ymTableConfig = ref({
height: '48vh',
border: true,
highlightCurrentRow: true,
cellStyle: ymCellStyleHd,
});
const ymHandleColumnDragEnd = (data: any) => {
ymColumns.value = data.columns;
}
const ymselectedRows = ref<ymTableDataItem[]>([]);
const ymRowHandle = (row: any) => {
ymselectedRows.value = [row];
}
const medDictRef = ref()
const kssMbRef = ref()
const kssType = ref('')
// 更换抗生素组
const changeKss = () => {
kssMbRef.value.openDictSelector();
kssType.value = '1'
}
// 添加抗生素组
const addKss = () => {
kssMbRef.value.openDictSelector();
kssType.value = '2'
}
const kssSelect = (row: any) => {
getmedgroupMbList({ mbmc: row.value }).then((res: any) => {
if (res.code == 0) {
if (kssType.value == '1') {
ymTableData.value = []
res.data?.forEach((item: any, index: number) => {
ymTableData.value.push({ ...item, zhywdh: item.ywdh + ' ' + item.ywmc, xh: index + 1 })
})
} else {
const existingNames = new Set(ymTableData.value.map((item: any) => item.ywdh))
res.data?.forEach((item: any) => {
if (!existingNames.has(item.ywdh)) {
ymTableData.value.push({ ...item, zhywdh: item.ywdh + ' ' + item.ywmc, xh: ymTableData.value.length + 1 })
existingNames.add(item.ywdh)
}
})
}
ymTableData.value.forEach((item: any) => {
item.ybh = labPatKey.value.ybh
item.yq = labPatKey.value.yq
item.jyrq = labPat.value.jyrq
item.xmdh = selectedRows.value[0].xmdh
})
savemedresultall(ymTableData.value).then((res: any) => {
if (res.code == 0) {
rowHandle(selectedRows.value[0])
}
})
}
})
}
const commentRef = ref()
const pyMb = () => {
commentRef.value.open()
}
const handleCommentConfirm = (text: string) => {
textarea.value = text
}
const addMed = () => {
medDictRef.value.openDictSelector();
}
const delMed = () => {
if (ymselectedRows.value.length === 0) return ElMessage.warning("请先选择要删除的记录");
const arr = ymselectedRows.value.filter((row: any) => !row.id);
if (arr.length) {
deletemedresult(ymselectedRows.value[0]).then((res: any) => {
if (res.code == 0) {
ElMessage.success('删除成功');
rowHandle(selectedRows.value[0])
}
})
} else {
const index = ymTableData.value.findIndex((item: any) => item.ywdh === ymselectedRows.value[0].ywdh);
if (index > -1) ymTableData.value.splice(index, 1);
}
ymselectedRows.value = [];
}
const medSelect = (row: any) => {
const ymFlag = tableData.value.some((item: any) => item.ywdh === row.value);
if (ymFlag) return ElMessage.warning(`抗生素【${row.label}】已存在`);
// 1. 构造新增行数据
const newRow = {
id: `temp_${Date.now()}_${Math.random().toString(36).substr(2, 8)}`,
zhywdh: row.value + ' ' + row.label,
ywdh: row.value,
ywmc: row.label,
mic: '',
rad: '',
csjg: '',
jgbz: '',
ckz: '',
bz: '',
txtresult: '',
cp_bz: '',
xh: ymTableData.value.length + 1,
...labPatKey.value,
jyrq: labPat.value.jyrq,
xmdh: selectedRows.value[0].xmdh
};
ymTableData.value.push(newRow);
savemedresult(newRow)
nextTick(() => {
ymselectedRows.value = [newRow];
ymTableRef.value.setCurrentRow(newRow);
ymTableRef.value.setScrollTo(ymTableData.value.length - 1)
// 聚焦到新行的输入框
const inputs = Array.from(document.querySelectorAll('.ymFoucs .el-input__inner'))
.filter(el => el instanceof HTMLElement) as HTMLElement[];
if (inputs.length > 0) {
inputs[inputs.length - 1].focus();
}
});
};
// 药敏结果保存
const ymHandleEnter = async (row: any) => {
if (!row) return
savemedresult({ ...row, ybh: labPat.value.ybh, jyrq: labPat.value.jyrq, yq: labPat.value.yq, xmdh: selectedRows.value[0].xmdh }).then((res: any) => {
if (res.code == 0) {
ElMessage.success('保存成功');
rowHandle(selectedRows.value[0])
}
});
};
const jgbzHandle = (val: string, row: any) => {
const obj: any = {
R: '耐药',
I: '中介',
S: '敏感',
N: '非敏感',
D: '剂量依赖性敏感'
}
row.csjg = obj[val]
ymHandleEnter(row)
};
onMounted(() => {
// 获取模板项目
emitter.on('dbMbHandle', (info: any) => {
combinedHandel(info)
})
});
const formatDict = (v: string, dictType: string) => {
return props.dictData[dictType]?.find((item: any) => item.value == v)?.label || v;
}
const formatJgbz = (v: string) => {
const jgbzMap = {
'H': '高',
'L': '低',
'N': '阴性',
'P': '阳性',
'Q': '弱阳性',
'M': '正常'
};
return jgbzMap[v as keyof typeof jgbzMap] ?? '';
}
</script>
<style scoped lang="scss">
.btns {
display: flex;
align-items: center;
span {
color: #1f6dd3;
margin-left: 15px;
}
}
.el-radio {
margin-right: .3125rem;
height: 1.875rem;
:deep(.el-radio__label) {
padding-left: 2px !important;
}
}
.tabs_btns {
position: relative;
.anchor {
position: absolute;
top: 0;
right: 0;
}
}
</style>