diff --git a/subPackages/sub_workbench/prescription_v2/index.vue b/subPackages/sub_workbench/prescription_v2/index.vue index 4b59249..0f55474 100644 --- a/subPackages/sub_workbench/prescription_v2/index.vue +++ b/subPackages/sub_workbench/prescription_v2/index.vue @@ -51,10 +51,10 @@ {{ (specialPrescriptionRecord.special_prescription && specialPrescriptionRecord.special_prescription.name) || '特色方' }} - + 剂量:{{ specialPrescriptionRecord.dose_count }} 剂 - + 0) { + milli += 10; + } + milli -= milli % 10; + return Math.round((milli / 1000) * 100) / 100; + // return milli / 1000; +} + +/** 模拟 PHP bcmul 在指定 scale 下向零截断 */ +function bcmulScale(a, b, scale) { + const product = parseFloat(a || 0) * parseFloat(b || 0); + const factor = 10 ** scale; + return Math.trunc(product * factor) / factor; +} + +/** 模拟 PHP bcadd 在指定 scale 下向零截断 */ +function bcaddScale(a, b, scale) { + const sum = a + b; + const factor = 10 ** scale; + return Math.trunc(sum * factor) / factor; +} + +/** + * 中药商品总价(与 PrescriptionService::createChineseReprice 一致) + */ +export function calculateChineseMedicineProductPriceLikeBackend(drugs, dosage = 7) { + if (!drugs || drugs.length === 0) { + return 0; + } + const dose = parseFloat(dosage || 0); + let total = 0; + for (const drug of drugs) { + const linePerDose = bcmulScale(drug.price, drug.number ?? 1, 3); + const lineTotal = bcmulScale(dose, linePerDose, 3); + total = bcaddScale(total, lineTotal, 3); + } + return formatPriceLikeBackend(total); +} + export class PrescriptionCalculator { /** * 计算中药商品总价 @@ -10,14 +59,7 @@ export class PrescriptionCalculator { * @returns {number} 商品总价 */ static calculateChineseMedicineProductPrice(drugs, dosage = 7) { - if (!drugs || drugs.length === 0) { - return 0; - } - return drugs.reduce((sum, drug) => { - const price = parseFloat(drug.price || 0); - const quantity = parseFloat(drug.number || 1); - return sum + (price * quantity * dosage); - }, 0); + return calculateChineseMedicineProductPriceLikeBackend(drugs, dosage); } static isValidBuyPrice(value) { diff --git a/subPackages/sub_workbench/workbench_infoPatient.vue b/subPackages/sub_workbench/workbench_infoPatient.vue index a7995ba..494d60f 100644 --- a/subPackages/sub_workbench/workbench_infoPatient.vue +++ b/subPackages/sub_workbench/workbench_infoPatient.vue @@ -38,6 +38,54 @@ + + + 特色方 + + + + + {{ (infoList.special_prescription_patient_record.special_prescription && infoList.special_prescription_patient_record.special_prescription.name) || '特色方' }} + + + 剂量 + {{ infoList.special_prescription_patient_record.dose_count }} 剂 + + + + + + + + + + + 导入 + + + + 挂号信息 @@ -67,54 +115,6 @@ - - - 特色方 - - - - - {{ (infoList.special_prescription_patient_record.special_prescription && infoList.special_prescription_patient_record.special_prescription.name) || '特色方' }} - - - 剂量 - {{ infoList.special_prescription_patient_record.dose_count }} 剂 - - - - - - - - - - - 导入 - - - - 健康信息 @@ -485,6 +485,9 @@ export default { if (this.apiOk(res)) { this.$toast('已接诊'); this.getList() + if (infoList.special_prescription_patient_record) { + return; + } setTimeout(() => { let url = `/subPackages/sub_workbench/prescription_v2/index?register_id=${e}`; if (pid) url += `&patient_id=${pid}`;