248 lines
7.3 KiB
Vue
248 lines
7.3 KiB
Vue
|
<template>
|
|||
|
<div id="PrintElementOptionSetting" style="display:none;"></div>
|
|||
|
|
|||
|
<ContentWrap style="height: 70px; display: flex; align-items: center;">
|
|||
|
<!-- 搜索工作栏 -->
|
|||
|
<el-form
|
|||
|
class="-mb-15px"
|
|||
|
:model="queryParams"
|
|||
|
ref="queryFormRef"
|
|||
|
:inline="true"
|
|||
|
label-width="68px"
|
|||
|
>
|
|||
|
<el-form-item label="体检编号" prop="medicalSn">
|
|||
|
<el-input
|
|||
|
v-model="queryParams.medicalSn"
|
|||
|
placeholder="请输入体检编号"
|
|||
|
clearable
|
|||
|
@keyup.enter="handleQuery"
|
|||
|
class="!w-200px"
|
|||
|
/>
|
|||
|
</el-form-item>
|
|||
|
<el-form-item label="姓名" prop="pname">
|
|||
|
<el-input
|
|||
|
v-model="queryParams.pname"
|
|||
|
placeholder="请输入姓名"
|
|||
|
clearable
|
|||
|
@input="handleQuery"
|
|||
|
class="!w-200px"
|
|||
|
/>
|
|||
|
</el-form-item>
|
|||
|
<el-form-item label="体检日期" prop="medicalDateTime">
|
|||
|
<el-date-picker
|
|||
|
v-model="queryParams.medicalDateTime"
|
|||
|
type="daterange"
|
|||
|
start-placeholder="开始日期"
|
|||
|
end-placeholder="结束日期"
|
|||
|
value-format="YYYY-MM-DD HH:mm:ss"
|
|||
|
:default-time="[
|
|||
|
new Date(2000, 1, 1, 0, 0, 0),
|
|||
|
new Date(2000, 1, 1, 23, 59, 59)
|
|||
|
]"
|
|||
|
clearable
|
|||
|
class="!w-320px"
|
|||
|
/>
|
|||
|
</el-form-item>
|
|||
|
<el-form-item>
|
|||
|
<el-button type="primary" @click="handleQuery">
|
|||
|
<Icon icon="ep:search" class="mr-5px" /> 查询
|
|||
|
</el-button>
|
|||
|
<el-button type="success" @click="handleImport">
|
|||
|
<Icon icon="ep:upload" class="mr-5px" /> 导入Excel文件
|
|||
|
</el-button>
|
|||
|
<input
|
|||
|
type="file"
|
|||
|
ref="fileInputRef"
|
|||
|
accept=".xlsx,.xls"
|
|||
|
style="display: none"
|
|||
|
@change="uploadFile"
|
|||
|
/>
|
|||
|
</el-form-item>
|
|||
|
</el-form>
|
|||
|
</ContentWrap>
|
|||
|
|
|||
|
<!-- 列表 -->
|
|||
|
<ContentWrap>
|
|||
|
<el-table
|
|||
|
v-loading="loading"
|
|||
|
:data="list"
|
|||
|
:stripe="true"
|
|||
|
:show-overflow-tooltip="true"
|
|||
|
:header-cell-style="{ background: 'rgb(235, 241, 250)', height: '56px',color:'#333333' }"
|
|||
|
:row-style="{ height: '56px' }"
|
|||
|
>
|
|||
|
<el-table-column label="体检编号" align="center" prop="medicalSn" />
|
|||
|
<el-table-column label="姓名" align="center" prop="pname" />
|
|||
|
<el-table-column label="性别" align="center" prop="gender" />
|
|||
|
<el-table-column label="身份证号" align="center" prop="cardId" />
|
|||
|
<el-table-column label="联系电话" align="center" prop="phoneNum" />
|
|||
|
<el-table-column label="住址" align="center" prop="domicileaddress" />
|
|||
|
<el-table-column label="体检日期" align="center" prop="medicalDateTime" :formatter="dateFormatter" />
|
|||
|
<el-table-column label="操作" align="center" fixed="right" width="120px">
|
|||
|
<template #default="scope">
|
|||
|
<el-button
|
|||
|
link
|
|||
|
type="primary"
|
|||
|
@click="handlePrint(scope.row)"
|
|||
|
>
|
|||
|
打印导检单
|
|||
|
</el-button>
|
|||
|
</template>
|
|||
|
</el-table-column>
|
|||
|
</el-table>
|
|||
|
<!-- 分页 -->
|
|||
|
<Pagination
|
|||
|
:total="total"
|
|||
|
v-model:page="queryParams.pageNo"
|
|||
|
v-model:limit="queryParams.pageSize"
|
|||
|
@pagination="getList"
|
|||
|
/>
|
|||
|
</ContentWrap>
|
|||
|
|
|||
|
<!-- 表单弹窗:添加/修改 -->
|
|||
|
<DepartmentForm ref="formRef" @success="getList" />
|
|||
|
</template>
|
|||
|
|
|||
|
<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";
|
|||
|
|
|||
|
defineOptions({ name: 'Department' })
|
|||
|
|
|||
|
const message = useMessage() // 消息弹窗
|
|||
|
const { t } = useI18n() // 国际化
|
|||
|
const loading = ref(true) // 列表的加载中
|
|||
|
const list = ref<PatientVO[]>([]) // 用于展示的数据
|
|||
|
const total = ref(0) // 列表的总页数
|
|||
|
const queryParams = reactive({
|
|||
|
pageNo: 1,
|
|||
|
pageSize: 10,
|
|||
|
medicalSn: undefined,
|
|||
|
pname: undefined,
|
|||
|
medicalDateTime: [],
|
|||
|
cardId: undefined,
|
|||
|
phoneNum: undefined,
|
|||
|
domicileaddress: undefined
|
|||
|
})
|
|||
|
const queryFormRef = ref() // 搜索的表单
|
|||
|
const fileInputRef = ref<HTMLInputElement | null>(null) // 文件输入引用
|
|||
|
|
|||
|
/** 获取列表 */
|
|||
|
const getList = async () => {
|
|||
|
loading.value = true
|
|||
|
try {
|
|||
|
const data = await PatientApi.getPatientPage({
|
|||
|
pageNo: queryParams.pageNo,
|
|||
|
pageSize: queryParams.pageSize,
|
|||
|
medicalSn: queryParams.medicalSn,
|
|||
|
pname: queryParams.pname,
|
|||
|
medicalDateTime: queryParams.medicalDateTime,
|
|||
|
cardId: queryParams.cardId,
|
|||
|
phoneNum: queryParams.phoneNum,
|
|||
|
domicileaddress: queryParams.domicileaddress
|
|||
|
})
|
|||
|
list.value = data.list
|
|||
|
total.value = data.total
|
|||
|
} finally {
|
|||
|
loading.value = false
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/** 搜索操作 */
|
|||
|
const handleQuery = () => {
|
|||
|
queryParams.pageNo = 1
|
|||
|
getList()
|
|||
|
}
|
|||
|
/** 添加/修改操作 */
|
|||
|
const formRef = ref()
|
|||
|
/** 初始化 **/
|
|||
|
onMounted(() => {
|
|||
|
getList()
|
|||
|
})
|
|||
|
|
|||
|
/** 打印报告按钮操作 */
|
|||
|
const handlePrint = async (row: PatientVO) => {
|
|||
|
try {
|
|||
|
console.log('开始打印,体检编号:', row.medicalSn);
|
|||
|
|
|||
|
// 使用SummaryApi打印导检单
|
|||
|
const dataPrint = await SummaryApi.printInfoOfMedicalSn(row.medicalSn);
|
|||
|
console.log('获取到的打印数据:', dataPrint);
|
|||
|
|
|||
|
// 创建打印模板 - 修改这里,使用固定的模板名称而不是动态获取
|
|||
|
const hiprintTemplate = newHiprintPrintTemplate("InspectionChecklist", {
|
|||
|
template: template,
|
|||
|
settingContainer: "#PrintElementOptionSetting",
|
|||
|
});
|
|||
|
console.log('打印模板创建成功');
|
|||
|
|
|||
|
// 打印设置
|
|||
|
const options = {leftOffset: -1, topOffset: -1};
|
|||
|
|
|||
|
// 扩展配置
|
|||
|
const ext = {
|
|||
|
callback: () => {
|
|||
|
console.log("浏览器打印窗口已打开");
|
|||
|
},
|
|||
|
styleHandler: () => {
|
|||
|
return "<style>.hiprint-printElement-text{color:black !important;}</style>";
|
|||
|
},
|
|||
|
};
|
|||
|
|
|||
|
// 调用浏览器打印
|
|||
|
hiprintTemplate.print(dataPrint, options, ext);
|
|||
|
} catch (error) {
|
|||
|
console.error('打印导检单失败,详细错误:', error);
|
|||
|
message.error(`打印导检单失败: ${error.message || '未知错误'}`);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/** 日期格式化 */
|
|||
|
const dateFormatter = (row: any, column: any) => {
|
|||
|
if (!row.medicalDateTime) return ''
|
|||
|
const date = new Date(row.medicalDateTime)
|
|||
|
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
|
|||
|
}
|
|||
|
|
|||
|
/** 处理导入按钮点击 */
|
|||
|
const handleImport = () => {
|
|||
|
fileInputRef.value?.click()
|
|||
|
}
|
|||
|
|
|||
|
/** 处理文件上传 */
|
|||
|
const uploadFile = async (event: Event) => {
|
|||
|
const target = event.target as HTMLInputElement
|
|||
|
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 {
|
|||
|
loading.value = true
|
|||
|
const formData = new FormData()
|
|||
|
formData.append('file', file)
|
|||
|
|
|||
|
await PatientApi.uploadExcel(formData)
|
|||
|
message.success('导入成功')
|
|||
|
// 重置文件输入
|
|||
|
if (fileInputRef.value) {
|
|||
|
fileInputRef.value.value = ''
|
|||
|
}
|
|||
|
// 刷新列表
|
|||
|
await getList()
|
|||
|
} catch (error) {
|
|||
|
console.error('导入失败:', error)
|
|||
|
message.error('导入失败,请检查文件格式是否正确')
|
|||
|
} finally {
|
|||
|
loading.value = false
|
|||
|
}
|
|||
|
}
|
|||
|
</script>
|