diff --git a/src/api/checkCode/index.ts b/src/api/checkCode/index.ts index d8d3901..76c6580 100644 --- a/src/api/checkCode/index.ts +++ b/src/api/checkCode/index.ts @@ -50,4 +50,36 @@ export function reportList(query?: Object) { method: 'post', data: query, }); +} +// 查询报告Pdf +export function reportPrintPdf(query?: Object) { + return request({ + url: '/report/pdf', + method: 'get', + params: query, + }); +} +// 查询项目报告 +export function reportResult(query?: Object) { + return request({ + url: '/report/result', + method: 'post', + data: query, + }); +} +// 查询微生物报告 +export function reportMedList(query?: Object) { + return request({ + url: '/report/MedList', + method: 'post', + data: query, + }); +} +// 查询微生物报告 +export function reportFsresult(query?: Object) { + return request({ + url: '/report/fsresult', + method: 'post', + data: query, + }); } \ No newline at end of file diff --git a/src/utils/classCom.ts b/src/utils/classCom.ts index 760394e..0773b35 100644 --- a/src/utils/classCom.ts +++ b/src/utils/classCom.ts @@ -55,7 +55,29 @@ function getContrastTextColor(bgColor: string): string { // 根据亮度返回对比色 return luminance > 0.5 ? '#333333' : '#FFFFFF'; } +// 打印base64 pdf +function printPDF(base64: string) { + const blob = base64ToBlob(base64); + const pdfUrl = URL.createObjectURL(blob); + const iframe = document.createElement('iframe'); + iframe.style.display = 'none'; + iframe.src = pdfUrl; + document.body.appendChild(iframe); + iframe.onload = () => { + iframe.contentWindow?.print(); + setTimeout(() => URL.revokeObjectURL(pdfUrl), 1000); // 释放内存 + }; +} + +function base64ToBlob(base64: string) { + const binaryString = atob(base64.replace(/[\n\r]/g, '')); + const bytes = new Uint8Array(binaryString.length); + for (let i = 0; i < binaryString.length; i++) { + bytes[i] = binaryString.charCodeAt(i); + } + return new Blob([bytes], { type: 'application/pdf' }); +} -export const classCom = { decimalToHexColor, getContrastTextColor } +export const classCom = { decimalToHexColor, getContrastTextColor, printPDF } diff --git a/src/views/checkCode/index.vue b/src/views/checkCode/index.vue index e980a92..abb6c19 100644 --- a/src/views/checkCode/index.vue +++ b/src/views/checkCode/index.vue @@ -488,10 +488,14 @@ const printHandle = () => { const data = { dept: '0235', userid: 'lis', - st: queryParams.times[0], - et: queryParams.times[1], + st: '', + et: '', yljg: queryParams.yljg } + if (queryParams.times && queryParams.times.length) { + data.st = queryParams.times[0] + data.et = queryParams.times[1] + } addObj(data).then((res: any) => { if (res.code == 0) { getList() diff --git a/src/views/checkCode/report/index.vue b/src/views/checkCode/report/index.vue index bcc53d8..379edcb 100644 --- a/src/views/checkCode/report/index.vue +++ b/src/views/checkCode/report/index.vue @@ -5,7 +5,7 @@ + end-placeholder="结束时间" format="YYYY-MM-DD" value-format="YYYY-MM-DD" /> @@ -15,7 +15,7 @@ - + @@ -65,7 +65,7 @@ 勾选中所有未打印 - 打印单张PDF报告 + 打印单张PDF报告 GUID打印报告 @@ -75,10 +75,14 @@ :columns="columns"> - + + @@ -95,11 +99,12 @@ 知识库 - + -
检验结果
- +
抗生素项目
+
@@ -110,16 +115,17 @@
- - - - @@ -127,7 +133,11 @@ import { ref, reactive, toRaw, computed, watch, nextTick, onMounted } from 'vue'; import CustomTable from '@/components/tableCom/index.vue' import { useRouter } from 'vue-router' -import { reportList } from '@/api/checkCode/index' +import { reportList, reportPrintPdf, reportResult, reportMedList, reportFsresult } from '@/api/checkCode/index' +import dayjs from 'dayjs'; +import { ElMessage, ElMessageBox } from 'element-plus' +import { classCom } from '@/utils/classCom' +import * as echarts from 'echarts'; //@ts-ignore import { comDict } from '@/utils/dict' const router = useRouter() @@ -135,46 +145,9 @@ const router = useRouter() const compactForm = ref(null); const heightForm = ref(90); const dialogVisible = ref(false) - const tableRefs = ref() -const openDB = () => { - dialogVisible.value = true -} - -const handleRowClick = (row: any) => { -} -const periods = [ - { - key: 'period1', - label: '2024-01-01~2024-01-07', - - }, - { - key: 'period2', - label: '2024-01-08~2024-01-14', - - } -] - -const compareTableData = [ - { - itemName: '血糖', - itemCode: 'GLU', - period1_value: 5.6, - period1_status: '正常', - period2_value: 6.2, - period2_status: '偏高' - }, - { - itemName: '血脂', - itemCode: 'CHOL', - period1_value: 4.8, - period1_status: '正常', - period2_value: 5.1, - period2_status: '正常' - } -] +const myEcharts = ref() interface QueryParams { times: string[]; // 明确类型为字符串元组 @@ -190,7 +163,7 @@ interface QueryParams { // 提交表单数据 const queryParams = reactive({ - times: ['2025-07-18 00:00:00', '2025-07-18 23:59:59'], + times: ['2025-08-19', '2025-08-19'], ksdh: '', brly: '', alarmflag: false, @@ -200,11 +173,14 @@ const queryParams = reactive({ sqh: '', dybz: '', }); - +const single = ref(true); +const multiple = ref(true); const alarmflag = ref('0') const jzbz = ref('0') const showSearch = ref(true); const queryRef = ref() +// 项目点击数据 +const Info = ref({}) // 定义校验规则 const queryRules = ref({ // clientId: [ @@ -229,27 +205,66 @@ const resetQuery = () => { } const loading = false; - +// 勾选框数据 +const rows = ref([]) // 数据源 const tableData = ref([]) // 配置项 const columns = ref([ { prop: 'dybz', label: '打印', visible: true, key: 0, slot: 'dybz', }, { prop: 'jzbz', label: '急诊', visible: true, key: 1, slot: 'jzbz', }, - { prop: 'alarmflag', label: '危急值', align: 'center', visible: true, key: 2, }, + { prop: 'alarmflag', label: '危急值', align: 'center', visible: true, key: 2, slot: 'alarmflag' }, { prop: 'jyrq', label: '检验日期', align: 'center', visible: true, key: 3, width: '150px' }, { prop: 'brdh', label: '病人代号', align: 'center', visible: true, key: 4, width: '110px' }, { prop: 'ch', label: '床号', align: 'center', visible: true, key: 5, sortable: true, }, { prop: 'yqdl', label: '仪器', align: 'center', visible: true, key: 6, width: '110px' }, { prop: 'ybh', label: '样本号', align: 'center', visible: true, key: 7, }, { prop: 'yblxname', label: '样本类型', align: 'center', visible: true, key: 8, }, - { prop: 'jymd', label: '检验目的', align: 'center', visible: true, key: 9, }, + { prop: 'jymd', label: '检验目的', align: 'center', visible: true, key: 9, width: '110px' }, { prop: 'brlyname', label: '病人类型', align: 'center', visible: true, key: 10, }, { prop: 'brxbname', label: '性别', align: 'center', visible: true, key: 11, }, { prop: 'yqmc', label: '仪器名称', align: 'center', visible: true, key: 12, width: '150px' }, { prop: 'yljg', label: '医疗机构', align: 'center', visible: true, key: 13, width: '150px' }, ]) +const selectionChange = (selection: any) => { + rows.value = selection + single.value = selection.length != 1; + multiple.value = !selection.length; +} + +const rowHandle = (row: any) => { + Info.value = row + const data = { + jyrq: row.jyrq, + yq: row.yq, + ybh: row.ybh, + } + reportResult(data).then((res: any) => { + if (res.code == 0) { + rightTableData.value = res.data + } + }) +} + +// 打印单张Pdf +const printPdf = () => { + const data = { + jyrq: rows.value[0].jyrq, + yq: rows.value[0].yq, + ybh: rows.value[0].ybh + } + reportPrintPdf(data).then((res: any) => { + if (res.code == 0) { + if (!res.data.base64PDF) return + classCom.printPDF(res.data.base64PDF) + } + }) +} + + + + // 单元格样式 const cellStyleHd = ({ row, column, rowIndex, columnIndex }: { row: any; @@ -261,6 +276,9 @@ const cellStyleHd = ({ row, column, rowIndex, columnIndex }: { if (column.label == "急诊" && row.jzbz == "1") { return { background: '#f00 !important', color: '#fff' }; } + if (column.label == "危急值" && row.alarmflag == "1") { + return { background: '#f00 !important', color: '#fff' }; + } }; @@ -281,6 +299,7 @@ const tableConfig = ref( // 勾选未打印 const selectStatusRows = () => { + tableRefs.value.clearSelection() tableData.value.forEach((item: any) => { if (item.dybz != 1) { tableRefs.value.toggleRowSelection(item, true) @@ -323,37 +342,15 @@ const updateColumns = (arr: Array) => { // 右侧数据源 -const rightTableData = [ - { - id: 1, tfailed1: 'P001', tfailed2: '项目A', tfailed3: 100, tfailed4: 2, tfailed5: '待处理', tfailed6: '是', - }, - { - id: 2, tfailed1: 'P002', tfailed2: '项目B', tfailed3: 100, tfailed4: 2, tfailed5: '待处理', tfailed6: '是', - }, - { - id: 2, tfailed1: 'P002', tfailed2: '项目B', tfailed3: 100, tfailed4: 2, tfailed5: '待处理', tfailed6: '是', - }, - { - id: 2, tfailed1: 'P002', tfailed2: '项目B', tfailed3: 100, tfailed4: 2, tfailed5: '待处理', tfailed6: '是', - }, - { - id: 2, tfailed1: 'P002', tfailed2: '项目B', tfailed3: 100, tfailed4: 2, tfailed5: '待处理', tfailed6: '是', - }, - { - id: 2, tfailed1: 'P002', tfailed2: '项目B', tfailed3: 100, tfailed4: 2, tfailed5: '待处理', tfailed6: '是', - }, - { - id: 2, tfailed1: 'P002', tfailed2: '项目B', tfailed3: 100, tfailed4: 2, tfailed5: '待处理', tfailed6: '是', - }, -] +const rightTableData = ref([]) // 配置项 const rightColumns = ref([ - { prop: 'tfailed1', label: '项目代号', visible: true, key: 0, sortable: true, width: '110px' }, - { prop: 'tfailed2', label: '项目名称', visible: true, key: 1 }, - { prop: 'tfailed3', label: '单价', align: 'center', visible: true, key: 2 }, - { prop: 'tfailed4', label: '数量', align: 'center', visible: true, key: 3 }, - { prop: 'tfailed5', label: '状态', align: 'center', visible: true, key: 4 }, - { prop: 'tfailed6', label: '计价标志', align: 'center', visible: true, key: 5 }, + { prop: 'xmdh', label: '项目代号', align: 'center', visible: true, key: 0, }, + { prop: 'xmmc', label: '项目名称', align: 'center', visible: true, key: 1 }, + { prop: 'csjg', label: '结果', align: 'center', visible: true, key: 2 }, + { prop: 'refs', label: '参考值', align: 'center', visible: true, key: 3 }, + { prop: 'dw', label: '单位', align: 'center', visible: true, key: 4 }, + { prop: 'jgbz', label: '结果标志', align: 'center', visible: true, key: 5 }, ]) // 表格配置 @@ -365,10 +362,200 @@ const rightTableConfig = ref( index: false, // 序号 height: '28vh', // 高度 highlightCurrentRow: true, // 高亮当前行 - fit: true } ) +const xmRow = ref({}) +// 查询抗生素 +const xmrowHandle = (row: any) => { + xmRow.value = row + const data = { + jyrq: Info.value.jyrq, + yq: Info.value.yq, + ybh: Info.value.ybh, + xmdh: row.xmdh + } + reportMedList(data).then((res: any) => { + if (res.code == 200) { + bottomTableData.value = res.rows + } + }) +} + +const periods = ref([]) + +const compareTableData = ref([]) + + +// 历史数据对比 +const openDB = () => { + // 00507620 + compareTableData.value = [] + if (!xmRow.value.xmdh) return ElMessage.error('至少选择一条数据进行对比') + const data = { + brdh: Info.value.brdh, + xmdh: xmRow.value.xmdh + } + reportFsresult(data).then((res: any) => { + periods.value = [] + if (res.code == 0) { + const arr: string[] = res.data.map((item: any) => item.confirmdt); + periods.value = [...new Set(arr)]; + res.data.forEach((v: any) => { + arr.forEach((item: any) => { + if (item == v.confirmdt) { + v[item] = v.csjg + } + }) + }); + + // @ts-ignore 忽略重组数据动态时间key + compareTableData.value = formatGroupedData(res.data) + dialogVisible.value = true + nextTick(() => { + handleRowClick(compareTableData.value[0]) + }) + } + }) +} + +// 数据重组 +const formatGroupedData = (data: any[]) => { + if (!data || data.length === 0) return []; + + const groupMap: any = {}; + data.forEach(item => { + const key = item.xmdh; + if (!groupMap[key]) { + groupMap[key] = { + xmdh: item.xmdh, + xmmc: item.xmmc, + // confirmdt: item.confirmdt + }; + } + const dateKeys = Object.keys(item).filter(key => + /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(key) // 匹配 YYYY-MM-DD HH:mm:ss 时间格式 + ); + // 将日期键值对添加到分组对象 + dateKeys.forEach(dateKey => { + groupMap[key][dateKey] = item[dateKey]; + }); + }); + // 将 Map 转为数组 + return Object.values(groupMap); +}; + +const handleRowClick = (row: any) => { + getEcharts(row) +} + +const getEcharts = (data: any) => { + const dateKeys = Object.keys(data).filter(key => + /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(key) + ); + const Intance = echarts.init(myEcharts.value); + const xData = dateKeys; + let seriesData = [] + seriesData = dateKeys.map(item => data[item]); + + const option = { + title: { + text: data.xmmc, + top: '5', + right: '5%', + left: '20', + // bottom: '20%' + // subtext: 'Feature Sample: Gradient Color, Shadow, Click Zoom' + }, + tooltip: { + trigger: 'axis' + }, + grid: { + top: '20%', + left: '3%', + right: '4%', + // bottom: '3%', + height: '80%', + containLabel: true + }, + xAxis: { + type: 'category', + data: xData, + axisTick: { + show: false + }, + axisLine: { + lineStyle: { + // color: 'rgba(193, 207, 220, 1)', + } + }, + axisLabel: { + rotate: 30, + textStyle: { + + color: "#8D949B " + } + }, + }, + yAxis: [{ + // name: '单位(mm)', + type: 'value', + axisLabel: { + textStyle: { + color: "#8D949B" + }, + // formatter: '{value}%' + + + }, + axisLine: { + show: false, + lineStyle: { + color: '#24abf2' + } + }, + splitLine: { + show: true, + lineStyle: { + type: 'dashed' + }, + }, + } + ], + series: [{ + name: data.xmmc, + type: 'line', + data: seriesData, + symbol: 'circle', + symbolSize: 5, //标记的大小 + lineStyle: { + normal: { + width: 2, + color: '#24abf2', + } + }, + itemStyle: { + normal: { + color: '#24abf2', + } + }, + smooth: true + } + ] + }; + + Intance.setOption(option); +} + +// 右侧数据源 +const bottomTableData = ref([]) +// 配置项 +const bottomColumns = ref([ + { prop: 'ywdh', label: '抗生素编号', align: 'center', visible: true, key: 0 }, + { prop: 'ywmc', label: '抗生素名称', align: 'center', visible: true, key: 1 }, + { prop: 'csjg', label: '测试结果', align: 'center', visible: true, key: 2 }, + { prop: 'jgbz', label: '结果标志', align: 'center', visible: true, key: 3 }, +]) // 表格配置 const bottomTableConfig = ref( { @@ -378,7 +565,6 @@ const bottomTableConfig = ref( index: false, // 序号 height: '28vh', // 高度 highlightCurrentRow: true, // 高亮当前行 - fit: true, } ) interface DictData { @@ -392,6 +578,11 @@ interface DictData { const dictData = ref({}); onMounted(async () => { + // 初始化3天区间(今天-前两天) + // const end = dayjs().format('YYYY-MM-DD HH:mm:ss'); + // const start = dayjs().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'); //add 时间往后 + // queryParams.times = [start, end]; + // console.log(queryParams.times); getList() adjustTableHeight(); @@ -408,8 +599,6 @@ onMounted(async () => { const getList = () => { const data = { - // dept: '0235', - // userid: 'lis', alarmflag: alarmflag.value, jzbz: jzbz.value, dybz: queryParams.dybz, @@ -418,14 +607,19 @@ const getList = () => { brxm: queryParams.brxm, brdh: queryParams.brdh, sqh: queryParams.sqh, - st: queryParams.times[0], - et: queryParams.times[1], + st: '', + et: '', yljg: 1 } + if (queryParams.times && queryParams.times.length) { + data.st = queryParams.times[0] + data.et = queryParams.times[1] + } reportList(data).then((res: any) => { - if (res.code == 200) { - tableData.value = res.rows - tableRefs.value.setCurrentRow(res.rows[0]) + if (res.code == 0) { + tableData.value = res.data + tableRefs.value.setCurrentRow(res.data[0]) + rowHandle(res.data[0]) } }) }