修复各界面测试BUG
This commit is contained in:
parent
d87da93abd
commit
d0aa46f87d
@ -24,6 +24,7 @@ export interface PatientVO {
|
||||
auditor: string // 审核人
|
||||
auditorTime: Date // 审核时间
|
||||
chargetime: Date // 收费时间
|
||||
headimage: string // 个人信息图片
|
||||
}
|
||||
|
||||
// 患者信息 API
|
||||
|
||||
@ -883,15 +883,19 @@ const formattedMedicalDateTime = computed(() => {
|
||||
}).replace(/\//g, '-')
|
||||
})
|
||||
|
||||
// 修改年龄计算属性
|
||||
const age = computed(() => {
|
||||
if (!reportData.value.birthday || !Array.isArray(reportData.value.birthday)) return ''
|
||||
if (!reportData.value.birthday) return ''
|
||||
|
||||
// 处理 YYYY-MM-DD 格式的生日
|
||||
const birthDate = new Date(reportData.value.birthday)
|
||||
if (isNaN(birthDate.getTime())) return '' // 日期无效时返回空字符串
|
||||
|
||||
const [year, month, day] = reportData.value.birthday
|
||||
const birthDate = new Date(year, month - 1, day) // 注意月份要减1,因为JS中月份从0开始
|
||||
const today = new Date()
|
||||
let age = today.getFullYear() - birthDate.getFullYear()
|
||||
const monthDiff = today.getMonth() - birthDate.getMonth()
|
||||
|
||||
// 如果还没到生日月份,或者是生日月但还没到具体日期,年龄减1
|
||||
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
|
||||
age--
|
||||
}
|
||||
|
||||
@ -161,28 +161,30 @@
|
||||
<div
|
||||
class="pic-box"
|
||||
:style="{
|
||||
border: personParam.avatar ? '0 !important;' : 'auto'
|
||||
border: personParam.avatar ? '0 !important;' : 'auto',
|
||||
cursor: isEditable ? 'pointer' : 'not-allowed',
|
||||
opacity: isEditable ? '1' : '0.6'
|
||||
}"
|
||||
@click.stop="handlePhotographInfo"
|
||||
@click.stop="isEditable ? handlePhotographInfo() : null"
|
||||
>
|
||||
<el-icon :size="20" color="#2988f3" v-if="!personParam.avatar">
|
||||
<el-icon :size="20" :color="isEditable ? '#2988f3' : '#909399'" v-if="!personParam.avatar">
|
||||
<Plus />
|
||||
</el-icon>
|
||||
<span
|
||||
style="
|
||||
font-size: 13.8px;
|
||||
line-height: 0;
|
||||
height: auto;
|
||||
margin-top: 26px;
|
||||
color: #2988f3;
|
||||
"
|
||||
:style="{
|
||||
fontSize: '13.8px',
|
||||
lineHeight: '0',
|
||||
height: 'auto',
|
||||
marginTop: '26px',
|
||||
color: isEditable ? '#2988f3' : '#909399'
|
||||
}"
|
||||
v-if="!personParam.avatar"
|
||||
>
|
||||
人像采集
|
||||
</span>
|
||||
<template v-else>
|
||||
<img :src="personParam.avatar" style="height: 100%; width: 100%" />
|
||||
<div class="demo-upload-list-cover">
|
||||
<div class="demo-upload-list-cover" v-if="isEditable">
|
||||
<el-icon :size="20" @click.stop="handlePhotographView(personParam.avatar)">
|
||||
<ZoomIn />
|
||||
</el-icon>
|
||||
@ -398,12 +400,7 @@
|
||||
体检项目
|
||||
</span>
|
||||
<el-button
|
||||
@click="
|
||||
() => {
|
||||
selectProjectDrawerTabName = 'comboInfo'
|
||||
selectProjectDrawerShow = true
|
||||
}
|
||||
"
|
||||
@click="handleOpenProjectDrawer"
|
||||
size="small"
|
||||
style="
|
||||
margin: 0;
|
||||
@ -481,7 +478,11 @@
|
||||
prop="section"
|
||||
min-width="180"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
>
|
||||
<template #default="scope">
|
||||
{{ scope.row.section || '暂无科室' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="销售价(元)"
|
||||
prop="price"
|
||||
@ -972,7 +973,10 @@ const handlePersonInfoSave = async () => {
|
||||
try {
|
||||
// 表单验证
|
||||
await personParamRef.value.validate()
|
||||
|
||||
var avatar=''
|
||||
if(personParam.value.avatar){
|
||||
avatar= personParam.value.avatar.split(',')[1]
|
||||
}
|
||||
// 准备患者数据
|
||||
const patientData: PatientVO = {
|
||||
id: selectedPatient.value?.id, // 如果是编辑模式,保留原ID
|
||||
@ -985,7 +989,8 @@ const handlePersonInfoSave = async () => {
|
||||
phoneNum: personParam.value.mobile,
|
||||
status: 0, // 患者登记状态
|
||||
headPicUrl: personParam.value.avatar,
|
||||
medicalDateTime: new Date().getTime() // 修改为时间戳
|
||||
medicalDateTime: new Date().getTime(), // 修改为时间戳
|
||||
headimage: avatar
|
||||
}
|
||||
|
||||
let result
|
||||
@ -1007,9 +1012,10 @@ const handlePersonInfoSave = async () => {
|
||||
price: item.price,
|
||||
discountedPrice: item.discountPrice,
|
||||
discounted: item.discount,
|
||||
sectionID: item.section,
|
||||
sectionID: item.sectionID,
|
||||
itemStatus: '0',
|
||||
createTime: new Date().getTime() // 修改为时间戳
|
||||
createTime: new Date().getTime(), // 修改为时间戳
|
||||
headimage: avatar
|
||||
}))
|
||||
|
||||
await PatientitemsApi.createPatientitemsBatch(saveItems)
|
||||
@ -1100,7 +1106,7 @@ const getPatientData = async () => {
|
||||
mobile: item.phoneNum,
|
||||
avatar: item.headPicUrl,
|
||||
physicalType: item.chargeType,
|
||||
status: item.status
|
||||
status: item.status,
|
||||
}))
|
||||
|
||||
personDataOriginal.value = mappedData // 保存原始数据
|
||||
@ -1191,7 +1197,8 @@ const loadPatientProjects = async (medicalSn) => {
|
||||
discount: item.discounted || 0,
|
||||
discountPrice: item.discountedPrice || 0,
|
||||
moduleName: item.moduleName || '',
|
||||
section: item.sectionID || '',
|
||||
section: item.section || '',
|
||||
sectionID: item.sectionID || '',
|
||||
itemCode: item.itemCode
|
||||
}))
|
||||
|
||||
@ -1316,31 +1323,6 @@ const getComboInfoData = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 确保在组件挂载和抽屉打开时都调用
|
||||
onMounted(() => {
|
||||
getComboInfoData()
|
||||
|
||||
// 初始化右侧表单数据,确保有默认值
|
||||
personParam.value = {
|
||||
avatar: '',
|
||||
testNum: '',
|
||||
personName: '',
|
||||
sex: '',
|
||||
age: '',
|
||||
idCard: '',
|
||||
mobile: ''
|
||||
}
|
||||
|
||||
// 确保表格数据初始化
|
||||
comboInfoTable1.value = []
|
||||
})
|
||||
|
||||
watch(() => selectProjectDrawerShow.value, (newVal) => {
|
||||
if (newVal) {
|
||||
getComboInfoData()
|
||||
}
|
||||
})
|
||||
|
||||
// 处理套餐搜索
|
||||
const handleComboInfoSearch = () => {
|
||||
comboInfoParam.value.pageNumber = 1
|
||||
@ -1413,7 +1395,6 @@ const handleCheckInfoSelection = (selection) => {
|
||||
const confirmSelectedProjects = async () => {
|
||||
try {
|
||||
let selectedProjects: ProjectDetail[] = []
|
||||
// 创建一个Set来跟踪已处理的itemCode
|
||||
const processedItemCodes = new Set()
|
||||
|
||||
// 先将现有项目的itemCode添加到Set中
|
||||
@ -1422,67 +1403,41 @@ const confirmSelectedProjects = async () => {
|
||||
})
|
||||
|
||||
if (selectProjectDrawerTabName.value === 'comboInfo') {
|
||||
// 处理套餐项目
|
||||
for (const combo of comboInfoSelectedData.value) {
|
||||
try {
|
||||
// 获取套餐下的所有项目
|
||||
const moduleItems = await ExammoduleApi.getListExammodule()
|
||||
// 过滤出当前套餐的项目
|
||||
const filteredItems = moduleItems.filter(item =>
|
||||
item.examModuleID === combo.examModuleID
|
||||
)
|
||||
|
||||
// 逐个处理套餐中的项目
|
||||
for (const moduleItem of filteredItems) {
|
||||
// 如果已经处理过这个itemCode,跳过
|
||||
if (processedItemCodes.has(moduleItem.itemCode)) {
|
||||
continue
|
||||
}
|
||||
|
||||
try {
|
||||
// 获取项目详情
|
||||
const itemDetail = await getItemDetailByCode(moduleItem.itemCode)
|
||||
const itemDetail = await itemsApi.getitemsPage({
|
||||
pageNum: 1,
|
||||
pageSize: 1,
|
||||
itemCode: moduleItem.itemCode
|
||||
})
|
||||
|
||||
// 添加到已处理集合
|
||||
processedItemCodes.add(moduleItem.itemCode)
|
||||
|
||||
if (itemDetail) {
|
||||
// 使用获取到的项目详情
|
||||
if (itemDetail?.list?.[0]) {
|
||||
const item = itemDetail.list[0]
|
||||
processedItemCodes.add(moduleItem.itemCode)
|
||||
selectedProjects.push({
|
||||
name: itemDetail.itemName,
|
||||
section: itemDetail.section || '',
|
||||
price: itemDetail.price || 0,
|
||||
discount: itemDetail.discounted || 0,
|
||||
discountPrice: itemDetail.discountedPrice || 0,
|
||||
moduleName: itemDetail.moduleName || moduleItem.examModuleName,
|
||||
itemCode: moduleItem.itemCode
|
||||
})
|
||||
} else {
|
||||
// 如果获取不到项目详情,使用套餐项目数据
|
||||
selectedProjects.push({
|
||||
name: moduleItem.examModuleName,
|
||||
section: '',
|
||||
price: 0,
|
||||
discount: 0,
|
||||
discountPrice: 0,
|
||||
moduleName: moduleItem.examModuleName,
|
||||
name: item.itemName,
|
||||
section: item.section, // 使用科室名称
|
||||
sectionID: item.sectionID, // 保存科室ID用于后端
|
||||
price: item.price || 0,
|
||||
discount: item.discounted || 0,
|
||||
discountPrice: item.discountedPrice || 0,
|
||||
moduleName: item.moduleName || moduleItem.examModuleName,
|
||||
itemCode: moduleItem.itemCode
|
||||
})
|
||||
}
|
||||
} catch (itemError) {
|
||||
// 出错时也尝试添加项目,使用套餐数据
|
||||
if (!processedItemCodes.has(moduleItem.itemCode)) {
|
||||
processedItemCodes.add(moduleItem.itemCode)
|
||||
selectedProjects.push({
|
||||
name: moduleItem.examModuleName,
|
||||
section: '',
|
||||
price: 0,
|
||||
discount: 0,
|
||||
discountPrice: 0,
|
||||
moduleName: moduleItem.examModuleName,
|
||||
itemCode: moduleItem.itemCode
|
||||
})
|
||||
}
|
||||
console.error('处理项目详情失败:', itemError)
|
||||
}
|
||||
}
|
||||
} catch (comboError) {
|
||||
@ -1490,19 +1445,16 @@ const confirmSelectedProjects = async () => {
|
||||
}
|
||||
}
|
||||
} else if (selectProjectDrawerTabName.value === 'checkInfo') {
|
||||
// 直接处理已选中的项目
|
||||
for (const item of checkInfoSelectedData.value) {
|
||||
// 如果已经处理过这个itemCode,跳过
|
||||
if (processedItemCodes.has(item.itemCode)) {
|
||||
continue
|
||||
}
|
||||
|
||||
// 添加到已处理集合
|
||||
processedItemCodes.add(item.itemCode)
|
||||
|
||||
selectedProjects.push({
|
||||
name: item.itemName,
|
||||
section: item.section,
|
||||
section: item.section, // 使用科室名称
|
||||
sectionID: item.sectionID, // 保存科室ID用于后端
|
||||
price: item.price,
|
||||
discount: item.discounted,
|
||||
discountPrice: item.discountedPrice,
|
||||
@ -1513,7 +1465,6 @@ const confirmSelectedProjects = async () => {
|
||||
}
|
||||
|
||||
if (selectedProjects.length > 0) {
|
||||
// 只添加到前端表格,不保存到数据库
|
||||
comboInfoTable1.value = [...comboInfoTable1.value, ...selectedProjects]
|
||||
message.success(`成功添加${selectedProjects.length}个新项目`)
|
||||
} else {
|
||||
@ -1526,24 +1477,6 @@ const confirmSelectedProjects = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 添加通过itemCode查询项目详情的方法
|
||||
const getItemDetailByCode = async (itemCode) => {
|
||||
try {
|
||||
// 先获取所有项目
|
||||
const allItems = await itemsApi.getitemsPage({
|
||||
pageNum: 1,
|
||||
pageSize: 100
|
||||
})
|
||||
|
||||
// 查找匹配itemCode的项目
|
||||
const item = allItems.list.find(item => item.itemCode === itemCode)
|
||||
return item || null
|
||||
} catch (error) {
|
||||
console.error('通过itemCode查询项目详情失败:', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/** 钩子方法 **/
|
||||
onMounted(() => {
|
||||
// 获取科室列表
|
||||
@ -1569,11 +1502,12 @@ const startIndex = computed(() => {
|
||||
// 添加接口定义
|
||||
interface ProjectDetail {
|
||||
name: string
|
||||
section: string // 科室名称
|
||||
sectionID: string // 科室ID
|
||||
price: number
|
||||
discount: number
|
||||
discountPrice: number
|
||||
moduleName: string
|
||||
section: string
|
||||
itemCode: string
|
||||
}
|
||||
|
||||
@ -1610,6 +1544,21 @@ const handleDeleteSelectedItems = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 修改打开抽屉的处理方法
|
||||
const handleOpenProjectDrawer = () => {
|
||||
// 清空选择状态
|
||||
comboInfoSelectedData.value = []
|
||||
checkInfoSelectedData.value = []
|
||||
|
||||
// 如果表格有清除选择的方法,调用它
|
||||
if (comboInfoTableRef.value) {
|
||||
comboInfoTableRef.value.clearSelection()
|
||||
}
|
||||
|
||||
selectProjectDrawerTabName.value = 'comboInfo'
|
||||
selectProjectDrawerShow.value = true
|
||||
}
|
||||
|
||||
// 添加身份证输入处理函数
|
||||
const handleIdCardInput = (value) => {
|
||||
if (!value || value.length < 15) return
|
||||
|
||||
@ -157,7 +157,7 @@ const getDepartmentList = async () => {
|
||||
try {
|
||||
const data = await DepartmentApi.getListDepartment()
|
||||
departmentOptions.value = data.map((item: DepartmentVO) => ({
|
||||
value: item.id,
|
||||
value: item.departmentCode,
|
||||
label: item.departmentName
|
||||
}))
|
||||
} catch (error) {
|
||||
|
||||
@ -68,23 +68,27 @@ async function handleSearch() {
|
||||
pageSize: pageSize.value
|
||||
}
|
||||
|
||||
// 修改关键词的处理逻辑
|
||||
const keyword = searchForm.keyword?.trim()
|
||||
if (keyword) {
|
||||
queryParams.itemName = keyword // 使用itemName作为查询参数
|
||||
queryParams.itemName = keyword
|
||||
}
|
||||
|
||||
if (searchForm.department) {
|
||||
queryParams.sectionID = searchForm.department // 使用section作为科室查询参数
|
||||
queryParams.sectionID = searchForm.department
|
||||
console.log('选中的科室ID:', searchForm.department)
|
||||
}
|
||||
|
||||
console.log('查询参数:', queryParams)
|
||||
|
||||
try {
|
||||
const res = await itemsApi.getitemsPage(queryParams)
|
||||
console.log('查询结果:', res)
|
||||
if (res) {
|
||||
tableData.value = res.list || []
|
||||
total.value = res.total || 0
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('查询失败:', error)
|
||||
ElMessage.error('查询失败')
|
||||
tableData.value = []
|
||||
total.value = 0
|
||||
@ -103,7 +107,9 @@ const getDepartmentList = async () => {
|
||||
value: item.departmentCode,
|
||||
label: item.departmentName
|
||||
}))
|
||||
console.log('科室列表数据:', departmentOptions.value)
|
||||
} catch (error) {
|
||||
console.error('获取科室列表错误:', error)
|
||||
ElMessage.error('获取科室列表失败')
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,11 +60,19 @@
|
||||
<el-button type="primary" @click="handleAdd">
|
||||
<el-icon><Plus /></el-icon>新增套餐
|
||||
</el-button>
|
||||
<el-button type="primary" @click="openDrawer">
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="openDrawer"
|
||||
:disabled="!selectedPackage"
|
||||
>
|
||||
<el-icon><Plus /></el-icon>添加项目
|
||||
</el-button>
|
||||
<el-button type="danger" @click="handleDeleteSelected">
|
||||
<el-icon><Delete /></el-icon>删除选中
|
||||
<el-button
|
||||
type="danger"
|
||||
@click="handleDeleteSelected"
|
||||
:disabled="!selectedPackage || multipleSelection.length === 0"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>删除项目
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user