Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
20d91d0fc9
@ -31,6 +31,7 @@ export interface PatientVO {
|
||||
shqx: string // 生化编号
|
||||
isprint: number // 是否打印
|
||||
printtime: Date // 打印时间
|
||||
barcodetime: Date // 条形码时间
|
||||
chiefinspectorid: string // 总检医生ID
|
||||
chiefinspector: string // 总检医生
|
||||
}
|
||||
@ -165,5 +166,11 @@ export const PatientApi = {
|
||||
//更新患者补充信息
|
||||
updatePatientSupplement: async (medicalSn: string,idCard: string) => {
|
||||
return await request.get({ url: `/inspect/patient/updatePatientSupplement?medicalSn=` + medicalSn + `&idCard=` + idCard})
|
||||
},
|
||||
//更新条形码打印时间
|
||||
updateBarcodeTime: async (medicalSn: string, barcodetime: Date) => {
|
||||
return await request.put({
|
||||
url: `/inspect/patient/updateBarcodeTime?medicalSn=${medicalSn}&barcodetime=${barcodetime.toISOString()}`
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -347,8 +347,56 @@ const createPrint = async (medicalSn) => {
|
||||
/** 打印条形码 */
|
||||
const handlePrintBarcode = async (row: PatientVO) => {
|
||||
try {
|
||||
// 获取最新的患者信息
|
||||
const patientInfo = await PatientApi.getPatientInfo(row.medicalSn)
|
||||
console.log('患者信息:', patientInfo)
|
||||
|
||||
// 检查是否存在条形码打印时间
|
||||
if(patientInfo.barcodetime){
|
||||
// 格式化上次打印时间,显示中文年月日格式
|
||||
const date = new Date(patientInfo.barcodetime)
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const lastPrintTime = `${year}年${month}月${day}日`
|
||||
|
||||
// 格式化报告打印时间
|
||||
let reportPrintTime = ''
|
||||
if (patientInfo.medicalDateTime && patientInfo.status == 1) {
|
||||
const reportDate = new Date(patientInfo.medicalDateTime)
|
||||
const reportYear = reportDate.getFullYear()
|
||||
const reportMonth = String(reportDate.getMonth() + 1).padStart(2, '0')
|
||||
const reportDay = String(reportDate.getDate()).padStart(2, '0')
|
||||
reportPrintTime = `${reportYear}年${reportMonth}月${reportDay}日`
|
||||
}
|
||||
|
||||
try {
|
||||
// 显示只有确定按钮的提示框
|
||||
await ElMessageBox.alert(
|
||||
`<div style="margin-bottom: 10px">该条形码已于 <span style="color: #f56c6c; font-weight: bold;">${lastPrintTime}</span> 打印。</div>` +
|
||||
(reportPrintTime ? `<div>该患者报告于 <span style="color: #f56c6c; font-weight: bold;">${reportPrintTime}</span> 打印。</div>` : ''),
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
type: 'warning',
|
||||
dangerouslyUseHTMLString: true
|
||||
}
|
||||
)
|
||||
} catch (error) {
|
||||
// 用户点击确定后继续执行
|
||||
console.log('用户确认重新打印')
|
||||
}
|
||||
}
|
||||
|
||||
// 获取条形码数据
|
||||
const databarcodePrint = await PatientApi.GetbarcodeInfo(row.medicalSn)
|
||||
|
||||
// 检查是否存在条形码数据
|
||||
if (!databarcodePrint || !databarcodePrint.barcodes || databarcodePrint.barcodes.length === 0) {
|
||||
message.warning('条形码不存在,无法打印')
|
||||
return
|
||||
}
|
||||
|
||||
// 基础打印数据 - 患者基本信息
|
||||
const baseData = {
|
||||
patientName: databarcodePrint.name || row.pname,
|
||||
@ -449,6 +497,13 @@ const handlePrintBarcode = async (row: PatientVO) => {
|
||||
|
||||
// 执行批量打印 - 直接传入数组数据
|
||||
hiprintTemplate.print(batchPrintData, options, ext);
|
||||
|
||||
// 打印成功后更新条形码打印时间
|
||||
await PatientApi.updateBarcodeTime(row.medicalSn, new Date())
|
||||
|
||||
// 刷新列表
|
||||
await getList()
|
||||
message.success('打印成功')
|
||||
} catch (error: any) {
|
||||
console.error('打印条形码失败,详细错误:', error);
|
||||
message.error(`打印条形码失败: ${error.message || '未知错误'}`);
|
||||
|
@ -3,77 +3,147 @@
|
||||
<el-row>
|
||||
<el-form-item label="统计时间">
|
||||
<el-radio-group v-model="radioType" @change="changeRadio">
|
||||
<el-radio v-for="item in radioSelector" :value="item.value" :key="item.value">{{item.label}}</el-radio>
|
||||
<el-radio v-for="item in radioSelector" :value="item.value" :key="item.value">{{
|
||||
item.label
|
||||
}}</el-radio>
|
||||
</el-radio-group>
|
||||
<el-date-picker
|
||||
style="margin-left: 10px;"
|
||||
style="margin-left: 10px"
|
||||
value-format="YYYY-MM-DD"
|
||||
v-model="time"
|
||||
type="daterange"
|
||||
range-separator="To"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
:default-time="[new Date().getDate() - 7,new Date()]"
|
||||
:default-time="[new Date().getDate() - 7, new Date()]"
|
||||
:shortcuts="shortcuts"
|
||||
size="big"
|
||||
@change="changeDatePick"
|
||||
/>
|
||||
<el-button type="primary" @click="getList" style="margin-left: 20px;">
|
||||
<el-button type="primary" @click="getList" style="margin-left: 20px">
|
||||
<Icon icon="ep:search" class="mr-5px" /> 查询
|
||||
</el-button>
|
||||
<el-button type="primary" @click="printData" style="margin-left: 20px;">
|
||||
<el-button type="primary" @click="printData" style="margin-left: 20px">
|
||||
<Icon icon="ep:printer" class="mr-5px" /> 打印
|
||||
</el-button>
|
||||
<el-button type="primary" @click="exportExcel" style="margin-left: 20px;"
|
||||
:loading="exportLoading">
|
||||
<Icon icon="ep:search" class="mr-5px" /> 导出excel
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="exportExcel"
|
||||
style="margin-left: 20px"
|
||||
:loading="exportLoading"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出excel
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-row>
|
||||
</ContentWrap>
|
||||
<ContentWrap>
|
||||
<el-table
|
||||
:data="data1" show-summary max-height="650"
|
||||
:data="data1"
|
||||
show-summary
|
||||
max-height="650"
|
||||
default-expand-all
|
||||
row-key="orgname"
|
||||
:tree-props="{ children: 'children' }"
|
||||
:default-sort="{ prop: 'sum', order: 'descending' }">
|
||||
<el-table-column label="卫生院" align="left" prop="orgname" min-width="180"/>
|
||||
<el-table-column label="行政村" align="center" prop="districtname" min-width="160"/>
|
||||
<el-table-column label="体检数" align="center" >
|
||||
<el-table-column label="老年人" align="center" prop="oldmanflag" min-width="80"/>
|
||||
<el-table-column label="高血压" align="center" prop="htnflag" min-width="80"/>
|
||||
<el-table-column label="糖尿病" align="center" prop="diaflag" min-width="80"/>
|
||||
<el-table-column label="精神病" align="center" prop="smiflag" min-width="80"/>
|
||||
<el-table-column label="肺结核" align="center" prop="pulflag" min-width="80"/>
|
||||
<el-table-column label="总数" align="center" prop="sum" min-width="80"/>
|
||||
:default-sort="{ prop: 'sum', order: 'descending' }"
|
||||
>
|
||||
<el-table-column label="卫生院" align="left" prop="orgname" min-width="180" />
|
||||
<el-table-column label="行政村" align="center" prop="districtname" min-width="160" />
|
||||
<el-table-column label="体检数" align="center">
|
||||
<el-table-column label="老年人" align="center" prop="oldmanflag" min-width="80" />
|
||||
<el-table-column label="高血压" align="center" prop="htnflag" min-width="80" />
|
||||
<el-table-column label="糖尿病" align="center" prop="diaflag" min-width="80" />
|
||||
<el-table-column label="精神病" align="center" prop="smiflag" min-width="80" />
|
||||
<el-table-column label="肺结核" align="center" prop="pulflag" min-width="80" />
|
||||
<el-table-column label="总数" align="center" prop="sum" min-width="80" />
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</ContentWrap>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import {StatisticsApi} from "@/api/inspect/statistics";
|
||||
import dayjs from "dayjs";
|
||||
import {PatientApi} from "@/api/inspect/inspectpatient";
|
||||
import {formatDate} from "@/utils/formatTime";
|
||||
import workload from './workload';
|
||||
import { hiprint } from "vue-plugin-hiprint";
|
||||
import { newHiprintPrintTemplate, preparePrintData } from './printHelper';
|
||||
import download from "@/utils/download";
|
||||
import dayjs from 'dayjs'
|
||||
import { PatientApi } from '@/api/inspect/inspectpatient'
|
||||
import { formatDate } from '@/utils/formatTime'
|
||||
import workload from './workload'
|
||||
import { hiprint } from 'vue-plugin-hiprint'
|
||||
import { newHiprintPrintTemplate, preparePrintData } from './printHelper'
|
||||
import download from '@/utils/download'
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const time = ref() // 日期
|
||||
const data = ref([
|
||||
{orgname: '北京', districtname:'A村',oldmanflag:1 ,htnflag :2 ,diaflag:1, smiflag:1 ,pulflag:1 ,sum : 6},
|
||||
{orgname: '北京', districtname:'B村',oldmanflag:2 ,htnflag :1 ,diaflag:1, smiflag:1 ,pulflag:1 ,sum :6},
|
||||
{orgname: '天津', districtname:'C村',oldmanflag:1 ,htnflag :4 ,diaflag:1, smiflag:1 ,pulflag:1 ,sum : 8},
|
||||
{orgname: '天津', districtname:'D村',oldmanflag:3 ,htnflag :1 ,diaflag:1, smiflag:1 ,pulflag:1 ,sum :7},
|
||||
{orgname: '安徽', districtname:'E村',oldmanflag:4 ,htnflag :3 ,diaflag:1, smiflag:1 ,pulflag:1 ,sum: 10},
|
||||
{orgname: '安徽', districtname:'F村',oldmanflag:4 ,htnflag :3 ,diaflag:1, smiflag:1 ,pulflag:1 ,sum: 10},
|
||||
{orgname: '安徽', districtname:'G村',oldmanflag:4 ,htnflag :3 ,diaflag:1, smiflag:1 ,pulflag:1 ,sum: 10},
|
||||
{
|
||||
orgname: '北京',
|
||||
districtname: 'A村',
|
||||
oldmanflag: 1,
|
||||
htnflag: 2,
|
||||
diaflag: 1,
|
||||
smiflag: 1,
|
||||
pulflag: 1,
|
||||
sum: 6
|
||||
},
|
||||
{
|
||||
orgname: '北京',
|
||||
districtname: 'B村',
|
||||
oldmanflag: 2,
|
||||
htnflag: 1,
|
||||
diaflag: 1,
|
||||
smiflag: 1,
|
||||
pulflag: 1,
|
||||
sum: 6
|
||||
},
|
||||
{
|
||||
orgname: '天津',
|
||||
districtname: 'C村',
|
||||
oldmanflag: 1,
|
||||
htnflag: 4,
|
||||
diaflag: 1,
|
||||
smiflag: 1,
|
||||
pulflag: 1,
|
||||
sum: 8
|
||||
},
|
||||
{
|
||||
orgname: '天津',
|
||||
districtname: 'D村',
|
||||
oldmanflag: 3,
|
||||
htnflag: 1,
|
||||
diaflag: 1,
|
||||
smiflag: 1,
|
||||
pulflag: 1,
|
||||
sum: 7
|
||||
},
|
||||
{
|
||||
orgname: '安徽',
|
||||
districtname: 'E村',
|
||||
oldmanflag: 4,
|
||||
htnflag: 3,
|
||||
diaflag: 1,
|
||||
smiflag: 1,
|
||||
pulflag: 1,
|
||||
sum: 10
|
||||
},
|
||||
{
|
||||
orgname: '安徽',
|
||||
districtname: 'F村',
|
||||
oldmanflag: 4,
|
||||
htnflag: 3,
|
||||
diaflag: 1,
|
||||
smiflag: 1,
|
||||
pulflag: 1,
|
||||
sum: 10
|
||||
},
|
||||
{
|
||||
orgname: '安徽',
|
||||
districtname: 'G村',
|
||||
oldmanflag: 4,
|
||||
htnflag: 3,
|
||||
diaflag: 1,
|
||||
smiflag: 1,
|
||||
pulflag: 1,
|
||||
sum: 10
|
||||
}
|
||||
]) // 表格数据
|
||||
/*const data1=ref([
|
||||
{
|
||||
@ -93,9 +163,9 @@ const data = ref([
|
||||
])*/
|
||||
const data1 = ref([])
|
||||
const radioSelector = ref([
|
||||
{value:2,label:'今天'},
|
||||
{value:3,label:'最近一周'},
|
||||
{value:4,label:'最近一个月'},
|
||||
{ value: 2, label: '今天' },
|
||||
{ value: 3, label: '最近一周' },
|
||||
{ value: 4, label: '最近一个月' }
|
||||
])
|
||||
const radioType = ref(3) //
|
||||
const shortcuts = [
|
||||
@ -106,7 +176,7 @@ const shortcuts = [
|
||||
const start = new Date()
|
||||
start.setDate(start.getDate() - 7)
|
||||
return [start, end]
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
text: '最近一个月',
|
||||
@ -115,7 +185,7 @@ const shortcuts = [
|
||||
const start = new Date()
|
||||
start.setMonth(start.getMonth() - 1)
|
||||
return [start, end]
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
text: '今日',
|
||||
@ -123,8 +193,8 @@ const shortcuts = [
|
||||
const end = new Date()
|
||||
const start = new Date()
|
||||
return [start, end]
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
]
|
||||
/**
|
||||
* 改变单选框
|
||||
@ -134,21 +204,21 @@ const changeRadio = (e) => {
|
||||
let end = new Date()
|
||||
let start = new Date()
|
||||
let date = null
|
||||
switch (e){
|
||||
case 2 :
|
||||
switch (e) {
|
||||
case 2:
|
||||
start = new Date()
|
||||
end = new Date()
|
||||
break
|
||||
case 3 :
|
||||
case 3:
|
||||
start.setDate(start.getDate() - 7)
|
||||
break
|
||||
case 4 :
|
||||
case 4:
|
||||
start.setMonth(start.getMonth() - 1)
|
||||
break
|
||||
default :
|
||||
default:
|
||||
start.setDate(start.getDate() - 7)
|
||||
}
|
||||
time.value = [formatDate(start,'YYYY-MM-DD'),formatDate(end,'YYYY-MM-DD')]
|
||||
time.value = [formatDate(start, 'YYYY-MM-DD'), formatDate(end, 'YYYY-MM-DD')]
|
||||
// 清空现有数据
|
||||
data1.value = []
|
||||
// 重新获取数据
|
||||
@ -161,15 +231,12 @@ const changeDatePick = () => {
|
||||
/**
|
||||
* 获取统计数据
|
||||
*/
|
||||
const getList = async ()=>{
|
||||
const getList = async () => {
|
||||
// 清空现有数据
|
||||
data1.value = []
|
||||
|
||||
const params = {
|
||||
dates: [
|
||||
dayjs(time.value[0]).format('YYYY-MM-DD'),
|
||||
dayjs(time.value[1]).format('YYYY-MM-DD')
|
||||
]
|
||||
dates: [dayjs(time.value[0]).format('YYYY-MM-DD'), dayjs(time.value[1]).format('YYYY-MM-DD')]
|
||||
}
|
||||
try {
|
||||
let resp = await PatientApi.getData(params)
|
||||
@ -186,7 +253,7 @@ const getList = async ()=>{
|
||||
*/
|
||||
const dataProcessing = (data) => {
|
||||
const result = data.reduce((acc, current) => {
|
||||
const key = current.orgname;
|
||||
const key = current.orgname
|
||||
// 初始化分组(若不存在)
|
||||
if (!acc[key]) {
|
||||
acc[key] = {
|
||||
@ -198,39 +265,38 @@ const dataProcessing = (data) => {
|
||||
pulflag: 0,
|
||||
sum: 0,
|
||||
children: []
|
||||
};
|
||||
}
|
||||
}
|
||||
// 累加各字段值
|
||||
acc[key].oldmanflag += current.oldmanflag;
|
||||
acc[key].htnflag += current.htnflag;
|
||||
acc[key].diaflag += current.diaflag;
|
||||
acc[key].smiflag += current.smiflag;
|
||||
acc[key].pulflag += current.pulflag;
|
||||
acc[key].sum += current.sum;
|
||||
acc[key].oldmanflag += current.oldmanflag
|
||||
acc[key].htnflag += current.htnflag
|
||||
acc[key].diaflag += current.diaflag
|
||||
acc[key].smiflag += current.smiflag
|
||||
acc[key].pulflag += current.pulflag
|
||||
acc[key].sum += current.sum
|
||||
// 将当前对象添加到 children 中,移除 orgname
|
||||
const child = { ...current };
|
||||
delete child.orgname;
|
||||
acc[key].children.push(child);
|
||||
acc[key].children.sort((a, b) => b.sum - a.sum);
|
||||
return acc;
|
||||
}, {});
|
||||
const child = { ...current }
|
||||
delete child.orgname
|
||||
acc[key].children.push(child)
|
||||
acc[key].children.sort((a, b) => b.sum - a.sum)
|
||||
return acc
|
||||
}, {})
|
||||
let value = Object.values(result)
|
||||
value.sort((a, b) => b.sum - a.sum);
|
||||
value.sort((a, b) => b.sum - a.sum)
|
||||
|
||||
return value;
|
||||
return value
|
||||
}
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
const exportExcel =async () => {
|
||||
const exportExcel = async () => {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
try {
|
||||
exportLoading.value = true
|
||||
const data =await PatientApi.exportData({dates:time.value})
|
||||
const data = await PatientApi.exportData({ dates: time.value })
|
||||
download.excel(data, '统计.xls')
|
||||
}catch (e) {
|
||||
|
||||
}finally {
|
||||
} catch (e) {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
@ -240,15 +306,12 @@ const exportExcel =async () => {
|
||||
const printData = () => {
|
||||
try {
|
||||
// 创建打印模板
|
||||
const hiprintTemplate = newHiprintPrintTemplate("workload", {
|
||||
const hiprintTemplate = newHiprintPrintTemplate('workload', {
|
||||
template: workload,
|
||||
settingContainer: "#workloadPrintElementOptionSetting",
|
||||
});
|
||||
|
||||
settingContainer: '#workloadPrintElementOptionSetting'
|
||||
})
|
||||
// 准备打印数据
|
||||
const printData = preparePrintData(data1.value, time.value);
|
||||
console.log('打印数据:', printData); // 添加调试信息
|
||||
|
||||
const printData = preparePrintData(data1.value, time.value)
|
||||
// 打印参数配置
|
||||
const options = {
|
||||
leftOffset: 0,
|
||||
@ -267,21 +330,20 @@ const printData = () => {
|
||||
printPanelIndex: 0,
|
||||
noRepeatPrint: false,
|
||||
disableHeaderRepeat: false
|
||||
};
|
||||
}
|
||||
|
||||
// 样式设置
|
||||
const ext = {
|
||||
callback: () => {
|
||||
console.log("打印窗口已打开");
|
||||
console.log('打印窗口已打开')
|
||||
// 添加表头样式
|
||||
setTimeout(() => {
|
||||
const table = document.querySelector('.hiprint-printPanel table');
|
||||
const table = document.querySelector('.hiprint-printPanel table')
|
||||
if (table) {
|
||||
const ths = table.querySelectorAll('th');
|
||||
ths.forEach((th, index) => {
|
||||
});
|
||||
const ths = table.querySelectorAll('th')
|
||||
ths.forEach((th, index) => {})
|
||||
}
|
||||
}, 100);
|
||||
}, 100)
|
||||
},
|
||||
styleHandler: () => {
|
||||
return `<style>
|
||||
@ -322,24 +384,22 @@ const printData = () => {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
</style>`;
|
||||
},
|
||||
};
|
||||
</style>`
|
||||
}
|
||||
}
|
||||
|
||||
// 调用打印
|
||||
hiprintTemplate.print(printData, options, ext);
|
||||
hiprintTemplate.print(printData, options, ext)
|
||||
|
||||
console.log('打印成功');
|
||||
console.log('打印成功')
|
||||
} catch (error) {
|
||||
console.error('打印失败:', error);
|
||||
console.error('打印失败:', error)
|
||||
}
|
||||
}
|
||||
onMounted(()=>{
|
||||
onMounted(() => {
|
||||
changeRadio(3)
|
||||
// getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
Loading…
Reference in New Issue
Block a user