机构短号

This commit is contained in:
Flow 2025-06-12 14:00:47 +08:00
parent 545f0978a8
commit fbc7699bfb
2 changed files with 164 additions and 167 deletions

View File

@ -37,6 +37,7 @@ export interface PatientVO {
examhoscode: string // 体检机构编码
examhosname: string // 体检机构名称
hospitalNo: string // 医院编号
shorid: string // 机构短号
}
// 患者信息 API
@ -177,9 +178,9 @@ export const PatientApi = {
})
},
//根据体检编号更新患者归属机构&医院编号
updatePatientOrg: async (medicalSn: string,examhoscode: string,examhosname: string,hospitalNo: string) => {
updatePatientOrg: async (medicalSn: string,examhoscode: string,examhosname: string,hospitalNo: string,shortid: string) => {
return await request.put({
url: `/inspect/patient/updatePatientOrg?medicalSn=${medicalSn}&examhoscode=${examhoscode}&examhosname=${examhosname}&hospitalNo=${hospitalNo}`
url: `/inspect/patient/updatePatientOrg?medicalSn=${medicalSn}&examhoscode=${examhoscode}&examhosname=${examhosname}&hospitalNo=${hospitalNo}&shortid=${shortid}`
})
},
//获取详情数据

View File

@ -1,15 +1,16 @@
<template>
<div id="PrintElementOptionSetting" style="display:none;"></div>
<div id="BarcodePrintElementOptionSetting" style="display:none;"></div>
<div id="PrintElementOptionSetting" style="display: none"></div>
<div id="BarcodePrintElementOptionSetting" style="display: none"></div>
<!-- 添加全屏加载遮罩 -->
<div
v-loading.fullscreen.lock="fullscreenLoading"
element-loading-text="正在导入数据,请勿关闭页面..."
element-loading-background="rgba(0, 0, 0, 0.8)">
v-loading.fullscreen.lock="fullscreenLoading"
element-loading-text="正在导入数据,请勿关闭页面..."
element-loading-background="rgba(0, 0, 0, 0.8)"
>
</div>
<ContentWrap style="height: 120px; display: flex; align-items: center; padding: 20px 0;">
<ContentWrap style="height: 120px; display: flex; align-items: center; padding: 20px 0">
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
@ -17,7 +18,7 @@ v-loading.fullscreen.lock="fullscreenLoading"
ref="queryFormRef"
:inline="true"
label-width="68px"
style="width: 100%;"
style="width: 100%"
>
<el-form-item label="体检编号" prop="medicalSn">
<el-input
@ -28,12 +29,7 @@ v-loading.fullscreen.lock="fullscreenLoading"
/>
</el-form-item>
<el-form-item label="姓名" prop="pname">
<el-input
v-model="queryParams.pname"
placeholder="请输入姓名"
clearable
class="!w-200px"
/>
<el-input v-model="queryParams.pname" placeholder="请输入姓名" clearable class="!w-200px" />
</el-form-item>
<el-form-item label="身份证号" prop="cardId">
<el-input
@ -43,11 +39,8 @@ v-loading.fullscreen.lock="fullscreenLoading"
class="!w-200px"
/>
</el-form-item>
<el-form-item prop="cardId">
<IDCardReader
v-model:cardId="queryParams.cardId"
@success="handleIdCardSuccess"
/>
<el-form-item prop="cardId">
<IDCardReader v-model:cardId="queryParams.cardId" @success="handleIdCardSuccess" />
</el-form-item>
<el-form-item label="打印日期" prop="printTimeRange">
<el-date-picker
@ -62,13 +55,23 @@ v-loading.fullscreen.lock="fullscreenLoading"
/>
</el-form-item>
<el-form-item label="状态" prop="isprint">
<el-select v-model="queryParams.isprint" placeholder="请选择状态" clearable class="!w-200px">
<el-select
v-model="queryParams.isprint"
placeholder="请选择状态"
clearable
class="!w-200px"
>
<el-option label="已打印" value="1" />
<el-option label="未打印" value="0" />
</el-select>
</el-form-item>
<el-form-item label="当前机构" prop="hospitalNo">
<el-select v-model="queryParams.hospitalNo" placeholder="请选择当前机构" clearable class="!w-200px">
<el-select
v-model="queryParams.hospitalNo"
placeholder="请选择当前机构"
clearable
class="!w-200px"
>
<el-option label="乌兰察布第四医院" value="121526004609160793" />
<el-option label="乌兰察布第四医院实验室" value="221526004609160793" />
</el-select>
@ -78,7 +81,7 @@ v-loading.fullscreen.lock="fullscreenLoading"
<Icon icon="ep:search" class="mr-5px" /> 查询
</el-button>
<el-button type="success" :loading="importLoading" @click="handleImport">
<Icon icon="ep:upload" class="mr-5px" /> 导入Excel文件
<Icon icon="ep:upload" class="mr-5px" /> 导入Excel文件
</el-button>
<el-button type="primary" @click="handleAdd()">
<Icon icon="ep:plus" class="mr-5px" /> 新增
@ -86,7 +89,7 @@ v-loading.fullscreen.lock="fullscreenLoading"
<input
type="file"
ref="fileInputRef"
accept=".xlsx,.xls"
accept=".xlsx,.xls"
style="display: none"
@change="uploadFile"
/>
@ -96,7 +99,6 @@ v-loading.fullscreen.lock="fullscreenLoading"
<Icon icon="ep:download" class="mr-5px" /> 导出Excel
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
@ -107,7 +109,7 @@ v-loading.fullscreen.lock="fullscreenLoading"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
:header-cell-style="{ background: 'rgb(235, 241, 250)', height: '56px',color:'#333333' }"
:header-cell-style="{ background: 'rgb(235, 241, 250)', height: '56px', color: '#333333' }"
:row-style="{ height: '56px' }"
>
<el-table-column label="体检编号" align="center" prop="medicalSn" />
@ -119,18 +121,8 @@ v-loading.fullscreen.lock="fullscreenLoading"
<el-table-column label="状态" align="center" prop="isprint" :formatter="statusFormatter" />
<el-table-column label="操作" align="center" fixed="right" width="240px">
<template #default="scope">
<el-button
link
type="primary"
@click="handlePrint(scope.row)"
>
打印导检单
</el-button>
<el-button
link
type="primary"
@click="handlePrintBarcode(scope.row)"
>
<el-button link type="primary" @click="handlePrint(scope.row)"> 打印导检单 </el-button>
<el-button link type="primary" @click="handlePrintBarcode(scope.row)">
打印条形码
</el-button>
</template>
@ -147,28 +139,27 @@ v-loading.fullscreen.lock="fullscreenLoading"
<!-- 表单弹窗添加/修改 -->
<DepartmentForm ref="formRef" @success="getList" />
<!-- 新增信息对话框 -->
<el-dialog
v-model="dialogVisible"
title="新增信息"
width="700px"
:close-on-click-modal="false"
>
<el-form
:model="addForm"
ref="addFormRef"
label-width="100px"
:rules="addFormRules"
>
<el-dialog v-model="dialogVisible" title="新增信息" width="700px" :close-on-click-modal="false">
<el-form :model="addForm" ref="addFormRef" label-width="100px" :rules="addFormRules">
<el-form-item label="姓名" prop="name">
<el-input v-model="addForm.name" placeholder="请输入姓名" />
</el-form-item>
<el-form-item label="身份证号" prop="cardId">
<div style="display: flex; align-items: center;">
<el-input v-model="addForm.cardId" placeholder="请输入身份证号" @blur="handleCardIdBlur" style="width: 75%;" />
<el-button type="primary" @click="handleGwPatientInfo" style="margin-left: 10px;">获取公卫患者信息</el-button>
<el-button type="primary" @click="handleReadIdCard" style="margin-left: 10px;">读取身份证</el-button>
<div style="display: flex; align-items: center">
<el-input
v-model="addForm.cardId"
placeholder="请输入身份证号"
@blur="handleCardIdBlur"
style="width: 75%"
/>
<el-button type="primary" @click="handleGwPatientInfo" style="margin-left: 10px"
>获取公卫患者信息</el-button
>
<el-button type="primary" @click="handleReadIdCard" style="margin-left: 10px"
>读取身份证</el-button
>
</div>
</el-form-item>
<el-form-item label="出生日期" prop="birthDate">
@ -201,14 +192,14 @@ v-loading.fullscreen.lock="fullscreenLoading"
<script setup lang="ts">
import { PatientApi, type PatientVO } from '@/api/inspect/inspectpatient'
import * as SummaryApi from "@/api/summary";
import { newHiprintPrintTemplate } from "@/views/summary/utils/template-helper";
import template from "@/views/summary/print/template";
import barcode from "@/views/summary/print/barcode";
import IDCardReader from '@/components/IDCardReader.vue';
import sdk from '@/components/IDCardReader/sdk';
import download from '@/utils/download' //
import { ElMessageBox } from 'element-plus' // ElMessageBox
import * as SummaryApi from '@/api/summary'
import { newHiprintPrintTemplate } from '@/views/summary/utils/template-helper'
import template from '@/views/summary/print/template'
import barcode from '@/views/summary/print/barcode'
import IDCardReader from '@/components/IDCardReader.vue'
import sdk from '@/components/IDCardReader/sdk'
import download from '@/utils/download' //
import { ElMessageBox } from 'element-plus' // ElMessageBox
import { InspectOrgApi, InspectOrgVO } from '@/api/inspect/inspectorg/index'
import * as UserApi from '@/api/system/user'
import { getUserProfile } from '@/api/system/user/profile'
@ -237,7 +228,7 @@ const queryParams = reactive({
const queryFormRef = ref() //
const fileInputRef = ref<HTMLInputElement | null>(null) //
const idCardReading = ref(false) //
const shortid = ref('')
//
const dialogVisible = ref(false)
const addFormRef = ref()
@ -255,13 +246,15 @@ const addFormRules = {
name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
cardId: [
{ required: true, message: '请输入身份证号', trigger: 'blur' },
{ pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '请输入正确的身份证号', trigger: 'blur' }
{
pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
message: '请输入正确的身份证号',
trigger: 'blur'
}
],
gender: [{ required: true, message: '请选择性别', trigger: 'change' }],
phone: [
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' }
],
address: [{ message: '请输入住址', trigger: 'blur' }]
phone: [{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' }],
address: [{ message: '请输入住址', trigger: 'blur' }]
}
/** 获取列表 */
@ -274,7 +267,7 @@ const getList = async () => {
isprint: queryParams.isprint || undefined,
printTimeRange: queryParams.printTimeRange
})
list.value = data.list
total.value = data.total
} catch (error) {
@ -293,9 +286,9 @@ const handleQuery = () => {
/** 处理身份证读卡成功事件 */
const handleIdCardSuccess = (cardInfo) => {
//
queryParams.cardId = cardInfo.idNumber;
queryParams.cardId = cardInfo.idNumber
//
handleQuery();
handleQuery()
}
/** 添加/修改操作 */
@ -326,8 +319,22 @@ const handlePrint = async (row: PatientVO) => {
const userInfo = await getUserProfile()
const deptInfo = await InspectOrgApi.getInspectOrg(userInfo.deptId)
if (queryParams.hospitalNo) {
console.log(queryParams.hospitalNo)
await PatientApi.updatePatientOrg(row.medicalSn,deptInfo.orgid,deptInfo.orgName,queryParams.hospitalNo)
if (queryParams.hospitalNo == '121526004609160793') {
shortid.value = '1001'
await PatientApi.updatePatientOrg(row.medicalSn, deptInfo.orgid, deptInfo.orgName, queryParams.hospitalNo, shortid.value)
}
if (queryParams.hospitalNo == '221526004609160793') {
shortid.value = '2001'
await PatientApi.updatePatientOrg(row.medicalSn, deptInfo.orgid, deptInfo.orgName, queryParams.hospitalNo, shortid.value)
}
} else {
ElMessageBox.alert('请选择当前机构', '提示', {
confirmButtonText: '确定',
type: 'warning',
dangerouslyUseHTMLString: true
})
return
}
await PatientApi.bindPatientProject(row.medicalSn)
await PatientApi.syncinspectApplyTj(row.medicalSn)
await createPrint(row.medicalSn)
@ -338,16 +345,7 @@ const handlePrint = async (row: PatientVO) => {
await getList()
message.success('打印成功')
//
PatientApi.updatePatientSupplement(row.medicalSn,row.cardId)
}
else{
ElMessageBox.alert('请选择当前机构', '提示', {
confirmButtonText: '确定',
type: 'warning',
dangerouslyUseHTMLString: true
})
return
}
PatientApi.updatePatientSupplement(row.medicalSn, row.cardId)
} catch (error: any) {
console.error('打印失败:', error)
message.error(`打印失败: ${error.message || '未知错误'}`)
@ -357,29 +355,28 @@ const handlePrint = async (row: PatientVO) => {
const createPrint = async (medicalSn) => {
try {
// 使SummaryApi
const dataPrint = await SummaryApi.printInfoOfMedicalSn(medicalSn);
const dataPrint = await SummaryApi.printInfoOfMedicalSn(medicalSn)
// - 使
const hiprintTemplate = newHiprintPrintTemplate("InspectionChecklist", {
const hiprintTemplate = newHiprintPrintTemplate('InspectionChecklist', {
template: template,
settingContainer: "#PrintElementOptionSetting",
});
settingContainer: '#PrintElementOptionSetting'
})
//
const options = {leftOffset: -1, topOffset: -1};
const options = { leftOffset: -1, topOffset: -1 }
//
const ext = {
callback: () => {
},
callback: () => {},
styleHandler: () => {
return "<style>.hiprint-printElement-text{color:black !important;}</style>";
},
};
return '<style>.hiprint-printElement-text{color:black !important;}</style>'
}
}
//
hiprintTemplate.print(dataPrint, options, ext);
hiprintTemplate.print(dataPrint, options, ext)
} catch (error: any) {
console.error('打印导检单失败,详细错误:', error);
message.error(`打印导检单失败: ${error.message || '未知错误'}`);
console.error('打印导检单失败,详细错误:', error)
message.error(`打印导检单失败: ${error.message || '未知错误'}`)
}
}
/** 打印条形码 */
@ -402,7 +399,7 @@ const handlePrintBarcode = async (row: PatientVO) => {
}
}
//
if(patientInfo.barcodetime){
if (patientInfo.barcodetime) {
//
const date = new Date(patientInfo.barcodetime)
const year = date.getFullYear()
@ -424,7 +421,9 @@ const handlePrintBarcode = async (row: PatientVO) => {
//
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>` : ''),
(reportPrintTime
? `<div>该患者报告于 <span style="color: #f56c6c; font-weight: bold;">${reportPrintTime}</span> 打印。</div>`
: ''),
'提示',
{
confirmButtonText: '确定',
@ -437,16 +436,16 @@ const handlePrintBarcode = async (row: PatientVO) => {
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,
@ -457,11 +456,11 @@ const handlePrintBarcode = async (row: PatientVO) => {
sampleSource: '体检',
billingTime: databarcodePrint.examinationDate || new Date().toLocaleDateString(),
medicalSn: row.medicalSn
};
}
//
const batchPrintData: any[] = [];
const batchPrintData: any[] = []
// 1
batchPrintData.push({
...baseData,
@ -469,52 +468,51 @@ const handlePrintBarcode = async (row: PatientVO) => {
billingItem: '体检编号',
checkTypeId: '体检',
count: '1/4' //
});
})
//
if (databarcodePrint.barcodes && databarcodePrint.barcodes.length > 0) {
databarcodePrint.barcodes.forEach((item, index) => {
//
let itemName = item.name || '检查项目';
let checkType = itemName; //
let itemName = item.name || '检查项目'
let checkType = itemName //
// ""
if (itemName === '生化') {
itemName = '生化全项'; // ""
checkType = '生化'; // ""
itemName = '生化全项' // ""
checkType = '生化' // ""
}
batchPrintData.push({
...baseData,
barCode: item.code,
billingItem: itemName,
checkTypeId: checkType,
count: `${index+2}/4` //
});
});
count: `${index + 2}/4` //
})
})
}
//
const hiprintTemplate = newHiprintPrintTemplate("Barcode", {
const hiprintTemplate = newHiprintPrintTemplate('Barcode', {
template: barcode,
settingContainer: "#BarcodePrintElementOptionSetting",
});
settingContainer: '#BarcodePrintElementOptionSetting'
})
// - barcode.js
const options = {
leftOffset: 0,
leftOffset: 0,
topOffset: 0,
printMode: 'popup',
paperType: 'A7', // A7
height: 30, // 30mm
width: 50, // 50mm
paperHeader: -6, // -6mm
paperFooter: 85.03937007874016 //
};
paperType: 'A7', // A7
height: 30, // 30mm
width: 50, // 50mm
paperHeader: -6, // -6mm
paperFooter: 85.03937007874016 //
}
//
const ext = {
callback: () => {
},
callback: () => {},
styleHandler: () => {
return `<style>
/* 条形码打印特定样式 */
@ -541,22 +539,22 @@ const handlePrintBarcode = async (row: PatientVO) => {
display: none !important;
}
}
</style>`;
},
};
</style>`
}
}
// -
hiprintTemplate.print(batchPrintData, options, ext);
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 || '未知错误'}`);
console.error('打印条形码失败,详细错误:', error)
message.error(`打印条形码失败: ${error.message || '未知错误'}`)
}
}
/** 状态格式化 */
@ -575,21 +573,21 @@ const uploadFile = async (event: Event) => {
if (!target.files || target.files.length === 0) {
return
}
const file = target.files[0]
if (!file.name.endsWith('.xlsx') && !file.name.endsWith('.xls')) {
message.error('请上传Excel文件(.xlsx或.xls格式)')
return
}
try {
importLoading.value = true // true
fullscreenLoading.value = true // true
console.log('全屏加载状态已设置为:', fullscreenLoading.value) //
const formData = new FormData()
formData.append('file', file)
await PatientApi.uploadExcel(formData)
message.success('导入成功')
//
@ -612,7 +610,7 @@ const uploadFile = async (event: Event) => {
const handleAdd = (row?: PatientVO) => {
//
dialogVisible.value = true
//
if (row) {
addForm.name = row.pname || ''
@ -626,7 +624,7 @@ const handleAdd = (row?: PatientVO) => {
//
const submitForm = async () => {
if (!addFormRef.value) return
await addFormRef.value.validate(async (valid: boolean) => {
if (valid) {
try {
@ -639,16 +637,16 @@ const submitForm = async () => {
domicileaddress: addForm.address,
birthday: addForm.birthDate ? new Date(addForm.birthDate) : undefined
}
const data=await PatientApi.insertPatinetInfo(patientData as PatientVO)
if(data){
const data = await PatientApi.insertPatinetInfo(patientData as PatientVO)
if (data) {
message.success('添加成功')
dialogVisible.value = false
//
resetForm()
//
await getList()
}else{
} else {
message.error('患者已存在')
}
} catch (error: any) {
@ -701,12 +699,12 @@ const handleCardIdBlur = () => {
const genderCode = parseInt(cardId.charAt(14))
addForm.gender = genderCode % 2 === 1 ? '男' : '女'
}
// YYYYMMDD -> YYYY-MM-DD
const year = birthDateStr.substring(0, 4)
const month = birthDateStr.substring(4, 6)
const day = birthDateStr.substring(6, 8)
//
addForm.birthDate = `${year}-${month}-${day}`
} catch (error: any) {
@ -718,14 +716,13 @@ const handleCardIdBlur = () => {
}
}
//
const handleGwPatientInfo = async () => {
if (!addForm.cardId) {
message.warning('请先输入身份证号')
return
}
try {
loading.value = true
// API
@ -752,30 +749,29 @@ const handleReadIdCard = async () => {
message.warning('正在读取身份证,请稍候...')
return
}
idCardReading.value = true
try {
// SDK
sdk.init_sdk()
//
await sdk.open_device()
message.success('读卡器连接成功')
//
const result = await sdk.read_card()
if (result) {
//
addForm.cardId = result.idNumber || ''
addForm.name = result.name || ''
addForm.address = result.address || ''
//
addForm.gender = result.gender || ''
//
if (result.birthday) {
addForm.birthDate = result.birthday
@ -783,7 +779,7 @@ const handleReadIdCard = async () => {
//
handleCardIdBlur()
}
message.success('读取身份证成功')
} else {
throw new Error('读取身份证失败')
@ -798,7 +794,7 @@ const handleReadIdCard = async () => {
} catch (e) {
console.error('断开连接失败:', e)
}
idCardReading.value = false
}
}
@ -827,7 +823,7 @@ const handleExport = async () => {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
dangerouslyUseHTMLString: true // 使 HTML
dangerouslyUseHTMLString: true // 使 HTML
}
)
//