This commit is contained in:
Your Name
2026-05-26 11:23:43 +08:00
parent 9af5c5be63
commit 5b233fb0ab
2 changed files with 186 additions and 34 deletions
@@ -931,31 +931,75 @@
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="用量">
<template v-if="detailPrescription.dosage_amount">
{{ detailPrescription.dosage_amount }}{{ detailPrescription.dosage_unit || 'g' }}
<template v-if="detailPrescription.prescription_type === '浓缩水丸'">
· {{ Number(detailPrescription.dosage_bag_count) > 0 ? Number(detailPrescription.dosage_bag_count) : 1 }}
</template>
<span v-if="detailPrescription.prescription_type === '饮片' && detailPrescription.need_decoction !== null" class="ml-2 text-gray-500">
({{ detailPrescription.need_decoction ? '代煎' : '不代煎' }})
</span>
</template>
<template v-else></template>
<div class="flex flex-col gap-1 text-sm leading-relaxed">
<div>
<span v-if="detailHasAuxHerbs" class="text-gray-500 mr-1">主方</span>
<template v-if="detailPrescription.dosage_amount">
{{ detailPrescription.dosage_amount }}{{ detailPrescription.dosage_unit || 'g' }}
<template v-if="detailPrescription.prescription_type === '浓缩水丸'">
· {{ Number(detailPrescription.dosage_bag_count) > 0 ? Number(detailPrescription.dosage_bag_count) : 1 }}
</template>
<span v-if="detailPrescription.prescription_type === '饮片' && detailPrescription.need_decoction !== null" class="ml-2 text-gray-500">
({{ detailPrescription.need_decoction ? '代煎' : '不代煎' }})
</span>
</template>
<template v-else></template>
</div>
<div v-if="detailHasAuxHerbs && detailAuxUsage">
<span class="text-gray-500 mr-1">辅方</span>
<template v-if="detailAuxUsage.dosage_amount != null && detailAuxUsage.dosage_amount !== 0">
{{ detailAuxUsage.dosage_amount }}{{ detailPrescription.dosage_unit || 'g' }}
<template v-if="detailPrescription.prescription_type === '浓缩水丸'">
· {{ Number(detailAuxUsage.dosage_bag_count) > 0 ? Number(detailAuxUsage.dosage_bag_count) : 1 }}
</template>
<span v-if="detailPrescription.prescription_type === '饮片'" class="ml-2 text-gray-500">
({{ detailAuxUsage.need_decoction ? '代煎' : '不代煎' }})
</span>
</template>
<template v-else></template>
</div>
</div>
</el-descriptions-item>
<el-descriptions-item label="服用方式">
<div class="flex flex-col gap-1.5 text-sm leading-relaxed">
<div>
<span class="text-gray-500">每天次数</span>
{{ detailPrescription.times_per_day ? detailPrescription.times_per_day + ' 次' : '—' }}
</div>
<div>
<span class="text-gray-500">处方开立</span>
{{
detailPrescription.usage_days != null && detailPrescription.usage_days !== ''
? detailPrescription.usage_days + ' 天'
: '—'
}}
</div>
<template v-if="detailHasAuxHerbs">
<div>
<span class="text-gray-500 mr-1">主方</span>
每天
{{ detailPrescription.times_per_day ? detailPrescription.times_per_day + ' 次' : '— 次' }}
· 处方开立
{{
detailPrescription.usage_days != null && detailPrescription.usage_days !== ''
? detailPrescription.usage_days + ' 天'
: '—'
}}
</div>
<div v-if="detailAuxUsage">
<span class="text-gray-500 mr-1">辅方</span>
每天
{{ detailAuxUsage.times_per_day ? detailAuxUsage.times_per_day + ' 次' : '— 次' }}
· 处方开立
{{
detailAuxUsage.usage_days != null && Number(detailAuxUsage.usage_days) > 0
? detailAuxUsage.usage_days + ' 天'
: '— 天'
}}
</div>
</template>
<template v-else>
<div>
<span class="text-gray-500">每天次数</span>
{{ detailPrescription.times_per_day ? detailPrescription.times_per_day + ' 次' : '—' }}
</div>
<div>
<span class="text-gray-500">处方开立</span>
{{
detailPrescription.usage_days != null && detailPrescription.usage_days !== ''
? detailPrescription.usage_days + ' 天'
: '—'
}}
</div>
</template>
<div>
<span class="text-gray-500">订单设置</span>
{{
@@ -2426,9 +2470,9 @@
</div>
<div class="rx-text">
<p v-if="prescriptionTabType === 'internal'">服法{{ rxUsageText }}</p>
<p v-if="prescriptionTabType === 'internal' || rxAuxUsageText">主服法{{ rxUsageText }}</p>
<p v-else>服法{{ rxUsageText }}</p>
<p v-if="prescriptionTabType === 'internal' && rxAuxUsageText">服法{{ rxAuxUsageText }}</p>
<p v-if="rxAuxUsageText">辅服法{{ rxAuxUsageText }}</p>
<p v-if="rxAdviceText">医嘱{{ rxAdviceText }}</p>
<p v-if="rxRemarkText">备注{{ rxRemarkText }}</p>
<p v-if="rxPharmacyRemarkText" class="rx-text-warn">
@@ -3856,6 +3900,20 @@ const detailLinkedAppointmentChannelText = computed(() => {
const detailRxHerbs = computed(() => normalizeSlipHerbs(detailPrescription.value?.herbs))
/** 详情:是否含辅方药材(用于决定是否展示辅方用量 / 用法) */
const detailHasAuxHerbs = computed(() => {
const herbs = detailPrescription.value?.herbs
if (!Array.isArray(herbs)) return false
return herbs.some((h: any) => normalizeSlipFormulaType(h?.formula_type) === '辅方')
})
/** 详情:辅方用法(aux_usage JSON 经规范化后的对象,与处方类型一致) */
const detailAuxUsage = computed(() => {
const rx = detailPrescription.value as any
if (!rx) return null
return normalizeSlipAuxUsageForm(rx.aux_usage, rx.prescription_type || '浓缩水丸')
})
/** false=无权限;true/缺省兼容旧接口(旧版未下发该字段时仍展示药材) */
const detailHerbsVisible = computed(() => detailData.value?.prescription_detail_herbs_visible !== false)
@@ -5571,6 +5629,22 @@ const slipPillGrams = computed(() => {
return days * times * doseG * bags
})
/** 辅方出丸克数:仅含辅方药材且为浓缩水丸时计算;公式同主方,用 aux_usage 字段 */
const slipAuxPillGrams = computed(() => {
const d = prescriptionViewData.value as any
if (!d || (d.prescription_type || '浓缩水丸') !== '浓缩水丸') return null
if (!slipAuxHerbs.value.length) return null
const aux = normalizeSlipAuxUsageForm(d.aux_usage, d.prescription_type || '浓缩水丸')
/** 辅方疗程优先用业务订单 medication_days(与主方共享一次配药周期),缺省回退辅方 usage_days */
const days = Number(d.medication_days ?? aux.usage_days)
const times = Number(aux.times_per_day)
const doseG = Number(aux.dosage_amount)
const bags = Number(aux.dosage_bag_count) > 0 ? Number(aux.dosage_bag_count) : 1
if (!Number.isFinite(days) || !Number.isFinite(times) || !Number.isFinite(doseG)) return null
if (days <= 0 || times <= 0 || doseG <= 0) return null
return days * times * doseG * bags
})
/* ============================================================
* A4 处方笺药房联相关计算 consumer/prescription/index.vue 保持一致
* ============================================================ */
@@ -5684,10 +5758,14 @@ const rxAuxUsageText = computed(() => {
)
})
/** 出丸:优先用 slipPillGrams(每袋用量×袋数×每天次数×服用天数),否则按药材总量×剂数 */
/** 出丸:优先用 slipPillGrams / slipAuxPillGrams(含辅方时相加),否则按药材总量×剂数 */
const rxOutPelletGrams = computed(() => {
const pill = slipPillGrams.value
if (typeof pill === 'number' && isFinite(pill) && pill > 0) return formatNum(pill)
const main = slipPillGrams.value
const aux = slipAuxPillGrams.value
const mainNum = typeof main === 'number' && isFinite(main) && main > 0 ? main : 0
const auxNum = typeof aux === 'number' && isFinite(aux) && aux > 0 ? aux : 0
const sum = mainNum + auxNum
if (sum > 0) return formatNum(sum)
const v = prescriptionViewData.value as any
if (!v) return ''
const explicit = v.out_pellet || v.total_weight
@@ -5723,7 +5801,17 @@ const rxPharmacyRemarkText = computed(() => {
const rxOutPelletText = computed(() => {
const out = rxOutPelletGrams.value
return out ? `${out}` : ''
if (!out) return ''
/** 含辅方时附带「主方 X克 + 辅方 Y克」明细,便于药房核对 */
const main = slipPillGrams.value
const aux = slipAuxPillGrams.value
if (
typeof main === 'number' && isFinite(main) && main > 0 &&
typeof aux === 'number' && isFinite(aux) && aux > 0
) {
return `${out}克(主方 ${formatNum(main)}克 + 辅方 ${formatNum(aux)}克)`
}
return `${out}`
})
function formatNum(n: number): string {