Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -124,7 +124,7 @@ public class CheckTypeController extends BaseController {
|
|||||||
return AjaxResult.success(result);
|
return AjaxResult.success(result);
|
||||||
} else {
|
} else {
|
||||||
List<CheckPackage> list = checkPackageService.list(wrapper);
|
List<CheckPackage> list = checkPackageService.list(wrapper);
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -760,13 +760,10 @@
|
|||||||
<el-table-column label="" align="center" prop="groupId" width="60">
|
<el-table-column label="" align="center" prop="groupId" width="60">
|
||||||
<template #header>
|
<template #header>
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-model="checkAll"
|
:model-value="getCheckAllState(prescription.id)"
|
||||||
@change="
|
@change="
|
||||||
(value) => {
|
(value) => {
|
||||||
prescriptionList.forEach((item, index) => {
|
handleCheckAllChange(value, prescription.id);
|
||||||
groupIndexList.push(index);
|
|
||||||
item.check = value;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
@@ -776,7 +773,7 @@
|
|||||||
v-model="scope.row.check"
|
v-model="scope.row.check"
|
||||||
@dblclick.stop=""
|
@dblclick.stop=""
|
||||||
placeholder=""
|
placeholder=""
|
||||||
@change="(value) => handleCheckBoxChange(value, scope.$index, scope.row)"
|
@change="(value) => handleCheckBoxChange(value, scope.$index, scope.row, prescription.id)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -1091,6 +1088,7 @@ const westernPrescriptions = ref([]); // 西药处方列表
|
|||||||
const currentPrescriptionId = ref(null); // 当前活跃的处方ID
|
const currentPrescriptionId = ref(null); // 当前活跃的处方ID
|
||||||
const prescriptionCounter = ref(0); // 处方计数器
|
const prescriptionCounter = ref(0); // 处方计数器
|
||||||
const allPrescriptionsData = ref({}); // 存储所有处方的数据,格式: { prescriptionId: [...prescriptionList] }
|
const allPrescriptionsData = ref({}); // 存储所有处方的数据,格式: { prescriptionId: [...prescriptionList] }
|
||||||
|
const allPrescriptionCheckStates = ref({}); // 存储每个处方的选中状态,格式: { prescriptionId: { checkedIndexes: [], checkAll: false } }
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
document.addEventListener('keydown', escKeyListener);
|
document.addEventListener('keydown', escKeyListener);
|
||||||
// 初始化时自动创建第一个西药处方
|
// 初始化时自动创建第一个西药处方
|
||||||
@@ -1361,32 +1359,80 @@ function getListInfo(addNewRow) {
|
|||||||
// 更新 allPrescriptionsData
|
// 更新 allPrescriptionsData
|
||||||
allPrescriptionsData.value = prescriptionGroups;
|
allPrescriptionsData.value = prescriptionGroups;
|
||||||
|
|
||||||
// 更新西药处方列表
|
// 更新西药处方列表 - 保持原有顺序,只更新数据
|
||||||
const existingPrescriptionIds = Object.keys(prescriptionGroups);
|
const existingPrescriptionIds = Object.keys(prescriptionGroups);
|
||||||
if (existingPrescriptionIds.length > 0 && existingPrescriptionIds[0] !== 'default') {
|
if (existingPrescriptionIds.length > 0 && existingPrescriptionIds[0] !== 'default') {
|
||||||
// 如果有保存的处方数据,重建处方列表
|
// 保存当前处方的ID,用于后续恢复
|
||||||
westernPrescriptions.value = existingPrescriptionIds.map((id, index) => {
|
const savedCurrentPrescriptionId = currentPrescriptionId.value;
|
||||||
const info = prescriptionInfoMap[id] || {};
|
|
||||||
// 查找是否已存在该处方,保留其属性
|
// 遍历前端已有的处方列表,保持原有顺序,只更新数据
|
||||||
const existing = westernPrescriptions.value.find(p => p.id === id);
|
const updatedPrescriptions = [];
|
||||||
return {
|
const processedBackendIds = new Set(); // 记录已处理的后端ID
|
||||||
id: id,
|
|
||||||
name: info.prescriptionNo ? `西药方${index + 1}` : `西药方${index + 1}`,
|
// 1. 首先处理前端已有的处方(保持原有顺序)
|
||||||
prescriptionNo: info.prescriptionNo || '',
|
westernPrescriptions.value.forEach((prescription, index) => {
|
||||||
conditionDefinitionId: existing?.conditionDefinitionId || conditionDefinitionId.value,
|
const info = prescriptionInfoMap[prescription.id] || {};
|
||||||
accountId: existing?.accountId || accountId.value,
|
|
||||||
expandOrder: existing?.expandOrder || []
|
// 检查这个前端处方是否有对应的后端数据
|
||||||
};
|
if (existingPrescriptionIds.includes(prescription.id)) {
|
||||||
|
// 如果后端有这个ID的数据,说明处方已保存,更新数据但保持顺序和名称
|
||||||
|
processedBackendIds.add(prescription.id);
|
||||||
|
updatedPrescriptions.push({
|
||||||
|
...prescription,
|
||||||
|
prescriptionNo: info.prescriptionNo || prescription.prescriptionNo || '',
|
||||||
|
// 保持原有名称,不要改变
|
||||||
|
name: prescription.name || `西药方${index + 1}`
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 如果后端没有这个ID的数据,可能是前端创建的临时处方,保持原样
|
||||||
|
updatedPrescriptions.push(prescription);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 设置当前活跃处方
|
// 2. 处理后端有但前端没有的处方(可能是新保存的处方,需要映射到前端)
|
||||||
if (!currentPrescriptionId.value || !existingPrescriptionIds.includes(currentPrescriptionId.value)) {
|
existingPrescriptionIds.forEach((prescriptionId) => {
|
||||||
currentPrescriptionId.value = existingPrescriptionIds[0];
|
if (!processedBackendIds.has(prescriptionId)) {
|
||||||
|
const info = prescriptionInfoMap[prescriptionId] || {};
|
||||||
|
// 这是新保存的处方,查找是否有对应的前端临时处方
|
||||||
|
// 通过查找最近保存的数据来确定
|
||||||
|
const prescriptionData = prescriptionGroups[prescriptionId] || [];
|
||||||
|
if (prescriptionData.length > 0) {
|
||||||
|
// 尝试找到对应的前端处方(通过数据匹配)
|
||||||
|
// 如果找不到,就在末尾添加
|
||||||
|
const newPrescription = {
|
||||||
|
id: prescriptionId,
|
||||||
|
name: `西药方${updatedPrescriptions.length + 1}`,
|
||||||
|
prescriptionNo: info.prescriptionNo || '',
|
||||||
|
conditionDefinitionId: conditionDefinitionId.value,
|
||||||
|
accountId: accountId.value,
|
||||||
|
expandOrder: []
|
||||||
|
};
|
||||||
|
updatedPrescriptions.push(newPrescription);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3. 更新处方列表,保持原有顺序
|
||||||
|
westernPrescriptions.value = updatedPrescriptions;
|
||||||
|
|
||||||
|
// 4. 恢复当前活跃处方
|
||||||
|
if (savedCurrentPrescriptionId && existingPrescriptionIds.includes(savedCurrentPrescriptionId)) {
|
||||||
|
currentPrescriptionId.value = savedCurrentPrescriptionId;
|
||||||
|
} else if (updatedPrescriptions.length > 0) {
|
||||||
|
// 如果当前处方不存在,选择第一个已保存的处方
|
||||||
|
const firstSavedPrescription = updatedPrescriptions.find(p => existingPrescriptionIds.includes(p.id));
|
||||||
|
if (firstSavedPrescription) {
|
||||||
|
currentPrescriptionId.value = firstSavedPrescription.id;
|
||||||
|
} else {
|
||||||
|
currentPrescriptionId.value = updatedPrescriptions[0].id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载当前处方的数据
|
// 5. 加载当前处方的数据
|
||||||
prescriptionList.value = [...(allPrescriptionsData.value[currentPrescriptionId.value] || [])];
|
prescriptionList.value = [...(allPrescriptionsData.value[currentPrescriptionId.value] || [])];
|
||||||
prescriptionCounter.value = westernPrescriptions.value.length;
|
|
||||||
|
// 6. 更新处方计数器
|
||||||
|
prescriptionCounter.value = Math.max(prescriptionCounter.value, westernPrescriptions.value.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.activeTab == 'prescription' && addNewRow) {
|
if (props.activeTab == 'prescription' && addNewRow) {
|
||||||
@@ -2274,24 +2320,47 @@ function handleSaveBatch(prescriptionId) {
|
|||||||
switchToActivePrescription(prescriptionId);
|
switchToActivePrescription(prescriptionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 确保使用对应处方的数据
|
||||||
|
const targetPrescriptionId = prescriptionId || currentPrescriptionId.value;
|
||||||
|
if (!targetPrescriptionId) {
|
||||||
|
proxy.$modal.msgWarning('请先创建处方');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从对应处方的数据中获取列表,而不是使用全局的 prescriptionList
|
||||||
|
const currentPrescriptionData = allPrescriptionsData.value[targetPrescriptionId] || [];
|
||||||
|
|
||||||
// 验证费用性质是否已选择
|
// 验证费用性质是否已选择
|
||||||
if (!accountId.value) {
|
const prescription = westernPrescriptions.value.find(p => p.id === targetPrescriptionId);
|
||||||
|
if (!prescription || !prescription.accountId) {
|
||||||
proxy.$modal.msgWarning('请先选择费用性质');
|
proxy.$modal.msgWarning('请先选择费用性质');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expandOrder.value.length > 0) {
|
// 获取对应处方的展开状态
|
||||||
|
const prescriptionExpandOrder = prescription.expandOrder || [];
|
||||||
|
if (prescriptionExpandOrder.length > 0) {
|
||||||
proxy.$modal.msgWarning('请先点击确定确认当前医嘱');
|
proxy.$modal.msgWarning('请先点击确定确认当前医嘱');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (prescriptionList.value[0].isEdit && !prescriptionList.value[0].adviceType) {
|
|
||||||
prescriptionList.value.shift();
|
// 处理空行
|
||||||
|
if (currentPrescriptionData.length > 0 && currentPrescriptionData[0].isEdit && !currentPrescriptionData[0].adviceType) {
|
||||||
|
currentPrescriptionData.shift();
|
||||||
isAdding.value = false;
|
isAdding.value = false;
|
||||||
updateExpandOrder([]);
|
// 更新存储的数据
|
||||||
|
allPrescriptionsData.value[targetPrescriptionId] = [...currentPrescriptionData];
|
||||||
|
// 如果当前显示的就是这个处方,同步到 prescriptionList
|
||||||
|
if (currentPrescriptionId.value === targetPrescriptionId) {
|
||||||
|
prescriptionList.value = [...currentPrescriptionData];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let saveList = prescriptionList.value
|
|
||||||
|
// 使用对应处方的数据来过滤和保存
|
||||||
|
let saveList = currentPrescriptionData
|
||||||
.filter((item) => {
|
.filter((item) => {
|
||||||
return item.statusEnum == 1 && !item.isSaved;
|
// 确保只保存属于当前处方的数据
|
||||||
|
return item.statusEnum == 1 && !item.isSaved && (item.prescriptionId === targetPrescriptionId || !item.prescriptionId);
|
||||||
})
|
})
|
||||||
.map((item) => {
|
.map((item) => {
|
||||||
// 为每个医嘱项设置minUnitQuantity值,避免后端null值异常
|
// 为每个医嘱项设置minUnitQuantity值,避免后端null值异常
|
||||||
@@ -2331,6 +2400,18 @@ function handleSaveBatch(prescriptionId) {
|
|||||||
savePrescription({ adviceSaveList: saveList }).then((res) => {
|
savePrescription({ adviceSaveList: saveList }).then((res) => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
proxy.$modal.msgSuccess('保存成功');
|
proxy.$modal.msgSuccess('保存成功');
|
||||||
|
// 保存成功后,更新当前处方的数据
|
||||||
|
currentPrescriptionData.forEach(item => {
|
||||||
|
if (saveList.find(saved => saved.uniqueKey === item.uniqueKey)) {
|
||||||
|
item.isSaved = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 更新存储的数据
|
||||||
|
allPrescriptionsData.value[targetPrescriptionId] = [...currentPrescriptionData];
|
||||||
|
// 如果当前显示的就是这个处方,同步到 prescriptionList
|
||||||
|
if (currentPrescriptionId.value === targetPrescriptionId) {
|
||||||
|
prescriptionList.value = [...currentPrescriptionData];
|
||||||
|
}
|
||||||
getListInfo(false);
|
getListInfo(false);
|
||||||
nextId.value = 1;
|
nextId.value = 1;
|
||||||
}
|
}
|
||||||
@@ -2999,18 +3080,49 @@ function sortPrescriptionList() {
|
|||||||
// return prescriptionList.value.filter((item) => item.check);
|
// return prescriptionList.value.filter((item) => item.check);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// 处理行chexkbox选中
|
// 获取指定处方的全选状态
|
||||||
function handleCheckBoxChange(value, index, row) {
|
function getCheckAllState(prescriptionId) {
|
||||||
|
const prescriptionData = allPrescriptionsData.value[prescriptionId] || [];
|
||||||
|
if (prescriptionData.length === 0) return false;
|
||||||
|
return prescriptionData.every(item => item.check === true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理处方的全选/取消全选
|
||||||
|
function handleCheckAllChange(value, prescriptionId) {
|
||||||
|
const prescriptionData = allPrescriptionsData.value[prescriptionId] || [];
|
||||||
|
// 更新该处方所有行的选中状态
|
||||||
|
prescriptionData.forEach((item) => {
|
||||||
|
item.check = value;
|
||||||
|
});
|
||||||
|
// 更新存储的数据
|
||||||
|
allPrescriptionsData.value[prescriptionId] = [...prescriptionData];
|
||||||
|
// 如果当前显示的就是这个处方,同步到 prescriptionList
|
||||||
|
if (currentPrescriptionId.value === prescriptionId) {
|
||||||
|
prescriptionList.value = [...prescriptionData];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理行checkbox选中
|
||||||
|
function handleCheckBoxChange(value, index, row, prescriptionId) {
|
||||||
|
// 获取对应处方的数据
|
||||||
|
const prescriptionData = allPrescriptionsData.value[prescriptionId] || [];
|
||||||
|
|
||||||
// 选中将当前行索引记录下来,取消将当前行索引删除
|
// 选中将当前行索引记录下来,取消将当前行索引删除
|
||||||
if (value) {
|
if (value) {
|
||||||
groupIndexList.value.push(index);
|
if (!groupIndexList.value.includes(index)) {
|
||||||
|
groupIndexList.value.push(index);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
groupIndexList.value.splice(groupIndexList.value.indexOf(index), 1);
|
const indexPos = groupIndexList.value.indexOf(index);
|
||||||
|
if (indexPos > -1) {
|
||||||
|
groupIndexList.value.splice(indexPos, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果选中或取消行有组号,将全部相同组号的行全部选中,并记录或删除这些行的索引
|
// 如果选中或取消行有组号,将全部相同组号的行全部选中,并记录或删除这些行的索引
|
||||||
if (row.groupId) {
|
if (row.groupId) {
|
||||||
// 获取组号相同行
|
// 获取组号相同行(在当前处方内)
|
||||||
let sameGroupIdList = prescriptionList.value.filter((item) => {
|
let sameGroupIdList = prescriptionData.filter((item) => {
|
||||||
return item.groupId == row.groupId;
|
return item.groupId == row.groupId;
|
||||||
});
|
});
|
||||||
// 如果只有一个组号的情况不做处理
|
// 如果只有一个组号的情况不做处理
|
||||||
@@ -3021,18 +3133,30 @@ function handleCheckBoxChange(value, index, row) {
|
|||||||
// 排除掉当前选中行
|
// 排除掉当前选中行
|
||||||
if (row.uniqueKey != item.uniqueKey) {
|
if (row.uniqueKey != item.uniqueKey) {
|
||||||
// 同步选中状态
|
// 同步选中状态
|
||||||
let currentIndex = prescriptionList.value.findIndex((k) => k.uniqueKey == item.uniqueKey);
|
let currentIndex = prescriptionData.findIndex((k) => k.uniqueKey == item.uniqueKey);
|
||||||
prescriptionList.value[currentIndex].check = value;
|
if (currentIndex !== -1) {
|
||||||
if (value) {
|
prescriptionData[currentIndex].check = value;
|
||||||
groupIndexList.value.push(currentIndex); // 或使用索引或唯一标识
|
if (value) {
|
||||||
} else if (!value) {
|
if (!groupIndexList.value.includes(currentIndex)) {
|
||||||
groupIndexList.value.splice(groupIndexList.value.indexOf(currentIndex), 1);
|
groupIndexList.value.push(currentIndex);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const indexPos = groupIndexList.value.indexOf(currentIndex);
|
||||||
|
if (indexPos > -1) {
|
||||||
|
groupIndexList.value.splice(indexPos, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// 更新存储的数据
|
||||||
|
allPrescriptionsData.value[prescriptionId] = [...prescriptionData];
|
||||||
|
// 如果当前显示的就是这个处方,同步到 prescriptionList
|
||||||
|
if (currentPrescriptionId.value === prescriptionId) {
|
||||||
|
prescriptionList.value = [...prescriptionData];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(groupIndexList.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 校验每个组号数量是否大于5和对应分组金额是否大于500
|
// 校验每个组号数量是否大于5和对应分组金额是否大于500
|
||||||
|
|||||||
@@ -95,9 +95,11 @@
|
|||||||
{{ getLevelLabel(row.packageLevel) }}
|
{{ getLevelLabel(row.packageLevel) }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</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 }">
|
<template #default="{ row }">
|
||||||
{{ getDeptName(row.department) }}
|
<span :title="row.department && /^[A-Z]\d{2}$/.test(row.department.trim()) ? '旧编码格式,建议编辑套餐重新选择科室' : ''">
|
||||||
|
{{ getDeptName(row.department) }}
|
||||||
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="user" label="用户" width="100" align="center" />
|
<el-table-column prop="user" label="用户" width="100" align="center" />
|
||||||
@@ -232,60 +234,65 @@ onMounted(async () => {
|
|||||||
console.error('获取套餐级别字典失败:', error)
|
console.error('获取套餐级别字典失败:', error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取科室列表 - 优先使用Organization API(包含编码和名称)
|
// 获取科室列表 - 使用Organization完整API(包含编码和名称)
|
||||||
try {
|
try {
|
||||||
// 尝试使用Organization API获取科室列表(包含编码)
|
// 使用Organization完整API获取科室列表(包含busNo编码)
|
||||||
const orgResponse = await request({
|
const orgResponse = await request({
|
||||||
url: '/app-common/department-list',
|
url: '/base-data-manage/organization/organization',
|
||||||
method: 'get'
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 1000 // 获取足够多的数据
|
||||||
|
}
|
||||||
})
|
})
|
||||||
console.log('科室Organization API响应:', orgResponse)
|
|
||||||
|
|
||||||
let orgList = []
|
let orgList = []
|
||||||
if (orgResponse) {
|
if (orgResponse) {
|
||||||
if (Array.isArray(orgResponse)) {
|
if (orgResponse.data) {
|
||||||
orgList = orgResponse
|
if (orgResponse.data.records && Array.isArray(orgResponse.data.records)) {
|
||||||
} else if (orgResponse.data) {
|
orgList = orgResponse.data.records
|
||||||
if (Array.isArray(orgResponse.data)) {
|
} else if (Array.isArray(orgResponse.data)) {
|
||||||
orgList = 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) {
|
} else if (Array.isArray(orgResponse)) {
|
||||||
orgList = Array.isArray(orgResponse.data) ? orgResponse.data : []
|
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) {
|
if (orgList && orgList.length > 0) {
|
||||||
// 使用Organization数据(包含编码和名称)
|
|
||||||
departments.value = orgList.map(org => {
|
departments.value = orgList.map(org => {
|
||||||
const busNo = (org.busNo || org.code || '').trim()
|
const busNo = (org.busNo || org.code || '').trim()
|
||||||
const name = (org.name || org.deptName || '').trim()
|
const name = (org.name || org.deptName || '').trim()
|
||||||
// 如果busNo是层级编码(如 "A01.001"),同时存储前缀("A01")用于匹配
|
|
||||||
const busNoPrefix = busNo ? busNo.split('.')[0] : ''
|
const busNoPrefix = busNo ? busNo.split('.')[0] : ''
|
||||||
return {
|
return {
|
||||||
dictValue: name,
|
dictValue: name,
|
||||||
dictLabel: name,
|
dictLabel: name,
|
||||||
deptId: org.id || org.deptId,
|
deptId: org.id || org.deptId,
|
||||||
deptCode: busNo || name, // 优先使用busNo,如果没有则使用名称
|
deptCode: busNo || name,
|
||||||
busNoPrefix: busNoPrefix, // 存储前缀用于匹配
|
busNoPrefix: busNoPrefix,
|
||||||
rawOrg: org // 保存原始数据用于调试
|
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 {
|
} else {
|
||||||
// 如果Organization API没有数据,使用系统部门API
|
// 如果Organization API没有数据,使用系统部门API
|
||||||
const deptResponse = await listDept()
|
const deptResponse = await listDept()
|
||||||
console.log('科室API响应:', deptResponse)
|
|
||||||
|
|
||||||
// 处理不同的响应格式
|
|
||||||
let deptList = []
|
let deptList = []
|
||||||
if (deptResponse) {
|
if (deptResponse) {
|
||||||
if (Array.isArray(deptResponse)) {
|
if (Array.isArray(deptResponse)) {
|
||||||
@@ -302,26 +309,21 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (deptList && deptList.length > 0) {
|
if (deptList && deptList.length > 0) {
|
||||||
// 将部门列表转换为字典格式
|
|
||||||
departments.value = deptList.map(dept => ({
|
departments.value = deptList.map(dept => ({
|
||||||
dictValue: dept.deptName || dept.name,
|
dictValue: dept.deptName || dept.name,
|
||||||
dictLabel: dept.deptName || dept.name,
|
dictLabel: dept.deptName || dept.name,
|
||||||
deptId: dept.deptId || dept.id,
|
deptId: dept.deptId || dept.id,
|
||||||
deptCode: dept.deptName || dept.name // 如果没有编码,使用名称
|
deptCode: dept.deptName || dept.name
|
||||||
}))
|
}))
|
||||||
console.log('科室数据加载成功(Dept):', departments.value.length, departments.value)
|
|
||||||
} else {
|
} else {
|
||||||
console.warn('科室列表为空,尝试使用字典方式')
|
|
||||||
// 如果获取失败,尝试使用字典方式
|
// 如果获取失败,尝试使用字典方式
|
||||||
try {
|
try {
|
||||||
const dictResponse = await getDicts('dept')
|
const dictResponse = await getDicts('dept')
|
||||||
console.log('科室字典响应:', dictResponse)
|
|
||||||
if (dictResponse && dictResponse.data) {
|
if (dictResponse && dictResponse.data) {
|
||||||
departments.value = dictResponse.data
|
departments.value = dictResponse.data
|
||||||
console.log('使用字典方式加载科室数据成功:', departments.value.length)
|
|
||||||
}
|
}
|
||||||
} catch (dictError) {
|
} catch (dictError) {
|
||||||
console.error('获取科室字典也失败:', dictError)
|
console.error('获取科室字典失败:', dictError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -432,34 +434,11 @@ function getDeptName(deptValue) {
|
|||||||
return dept.dictLabel
|
return dept.dictLabel
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果找不到,输出详细信息用于调试
|
// 无法匹配时,返回原始编码值
|
||||||
const deptCodes = departments.value.map(d => ({
|
const isOldFormat = /^[A-Z]\d{2}$/.test(trimmedValue)
|
||||||
deptCode: String(d.deptCode || '').trim(),
|
if (isOldFormat) {
|
||||||
deptCodeUpper: String(d.deptCode || '').trim().toUpperCase(),
|
return trimmedValue + ' (旧格式)'
|
||||||
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()
|
|
||||||
|
|
||||||
return trimmedValue
|
return trimmedValue
|
||||||
}
|
}
|
||||||
@@ -494,8 +473,6 @@ async function handleQuery() {
|
|||||||
tableData.value = []
|
tableData.value = []
|
||||||
total.value = 0
|
total.value = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('查询成功,共', total.value, '条数据')
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('查询失败:', error)
|
console.error('查询失败:', error)
|
||||||
@@ -520,28 +497,17 @@ function handleReset() {
|
|||||||
handleQuery()
|
handleQuery()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回套餐设置界面
|
|
||||||
function handleBackToSettings() {
|
|
||||||
emit('back-to-settings')
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增
|
// 新增
|
||||||
function handleAdd() {
|
function handleAdd() {
|
||||||
console.log('新增套餐')
|
|
||||||
// 通知父组件切换到套餐设置界面,模式为新增
|
|
||||||
emit('switch-to-settings', { mode: 'add', data: null })
|
emit('switch-to-settings', { mode: 'add', data: null })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑
|
// 编辑
|
||||||
async function handleEdit(row) {
|
async function handleEdit(row) {
|
||||||
try {
|
try {
|
||||||
console.log('编辑套餐:', row.id)
|
|
||||||
|
|
||||||
// 获取完整的套餐数据(包含明细)
|
|
||||||
const response = await getCheckPackage(row.id)
|
const response = await getCheckPackage(row.id)
|
||||||
|
|
||||||
if (response && (response.code === 200 || response.code === 0) && response.data) {
|
if (response && (response.code === 200 || response.code === 0) && response.data) {
|
||||||
// 通知父组件切换到套餐设置界面,模式为编辑
|
|
||||||
emit('switch-to-settings', { mode: 'edit', data: response.data })
|
emit('switch-to-settings', { mode: 'edit', data: response.data })
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error('加载套餐数据失败')
|
ElMessage.error('加载套餐数据失败')
|
||||||
@@ -555,13 +521,9 @@ async function handleEdit(row) {
|
|||||||
// 查看
|
// 查看
|
||||||
async function handleView(row) {
|
async function handleView(row) {
|
||||||
try {
|
try {
|
||||||
console.log('查看套餐:', row.id)
|
|
||||||
|
|
||||||
// 获取完整的套餐数据(包含明细)
|
|
||||||
const response = await getCheckPackage(row.id)
|
const response = await getCheckPackage(row.id)
|
||||||
|
|
||||||
if (response && (response.code === 200 || response.code === 0) && response.data) {
|
if (response && (response.code === 200 || response.code === 0) && response.data) {
|
||||||
// 通知父组件切换到套餐设置界面,模式为查看
|
|
||||||
emit('switch-to-settings', { mode: 'view', data: response.data })
|
emit('switch-to-settings', { mode: 'view', data: response.data })
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error('加载套餐数据失败')
|
ElMessage.error('加载套餐数据失败')
|
||||||
@@ -589,7 +551,6 @@ function handleDelete(row) {
|
|||||||
|
|
||||||
if (response && (response.code === 200 || response.code === 0)) {
|
if (response && (response.code === 200 || response.code === 0)) {
|
||||||
ElMessage.success('删除成功')
|
ElMessage.success('删除成功')
|
||||||
// 刷新列表
|
|
||||||
handleQuery()
|
handleQuery()
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error(response?.msg || response?.message || '删除失败')
|
ElMessage.error(response?.msg || response?.message || '删除失败')
|
||||||
@@ -598,9 +559,7 @@ function handleDelete(row) {
|
|||||||
console.error('删除失败:', error)
|
console.error('删除失败:', error)
|
||||||
ElMessage.error('删除失败: ' + (error.message || '未知错误'))
|
ElMessage.error('删除失败: ' + (error.message || '未知错误'))
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch(() => {})
|
||||||
console.log('用户取消删除')
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 基本信息表单区 -->
|
<!-- 基本信息表单区 -->
|
||||||
<div class="basic-info-section" v-loading="loading" element-loading-text="正在加载诊疗项目数据...">
|
<div class="basic-info-section">
|
||||||
<h3 class="section-title">基本信息</h3>
|
<h3 class="section-title">基本信息</h3>
|
||||||
<el-form
|
<el-form
|
||||||
ref="basicFormRef"
|
ref="basicFormRef"
|
||||||
@@ -49,12 +49,12 @@
|
|||||||
|
|
||||||
<el-col v-if="formData.packageLevel === '2'" :xs="24" :sm="12" :md="8" :lg="6">
|
<el-col v-if="formData.packageLevel === '2'" :xs="24" :sm="12" :md="8" :lg="6">
|
||||||
<el-form-item label="科室选择" prop="department">
|
<el-form-item label="科室选择" prop="department">
|
||||||
<el-select v-model="formData.department" placeholder="请选择科室" style="width: 100%">
|
<el-select v-model="formData.department" placeholder="请选择科室" style="width: 100%" :disabled="isReadOnly">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dept in departments"
|
v-for="dept in departments"
|
||||||
:key="dept.dictValue"
|
:key="dept.deptCode || dept.dictValue"
|
||||||
:label="dept.dictLabel"
|
:label="dept.dictLabel"
|
||||||
:value="dept.dictValue"
|
:value="dept.deptCode || dept.busNoPrefix || dept.rawOrg?.busNo || dept.dictValue"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -95,7 +95,7 @@
|
|||||||
<el-input
|
<el-input
|
||||||
v-model="formData.discount"
|
v-model="formData.discount"
|
||||||
placeholder="请输入折扣"
|
placeholder="请输入折扣"
|
||||||
@input="validateNumberInput($event, 'discount')"
|
@input="handleDiscountChange"
|
||||||
:disabled="isReadOnly"
|
:disabled="isReadOnly"
|
||||||
>
|
>
|
||||||
<template #append>%</template>
|
<template #append>%</template>
|
||||||
@@ -386,6 +386,7 @@ import { addCheckPackage, updateCheckPackage } from '@/api/system/checkType'
|
|||||||
import { getDiagnosisTreatmentList } from '@/views/catalog/diagnosistreatment/components/diagnosistreatment'
|
import { getDiagnosisTreatmentList } from '@/views/catalog/diagnosistreatment/components/diagnosistreatment'
|
||||||
import useUserStore from '@/store/modules/user'
|
import useUserStore from '@/store/modules/user'
|
||||||
import request from '@/utils/request' // 导入request工具用于调用Organization API
|
import request from '@/utils/request' // 导入request工具用于调用Organization API
|
||||||
|
import cache from '@/plugins/cache' // 导入缓存工具
|
||||||
|
|
||||||
// 接收props
|
// 接收props
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -477,7 +478,6 @@ const detailData = ref([])
|
|||||||
// 监听packageData变化,加载数据
|
// 监听packageData变化,加载数据
|
||||||
watch(() => props.packageData, (newData) => {
|
watch(() => props.packageData, (newData) => {
|
||||||
if (newData) {
|
if (newData) {
|
||||||
console.log('加载套餐数据:', newData)
|
|
||||||
loadPackageData(newData)
|
loadPackageData(newData)
|
||||||
}
|
}
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
@@ -486,12 +486,33 @@ watch(() => props.packageData, (newData) => {
|
|||||||
function loadPackageData(data) {
|
function loadPackageData(data) {
|
||||||
if (!data) return
|
if (!data) return
|
||||||
|
|
||||||
console.log('开始加载套餐数据到表单...')
|
|
||||||
|
|
||||||
// 填充基本信息
|
// 填充基本信息
|
||||||
Object.keys(formData).forEach(key => {
|
Object.keys(formData).forEach(key => {
|
||||||
if (data[key] !== undefined) {
|
if (data[key] !== undefined) {
|
||||||
formData[key] = data[key]
|
// 特殊处理科室字段:检查编码格式并匹配
|
||||||
|
if (key === 'department' && data[key]) {
|
||||||
|
const deptValue = String(data[key]).trim()
|
||||||
|
const isOldFormat = /^[A-Z]\d{2}$/.test(deptValue)
|
||||||
|
|
||||||
|
if (isOldFormat && departments.value.length > 0) {
|
||||||
|
// 旧编码格式:在下拉框中添加临时选项
|
||||||
|
const tempDept = {
|
||||||
|
deptCode: deptValue,
|
||||||
|
dictLabel: `旧编码: ${deptValue} (请重新选择)`,
|
||||||
|
dictValue: deptValue,
|
||||||
|
isOldFormat: true
|
||||||
|
}
|
||||||
|
const exists = departments.value.find(d => d.deptCode === deptValue)
|
||||||
|
if (!exists) {
|
||||||
|
departments.value.unshift(tempDept)
|
||||||
|
}
|
||||||
|
formData[key] = deptValue
|
||||||
|
} else {
|
||||||
|
formData[key] = data[key]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
formData[key] = data[key]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -515,8 +536,6 @@ function loadPackageData(data) {
|
|||||||
filteredList: diagnosisTreatmentList.value
|
filteredList: diagnosisTreatmentList.value
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('套餐数据加载完成')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
@@ -534,30 +553,53 @@ onMounted(async () => {
|
|||||||
console.error('✗ 获取套餐级别字典失败:', error)
|
console.error('✗ 获取套餐级别字典失败:', error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取科室列表 - 优先使用Organization API(包含编码和名称)
|
// 获取科室列表 - 使用Organization完整API(包含编码和名称)
|
||||||
try {
|
try {
|
||||||
// 尝试使用Organization API获取科室列表(包含编码)
|
// 使用Organization完整API获取科室列表(包含busNo编码)
|
||||||
const orgResponse = await request({
|
const orgResponse = await request({
|
||||||
url: '/app-common/department-list',
|
url: '/base-data-manage/organization/organization',
|
||||||
method: 'get'
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 1000 // 获取足够多的数据
|
||||||
|
}
|
||||||
})
|
})
|
||||||
console.log('科室Organization API响应:', orgResponse)
|
console.log('科室Organization完整API响应:', orgResponse)
|
||||||
|
|
||||||
let orgList = []
|
let orgList = []
|
||||||
if (orgResponse) {
|
if (orgResponse) {
|
||||||
if (Array.isArray(orgResponse)) {
|
// 处理分页响应格式:{ code: 200, data: { records: [...], total: ... } }
|
||||||
orgList = orgResponse
|
if (orgResponse.data) {
|
||||||
} else if (orgResponse.data) {
|
if (orgResponse.data.records && Array.isArray(orgResponse.data.records)) {
|
||||||
if (Array.isArray(orgResponse.data)) {
|
// 分页格式,提取records
|
||||||
|
orgList = orgResponse.data.records
|
||||||
|
} else if (Array.isArray(orgResponse.data)) {
|
||||||
orgList = 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) {
|
} else if (Array.isArray(orgResponse)) {
|
||||||
orgList = Array.isArray(orgResponse.data) ? orgResponse.data : []
|
orgList = orgResponse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果是树结构,需要展开所有节点(包括children),并过滤出科室类型(typeEnum=2)
|
||||||
|
if (orgList && orgList.length > 0) {
|
||||||
|
const flattenList = []
|
||||||
|
function flatten(nodes) {
|
||||||
|
nodes.forEach(node => {
|
||||||
|
// 只包含科室类型(typeEnum=2)且有busNo的节点
|
||||||
|
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
|
||||||
|
console.log('展开后的科室列表(包含busNo):', orgList.length, orgList.slice(0, 3).map(o => ({ busNo: o.busNo, name: o.name })))
|
||||||
|
}
|
||||||
|
|
||||||
if (orgList && orgList.length > 0) {
|
if (orgList && orgList.length > 0) {
|
||||||
// 使用Organization数据(包含编码和名称)
|
// 使用Organization数据(包含编码和名称)
|
||||||
departments.value = orgList.map(org => {
|
departments.value = orgList.map(org => {
|
||||||
@@ -637,91 +679,127 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取诊疗项目列表 - 使用分批加载策略
|
// 加载诊疗项目列表(优先使用缓存)
|
||||||
loading.value = true
|
await loadDiagnosisTreatmentList(false)
|
||||||
|
|
||||||
|
// 初始化一行空数据
|
||||||
|
handleAddRow()
|
||||||
|
} catch (error) {
|
||||||
|
console.error('✗ 初始化数据失败:', error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 诊疗项目列表缓存key和过期时间(30分钟)
|
||||||
|
const DIAGNOSIS_TREATMENT_CACHE_KEY = 'check_package_diagnosis_treatment_list'
|
||||||
|
const CACHE_EXPIRE_TIME = 30 * 60 * 1000 // 30分钟
|
||||||
|
|
||||||
|
// 加载诊疗项目列表(支持缓存)
|
||||||
|
async function loadDiagnosisTreatmentList(forceRefresh = false) {
|
||||||
|
// 如果不是强制刷新,先尝试从缓存加载
|
||||||
|
if (!forceRefresh) {
|
||||||
try {
|
try {
|
||||||
console.log('开始获取诊疗项目列表...')
|
const cachedData = cache.session.getJSON(DIAGNOSIS_TREATMENT_CACHE_KEY)
|
||||||
|
if (cachedData && cachedData.data && cachedData.timestamp) {
|
||||||
// 分批加载数据,避免一次性加载过多导致超时
|
const now = Date.now()
|
||||||
let allItems = []
|
const cacheAge = now - cachedData.timestamp
|
||||||
const maxBatches = 3 // 最多加载3批
|
|
||||||
const batchSize = 50 // 每批50条
|
// 检查缓存是否过期
|
||||||
|
if (cacheAge < CACHE_EXPIRE_TIME) {
|
||||||
for (let page = 1; page <= maxBatches; page++) {
|
diagnosisTreatmentList.value = cachedData.data
|
||||||
try {
|
// 静默加载,不显示消息
|
||||||
const treatmentResponse = await getDiagnosisTreatmentList({
|
return
|
||||||
pageNo: page,
|
|
||||||
pageSize: batchSize
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log(`第${page}批API响应:`, treatmentResponse)
|
|
||||||
|
|
||||||
// 处理不同的响应格式
|
|
||||||
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)
|
|
||||||
console.log(`✓ 第${page}批加载成功: ${batchData.length}条,累计: ${allItems.length}条`)
|
|
||||||
|
|
||||||
// 如果这批数据少于pageSize,说明已经是最后一批了
|
|
||||||
if (batchData.length < batchSize) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
break // 没有更多数据了
|
|
||||||
}
|
|
||||||
} catch (batchError) {
|
|
||||||
console.error(`第${page}批加载失败:`, batchError)
|
|
||||||
break // 出错就停止继续加载
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// 缓存读取失败,继续从API加载
|
||||||
|
console.error('读取缓存失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从API加载数据
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
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 (allItems.length > 0) {
|
||||||
|
diagnosisTreatmentList.value = allItems
|
||||||
|
|
||||||
if (allItems.length > 0) {
|
// 保存到缓存
|
||||||
diagnosisTreatmentList.value = allItems
|
try {
|
||||||
console.log(`✓ 诊疗项目加载完成,共${allItems.length}条`)
|
cache.session.setJSON(DIAGNOSIS_TREATMENT_CACHE_KEY, {
|
||||||
|
data: allItems,
|
||||||
|
timestamp: Date.now()
|
||||||
|
})
|
||||||
|
} catch (cacheError) {
|
||||||
|
console.error('保存缓存失败:', cacheError)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 只在强制刷新时显示成功消息
|
||||||
|
if (forceRefresh) {
|
||||||
ElMessage.success(`成功加载${allItems.length}个诊疗项目`)
|
ElMessage.success(`成功加载${allItems.length}个诊疗项目`)
|
||||||
} else {
|
}
|
||||||
console.warn('未获取到任何诊疗项目数据')
|
} else {
|
||||||
|
if (forceRefresh) {
|
||||||
ElMessage.warning({
|
ElMessage.warning({
|
||||||
message: '未获取到诊疗项目数据。请先在【系统管理-目录管理-诊疗项目】中添加数据',
|
message: '未获取到诊疗项目数据。请先在【系统管理-目录管理-诊疗项目】中添加数据',
|
||||||
duration: 6000,
|
duration: 6000,
|
||||||
showClose: true
|
showClose: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取诊疗项目列表失败:', error)
|
console.error('获取诊疗项目列表失败:', error)
|
||||||
|
if (forceRefresh) {
|
||||||
ElMessage.error({
|
ElMessage.error({
|
||||||
message: '获取诊疗项目列表失败,请检查网络连接或联系管理员',
|
message: '获取诊疗项目列表失败,请检查网络连接或联系管理员',
|
||||||
duration: 6000,
|
duration: 6000,
|
||||||
showClose: true
|
showClose: true
|
||||||
})
|
})
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
// 初始化一行空数据
|
loading.value = false
|
||||||
handleAddRow()
|
|
||||||
|
|
||||||
console.log('=== PackageSettings 组件初始化完成 ===')
|
|
||||||
console.log('最终诊疗项目列表:', diagnosisTreatmentList.value)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('✗ 初始化数据失败:', error)
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
// 套餐级别变更处理
|
// 套餐级别变更处理
|
||||||
function handlePackageLevelChange(value) {
|
function handlePackageLevelChange(value) {
|
||||||
console.log('套餐级别变更:', value)
|
|
||||||
// 重置关联字段
|
// 重置关联字段
|
||||||
if (value !== '2') {
|
if (value !== '2') {
|
||||||
formData.department = ''
|
formData.department = ''
|
||||||
@@ -915,10 +993,45 @@ function calculateTotal(row) {
|
|||||||
calculatePackagePrice()
|
calculatePackagePrice()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算套餐金额
|
// 计算套餐金额(应用折扣)
|
||||||
function calculatePackagePrice() {
|
function calculatePackagePrice() {
|
||||||
|
// 计算所有明细项目的总金额
|
||||||
const total = detailData.value.reduce((sum, item) => sum + (item.total || 0), 0)
|
const total = detailData.value.reduce((sum, item) => sum + (item.total || 0), 0)
|
||||||
formData.packagePrice = total.toFixed(2)
|
|
||||||
|
// 如果有折扣,应用折扣计算
|
||||||
|
let finalPrice = total
|
||||||
|
if (formData.discount && parseFloat(formData.discount) > 0 && parseFloat(formData.discount) <= 100) {
|
||||||
|
const discountRate = parseFloat(formData.discount) / 100 // 将百分比转换为小数(如10% -> 0.1)
|
||||||
|
const discountAmount = total * discountRate // 折扣金额
|
||||||
|
finalPrice = total - discountAmount // 折扣后金额
|
||||||
|
}
|
||||||
|
|
||||||
|
formData.packagePrice = finalPrice.toFixed(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 折扣变更处理
|
||||||
|
function handleDiscountChange(value) {
|
||||||
|
// 验证并清理输入
|
||||||
|
const regex = /^\d*\.?\d*$/
|
||||||
|
if (!regex.test(value)) {
|
||||||
|
formData.discount = value.replace(/[^\d.]/g, '')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证折扣范围
|
||||||
|
const discountValue = parseFloat(formData.discount)
|
||||||
|
if (discountValue && (discountValue < 0 || discountValue > 100)) {
|
||||||
|
ElMessage.warning('折扣必须在0-100之间')
|
||||||
|
// 重置为有效值
|
||||||
|
if (discountValue < 0) {
|
||||||
|
formData.discount = '0'
|
||||||
|
} else if (discountValue > 100) {
|
||||||
|
formData.discount = '100'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重新计算套餐金额
|
||||||
|
calculatePackagePrice()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 套餐管理
|
// 套餐管理
|
||||||
@@ -927,66 +1040,12 @@ function handlePackageManagement() {
|
|||||||
emit('switch-to-management')
|
emit('switch-to-management')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新 - 重新加载诊疗项目数据
|
// 刷新 - 清除缓存并重新加载诊疗项目数据
|
||||||
async function handleRefresh() {
|
async function handleRefresh() {
|
||||||
try {
|
// 清除缓存
|
||||||
loading.value = true
|
cache.session.remove(DIAGNOSIS_TREATMENT_CACHE_KEY)
|
||||||
console.log('开始刷新诊疗项目数据...')
|
// 强制刷新加载
|
||||||
|
await loadDiagnosisTreatmentList(true)
|
||||||
// 分批加载数据,避免一次性加载过多导致超时
|
|
||||||
let allItems = []
|
|
||||||
const maxBatches = 3 // 最多加载3批
|
|
||||||
const batchSize = 50 // 每批50条
|
|
||||||
|
|
||||||
for (let page = 1; page <= maxBatches; page++) {
|
|
||||||
try {
|
|
||||||
const treatmentResponse = await getDiagnosisTreatmentList({
|
|
||||||
pageNo: page,
|
|
||||||
pageSize: batchSize
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log(`第${page}批API响应:`, treatmentResponse)
|
|
||||||
|
|
||||||
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)
|
|
||||||
console.log(`✓ 第${page}批加载成功: ${batchData.length}条,累计: ${allItems.length}条`)
|
|
||||||
|
|
||||||
// 如果这批数据少于pageSize,说明已经是最后一批了
|
|
||||||
if (batchData.length < batchSize) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
break // 没有更多数据了
|
|
||||||
}
|
|
||||||
} catch (batchError) {
|
|
||||||
console.error(`第${page}批加载失败:`, batchError)
|
|
||||||
break // 出错就停止继续加载
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allItems.length > 0) {
|
|
||||||
diagnosisTreatmentList.value = allItems
|
|
||||||
ElMessage.success('刷新成功,共加载 ' + allItems.length + ' 个项目')
|
|
||||||
} else {
|
|
||||||
ElMessage.warning('未获取到项目数据,请先在【系统管理-目录管理-诊疗项目】中添加数据')
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('刷新失败:', error)
|
|
||||||
ElMessage.error('刷新失败,请检查网络连接或联系管理员')
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数字输入验证 - 用于表单字段
|
// 数字输入验证 - 用于表单字段
|
||||||
|
|||||||
@@ -55,17 +55,17 @@
|
|||||||
|
|
||||||
<!-- 检查类型/方法/部位的表格视图 -->
|
<!-- 检查类型/方法/部位的表格视图 -->
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h1>{{ activeMenu }}管理</h1>
|
<h1>{{ activeMenu }}管理</h1>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
<button class="btn btn-add-new" @click="handleAddNewRow">
|
<button class="btn btn-add-new" @click="handleAddNewRow">
|
||||||
+
|
+
|
||||||
</button>
|
</button>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="table-container">
|
<div class="table-container">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 50px;">行</th>
|
<th style="width: 50px;">行</th>
|
||||||
@@ -196,12 +196,12 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 分页区域 -->
|
<!-- 分页区域 -->
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
<button class="pagination-btn">‹</button>
|
<button class="pagination-btn">‹</button>
|
||||||
<span>1</span>
|
<span>1</span>
|
||||||
<button class="pagination-btn">›</button>
|
<button class="pagination-btn">›</button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -322,7 +322,7 @@ function handleMenuClick(menu) {
|
|||||||
currentPackageData.value = null
|
currentPackageData.value = null
|
||||||
console.log('显示套餐设置界面')
|
console.log('显示套餐设置界面')
|
||||||
} else {
|
} else {
|
||||||
loadMenuData(menu);
|
loadMenuData(menu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user