Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
60
openhis-ui-vue3/src/api/lab/labActivityDefinition.js
Normal file
60
openhis-ui-vue3/src/api/lab/labActivityDefinition.js
Normal file
@@ -0,0 +1,60 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
/**
|
||||
* 检验项目维护专属 API(操作 lab_activity_definition 表)
|
||||
* 后端路径前缀:/lab/activity-definition
|
||||
*/
|
||||
|
||||
// 分页查询检验项目列表
|
||||
export function getLabActivityDefinitionPage(query) {
|
||||
return request({
|
||||
url: '/lab/activity-definition/page',
|
||||
method: 'get',
|
||||
params: query,
|
||||
});
|
||||
}
|
||||
|
||||
// 查询检验项目详情
|
||||
export function getLabActivityDefinitionOne(id) {
|
||||
return request({
|
||||
url: '/lab/activity-definition/one',
|
||||
method: 'get',
|
||||
params: { id },
|
||||
});
|
||||
}
|
||||
|
||||
// 新增检验项目
|
||||
export function addLabActivityDefinition(data) {
|
||||
return request({
|
||||
url: '/lab/activity-definition/add',
|
||||
method: 'post',
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
// 编辑检验项目
|
||||
export function editLabActivityDefinition(data) {
|
||||
return request({
|
||||
url: '/lab/activity-definition/edit',
|
||||
method: 'put',
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
// 停用检验项目
|
||||
export function stopLabActivityDefinition(ids) {
|
||||
return request({
|
||||
url: '/lab/activity-definition/stop',
|
||||
method: 'put',
|
||||
data: ids,
|
||||
});
|
||||
}
|
||||
|
||||
// 启用检验项目
|
||||
export function startLabActivityDefinition(ids) {
|
||||
return request({
|
||||
url: '/lab/activity-definition/start',
|
||||
method: 'put',
|
||||
data: ids,
|
||||
});
|
||||
}
|
||||
@@ -293,7 +293,7 @@ function getList() {
|
||||
emits('diagnosisSave', false);
|
||||
}
|
||||
});
|
||||
getTcmDiagnosis({ encounterId: patientInfo.value.encounterId }).then((res) => {
|
||||
getTcmDiagnosis({ encounterId: props.patientInfo.encounterId }).then((res) => {
|
||||
console.log('getTcmDiagnosis=======>', JSON.stringify(res.data.illness));
|
||||
|
||||
if (res.code == 200) {
|
||||
@@ -337,7 +337,6 @@ function init() {
|
||||
|
||||
function handleImport() {
|
||||
if (!props.patientInfo || !props.patientInfo.encounterId) {
|
||||
console.warn('患者就诊信息不完整,无法导入慢性病信息');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -355,8 +354,10 @@ function handleImport() {
|
||||
diagSrtNo: form.value.diagnosisList.length + 1,
|
||||
iptDiseTypeCode: 2,
|
||||
diagnosisDesc: '',
|
||||
diagnosisDoctor: props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
|
||||
diagnosisTime: new Date().toLocaleString('zh-CN')
|
||||
diagnosisDoctor: props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
|
||||
diagnosisTime: new Date().toLocaleString('zh-CN'),
|
||||
//添加 patientId
|
||||
patientId: props.patientInfo.patientId
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -469,7 +470,6 @@ function handleAddDiagnosis() {
|
||||
* 添加诊断项
|
||||
*/
|
||||
function addDiagnosisItem() {
|
||||
console.log('执行添加诊断,当前列表长度:', form.value.diagnosisList.length);
|
||||
form.value.diagnosisList.push({
|
||||
showPopover: false,
|
||||
name: undefined,
|
||||
@@ -479,12 +479,15 @@ function addDiagnosisItem() {
|
||||
iptDiseTypeCode: 2,
|
||||
diagnosisDesc: '',
|
||||
diagnosisDoctor: props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
|
||||
diagnosisTime: new Date().toLocaleString('zh-CN')
|
||||
diagnosisTime: new Date().toLocaleString('zh-CN'),
|
||||
|
||||
// 新增这一行:为每个诊断项添加 patientId
|
||||
patientId: props.patientInfo.patientId
|
||||
});
|
||||
|
||||
if (form.value.diagnosisList.length == 1) {
|
||||
form.value.diagnosisList[0].maindiseFlag = 1;
|
||||
}
|
||||
console.log('添加完成,新列表长度:', form.value.diagnosisList.length);
|
||||
}
|
||||
|
||||
// 添加中医诊断
|
||||
@@ -565,8 +568,6 @@ function handleMaindise(value, index) {
|
||||
* 保存诊断
|
||||
*/
|
||||
function handleSaveDiagnosis() {
|
||||
console.log('form.value.diagnosisList=======>', JSON.stringify(form.value.diagnosisList));
|
||||
|
||||
for (let index = 0; index < (form.value.diagnosisList || []).length; index++) {
|
||||
const item = form.value.diagnosisList[index];
|
||||
if (!item.diagSrtNo) {
|
||||
@@ -690,11 +691,13 @@ function handleNodeClick(data) {
|
||||
ybNo: data.ybNo,
|
||||
name: data.name,
|
||||
verificationStatusEnum: 4,
|
||||
medTypeCode: undefined, // 不设默认值
|
||||
medTypeCode: undefined,
|
||||
diagSrtNo: form.value.diagnosisList.length + 1,
|
||||
definitionId: data.definitionId,
|
||||
diagnosisDoctor: props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
|
||||
diagnosisTime: new Date().toLocaleString('zh-CN')
|
||||
diagnosisTime: new Date().toLocaleString('zh-CN'),
|
||||
// 添加 patientId
|
||||
patientId: props.patientInfo.patientId
|
||||
});
|
||||
if (form.value.diagnosisList.length == 1) {
|
||||
form.value.diagnosisList[0].maindiseFlag = 1;
|
||||
|
||||
@@ -151,6 +151,8 @@ const handleItemClick = (node) => {
|
||||
// 同时更新本地和全局状态,确保模块内组件和跨模块组件都能正确响应
|
||||
updatePatientInfo(node);
|
||||
updateLocalPatientInfo(node);
|
||||
// 关键修复:同步更新 currentPatientInfo,确保诊断组件能获取到 patientId 和 encounterId
|
||||
currentPatientInfo.value = node;
|
||||
|
||||
diagnosisRef.value?.getList();
|
||||
diagnosisRef.value?.getDetail(node?.encounterId);
|
||||
|
||||
@@ -431,9 +431,9 @@ async function loadData() {
|
||||
level: item.packageLevel || '',
|
||||
dept: item.department || '',
|
||||
user: item.userId || '',
|
||||
amount: parseFloat(item.packageAmount || 0),
|
||||
amount: parseFloat((parseFloat(item.packageAmount || 0) - parseFloat(item.serviceFee || 0)).toFixed(2)),
|
||||
fee: parseFloat(item.serviceFee || 0),
|
||||
total: parseFloat(item.packageAmount || 0) + parseFloat(item.serviceFee || 0),
|
||||
total: parseFloat(item.packageAmount || 0),
|
||||
combined: item.enablePackagePrice === true ? '是' : '否',
|
||||
display: item.showPackageName === true ? '是' : '否',
|
||||
enabled: item.isDisabled === true ? '否' : '是',
|
||||
|
||||
@@ -816,11 +816,14 @@ import {
|
||||
} from '@/api/system/inspectionType';
|
||||
import {
|
||||
getDiagnosisTreatmentList,
|
||||
addDiagnosisTreatment,
|
||||
editDiagnosisTreatment,
|
||||
stopDiseaseTreatment,
|
||||
getDiseaseTreatmentInit
|
||||
} from '@/views/catalog/diagnosistreatment/components/diagnosistreatment';
|
||||
import {
|
||||
getLabActivityDefinitionPage,
|
||||
addLabActivityDefinition,
|
||||
editLabActivityDefinition,
|
||||
stopLabActivityDefinition
|
||||
} from '@/api/lab/labActivityDefinition';
|
||||
import {listLisGroup} from '@/api/system/checkType';
|
||||
import {
|
||||
addInspectionPackage,
|
||||
@@ -1374,7 +1377,7 @@ const loadObservationItems = async (resetPage = false) => {
|
||||
}
|
||||
}
|
||||
|
||||
const response = await getDiagnosisTreatmentList(params);
|
||||
const response = await getLabActivityDefinitionPage(params);
|
||||
|
||||
if (response.code === 200) {
|
||||
let data = [];
|
||||
@@ -1643,25 +1646,37 @@ const cancelEditItem = (index) => {
|
||||
};
|
||||
|
||||
// 计算套餐金额和服务费
|
||||
// 规则:
|
||||
// 单价 = 原始单价 × (折扣% / 100)
|
||||
// 金额 = 折后单价 × 数量
|
||||
// 总金额 = 金额 + 服务费
|
||||
// 套餐金额 = 各行总金额之和
|
||||
const calculateAmounts = () => {
|
||||
// 更新每个项目的金额(金额 = 数量 × 单价,不受折扣影响)和总金额
|
||||
const discountRate = parseFloat(discount.value);
|
||||
const hasDiscount = !isNaN(discountRate) && discountRate > 0;
|
||||
|
||||
packageItems.value.forEach(item => {
|
||||
item.amount = parseFloat(((item.quantity || 1) * (item.unitPrice || 0.00)).toFixed(2));
|
||||
// serviceFee 由用户手动输入,不覆盖;只更新 totalAmount
|
||||
item.totalAmount = parseFloat(((item.amount) + (item.serviceFee || 0)).toFixed(2));
|
||||
// 单价 = 原始单价 × 折扣比例
|
||||
const originalPrice = item.originalPrice != null ? item.originalPrice : item.unitPrice;
|
||||
item.originalPrice = originalPrice; // 确保 originalPrice 始终保留
|
||||
if (hasDiscount) {
|
||||
item.unitPrice = parseFloat((originalPrice * discountRate / 100).toFixed(2));
|
||||
} else {
|
||||
item.unitPrice = parseFloat(originalPrice.toFixed(2));
|
||||
}
|
||||
// 金额 = 折后单价 × 数量
|
||||
item.amount = parseFloat(((item.quantity || 1) * item.unitPrice).toFixed(2));
|
||||
// 总金额 = 金额 + 服务费
|
||||
item.totalAmount = parseFloat((item.amount + (item.serviceFee || 0)).toFixed(2));
|
||||
});
|
||||
|
||||
// 汇总各明细行服务费到基本信息服务费(只读展示)
|
||||
serviceFee.value = parseFloat(packageItems.value.reduce((sum, item) => sum + (item.serviceFee || 0), 0).toFixed(2));
|
||||
|
||||
// 套餐总金额 = (各行金额之和 + 各行服务费之和) × 折扣比例
|
||||
const rawTotal = packageItems.value.reduce((sum, item) => sum + (item.amount || 0) + (item.serviceFee || 0), 0);
|
||||
let finalTotal = rawTotal;
|
||||
if (discount.value && !isNaN(parseFloat(discount.value)) && parseFloat(discount.value) > 0) {
|
||||
const discountRate = parseFloat(discount.value) / 100; // 80 → 0.8,表示八折保留80%
|
||||
finalTotal = rawTotal * discountRate;
|
||||
}
|
||||
packageAmount.value = parseFloat(finalTotal.toFixed(2));
|
||||
// 套餐金额 = 各行总金额之和
|
||||
packageAmount.value = parseFloat(
|
||||
packageItems.value.reduce((sum, item) => sum + (item.totalAmount || 0), 0).toFixed(2)
|
||||
);
|
||||
};
|
||||
|
||||
const itemNameRefs = ref([]);
|
||||
@@ -2030,16 +2045,18 @@ const saveItem = async (item) => {
|
||||
|
||||
// 判断是新增还是更新
|
||||
if (typeof item.id === 'number') { // 临时ID(数字类型),新增
|
||||
const response = await addDiagnosisTreatment(submitData);
|
||||
const response = await addLabActivityDefinition(submitData);
|
||||
if (response.code === 200) {
|
||||
ElMessage.success('添加成功');
|
||||
// 新增成功后跳到第1页,后端按id降序排列,最新数据在第1页首位
|
||||
inspectionCurrentPage.value = 1;
|
||||
await loadObservationItems();
|
||||
} else {
|
||||
ElMessage.error(response.msg || '添加失败');
|
||||
}
|
||||
} else { // 真实ID(字符串类型),更新
|
||||
submitData.id = item.id;
|
||||
const response = await editDiagnosisTreatment(submitData);
|
||||
const response = await editLabActivityDefinition(submitData);
|
||||
if (response.code === 200) {
|
||||
ElMessage.success('更新成功');
|
||||
await loadObservationItems();
|
||||
@@ -2062,7 +2079,7 @@ const deleteItem = async (id) => {
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
try {
|
||||
const response = await stopDiseaseTreatment([id]);
|
||||
const response = await stopLabActivityDefinition([id]);
|
||||
if (response.code === 200) {
|
||||
ElMessage.success('删除成功');
|
||||
await loadObservationItems();
|
||||
@@ -2208,10 +2225,11 @@ const handleSave = () => {
|
||||
days: item.days,
|
||||
quantity: item.quantity,
|
||||
unit: item.unit,
|
||||
unitPrice: item.unitPrice,
|
||||
originalPrice: item.originalPrice != null ? item.originalPrice : item.unitPrice, // 原始单价
|
||||
unitPrice: item.unitPrice, // 折后单价
|
||||
amount: item.amount,
|
||||
serviceFee: item.serviceFee || 0,
|
||||
totalAmount: parseFloat(((item.amount || 0) + (item.serviceFee || 0)).toFixed(2)),
|
||||
totalAmount: item.totalAmount, // 金额 + 服务费
|
||||
origin: item.origin,
|
||||
createTime: new Date().toISOString(),
|
||||
updateTime: new Date().toISOString()
|
||||
@@ -2314,7 +2332,16 @@ const handleProjectInlineSearch = async (query, cb, row) => {
|
||||
const handleProjectInlineSelect = (selectedItem, row) => {
|
||||
row.name = selectedItem.name;
|
||||
row.spec = selectedItem.spec || '';
|
||||
row.unitPrice = parseFloat(selectedItem.retailPrice || 0);
|
||||
// 保存原始单价,供折扣计算使用
|
||||
const originalPrice = parseFloat(selectedItem.retailPrice || 0);
|
||||
row.originalPrice = originalPrice;
|
||||
// 单价 = 原始单价 × 折扣比例
|
||||
const discountRate = parseFloat(discount.value);
|
||||
if (!isNaN(discountRate) && discountRate > 0) {
|
||||
row.unitPrice = parseFloat((originalPrice * discountRate / 100).toFixed(2));
|
||||
} else {
|
||||
row.unitPrice = originalPrice;
|
||||
}
|
||||
row.unit = selectedItem.permittedUnitCode_dictText || selectedItem.unit || '次';
|
||||
if (!row.quantity) row.quantity = 1;
|
||||
row.amount = parseFloat((row.unitPrice * row.quantity).toFixed(2));
|
||||
@@ -2557,21 +2584,39 @@ const loadInspectionPackage = async (packageId) => {
|
||||
remarks.value = basicData.remarks || '';
|
||||
|
||||
// 填充明细数据(必须映射 id,否则取消编辑时会被误判为新增行删除)
|
||||
packageItems.value = detailData.map(item => ({
|
||||
id: item.detailId || item.id,
|
||||
name: item.itemName || item.name,
|
||||
dosage: item.dosage || '',
|
||||
route: item.route || '',
|
||||
frequency: item.frequency || '',
|
||||
days: item.days || '',
|
||||
quantity: item.quantity || 1,
|
||||
unit: item.unit || '',
|
||||
unitPrice: parseFloat(item.unitPrice || 0),
|
||||
amount: parseFloat(item.amount || 0),
|
||||
serviceFee: parseFloat(item.serviceFee || 0),
|
||||
totalAmount: parseFloat(item.totalAmount || 0),
|
||||
origin: item.origin || ''
|
||||
}));
|
||||
const loadedDiscount = parseFloat(basicData.discount);
|
||||
packageItems.value = detailData.map(item => {
|
||||
const savedOriginalPrice = parseFloat(item.originalPrice || 0);
|
||||
const savedUnitPrice = parseFloat(item.unitPrice || 0);
|
||||
// 恢复原始单价:
|
||||
// 1. 后端有 originalPrice 时直接用
|
||||
// 2. 旧数据无 originalPrice 时,通过折扣反推:originalPrice = unitPrice / (discount/100)
|
||||
let originalPrice;
|
||||
if (savedOriginalPrice > 0) {
|
||||
originalPrice = savedOriginalPrice;
|
||||
} else if (!isNaN(loadedDiscount) && loadedDiscount > 0 && loadedDiscount !== 100) {
|
||||
originalPrice = parseFloat((savedUnitPrice / (loadedDiscount / 100)).toFixed(2));
|
||||
} else {
|
||||
// 折扣为空或100(原价),originalPrice = unitPrice
|
||||
originalPrice = savedUnitPrice;
|
||||
}
|
||||
return {
|
||||
id: item.detailId || item.id,
|
||||
name: item.itemName || item.name,
|
||||
dosage: item.dosage || '',
|
||||
route: item.route || '',
|
||||
frequency: item.frequency || '',
|
||||
days: item.days || '',
|
||||
quantity: item.quantity || 1,
|
||||
unit: item.unit || '',
|
||||
originalPrice,
|
||||
unitPrice: savedUnitPrice,
|
||||
amount: parseFloat(item.amount || 0),
|
||||
serviceFee: parseFloat(item.serviceFee || 0),
|
||||
totalAmount: parseFloat(item.totalAmount || 0),
|
||||
origin: item.origin || ''
|
||||
};
|
||||
});
|
||||
|
||||
// 恢复监听
|
||||
isLoadingPackage.value = false;
|
||||
|
||||
Reference in New Issue
Block a user