2025-11-26 18:09:02 +08:00

1145 lines
34 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="result-container">
<div class="flex-between mb10">
<div>
<el-button class="btn_green" :size="aotuSize" @click="handleCheck(1)">初审</el-button>
<el-button class="btn_green" :size="aotuSize" v-if="labPat.jgbz != 2" @click="handleCheck(2)">审核</el-button>
<el-button class="btn_green" :size="aotuSize" v-if="labPat.jgbz == 2" @click="handleCheck(3)">取消审核</el-button>
<el-button type="primary" :size="aotuSize" plain :disabled="labPat.jgbz != null && labPat.jgbz != 0"
@click="openItemDictDialog">新增</el-button>
<el-button type="danger" :size="aotuSize" :disabled="labPat.jgbz != null && labPat.jgbz != 0" plain
@click="handleBatchDelete">删除</el-button>
</div>
<div>
<el-button type="primary" plain icon="Files" :size="aotuSize" @click="printHandle">打印</el-button>
<el-button type="primary" plain icon="View" :size="aotuSize" @click="previewHandle">预览</el-button>
</div>
</div>
<ContextMenu :items="contextMenuItems" @select="handleMenuSelect">
<CustomTable ref="tableRef" :data="tableData" :columns="columns" :config="tableConfig" :enable-column-drag="true"
@row-click="handleRowClick" @column-drag-end="handleColumnDragEnd" class="custom-table-container">
<template #index="{ row, $index }">
<el-popover effect="dark" v-if="row.cp_modify == 1" @before-enter="beforeEnter(row)" width="300">
<template #reference>
<div style="width: 100%;">{{ $index + 1 }}</div>
</template>
<template #default>
<el-row>
<el-col>修改前结果:{{ lastResult.csjg }}</el-col>
<el-col>修改日期:{{ lastResult.xgrq }}</el-col>
<el-col>修改人:{{ formatYs(lastResult.xgr) }}</el-col>
<el-col>上次审核时间:{{ lastResult.shsj }}</el-col>
<el-col>上次审核人:{{ formatYs(lastResult.shys) }}</el-col>
</el-row>
</template>
</el-popover>
<span v-else>{{ $index + 1 }}</span>
</template>
<template #csjg="{ row }">
<el-input v-model="row.csjg" v-if="labPat.jgbz == 0 || labPat.jgbz == null" size="small"
class="full-width-input" @change="handleCsjgEnter(row)" @dblclick="handleInputFocus(row)" />
<span v-else>{{ row.csjg }}</span>
</template>
<template #cp_compa="{ column, $index }">
{{ lastjyrq }}
</template>
<template #refs="{ row }">
{{ row.refs }}{{ row.dw }}
</template>
<template #od="{ row }">
<el-input v-model="row.od" v-if="labPat.jgbz == 0 || labPat.jgbz == null" size="small"
class="full-width-input" @change="handleCsjgEnter(row)" />
<span v-else>{{ row.od }}</span>
</template>
<template #cutoff="{ row }">
<el-input v-model="row.cutoff" v-if="labPat.jgbz == 0 || labPat.jgbz == null" size="small"
class="full-width-input" @change="handleCsjgEnter(row)" />
<span v-else>{{ row.cutoff }}</span>
</template>
</CustomTable>
</ContextMenu>
<!-- <div class="flex-between mt10">
<div>
<el-button class="btn_green" @click=" ">初报</el-button>
<el-button class="btn_green" @click=" ">二报</el-button>
<el-button class="btn_green" @click=" ">锁定</el-button>
</div>
<div>
</div>
</div> -->
<!-- csjg弹窗 -->
<projectsJg ref="csjgRef" :tableData='csjgTableData' :dialog-title="'项目常用结果选择'" @selectItem="selectItem"
label="qz" />
<!-- 新增明细 -->
<ProjectDetails ref="itemDictRef" :dialog-title="'选择检验项目'" :tableKey="tableKey" @select="handleItemSelect" />
<!-- 校验用户 -->
<CheckUser ref="checkUserRef" :title="checktitle" @onConfirm="handleCheckUserConfirm" />
<!-- 危急值结果上报 -->
<UploadWarning ref="uploadwarningRef" :warningMsgdata="warningMsgdata" :tableKey="tableKey"
@onupload="shHandleCheck" />
<!-- 操作原因 -->
<Unconfirmlog ref="unconfirmlogRef" :reasonText="reasonText" :tableKey="tableKey" @onConfirm="unShHandle" />
<!-- 合并当前病人其他结果 -->
<el-dialog v-model="jgShow" title="绑定其他结果" width="40vw" :close-on-click-modal="false" :draggable="true">
<el-row>
<el-col :span="8">
<el-radio-group v-model="radio2">
<el-radio value="1">5天内</el-radio>
<el-radio value="2">10天内</el-radio>
<el-radio value="2">20天内</el-radio>
<el-radio value="2">30天内</el-radio>
</el-radio-group>
</el-col>
<el-col :span="4">
<el-radio-group v-model="radio2">
<el-radio value="1">复制</el-radio>
<el-radio value="2">移动</el-radio>
</el-radio-group>
</el-col>
<el-col :span="4">
<el-radio-group v-model="radio2">
<el-radio value="1">覆盖</el-radio>
<el-radio value="2">不覆盖</el-radio>
</el-radio-group>
</el-col>
<el-col :span="8">
<div> <el-checkbox>只显示同一申请单号</el-checkbox> </div>
<div>
<el-button type="primary">合并</el-button>
<el-button>取消</el-button>
</div>
</el-col>
</el-row>
<CustomTable :data="mTableData" :columns="mColumns" :config="mTableConfig" :enable-column-drag="true"
@column-drag-end="mDragEnd" @selection-change="mSelectionChange">
<template #brxb="{ row }">
{{ formatDict(row.brxb, 'SX') }}
</template>
<template #nldw="{ row }">
{{ formatDict(row.nldw, 'AU') }}
</template>
</CustomTable>
</el-dialog>
<!-- 用户校验 -->
<userVerification ref="formRef" :title="verTitle" :form-value="formData" :userList="userList"
@confirm="handleConfirm" @cancel="handleCancel" />
<!-- 双工流水线 -->
<el-dialog v-model="dlShow" title="双工流水线申请单列表" width="40vw" :close-on-click-modal="false" :draggable="true">
<div class="mb10">
<el-button type="primary" @click="getDlList">刷新</el-button>
<el-button type="primary" @click="cfHandle">重发申请单</el-button>
<el-button @click="closeHandle">取消申请单</el-button>
</div>
<CustomTable :data="dlTableData" :columns="dlColumns" :config="dlTableConfig" :enable-column-drag="true"
@column-drag-end="dlDragEnd" @selection-change="dlSelectionChange">
<template #instrid="{ row }">
{{ row.instrid ? dlObj[row.instrid] : '未发送指令' }}
</template>
<template #brxb="{ row }">
{{ formatDict(row.brxb, 'SX') }}
</template>
<template #nldw="{ row }">
{{ formatDict(row.nldw, 'AU') }}
</template>
</CustomTable>
<div class="mt5" style="text-align: center;color:blue;">样本总数:{{ dlTableData.length }}</div>
</el-dialog>
<!-- 查看备份数据 -->
<ViewBackup ref="backRef" :backLabInfo="backLabInfo" :backTableData="backTableData" :userList="userList"
:dictData="dictData" />
<!-- 未建项目结果 -->
<el-dialog v-model="builtShow" title="检验结果对照" width="40vw" :close-on-click-modal="false" :draggable="true">
<div class="tips mb10">字典中不存在项目</div>
<el-row :gutter="10">
<el-col :span="16">
<el-table :data="builtTableData" height="50vh" border show-overflow-tooltip>
<el-table-column label="接口/通道号" prop="xmdh" />
<el-table-column label="结果" prop="csjg" />
<el-table-column label="对应检验项目" width="180">
<template #default="{ row }">
<el-select v-model="row.xmdh0" placeholder="" filterable @change="" size="small"
class="full-width-input">
<el-option v-for="item in builtOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</template>
</el-table-column>
</el-table>
</el-col>
<el-col :span="8">
<div class="tips">
提示:<br />
如果结果就是某个检验项目的结果,请在“对应检验项目”列表中直接选择进行对照。<br />
如果不是,<br />
请选择菜单“字典”一>“检验项目”进入检验维护作业后点击按钮<br />
自动加载”加入项目。<br />
</div>
<div class="btns_box">
<div class="btn" @click="cpHandle">存盘</div>
<div class="btn" @click="builtShow = false">退出</div>
<div class="btn" @lcick="clearProHandle">清除未做</div>
</div>
</el-col>
</el-row>
</el-dialog>
</div>
</template>
<script setup>
import { ref, toRefs, watch, nextTick, onMounted, computed } from "vue";
import userVerification from "@/components/userVerification/index.vue";
import {
check1, check2, uncheck2, unconfirmlog, checkuser, reglimit, deleteresult, changeresult, allPatquery, emrquery, datalink, changeLinkList,
viewBackup, newresult, queryXmVal, printListwork, getresultchangelog, setinputmdl, saveResult, lockSample, unLockSample, clearnotComplete, clearPrintflag,
noiteMresult, queryXmInfo, setitemInter
} from "@/api/liswork/work/LisWork";
import { ElMessageBox, ElMessage } from "element-plus";
import ProjectDetails from "@/components/projectDetails/index.vue";
import projectsJg from "@/components/projectsjg/index.vue"
import { classCom } from '@/utils/classCom'
import CustomTable from '@/components/elTable/index.vue'
import dayjs from 'dayjs';
import emitter from "@/utils/mitt";
import CheckUser from "./CheckUser.vue";
import Unconfirmlog from './unconfirmlog.vue';
import UploadWarning from "./uploadwarning.vue";
import { useCommonStore } from "@/store/modules/commonStore";
import ContextMenu from "@/components/contextMenu/index.vue";
import ViewBackup from "./viewBackup.vue";
// 组件属性定义
const props = defineProps({
resultSysList: { type: Array, required: true },
tableData: { type: Array, default: () => [] },
tableKey: {
type: Object, default: () => { }
},
labPat: { type: Object, required: true },
userList: { type: Array, default: () => [] },
dictData: { type: Object, default: () => ({}) }
});
// 解构props
const { tableData, tableKey, labPat, userList } = toRefs(props);
const selectedRows = ref([]);
const lastjyrq = ref('');
const mbStore = useCommonStore();
const aotuSize = classCom.useAutoSize();
const radio2 = ref('1');
const jgShow = ref(false);
watch(() => props.tableData, (newVal) => {
selectedRows.value = [];
if (newVal) {
const index = newVal.findIndex((item) => item.cp_lastjyrq)
if (index !== -1) {
lastjyrq.value = dayjs(newVal[index].cp_lastjyrq).format('YY/MM/DD');
} else {
lastjyrq.value = '上次结果'
}
}
if (props.labPat.jgbz != null && props.labPat.jgbz != 0 && props.labPat.jgbz != 'C') return;
// console.log('mbStore==>', mbStore.lxsrs);
if (mbStore.lxsrs.length > 0) {
mbStore.lxsrs.forEach((mbmc) => {
const data = {
...tableKey.value,
mbmc: mbmc,
}
setinputmdl(data).then((res) => {
if (res.code == 0) {
const existingNames = new Set(tableData.value.map(item => item.xmdh))
res.data?.forEach(item => {
if (!existingNames.has(item.xmdh)) {
tableData.value.push(item)
existingNames.add(item.xmdh)
}
})
emitter.emit('clearLxsrList')
}
});
});
}
});
watch(() => props.resultSysList, (newVal) => {
// 深拷贝原避免直接修改响应式对象的引用
const newColumns = JSON.parse(JSON.stringify(columns.value));
newVal.forEach(v => {
const column = newColumns.find(item => item.prop === v.zdmc);
if (column) {
column.visible = (v.kj === '1' ? true : false);
}
});
columns.value = newColumns;
// 强制表格重新渲染
nextTick(() => {
if (tableRef.value?.doLayout) {
tableRef.value.doLayout();
}
});
}, { deep: true });
// 右键菜单配置
const contextMenuItems = computed(() => [
{ 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) => {
switch (item.action) {
case 'view':
printHandle() //打印预览
break;
case 'bgyl':
previewHandle() //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 builtShow = ref(false)
const builtTableData = ref([])
const builtOptions = ref([])
const unbuiltHandle = () => {
queryXmInfo({ yq: tableKey.value.yq }).then(res => {
if (res.code == 0) {
builtOptions.value = res.data.map(item => {
return {
value: item.xmdh,
label: item.xmdh + ' - ' + item.xmmc
}
})
}
})
noiteMresult(tableKey.value).then(res => {
builtTableData.value = res.data.map(item => {
return {
...item,
xmdh0: ''
}
})
})
builtShow.value = true
};
const cpHandle = () => {
const validItems = builtTableData.value.filter(item => item.xmdh0);
if (validItems.length === 0) {
console.log("没有需要处理的项");
return;
}
let successCount = 0;
let failCount = 0;
const requests = validItems.map((item, index) => {
return setitemInter({ ...tableKey.value, xmdh0: item.xmdh0, xmdh: item.xmdh })
.then(response => ({
index,
success: true,
data: response
}))
.catch(error => ({
index,
success: false,
error: error
}));
});
Promise.all(requests).then(results => {
results.forEach(result => {
if (result.success) {
successCount++;
// console.log(`第 ${result.index + 1} 项成功:`, result.data);
} else {
failCount++;
// console.error(`第 ${result.index + 1} 项失败:`, result.error);
}
});
// 输出统计结果
ElMessageBox.alert(
`项目与通道号对照已经完成,成功${successCount}个;失败${failCount}个。<br />你可以重新从仪器端传送一遍数据,就可以看到正确的结果了。`,
'信息',
{
dangerouslyUseHTMLString: true,
}
)
})
};
const clearPrintHandle = () => {
clearPrintflag(tableKey.value).then(res => {
if (res.code == 0) {
emits('changeStatus', labPat.value)
}
})
};
const clearProHandle = () => {
clearnotComplete(tableKey.value).then(res => {
if (res.code == 0) {
emits('fetchLabResults')
}
})
};
const mTableData = ref([])
const mColumns = ref([
{ label: "选择", type: 'selection', align: 'center', width: 40, visible: true, },
{ label: "仪器", prop: "yq", visible: true, },
{ label: "检验日期", prop: "jyrq", visible: true, },
{ label: "样本号", prop: "ybh", visible: true, },
{ label: "病历号", prop: "brdh", visible: true, },
{ label: "病人姓名", prop: "brxm", visible: true, },
{ label: "年", prop: "nl", width: 40, visible: true, },
{ label: "龄", prop: "nldw", width: 30, visible: true, slot: "nldw" },
{ label: "检验项目", prop: "xmdh", visible: true, },
{ label: "检验结果", prop: "csjg", width: 60, visible: true, },
{ label: "申请号", prop: "sqh", visible: true, },
])
const mTableConfig = {
border: true
}
const mDragEnd = (data) => {
mColumns.value = data.columns
}
const mSelectionChange = (data) => {
}
const mergeHandle = () => {
jgShow.value = true;
};
const emrqueryHandle = () => {
emrquery(tableKey.value).then(res => {
if (res.data) {
window.open(res.data)
}
})
};
const patqueryHandle = () => {
allPatquery(tableKey.value).then(res => {
if (res.data) {
window.open(res.data)
}
})
};
const backRef = ref()
const backLabInfo = ref({})
const backTableData = ref([])
const viewbackupHandle = () => {
viewBackup(tableKey.value).then(res => {
if (res.data) {
backTableData.value = res.data.labresultbk
backLabInfo.value = res.data.labpatbk
}
})
backRef.value.openDialog()
};
const dlObj = {
0: '申请发送',
1: '已发送指令',
2: '申请撤销中'
}
const dlShow = ref(false)
const dlTableData = ref([])
const dlColumns = ref([
{ label: "选择", type: 'selection', align: 'center', width: 40, visible: true, },
{ label: "动作状态", prop: "instrid", align: 'center', visible: true, slot: 'instrid' },
{ label: "申请号", prop: "sqh", align: 'center', visible: true, },
{ label: "样本号", prop: "ybh", align: 'center', visible: true, },
{ label: "姓名", prop: "brxm", align: 'center', visible: true, },
{ label: "性别", prop: "brxb", width: 30, align: 'center', visible: true, slot: 'brxb' },
{ label: "年", prop: "nl", width: 30, align: 'center', visible: true, },
{ label: "龄", prop: "nldw", width: 30, align: 'center', visible: true, slot: "nldw" },
{ label: "检验目的", prop: "jymd", width: 180, visible: true, },
])
const dlTableConfig = ref({
border: true,
maxHeight: 500,
cellStyle: ({ row, column }) => {
if (row.instrid == 1) {
return { background: '#c0c0c0 !important' }
}
},
})
const dlDragEnd = (data) => {
dlColumns.value = data.columns
}
const dlList = ref([])
const dlSelectionChange = (selection) => {
dlList.value = selection
}
const datalinkHandle = () => {
getDlList()
dlShow.value = true;
};
const getDlList = () => {
datalink(tableKey.value).then(res => {
dlTableData.value = res.data;
})
}
const cfHandle = () => {
if (dlList.value.length < 0) return ElMessage.warning('请选择数据')
const arr = dlList.value.filter(item => item.instrid == 1)
arr.forEach(v => {
v.instrid = null
})
changeLinkList(arr).then(res => {
if (res.code == 0) {
getDlList()
}
})
}
const closeHandle = () => {
dlList.value.forEach(v => {
v.instrid = 2
})
changeLinkList(dlList.value).then(res => {
if (res.code == 0) {
getDlList()
}
})
}
const formRef = ref();
const formData = ref({
yhdh: '',
userName: '',
mm: '',
})
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) => {
const obj = {
yhdh: data.yhdh,
...tableKey.value
}
if (lockType.value == 1) {
lockSample(obj).then((res) => {
if (res.code == 0) {
formRef.value?.cancel()
ElMessage.success(res.msg)
emits('fetchLabResults', true)
}
});
} else {
unLockSample(obj).then((res) => {
if (res.code == 0) {
formRef.value?.cancel()
ElMessage.success(res.msg)
emits('fetchLabResults', true)
}
});
}
}
const handleCancel = () => {
formData.value = {
yhdh: '',
userName: '',
mm: '',
}
}
const columns = ref([
{ label: 'No', prop: 'index', width: 30, align: 'center', visible: true, slot: "index" },
{ label: "复", prop: "redo_flag", width: 30, align: 'center', visible: true, },
{ label: "项目", prop: "xmdh", width: 50, visible: true, },
{ label: "名称", prop: "xmmc", width: 180, visible: true, },
{ label: "结果", prop: "csjg", width: 60, visible: true, slot: "csjg" },
{ label: "上次结果", prop: "cp_compa", width: 60, visible: true, headerSlot: "cp_compa" },
{ label: "OD", prop: "od", width: 80, visible: true, slot: "od" },
{ label: "CUTOFF", prop: "cutoff", width: 80, visible: true, slot: "cutoff" },
{ label: "参考值", prop: "refs", width: 100, visible: true, slot: "refs" },
// { label: "单位", prop: "dw", width: 80, visible: true, },
{ label: "子模块", prop: "bz1", visible: true, },
])
const cellStyle = ({ row, column, rowIndex, columnIndex }) => {
if (column.label == "结果" && (row.alarm_flag ?? "").trim().length > 0) {
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: '#FFF' };
}
if (column.label == "上次结果" && row.cp_lastflag == "J") {
return { background: '#f00 !important', color: '#FFF' };
}
if (column.label == "上次结果" && row.cp_lastflag == "H") {
return { background: '#ffc0c0 !important', color: '#606266' };
}
if (column.label == "上次结果" && row.cp_lastflag == "L") {
return { background: '#8080ff !important', color: '#fff' };
}
if (column.label == "上次结果" && row.cp_lastflag == "P") {
return { background: '#ffc0c0 !important', color: '#606266' };
}
if (column.label == "上次结果" && row.cp_lastflag == "Q") {
return { background: '#ffff80 !important', color: '#FFF' };
}
if (column.label == "复" && row.redo_flag == "1") {
return { background: '#f00 !important', color: '#FFF' };
}
if (column.label == "No" && row.cp_modify == "1") {
return { background: '#ff00ff !important', color: '#FFF' };
}
};
const tableConfig = ref({
border: true, // 边框
height: '100%', // 高度
maxHeight: '78vh', // max高度
highlightCurrentRow: true, // 高亮当前行
cellStyle: cellStyle,
})
const handleColumnDragEnd = (data) => {
columns.value = data.columns;
};
const lastResult = ref({});
const beforeEnter = (row) => {
const data = {
...tableKey.value,
xmdh: row.xmdh,
}
getresultchangelog(data).then(res => {
lastResult.value = res.data || {}
})
};
const reasonText = ref('');
const warningMsgdata = ref('');
const checkuserid = ref()
const checkShow = ref(false);
const checktitle = ref('');
const checkUserRef = ref();
const csjgRef = ref();
const itemDictRef = ref(); // DictInput组件引用
const tableRef = ref();
const runnextstepname = ref(-1)
const handleCheck = (checkType) => {
runnextstepname.value = checkType
tableKey.value.problemId = 0;
// tableKey.value.yhdh = checkuserid.value
if (!tableKey.value.yhdh) {
checktitle.value = '审核人工号密码验证'
checkUserRef.value.open()
} else {
proceedCheck(checkType)
}
};
const handleCheckUserConfirm = (info) => {
checkuser({ yhdh: info.yhdh, mm: info.mm }).then(response => {
if (response.code == 0) {
emits('update:tableKey', {
...tableKey.value,
yhdh: info.yhdh
});
proceedCheck(runnextstepname.value)
}
})
}
const proceedCheck = (checkType) => {
switch (checkType) {
case 1: // 初审
check1({ ...tableKey.value, yhdh: props.labPat.yhdh }).then(res => {
emits("changeStatus", props.labPat);
})
break;
case 2: // 审核
tableKey.value.problemId = 0
shHandleCheck()
break;
case 3: // 取消审核
tableKey.value.problemId = 0
unShHandle()
break;
default:
break;
}
}
const uploadwarningRef = ref();
const shHandleCheck = () => {
check2({ ...props.tableKey, yhdh: props.labPat.yhdh }).then(res => {
emits("changeStatus", props.labPat);
if (res.code == "4" && res.problemId === 4) {
tableKey.value.problemId = res.problemId;
warningMsgdata.value = res.msg;
uploadwarningRef.value.open();
}
})
};
const unconfirmlogRef = ref();
const unShHandle = () => {
uncheck2({ ...tableKey.value, yhdh: props.labPat.yhdh }).then(res => {
if (res.code == "4") {
tableKey.value.problemId = res.problemId;
reasonText.value = res.msg;
unconfirmlogRef.value.open();
}
emits("changeStatus", props.labPat);
})
};
const ruleFormRef = ref(null);
const submitForm = () => {
ruleFormRef.value.validate((valid) => {
if (valid) {
checkuser(ruleForm.value).then(res => {
if (res.code == 0) {
checkuserid.value = ruleForm.value.yhdh
checkShow.value = false;
ElMessage.success("验证成功");
}
})
} else {
return false;
}
});
}
// 2. 打开项目选择弹窗
const openItemDictDialog = () => {
itemDictRef.value.openDictSelector();
};
// 3. 处理项目选择结果:传递给labresult子组件新增行
const handleItemSelect = async (selectedItem) => {
// 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: tableKey.value.jyrq,
yq: tableKey.value.yq,
ybh: tableKey.value.ybh,
};
addRowFromDict(newRow);
// ElMessage.success(`已新增项目:${newRow.xmmc}`);
};
// 新增行核心方法:接收父组件传递的项目数据
const addRowFromDict = async (rowData) => {
if (!rowData.xmdh) return ElMessage.error("新增失败:项目编码不能为空");
const isDuplicate = tableData.value.some(item => item.xmdh === rowData.xmdh);
if (isDuplicate) return ElMessage.warning(`项目【${rowData.xmmc}】已存在`);
const newRow = { ...rowData, csjg: "" };
tableData.value.push(newRow);
// 5. 自动聚焦
nextTick(() => {
selectedRows.value = [newRow];
tableRef.value.setCurrentRow(newRow);
tableRef.value.setScrollTo(tableData.value.length - 1)
// 聚焦到新行的输入框
const inputs = document.querySelectorAll('.full-width-input .el-input__inner');
if (inputs.length > 0) {
inputs[inputs.length - 1].focus();
}
});
};
// 事件定义
const emits = defineEmits([
'fetchLabResults',
'changeStatus',
'previewHandle',
'update:tableKey'
]);
const csjgTableData = ref([]);
// const dbRow = ref({});
const handleInputFocus = (row) => {
// dbRow.value = row
queryXmVal({ yq: tableKey.value.yq, xmdh: row.xmdh }).then(res => {
if (res.code == 0) {
csjgTableData.value = res.data
}
nextTick(() => {
csjgRef.value.open()
})
})
};
const selectItem = (row) => {
// 查找修改行
const index = tableData.value.findIndex(item => item.xmdh == row.xmdh)
tableData.value[index].csjg = row.qz
handleCsjgEnter(tableData.value[index])
};
/**
* csjg输入框回车触发保存
*/
const handleCsjgEnter = async (row) => {
// 判断数据中包含模板新增的数据 flag
if (tableData.value.length == 0) return
const flag = tableData.value.some(item => item.changeflag == 2)
if (flag) {
saveResult(tableData.value).then((res) => {
if (res.code == 0) {
emitter.emit('saveResult');
}
})
} else {
if (!row) return
if (row && row.id) {
emitter.emit('saveResult');
newresult(row).then(response => {
ElMessage.success("结果保存成功");
emits('fetchLabResults');
}).catch(error => {
emits('fetchLabResults');
});
} else {
changeresult(row).then(response => {
ElMessage.success("结果保存成功");
emits('fetchLabResults');
}).catch(error => {
emits('fetchLabResults');
});
}
nextTick(() => {
const input = document.activeElement;
if (input.tagName === "INPUT") input.blur();
});
}
};
/**
* 处理选择变化
*/
const handleRowClick = (row) => {
selectedRows.value = [row];
emitter.emitWithCache('refreshClinical', row);
};
/**
* 新增行
*/
const handleAdd = () => {
const newRow = {
// 生成临时ID确保唯一性
id: `temp_${Date.now()}`,
jyrq: tableKey.value?.jyrq,
yq: tableKey.value?.yq,
ybh: tableKey.value?.ybh,
csjg: ""
};
tableData.value.push(newRow);
nextTick(() => {
const tableBody = document.querySelector('.el-table__body-wrapper');
if (tableBody) {
tableBody.scrollTop = tableBody.scrollHeight;
}
// 聚焦到新行的输入框
const inputs = document.querySelectorAll('.full-width-input .el-input__inner');
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 => !row.id);
ElMessageBox.confirm(
`确定要删除选中的 ${selectedRows.value.length} 条记录吗?`,
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
if (arr.length == 0) {
const index = tableData.value.findIndex(item => item.xmdh === selectedRows.value[0].xmdh);
if (index > -1) tableData.value.splice(index, 1);
selectedRows.value = [];
} else {
deleteresult(arr).then(res => {
if (res.code == 0) {
ElMessage.success('删除成功');
emits('fetchLabResults');
}
})
}
}).catch(() => {
});
};
const printHandle = () => {
const data = {
jyrq: tableKey.value.jyrq,
yq: tableKey.value.yq,
ybh: tableKey.value.ybh,
sqh: tableKey.value.sqh
}
printListwork(data).then(res => {
if (res.code == 0) {
classCom.printBase64PDF(res.data)
}
})
};
const previewHandle = () => {
const data = {
jyrq: tableKey.value.jyrq,
yq: tableKey.value.yq,
ybh: tableKey.value.ybh,
sqh: tableKey.value.sqh
}
printListwork(data).then(res => {
if (res.code == 0) {
emits('previewHandle', res.data);
}
})
};
/**
* 获取行号
*/
const getRowIndex = (index) => {
return index + 1;
};
onMounted(() => {
// 获取模板项目
emitter.on('dbMbHandle', (info) => {
// console.log('data==>', info);
if (props.labPat.jgbz != null && props.labPat.jgbz != 0 && props.labPat.jgbz != 'C') return ElMessage.warning('已审核结果不可添加模板项目');
const data = {
...tableKey.value,
mbmc: info.mbmc,
}
setinputmdl(data).then((res) => {
if (res.code == 0) {
const existingNames = new Set(tableData.value.map(item => item.xmdh))
res.data?.forEach(item => {
if (!existingNames.has(item.xmdh)) {
tableData.value.push(item)
existingNames.add(item.xmdh)
}
})
handleCsjgEnter(null)
emitter.emit('clearLxsrList')
}
});
})
// 监听病人信息修改同时保存病人结果
emitter.on('saveLab', () => {
handleCsjgEnter(null)
})
});
const formatYs = (v) => {
return userList.value.find((item) => item.userName == v)?.nickName || v
};
const formatDict = (v, dictType) => {
return props.dictData[dictType]?.find((item) => item.value == v)?.label || v;
}
</script>
<style scoped lang="scss">
.result-container {
height: calc(90vh - 4.3rem);
display: flex;
flex-direction: column;
overflow: hidden;
}
.flex-between {
// height: 32px;
margin-bottom: 0.5rem;
}
.custom-table-container {
height: 100%;
}
.tips {
font-family: SourceHanSansCN, SourceHanSansCN;
}
.btns_box {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
margin-top: 1.875rem;
.btn {
width: 80%;
height: 2.5rem;
line-height: 2.5rem;
margin-bottom: 0.5rem;
font-size: 0.9rem;
font-weight: 500;
border-radius: 0.5rem;
background-color: var(--el-color-primary);
color: var(--el-color-white);
cursor: pointer;
&:hover {
background-color: var(--el-color-primary-light-2);
}
&:last-child {
margin-bottom: 0;
}
&.disabled {
background-color: var(--el-color-primary-light-5);
cursor: not-allowed;
}
}
}
</style>