825 lines
25 KiB
Vue
825 lines
25 KiB
Vue
<template>
|
||
<div class="app-container">
|
||
<div ref="compactForm">
|
||
<el-row :gutter="5" class="compact-form" v-show="showSearch">
|
||
<el-form :model="queryParams" ref="queryRef" label-width="100px" :rules="queryRules" style="width: 100%;">
|
||
<el-row>
|
||
<el-col :span="5">
|
||
<el-form-item label="日期:" prop="times">
|
||
<el-date-picker v-model="queryParams.times" type="daterange" range-separator="-"
|
||
start-placeholder="开始时间" end-placeholder="结束时间" format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="5">
|
||
<el-form-item label="打印状态:" prop="dybz">
|
||
<el-select v-model="queryParams.dybz" placeholder="请选择" clearable>
|
||
<el-option label="已打印" value="1" />
|
||
<el-option label="未打印" value="0" />
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="5">
|
||
<el-form-item label="科室:" prop="ksdh">
|
||
<el-select v-model="queryParams.ksdh" placeholder="请选择" filterable clearable>
|
||
<el-option v-for="item in dictData.DP" :key="item.value" :label="item.label" :value="item.value" />
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="5">
|
||
<el-form-item label="病人类型:" prop="brlyname">
|
||
<el-select v-model="queryParams.brlyname" placeholder="请选择" clearable>
|
||
<el-option v-for="item in dictData.PT" :key="item.value" :label="item.label" :value="item.label" />
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
|
||
</el-row>
|
||
<el-row>
|
||
<el-col :span="5">
|
||
<el-form-item label-width="50px">
|
||
<el-checkbox v-model="queryParams.alarmflag" label="仅危急值" @change="alarmHandle" size="large" />
|
||
<el-checkbox v-model="queryParams.jzbz" label="仅急诊" @change="jzbzHandle" size="large" />
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="5">
|
||
<el-form-item label="姓名:" prop="brxm">
|
||
<el-input v-model="queryParams.brxm" clearable placeholder="请输入姓名" @keyup.enter="handleQuery"
|
||
@clear="handleQuery" />
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="5">
|
||
<el-form-item label="病人号:" prop="brdh">
|
||
<el-input v-model="queryParams.brdh" clearable placeholder="请输入病人号" @keyup.enter="handleQuery"
|
||
@clear="handleQuery" />
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="5">
|
||
<el-form-item label="床号:" prop="ch">
|
||
<el-input v-model="queryParams.ch" clearable placeholder="请输入床号" @keyup.enter="handleQuery"
|
||
@clear="handleQuery" />
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="4">
|
||
<el-form-item label-width="50px">
|
||
<el-button icon="search" type="primary" @click="handleQuery">
|
||
搜索
|
||
</el-button>
|
||
<!-- <el-button icon="Refresh" @click="resetQuery">重置</el-button> -->
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
|
||
</el-form>
|
||
</el-row>
|
||
</div>
|
||
<el-row :gutter="20">
|
||
<el-col :span="16" class="right-table">
|
||
<el-row :gutter="10" class="mb8 mt10">
|
||
<el-col :span="1.5">
|
||
<el-button type="primary" plain icon="Edit" @click="selectStatusRows">勾选所有未打印</el-button>
|
||
</el-col>
|
||
<el-col :span="1.5">
|
||
</el-col>
|
||
<el-col :span="1.5">
|
||
<el-button type="primary" plain icon="Upload" @click="printPdf">打印报告</el-button>
|
||
</el-col>
|
||
|
||
<!-- <right-toolbar v-model:showSearch="showSearch" @updateColumns="updateColumns" @queryTable="handleQuery"
|
||
:columns="columns"></right-toolbar> -->
|
||
</el-row>
|
||
|
||
<CustomTable ref="tableRefs" :data="tableData" :columns="columns" :config="tableConfig" :loading="loading"
|
||
@selection-change="selectionChange" @row-click="rowHandle">
|
||
<template #dybz="{ row }">
|
||
{{ row.dybz == 1 ? '✅' : '❌' }}
|
||
</template>
|
||
<template #alarmflag="{ row }">
|
||
{{ row.alarmflag == 1 ? '危' : '' }}
|
||
</template>
|
||
<template #jzbz="{ row }">
|
||
{{ row.jzbz == 1 ? '急' : '' }}
|
||
</template>
|
||
</CustomTable>
|
||
|
||
</el-col>
|
||
<el-col :span="8" class="right-table">
|
||
<!-- <div class="title">检验结果</div> -->
|
||
<div class="mb8 mt10">
|
||
<el-button type="primary" plain @click="openDB">对比历史</el-button>
|
||
<el-select class="ml10" placeholder="请选择复制" style="width: 140px" @change="copyData">
|
||
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
|
||
</el-select>
|
||
<!-- <el-button type="primary">知识库</el-button> -->
|
||
</div>
|
||
|
||
<CustomTable :data="rightTableData" :columns="rightColumns" :config="rightTableConfig" :loading="loading"
|
||
@row-click="xmrowHandle" ref="rightTableRef">
|
||
<template #jgbz="{ row }">
|
||
{{ formatJgbz(row.jgbz) }}
|
||
</template>
|
||
</CustomTable>
|
||
|
||
<div class="mt10" v-if="bottomTableData.length > 0"></div>
|
||
<CustomTable v-if="bottomTableData.length > 0" :data="bottomTableData" :columns="bottomColumns"
|
||
:config="bottomTableConfig" :loading="loading">
|
||
</CustomTable>
|
||
</el-col>
|
||
</el-row>
|
||
|
||
|
||
<!-- 结果对比 -->
|
||
<el-dialog v-model="dialogVisible" title="结果对比" draggable :close-on-click-modal="false">
|
||
<div class="flex-between">
|
||
|
||
</div>
|
||
<el-table :data="compareTableData" style="width: 100%" @row-click="handleRowClick" highlight-current-row border
|
||
max-height="350px">
|
||
<el-table-column prop="xmdh" label="项目编号" fixed align="center" width="150px" />
|
||
<el-table-column prop="xmmc" label="项目名称" fixed align="center" />
|
||
<template v-for="(period) in periods" :key="period">
|
||
<el-table-column :label="period" :prop="period" :width="150" align="center" />
|
||
</template>
|
||
</el-table>
|
||
|
||
<div ref="myEcharts" style="width:100%;height: 350px" />
|
||
</el-dialog>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { ref, reactive, toRaw, computed, watch, nextTick, onMounted } from 'vue';
|
||
import CustomTable from '@/components/elTable/index.vue'
|
||
import { useRouter } from 'vue-router'
|
||
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 { HiprintPrinter } from '@/utils/hiprintPrinter';
|
||
import * as echarts from 'echarts';
|
||
//@ts-ignore
|
||
import { comDict } from '@/utils/dict'
|
||
import { usePrintStore } from '@/store/modules/printStore'
|
||
//@ts-ignore
|
||
import useUserStore from '@/store/modules/user'
|
||
import { useRoute } from 'vue-router'
|
||
|
||
const route = useRoute()
|
||
|
||
const userStore = useUserStore()
|
||
const compactForm = ref<HTMLElement | null>(null);
|
||
const heightForm = ref(90);
|
||
const dialogVisible = ref(false)
|
||
const tableRefs = ref()
|
||
|
||
const myEcharts = ref()
|
||
const options = ref([
|
||
{ label: '复制全部数据', value: 'All' },
|
||
{ label: '复制异常数据', value: 'N' },
|
||
{ label: '复制正常数据', value: 'Y' },
|
||
]
|
||
)
|
||
interface QueryParams {
|
||
times: string[]; // 明确类型为字符串元组
|
||
alarmflag: boolean,
|
||
jzbz: boolean,
|
||
ksdh: string,
|
||
brlyname: string,
|
||
brxm: string,
|
||
brdh: string,
|
||
ch: string,
|
||
dybz: string,
|
||
sqh: string,
|
||
userid: string
|
||
}
|
||
|
||
// 提交表单数据
|
||
const queryParams = reactive<QueryParams>({
|
||
times: ['2025-08-19', '2025-08-19'],
|
||
// ksdh: '0203',
|
||
ksdh: '0210',
|
||
brlyname: '',
|
||
sqh: '25080109476',
|
||
alarmflag: false,
|
||
jzbz: false,
|
||
brxm: '',
|
||
brdh: '',
|
||
ch: '',
|
||
dybz: '',
|
||
userid: ''
|
||
});
|
||
|
||
const startDate = typeof route.query.startdate === 'string' ? route.query.startdate : '';
|
||
const endDate = typeof route.query.endate === 'string' ? route.query.endate : '';
|
||
queryParams.times = [startDate, endDate];
|
||
queryParams.ksdh = (route.query.deptcode as string) || '';
|
||
queryParams.userid = (route.query.userid as string) || '';
|
||
queryParams.brdh = (route.query.brdh as string) || '';
|
||
|
||
console.log('queryParams==>', queryParams);
|
||
|
||
const single = ref(true);
|
||
const multiple = ref(true);
|
||
const alarmflag = ref()
|
||
const jzbz = ref()
|
||
const showSearch = ref(true);
|
||
const queryRef = ref()
|
||
// 项目点击数据
|
||
const Info = ref<any>({})
|
||
// 定义校验规则
|
||
const queryRules = ref({
|
||
// clientId: [
|
||
// { required: true, message: '编号不能为空', trigger: 'blur' },
|
||
|
||
// ],
|
||
|
||
// failed3: [
|
||
// { required: true, message: '条码状态不能为空', trigger: 'change' },
|
||
// ],
|
||
})
|
||
|
||
const handleQuery = async () => {
|
||
const valid = await queryRef.value.validate().catch(() => { });
|
||
if (!valid) return false;
|
||
getList()
|
||
}
|
||
// 重置
|
||
const resetQuery = () => {
|
||
queryRef.value?.resetFields();
|
||
getList()
|
||
}
|
||
|
||
const loading = false;
|
||
// 勾选框数据
|
||
const rows = ref<any[]>([])
|
||
// 数据源
|
||
const tableData = ref([])
|
||
// 配置项
|
||
const columns = ref([
|
||
{ type: 'selection', visible: true, align: 'center', width: 55, label: '多选框' },
|
||
{ prop: 'dybz', label: '打印', align: 'center', visible: true, key: 0, slot: 'dybz', width: 60 },
|
||
{ prop: 'jzbz', label: '急诊', align: 'center', visible: true, key: 1, slot: 'jzbz', },
|
||
{ prop: 'alarmflag', label: '危急值', align: 'center', visible: true, key: 2, slot: 'alarmflag' },
|
||
{ prop: 'jyrq', label: '检验日期', align: 'center', visible: true, key: 3, sortable: true, width: 150 },
|
||
{ prop: 'brdh', label: '病人代号', align: 'center', visible: true, key: 4, width: 110 },
|
||
{ prop: 'brxm', label: '病人姓名', align: 'center', visible: true, key: 4, },
|
||
{ prop: 'brxbname', label: '性别', align: 'center', visible: true, key: 11, },
|
||
{ prop: 'ch', label: '床号', align: 'center', visible: true, key: 5, },
|
||
{ prop: 'yqdl', label: '仪器', align: 'center', visible: true, key: 6, width: 110 },
|
||
{ 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, width: 110 },
|
||
{ prop: 'brlyname', label: '病人类型', align: 'center', visible: true, key: 10, },
|
||
{ prop: 'yqmc', label: '仪器名称', align: 'center', visible: true, key: 12, width: 150 },
|
||
{ prop: 'yljg', label: '医疗机构', align: 'center', visible: true, key: 13, width: 150 },
|
||
])
|
||
|
||
const selectionChange = (selection: any) => {
|
||
rows.value = selection
|
||
single.value = selection.length != 1;
|
||
multiple.value = !selection.length;
|
||
}
|
||
|
||
const rightTableRef = ref()
|
||
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
|
||
rightTableRef.value.setCurrentRow(res.data[0])
|
||
xmrowHandle(res.data[0])
|
||
}
|
||
})
|
||
}
|
||
|
||
// 打印单张Pdf
|
||
const printPdf = () => {
|
||
const printStore = usePrintStore();
|
||
const merge = rows.value.map((item: any) => { return `${item.jyrqname.replace(/-/g, '')}_${item.yq.trim()}_${item.ybh}` })
|
||
// const merge = [
|
||
// "20250819_11_1",
|
||
// "20250819_11_10",
|
||
// "20250819_11_11"
|
||
// ]
|
||
reportPrintPdf(merge).then((res: any) => {
|
||
if (res.code == 0) {
|
||
if (!res.data) return ElMessage.warning('未找到打印文件')
|
||
classCom.printBase64PDF(res.data)
|
||
// if (printStore.isConnected) {
|
||
// HiprintPrinter.silentPrint([res.data])
|
||
// } else {
|
||
// classCom.printBase64PDF(res.data)
|
||
// }
|
||
}
|
||
})
|
||
}
|
||
|
||
// 单元格样式
|
||
const cellStyleHd = ({ row, column, rowIndex, columnIndex }: {
|
||
row: any;
|
||
column: any;
|
||
rowIndex: number;
|
||
columnIndex: number;
|
||
}) => {
|
||
// console.log(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' };
|
||
}
|
||
};
|
||
|
||
// 表格配置
|
||
const tableConfig = ref(
|
||
{
|
||
// stripe: true, // 斑马纹
|
||
border: true, // 边框
|
||
height: '', // 高度
|
||
highlightCurrentRow: true, // 高亮当前行
|
||
fit: true,
|
||
cellStyle: cellStyleHd
|
||
}
|
||
)
|
||
|
||
// 勾选未打印
|
||
const selectStatusRows = () => {
|
||
tableRefs.value.clearSelection()
|
||
tableData.value.forEach((item: any) => {
|
||
if (item.dybz != 1) {
|
||
tableRefs.value.toggleRowSelection(item, true)
|
||
}
|
||
})
|
||
}
|
||
const alarmHandle = (val: boolean) => {
|
||
if (val) {
|
||
queryParams.jzbz = false
|
||
alarmflag.value = '1'
|
||
jzbz.value = null
|
||
} else {
|
||
alarmflag.value = null
|
||
}
|
||
|
||
}
|
||
const jzbzHandle = (val: boolean) => {
|
||
if (val) {
|
||
queryParams.alarmflag = false
|
||
alarmflag.value = null
|
||
jzbz.value = '1'
|
||
} else {
|
||
jzbz.value = null
|
||
}
|
||
}
|
||
|
||
|
||
interface ColumnItem {
|
||
prop: string;
|
||
label: string;
|
||
visible: boolean;
|
||
key: number;
|
||
align?: string;
|
||
slot?: string;
|
||
width?: string | number;
|
||
sortable?: boolean;
|
||
type?: string;
|
||
}
|
||
// 更新列
|
||
const updateColumns = (arr: any[]) => {
|
||
columns.value = arr
|
||
};
|
||
|
||
|
||
// 右侧数据源
|
||
const rightTableData = ref([])
|
||
// 配置项
|
||
const rightColumns = ref([
|
||
{ 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, slot: 'jgbz' },
|
||
])
|
||
|
||
const rightCellStyleHd = ({ row, column, rowIndex, columnIndex }: {
|
||
row: any;
|
||
column: any;
|
||
rowIndex: number;
|
||
columnIndex: number;
|
||
}) => {
|
||
if (column.label == "检验结果" && (row.alarm_flag ?? "").trim().length > 0) {
|
||
return { background: '#f00 !important', color: '#FFF' };
|
||
}
|
||
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: '#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 rightTableConfig = ref(
|
||
{
|
||
// stripe: true, // 斑马纹
|
||
border: true, // 边框
|
||
height: '40vh', // 高度
|
||
highlightCurrentRow: true, // 高亮当前行
|
||
cellStyle: rightCellStyleHd
|
||
}
|
||
)
|
||
|
||
const formatJgbz = (v: string) => {
|
||
return v == 'H' ? '高' : v == 'L' ? '低' : v == 'N' ? '阴性' : v == 'P' ? '阳性' : v == 'Q' ? '弱阳性' : v == 'M' ? '正常' : ''
|
||
}
|
||
|
||
|
||
const xmRow = ref<any>({})
|
||
// 查询抗生素
|
||
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
|
||
if (res.rows.length > 0) {
|
||
nextTick(() => {
|
||
rightTableConfig.value.height = `calc(55vh - ${heightForm.value}px)`
|
||
rightTableRef.value?.doLayout && rightTableRef.value.doLayout();
|
||
});
|
||
} else {
|
||
nextTick(() => {
|
||
rightTableConfig.value.height = `calc(93vh - ${heightForm.value}px)`
|
||
rightTableRef.value?.doLayout && rightTableRef.value.doLayout();
|
||
});
|
||
}
|
||
}
|
||
})
|
||
}
|
||
|
||
const periods = ref<string[]>([])
|
||
|
||
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])
|
||
})
|
||
}
|
||
})
|
||
}
|
||
|
||
|
||
interface copyItem {
|
||
xmdh: string;
|
||
xmmc: string;
|
||
csjg: string | number;
|
||
refs: string | number;
|
||
dw: string;
|
||
jgbz: string;
|
||
}
|
||
// 复制函数
|
||
const copyData = (type: string) => {
|
||
let str = ''
|
||
const getCommonRow = (item: copyItem) => `${item.xmdh}\t${item.xmmc}\t${item.csjg}\t${item.refs}\t${item.dw}\t${item.jgbz}\t\r\n`;
|
||
rightTableData.value.forEach((v: any) => {
|
||
if (type == 'All') {
|
||
str = str + getCommonRow(v)
|
||
str = str + v.xmmc + v.csjg + v.dw + + ',';
|
||
}
|
||
if (type == 'N' && v.jgbz != 'M' && v.jgbz != '') {
|
||
str = str + getCommonRow(v)
|
||
}
|
||
if (type == 'Y' && v.jgbz == 'M' && v.jgbz != '') {
|
||
str = str + getCommonRow(v)
|
||
}
|
||
})
|
||
|
||
var input = document.createElement('textarea');
|
||
if (!str) return ElMessage.error('没有数据可复制');
|
||
// 把文字放进input中,供复制
|
||
input.value = str;
|
||
document.body.appendChild(input);
|
||
// 选中创建的input
|
||
input.select();
|
||
var copy_result = document.execCommand('copy');
|
||
if (copy_result) {
|
||
ElMessage.success('复制成功');
|
||
} else {
|
||
ElMessage.error('复制失败');
|
||
}
|
||
// 移除
|
||
document.body.removeChild(input);
|
||
}
|
||
|
||
// 数据重组
|
||
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, },
|
||
{ prop: 'ywmc', label: '抗生素名称', align: 'center', visible: true, },
|
||
{ prop: 'csjg', label: '测试结果', align: 'center', visible: true },
|
||
// { prop: 'jgbz', label: '结果标志', align: 'center', visible: true },
|
||
])
|
||
const botCellStyleHd = ({ 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.trim() == "") {
|
||
return { background: '#ffff80 !important', color: '#606266' };
|
||
}
|
||
}
|
||
// 表格配置
|
||
const bottomTableConfig = ref(
|
||
{
|
||
// stripe: true, // 斑马纹
|
||
border: true, // 边框
|
||
height: '37vh', // 高度
|
||
highlightCurrentRow: true, // 高亮当前行
|
||
cellStyle: botCellStyleHd
|
||
}
|
||
)
|
||
interface DictData {
|
||
DP?: Array<any>;
|
||
PT?: Array<any>;
|
||
[key: string]: any[] | undefined; // 添加索引签名以支持动态访问
|
||
}
|
||
|
||
|
||
// 字典数据存储
|
||
const dictData = ref<DictData>({});
|
||
|
||
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);
|
||
// 进入页面单点登录
|
||
userStore.loginAnonymous({ name: 'admin' })
|
||
getList()
|
||
adjustTableHeight();
|
||
|
||
// 加载病人来源字典
|
||
const dictRefs = await comDict('PT', 'DP');
|
||
|
||
// 从 ref 中获取实际数据
|
||
dictData.value = {
|
||
PT: toRaw(dictRefs.PT.value) || [],
|
||
DP: toRaw(dictRefs.DP.value) || [],
|
||
};
|
||
});
|
||
|
||
|
||
const getList = () => {
|
||
if (!queryParams.ksdh) return ElMessage.error('科室代号不能为空');
|
||
if (!queryParams.userid) return ElMessage.error('用户userid不能为空');
|
||
const data = {
|
||
alarmflag: alarmflag.value,
|
||
jzbz: jzbz.value,
|
||
dybz: queryParams.dybz,
|
||
ksdh: queryParams.ksdh,
|
||
brlyname: queryParams.brlyname,
|
||
brxm: queryParams.brxm,
|
||
brdh: queryParams.brdh,
|
||
ch: queryParams.ch,
|
||
userid: queryParams.userid,
|
||
st: '',
|
||
et: '',
|
||
yljg: 1,
|
||
|
||
}
|
||
if (queryParams.times && queryParams.times.length) {
|
||
data.st = queryParams.times[0]
|
||
data.et = queryParams.times[1]
|
||
} else {
|
||
return ElMessage.error('日期时间段不能为空');
|
||
}
|
||
reportList(data).then((res: any) => {
|
||
if (res.code == 0) {
|
||
tableData.value = res.data
|
||
tableRefs.value.setCurrentRow(res.data[0])
|
||
rowHandle(res.data[0])
|
||
}
|
||
})
|
||
}
|
||
|
||
// 计算table高度
|
||
watch(showSearch, () => {
|
||
nextTick(() => {
|
||
adjustTableHeight();
|
||
})
|
||
}, { immediate: true });
|
||
|
||
function adjustTableHeight() {
|
||
if (compactForm.value) {
|
||
heightForm.value = compactForm.value.offsetHeight;
|
||
|
||
nextTick(() => {
|
||
tableConfig.value.height = `calc(93vh - ${heightForm.value}px)`
|
||
tableRefs.value?.doLayout && tableRefs.value.doLayout();
|
||
});
|
||
|
||
}
|
||
}
|
||
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.compact-form {
|
||
border-bottom: 1px solid #E1E9F7;
|
||
}
|
||
|
||
.title {
|
||
border-bottom: 1px solid #E1E9F7;
|
||
margin-bottom: 10px;
|
||
padding: 10px;
|
||
font-weight: 700;
|
||
}
|
||
</style> |