bug241 264 265 fixed
This commit is contained in:
@@ -130,4 +130,13 @@ public interface IDiagTreatMAppService {
|
||||
* @return 结果
|
||||
*/
|
||||
R<?> updatePricingFlag(List<Long> ids, Integer pricingFlag);
|
||||
|
||||
/**
|
||||
* 诊疗目录下拉列表(轻量级,用于套餐设置)
|
||||
*
|
||||
* @param statusEnum 状态(2=启用)
|
||||
* @param searchKey 搜索关键词(可选)
|
||||
* @return 只包含 id, name, busNo, retailPrice
|
||||
*/
|
||||
R<?> getDiagnosisTreatmentSimpleList(Integer statusEnum, String searchKey);
|
||||
}
|
||||
@@ -822,4 +822,20 @@ public class DiagTreatMAppServiceImpl implements IDiagTreatMAppService {
|
||||
}
|
||||
return activityDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* 诊疗目录下拉列表(轻量级,用于套餐设置)
|
||||
* 只查询必要字段,减少JOIN,提高查询速度
|
||||
* 支持搜索关键词过滤
|
||||
*
|
||||
* @param statusEnum 状态(2=启用)
|
||||
* @param searchKey 搜索关键词
|
||||
* @return 只包含 id, name, busNo, retailPrice
|
||||
*/
|
||||
@Override
|
||||
public R<?> getDiagnosisTreatmentSimpleList(Integer statusEnum, String searchKey) {
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
List<DiagnosisTreatmentDto> list = activityDefinitionManageMapper.getDiagnosisTreatmentSimpleList(statusEnum, tenantId, searchKey);
|
||||
return R.ok(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,4 +207,21 @@ public class DiagnosisTreatmentController {
|
||||
.orderByAsc(InspectionType::getSortOrder);
|
||||
return R.ok(inspectionTypeService.list(queryWrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 诊疗目录下拉列表(轻量级,用于套餐设置)
|
||||
* 只查询必要字段,减少JOIN,提高查询速度
|
||||
* 支持搜索关键词过滤
|
||||
*
|
||||
* @param statusEnum 状态(2=启用)
|
||||
* @param searchKey 搜索关键词
|
||||
* @return 只包含 id, name, busNo, retailPrice
|
||||
*/
|
||||
@GetMapping("/simple-list")
|
||||
public R<?> getDiagnosisTreatmentSimpleList(@RequestParam(required = false) Integer statusEnum, @RequestParam(required = false) String searchKey) {
|
||||
if (statusEnum == null) {
|
||||
statusEnum = 2;
|
||||
}
|
||||
return diagTreatMAppService.getDiagnosisTreatmentSimpleList(statusEnum, searchKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.openhis.web.datadictionary.dto.DiagnosisTreatmentDto;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 诊疗定义管理
|
||||
*
|
||||
@@ -36,4 +38,14 @@ public interface ActivityDefinitionManageMapper {
|
||||
*/
|
||||
DiagnosisTreatmentDto getDiseaseTreatmentOne(@Param("id") Long id, @Param("tenantId") Integer tenantId);
|
||||
|
||||
/**
|
||||
* 诊疗目录下拉列表(轻量级,只查4个字段)
|
||||
*
|
||||
* @param statusEnum 状态
|
||||
* @param tenantId 租户ID
|
||||
* @param searchKey 搜索关键词(可选)
|
||||
* @return id, name, busNo, retailPrice
|
||||
*/
|
||||
List<DiagnosisTreatmentDto> getDiagnosisTreatmentSimpleList(@Param("statusEnum") Integer statusEnum, @Param("tenantId") Integer tenantId, @Param("searchKey") String searchKey);
|
||||
|
||||
}
|
||||
|
||||
@@ -78,6 +78,36 @@
|
||||
ORDER BY T1.id DESC
|
||||
</select>
|
||||
|
||||
<!-- 诊疗目录下拉列表(轻量级,只查4个字段,1个JOIN) -->
|
||||
<select id="getDiagnosisTreatmentSimpleList" resultType="com.openhis.web.datadictionary.dto.DiagnosisTreatmentDto">
|
||||
SELECT
|
||||
T1.id,
|
||||
T1.bus_no,
|
||||
T1.name,
|
||||
T2.price as retail_price
|
||||
FROM wor_activity_definition T1
|
||||
INNER JOIN adm_charge_item_definition T2
|
||||
ON T1.id = T2.instance_id
|
||||
AND T2.instance_table = 'wor_activity_definition'
|
||||
WHERE T1.delete_flag = '0'
|
||||
AND T1.status_enum = #{statusEnum}
|
||||
AND T1.tenant_id = #{tenantId}
|
||||
<if test="searchKey != null and searchKey != ''">
|
||||
AND (
|
||||
T1.name LIKE '%' || #{searchKey} || '%'
|
||||
OR T1.bus_no LIKE '%' || #{searchKey} || '%'
|
||||
OR T1.py_str LIKE '%' || #{searchKey} || '%'
|
||||
)
|
||||
</if>
|
||||
ORDER BY T1.id DESC
|
||||
<if test="searchKey != null and searchKey != ''">
|
||||
LIMIT 1500
|
||||
</if>
|
||||
<if test="searchKey == null or searchKey == ''">
|
||||
LIMIT 500
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getDiseaseTreatmentOne" resultType="com.openhis.web.datadictionary.dto.DiagnosisTreatmentDto">
|
||||
SELECT
|
||||
T1.id,
|
||||
|
||||
@@ -123,4 +123,13 @@ export function updatePricingFlag (ids, pricingFlag) {
|
||||
});
|
||||
}
|
||||
|
||||
// 诊疗目录下拉列表(轻量级,用于套餐设置)
|
||||
export function getDiagnosisTreatmentSimpleList (statusEnum, searchKey) {
|
||||
return request ({
|
||||
url: '/data-dictionary/diagnosis-treatment/simple-list',
|
||||
method: 'get',
|
||||
params: { statusEnum, searchKey },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -75,7 +75,12 @@
|
||||
<el-col :xs="24" :sm="12" :md="8" :lg="6">
|
||||
<el-form-item label="卫生机构">
|
||||
<el-select v-model="formData.organization" placeholder="请选择卫生机构" style="width: 100%" :disabled="isReadOnly">
|
||||
<el-option label="演示医院" value="演示医院" />
|
||||
<el-option
|
||||
v-for="org in organizationOptions"
|
||||
:key="org.value"
|
||||
:label="org.label"
|
||||
:value="org.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -225,13 +230,13 @@
|
||||
</el-option>
|
||||
<template #empty>
|
||||
<div style="padding: 10px; text-align: center; color: #999;">
|
||||
<div v-if="diagnosisTreatmentList.length === 0">
|
||||
暂无项目数据<br/>
|
||||
<small>请先在【系统管理-目录管理-诊疗项目】中添加项目</small>
|
||||
<div v-if="diagnosisTreatmentList.length > 0">
|
||||
无匹配项目<br/>
|
||||
<small>请尝试其他关键词</small>
|
||||
</div>
|
||||
<div v-else>
|
||||
无匹配项目<br/>
|
||||
<small>支持:名称模糊搜索、首字母搜索、编号搜索</small>
|
||||
暂无项目数据<br/>
|
||||
<small>请先在【系统管理-目录管理-诊疗项目】中添加项目</small>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -388,10 +393,11 @@ import {ElMessage, ElMessageBox} from 'element-plus'
|
||||
import {getDicts} from '@/api/system/dict/data'
|
||||
import {listDept} from '@/api/system/dept'
|
||||
import {addCheckPackage, updateCheckPackage} from '@/api/system/checkType'
|
||||
import {getDiagnosisTreatmentList} from '@/views/catalog/diagnosistreatment/components/diagnosistreatment'
|
||||
import {getDiagnosisTreatmentSimpleList} from '@/views/catalog/diagnosistreatment/components/diagnosistreatment'
|
||||
import {getTenantPage} from '@/api/system/tenant'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import request from '@/utils/request' // 导入request工具用于调用Organization API
|
||||
import cache from '@/plugins/cache' // 导入缓存工具
|
||||
import request from '@/utils/request'
|
||||
import cache from '@/plugins/cache'
|
||||
|
||||
// 接收props
|
||||
const props = defineProps({
|
||||
@@ -439,7 +445,7 @@ const formData = reactive({
|
||||
department: '',
|
||||
user: '',
|
||||
packageName: '',
|
||||
organization: '演示医院',
|
||||
organization: '',
|
||||
packagePrice: '0.00',
|
||||
discount: '',
|
||||
creator: userStore.name || '当前用户',
|
||||
@@ -469,6 +475,8 @@ const formRules = {
|
||||
const packageLevelOptions = ref([])
|
||||
// 科室选项
|
||||
const departments = ref([])
|
||||
// 卫生机构选项
|
||||
const organizationOptions = ref([])
|
||||
// 诊疗项目列表
|
||||
const diagnosisTreatmentList = ref([])
|
||||
// 过滤后的诊疗项目列表(用于搜索)
|
||||
@@ -684,8 +692,11 @@ onMounted(async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 加载诊疗项目列表(优先使用缓存)
|
||||
await loadDiagnosisTreatmentList(true)
|
||||
// 加载诊疗项目列表(默认加载500条)
|
||||
await loadDiagnosisTreatmentList(false)
|
||||
|
||||
// 加载卫生机构列表(只获取启用的租户)
|
||||
await loadOrganizationList()
|
||||
|
||||
// 初始化一行空数据
|
||||
if(props.mode === 'add'){
|
||||
@@ -697,109 +708,103 @@ onMounted(async () => {
|
||||
}
|
||||
})
|
||||
|
||||
// 诊疗项目列表缓存key和过期时间(30分钟)
|
||||
const DIAGNOSIS_TREATMENT_CACHE_KEY = 'check_package_diagnosis_treatment_list'
|
||||
// 加载卫生机构列表(从租户列表获取,只获取启用的)
|
||||
async function loadOrganizationList() {
|
||||
try {
|
||||
const response = await getTenantPage({
|
||||
pageNo: 1,
|
||||
pageSize: 1000,
|
||||
status: '0'
|
||||
})
|
||||
|
||||
if (response && response.code === 200) {
|
||||
const records = response.data?.records || response.data || []
|
||||
organizationOptions.value = records.map(item => ({
|
||||
value: item.tenantName || item.name,
|
||||
label: item.tenantName || item.name,
|
||||
tenantId: item.tenantId
|
||||
}))
|
||||
console.log('✓ 卫生机构数据加载成功:', organizationOptions.value.length)
|
||||
|
||||
// 优先使用当前登录账号的机构名称作为默认值
|
||||
const currentOrgName = userStore.tenantName
|
||||
if (currentOrgName && organizationOptions.value.find(o => o.value === currentOrgName)) {
|
||||
formData.organization = currentOrgName
|
||||
} else if (!formData.organization && organizationOptions.value.length > 0) {
|
||||
// 其次设置为列表第一个
|
||||
formData.organization = organizationOptions.value[0].value
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('✗ 获取卫生机构列表失败:', error)
|
||||
}
|
||||
}
|
||||
// 诊疗项目缓存key和过期时间
|
||||
const DIAGNOSIS_TREATMENT_CACHE_KEY = 'check_package_diagnosis_treatment_cache'
|
||||
const CACHE_EXPIRE_TIME = 30 * 60 * 1000 // 30分钟
|
||||
|
||||
// 加载诊疗项目列表(支持缓存)
|
||||
// 诊疗项目ID到项目信息的映射缓存(用于选择后获取详情)
|
||||
const diagnosisTreatmentCache = ref({})
|
||||
|
||||
// 加载诊疗项目详情到缓存
|
||||
async function loadDiagnosisTreatmentItem(itemId, itemData) {
|
||||
if (!itemData) return
|
||||
diagnosisTreatmentCache.value[itemId] = itemData
|
||||
}
|
||||
|
||||
// 加载诊疗项目列表(默认加载500条,支持缓存)
|
||||
async function loadDiagnosisTreatmentList(forceRefresh = false) {
|
||||
// 如果不是强制刷新,先尝试从缓存加载
|
||||
if (!forceRefresh) {
|
||||
// 如果不是强制刷新且已有数据且未过期,直接返回
|
||||
if (!forceRefresh && diagnosisTreatmentList.value.length > 0) {
|
||||
return
|
||||
}
|
||||
|
||||
// 从session缓存读取
|
||||
try {
|
||||
const cachedData = cache.session.getJSON(DIAGNOSIS_TREATMENT_CACHE_KEY)
|
||||
if (cachedData && cachedData.data && cachedData.timestamp) {
|
||||
if (cachedData && cachedData.timestamp) {
|
||||
const now = Date.now()
|
||||
const cacheAge = now - cachedData.timestamp
|
||||
|
||||
// 检查缓存是否过期
|
||||
if (cacheAge < CACHE_EXPIRE_TIME) {
|
||||
diagnosisTreatmentList.value = cachedData.data
|
||||
// 静默加载,不显示消息
|
||||
diagnosisTreatmentList.value = cachedData.data || []
|
||||
return
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// 缓存读取失败,继续从API加载
|
||||
console.error('读取缓存失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 从API加载数据
|
||||
loading.value = true
|
||||
try {
|
||||
const response = await getDiagnosisTreatmentSimpleList(2)
|
||||
|
||||
let allItems = []
|
||||
const maxBatches = 3
|
||||
const batchSize = 50
|
||||
|
||||
for (let page = 1; page <= maxBatches; page++) {
|
||||
try {
|
||||
const treatmentResponse = await getDiagnosisTreatmentList({
|
||||
pageNo: page,
|
||||
pageSize: batchSize
|
||||
})
|
||||
|
||||
let batchData = []
|
||||
if (treatmentResponse) {
|
||||
if (treatmentResponse.data && treatmentResponse.data.records) {
|
||||
batchData = treatmentResponse.data.records
|
||||
} else if (treatmentResponse.data && Array.isArray(treatmentResponse.data)) {
|
||||
batchData = treatmentResponse.data
|
||||
} else if (treatmentResponse.records && Array.isArray(treatmentResponse.records)) {
|
||||
batchData = treatmentResponse.records
|
||||
}
|
||||
}
|
||||
|
||||
if (batchData.length > 0) {
|
||||
allItems = allItems.concat(batchData)
|
||||
if (batchData.length < batchSize) {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
break
|
||||
}
|
||||
} catch (batchError) {
|
||||
console.error(`第${page}批加载失败:`, batchError)
|
||||
if (page === 1) {
|
||||
throw batchError
|
||||
}
|
||||
break
|
||||
}
|
||||
if (response && response.code === 200 && response.data) {
|
||||
allItems = Array.isArray(response.data) ? response.data : response.data.records || []
|
||||
}
|
||||
|
||||
if (allItems.length > 0) {
|
||||
diagnosisTreatmentList.value = allItems
|
||||
|
||||
// 保存到缓存
|
||||
try {
|
||||
cache.session.setJSON(DIAGNOSIS_TREATMENT_CACHE_KEY, {
|
||||
data: allItems,
|
||||
timestamp: Date.now()
|
||||
})
|
||||
} catch (cacheError) {
|
||||
console.error('保存缓存失败:', cacheError)
|
||||
}
|
||||
|
||||
// 只在强制刷新时显示成功消息
|
||||
if (forceRefresh) {
|
||||
ElMessage.success(`成功加载${allItems.length}个诊疗项目`)
|
||||
}
|
||||
} else {
|
||||
if (forceRefresh) {
|
||||
ElMessage.warning({
|
||||
message: '未获取到诊疗项目数据。请先在【系统管理-目录管理-诊疗项目】中添加数据',
|
||||
duration: 6000,
|
||||
showClose: true
|
||||
})
|
||||
}
|
||||
} else if (forceRefresh) {
|
||||
ElMessage.warning('未获取到诊疗项目数据')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取诊疗项目列表失败:', error)
|
||||
if (forceRefresh) {
|
||||
ElMessage.error({
|
||||
message: '获取诊疗项目列表失败,请检查网络连接或联系管理员',
|
||||
duration: 6000,
|
||||
showClose: true
|
||||
})
|
||||
ElMessage.error('获取诊疗项目列表失败')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -932,53 +937,65 @@ function getPinYinFirstLetter(str) {
|
||||
return result
|
||||
}
|
||||
|
||||
// 初始化搜索列表
|
||||
// 初始化搜索列表(聚焦时显示默认加载的500条数据)
|
||||
function initializeSearchList(row) {
|
||||
if (!row.filteredList) {
|
||||
row.filteredList = diagnosisTreatmentList.value
|
||||
}
|
||||
}
|
||||
|
||||
// 项目搜索处理(支持首字母和模糊搜索)
|
||||
function handleProjectSearch(query, row) {
|
||||
// 项目搜索处理(支持名称/编号/拼音模糊搜索)
|
||||
async function handleProjectSearch(query, row) {
|
||||
|
||||
// 如果输入为空,显示默认列表
|
||||
if (!query || query.trim() === '') {
|
||||
row.filteredList = diagnosisTreatmentList.value
|
||||
return
|
||||
}
|
||||
|
||||
const searchText = query.trim().toUpperCase()
|
||||
const searchText = query.trim()
|
||||
|
||||
row.filteredList = diagnosisTreatmentList.value.filter(item => {
|
||||
const name = (item.name || item.itemName || '').toUpperCase()
|
||||
const code = (item.busNo || item.code || '').toUpperCase()
|
||||
// 调用后端接口搜索
|
||||
loading.value = true
|
||||
try {
|
||||
const response = await getDiagnosisTreatmentSimpleList(2, searchText)
|
||||
|
||||
// 1. 名称模糊匹配
|
||||
if (name.includes(searchText)) {
|
||||
return true
|
||||
let items = []
|
||||
if (response && response.code === 200 && response.data) {
|
||||
items = Array.isArray(response.data) ? response.data : []
|
||||
}
|
||||
|
||||
// 2. 编号模糊匹配
|
||||
if (code.includes(searchText)) {
|
||||
return true
|
||||
// 如果搜索结果为空,显示默认列表
|
||||
if (items.length === 0) {
|
||||
row.filteredList = diagnosisTreatmentList.value
|
||||
} else {
|
||||
row.filteredList = items
|
||||
}
|
||||
|
||||
// 3. 拼音首字母匹配
|
||||
const pinyin = getPinYinFirstLetter(item.name || item.itemName || '')
|
||||
if (pinyin.includes(searchText)) {
|
||||
return true
|
||||
console.log(`搜索"${searchText}"找到 ${items.length} 个结果`)
|
||||
} catch (error) {
|
||||
console.error('搜索失败:', error)
|
||||
row.filteredList = diagnosisTreatmentList.value
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
console.log(`搜索"${query}"找到 ${row.filteredList.length} 个结果`)
|
||||
}
|
||||
|
||||
// 项目选择处理
|
||||
// 项目选择处理(从搜索结果或缓存中获取)
|
||||
function handleItemSelect(row) {
|
||||
console.log('选择项目ID:', row.itemId)
|
||||
const item = diagnosisTreatmentList.value.find(i => i.id === row.itemId)
|
||||
|
||||
// 优先从搜索结果中获取
|
||||
let item = row.filteredList?.find(i => i.id === row.itemId)
|
||||
|
||||
// 其次从缓存中获取
|
||||
if (!item) {
|
||||
item = diagnosisTreatmentCache.value[row.itemId]
|
||||
}
|
||||
|
||||
// 最后从诊断列表中获取
|
||||
if (!item) {
|
||||
item = diagnosisTreatmentList.value.find(i => i.id === row.itemId)
|
||||
}
|
||||
|
||||
console.log('找到的项目:', item)
|
||||
|
||||
if (item) {
|
||||
@@ -986,6 +1003,10 @@ function handleItemSelect(row) {
|
||||
row.code = item.busNo || item.code || item.itemCode || ''
|
||||
row.unitPrice = parseFloat(item.retailPrice || item.unitPrice || item.price || 0)
|
||||
console.log('设置单价:', row.unitPrice)
|
||||
|
||||
// 缓存选中的项目
|
||||
loadDiagnosisTreatmentItem(row.itemId, item)
|
||||
|
||||
calculateAmount(row)
|
||||
} else {
|
||||
ElMessage.warning('未找到该项目信息')
|
||||
|
||||
Reference in New Issue
Block a user