检查项目设置->套餐设置->套餐管理补充
This commit is contained in:
@@ -95,9 +95,11 @@
|
||||
{{ getLevelLabel(row.packageLevel) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="department" label="科室" width="120" align="center">
|
||||
<el-table-column prop="department" label="科室" width="150" align="center">
|
||||
<template #default="{ row }">
|
||||
{{ getDeptName(row.department) }}
|
||||
<span :title="row.department && /^[A-Z]\d{2}$/.test(row.department.trim()) ? '旧编码格式,建议编辑套餐重新选择科室' : ''">
|
||||
{{ getDeptName(row.department) }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="user" label="用户" width="100" align="center" />
|
||||
@@ -232,60 +234,65 @@ onMounted(async () => {
|
||||
console.error('获取套餐级别字典失败:', error)
|
||||
}
|
||||
|
||||
// 获取科室列表 - 优先使用Organization API(包含编码和名称)
|
||||
// 获取科室列表 - 使用Organization完整API(包含编码和名称)
|
||||
try {
|
||||
// 尝试使用Organization API获取科室列表(包含编码)
|
||||
// 使用Organization完整API获取科室列表(包含busNo编码)
|
||||
const orgResponse = await request({
|
||||
url: '/app-common/department-list',
|
||||
method: 'get'
|
||||
url: '/base-data-manage/organization/organization',
|
||||
method: 'get',
|
||||
params: {
|
||||
pageNo: 1,
|
||||
pageSize: 1000 // 获取足够多的数据
|
||||
}
|
||||
})
|
||||
console.log('科室Organization API响应:', orgResponse)
|
||||
|
||||
let orgList = []
|
||||
if (orgResponse) {
|
||||
if (Array.isArray(orgResponse)) {
|
||||
orgList = orgResponse
|
||||
} else if (orgResponse.data) {
|
||||
if (Array.isArray(orgResponse.data)) {
|
||||
if (orgResponse.data) {
|
||||
if (orgResponse.data.records && Array.isArray(orgResponse.data.records)) {
|
||||
orgList = orgResponse.data.records
|
||||
} else if (Array.isArray(orgResponse.data)) {
|
||||
orgList = orgResponse.data
|
||||
} else if (orgResponse.data.data && Array.isArray(orgResponse.data.data)) {
|
||||
orgList = orgResponse.data.data
|
||||
}
|
||||
} else if (orgResponse.code === 200 && orgResponse.data) {
|
||||
orgList = Array.isArray(orgResponse.data) ? orgResponse.data : []
|
||||
} else if (Array.isArray(orgResponse)) {
|
||||
orgList = orgResponse
|
||||
}
|
||||
}
|
||||
|
||||
// 展开树结构,过滤出科室类型(typeEnum=2)
|
||||
if (orgList && orgList.length > 0) {
|
||||
const flattenList = []
|
||||
function flatten(nodes) {
|
||||
nodes.forEach(node => {
|
||||
if (node.typeEnum === 2 && node.busNo && node.name) {
|
||||
flattenList.push(node)
|
||||
}
|
||||
if (node.children && node.children.length > 0) {
|
||||
flatten(node.children)
|
||||
}
|
||||
})
|
||||
}
|
||||
flatten(orgList)
|
||||
orgList = flattenList
|
||||
}
|
||||
|
||||
if (orgList && orgList.length > 0) {
|
||||
// 使用Organization数据(包含编码和名称)
|
||||
departments.value = orgList.map(org => {
|
||||
const busNo = (org.busNo || org.code || '').trim()
|
||||
const name = (org.name || org.deptName || '').trim()
|
||||
// 如果busNo是层级编码(如 "A01.001"),同时存储前缀("A01")用于匹配
|
||||
const busNoPrefix = busNo ? busNo.split('.')[0] : ''
|
||||
return {
|
||||
dictValue: name,
|
||||
dictLabel: name,
|
||||
deptId: org.id || org.deptId,
|
||||
deptCode: busNo || name, // 优先使用busNo,如果没有则使用名称
|
||||
busNoPrefix: busNoPrefix, // 存储前缀用于匹配
|
||||
rawOrg: org // 保存原始数据用于调试
|
||||
deptCode: busNo || name,
|
||||
busNoPrefix: busNoPrefix,
|
||||
rawOrg: org
|
||||
}
|
||||
})
|
||||
console.log('科室数据加载成功(Organization):', departments.value.length)
|
||||
console.log('科室映射关系(前5个):', departments.value.slice(0, 5).map(d => ({
|
||||
deptCode: `"${d.deptCode}"`,
|
||||
busNoPrefix: `"${d.busNoPrefix}"`,
|
||||
codeLength: d.deptCode ? d.deptCode.length : 0,
|
||||
name: d.dictLabel,
|
||||
rawBusNo: d.rawOrg?.busNo
|
||||
})))
|
||||
} else {
|
||||
// 如果Organization API没有数据,使用系统部门API
|
||||
const deptResponse = await listDept()
|
||||
console.log('科室API响应:', deptResponse)
|
||||
|
||||
// 处理不同的响应格式
|
||||
let deptList = []
|
||||
if (deptResponse) {
|
||||
if (Array.isArray(deptResponse)) {
|
||||
@@ -302,26 +309,21 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
if (deptList && deptList.length > 0) {
|
||||
// 将部门列表转换为字典格式
|
||||
departments.value = deptList.map(dept => ({
|
||||
dictValue: dept.deptName || dept.name,
|
||||
dictLabel: dept.deptName || dept.name,
|
||||
deptId: dept.deptId || dept.id,
|
||||
deptCode: dept.deptName || dept.name // 如果没有编码,使用名称
|
||||
deptCode: dept.deptName || dept.name
|
||||
}))
|
||||
console.log('科室数据加载成功(Dept):', departments.value.length, departments.value)
|
||||
} else {
|
||||
console.warn('科室列表为空,尝试使用字典方式')
|
||||
// 如果获取失败,尝试使用字典方式
|
||||
try {
|
||||
const dictResponse = await getDicts('dept')
|
||||
console.log('科室字典响应:', dictResponse)
|
||||
if (dictResponse && dictResponse.data) {
|
||||
departments.value = dictResponse.data
|
||||
console.log('使用字典方式加载科室数据成功:', departments.value.length)
|
||||
}
|
||||
} catch (dictError) {
|
||||
console.error('获取科室字典也失败:', dictError)
|
||||
console.error('获取科室字典失败:', dictError)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -432,34 +434,11 @@ function getDeptName(deptValue) {
|
||||
return dept.dictLabel
|
||||
}
|
||||
|
||||
// 如果找不到,输出详细信息用于调试
|
||||
const deptCodes = departments.value.map(d => ({
|
||||
deptCode: String(d.deptCode || '').trim(),
|
||||
deptCodeUpper: String(d.deptCode || '').trim().toUpperCase(),
|
||||
busNoPrefix: String(d.busNoPrefix || '').trim().toUpperCase(),
|
||||
name: d.dictLabel,
|
||||
rawBusNo: d.rawOrg?.busNo,
|
||||
rawBusNoUpper: d.rawOrg?.busNo ? String(d.rawOrg.busNo).trim().toUpperCase() : '',
|
||||
rawBusNoPrefix: d.rawOrg?.busNo ? String(d.rawOrg.busNo).trim().toUpperCase().split('.')[0] : ''
|
||||
}))
|
||||
|
||||
// 输出详细的调试信息,包括所有科室的完整信息
|
||||
console.group('🔍 科室匹配失败 - 详细信息')
|
||||
console.log('搜索值:', trimmedValue)
|
||||
console.log('搜索值(大写):', trimmedValue.toUpperCase())
|
||||
console.log('搜索值长度:', trimmedValue.length)
|
||||
console.log('可用科室总数:', deptCodes.length)
|
||||
console.log('前5个科室详情:', deptCodes.slice(0, 5))
|
||||
console.log('所有科室编码列表:', deptCodes.map(d => ({
|
||||
deptCode: d.deptCode,
|
||||
deptCodeUpper: d.deptCodeUpper,
|
||||
busNoPrefix: d.busNoPrefix,
|
||||
rawBusNo: d.rawBusNo,
|
||||
rawBusNoUpper: d.rawBusNoUpper,
|
||||
rawBusNoPrefix: d.rawBusNoPrefix,
|
||||
name: d.name
|
||||
})))
|
||||
console.groupEnd()
|
||||
// 无法匹配时,返回原始编码值
|
||||
const isOldFormat = /^[A-Z]\d{2}$/.test(trimmedValue)
|
||||
if (isOldFormat) {
|
||||
return trimmedValue + ' (旧格式)'
|
||||
}
|
||||
|
||||
return trimmedValue
|
||||
}
|
||||
@@ -494,8 +473,6 @@ async function handleQuery() {
|
||||
tableData.value = []
|
||||
total.value = 0
|
||||
}
|
||||
|
||||
console.log('查询成功,共', total.value, '条数据')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('查询失败:', error)
|
||||
@@ -520,28 +497,17 @@ function handleReset() {
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
// 返回套餐设置界面
|
||||
function handleBackToSettings() {
|
||||
emit('back-to-settings')
|
||||
}
|
||||
|
||||
// 新增
|
||||
function handleAdd() {
|
||||
console.log('新增套餐')
|
||||
// 通知父组件切换到套餐设置界面,模式为新增
|
||||
emit('switch-to-settings', { mode: 'add', data: null })
|
||||
}
|
||||
|
||||
// 编辑
|
||||
async function handleEdit(row) {
|
||||
try {
|
||||
console.log('编辑套餐:', row.id)
|
||||
|
||||
// 获取完整的套餐数据(包含明细)
|
||||
const response = await getCheckPackage(row.id)
|
||||
|
||||
if (response && (response.code === 200 || response.code === 0) && response.data) {
|
||||
// 通知父组件切换到套餐设置界面,模式为编辑
|
||||
emit('switch-to-settings', { mode: 'edit', data: response.data })
|
||||
} else {
|
||||
ElMessage.error('加载套餐数据失败')
|
||||
@@ -555,13 +521,9 @@ async function handleEdit(row) {
|
||||
// 查看
|
||||
async function handleView(row) {
|
||||
try {
|
||||
console.log('查看套餐:', row.id)
|
||||
|
||||
// 获取完整的套餐数据(包含明细)
|
||||
const response = await getCheckPackage(row.id)
|
||||
|
||||
if (response && (response.code === 200 || response.code === 0) && response.data) {
|
||||
// 通知父组件切换到套餐设置界面,模式为查看
|
||||
emit('switch-to-settings', { mode: 'view', data: response.data })
|
||||
} else {
|
||||
ElMessage.error('加载套餐数据失败')
|
||||
@@ -589,7 +551,6 @@ function handleDelete(row) {
|
||||
|
||||
if (response && (response.code === 200 || response.code === 0)) {
|
||||
ElMessage.success('删除成功')
|
||||
// 刷新列表
|
||||
handleQuery()
|
||||
} else {
|
||||
ElMessage.error(response?.msg || response?.message || '删除失败')
|
||||
@@ -598,9 +559,7 @@ function handleDelete(row) {
|
||||
console.error('删除失败:', error)
|
||||
ElMessage.error('删除失败: ' + (error.message || '未知错误'))
|
||||
}
|
||||
}).catch(() => {
|
||||
console.log('用户取消删除')
|
||||
})
|
||||
}).catch(() => {})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user