处方作废不再受签署/审核/订单状态限制,作废后订单随重新开方自动关联;签署原文去掉辅方方名;出丸显示辅方克数;查看处方可下载 CA 原件或药房联/处方联

- 作废:药师签署、审核通过、已有业务订单后均可作废(仍需「作废」权限;已提交药房的订单须先远端取消)。
  作废时关联的待审核/履约中订单处方审核重置为待审核(履约中退回待审核,支付审核保留),
  同诊单重新开方后自动改关联到新处方并写订单日志;已发货/已完成订单按原处方留档。
  迁移 2026_11_30_prescription_order_reissue.sql 新增 reissue_from_prescription_id
- 签署 PDF 不再写入「辅方方名」
- 出丸:有辅方药材时显示「主方 X克,辅方 Y克」(管理后台与桌面端)
- 已开处方「查看处方」下载改为下拉:CA 签署处方 PDF、药房联 PDF、处方联 PDF(A4,按当前笺面样式)
- 重新构建管理后台

Co-Authored-By: Claude Opus 5 <[EMAIL]>
This commit is contained in:
Your Name
2026-11-30 10:45:08 +08:00
co-authored by Claude Opus 5
parent 0eeb572f0f
commit b55f30753c
396 changed files with 582 additions and 459 deletions
@@ -308,8 +308,29 @@ function computeOutPellet(data: Record<string, any>): string {
return formatNum(perDose * getDoseCount(data))
}
/** 辅方出丸 = 辅方服用天数 × 每日次数 × 每袋用量 × 每次袋数;仅浓缩水丸且确有辅方药材时计算。 */
function computeAuxOutPellet(data: Record<string, any>): string {
if ((data.prescription_type || '浓缩水丸') !== '浓缩水丸' || !getAuxHerbs(data).length) return ''
let raw = data.aux_usage
if (typeof raw === 'string') {
try {
raw = JSON.parse(raw)
} catch {
raw = null
}
}
const aux = normalizeAuxUsageForm(raw, '浓缩水丸')
const days = Number(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
return days > 0 && times > 0 && doseG > 0 ? formatNum(days * times * doseG * bags) : ''
}
export function rxOutPelletText(data: Record<string, any> | null | undefined): string {
if (!data) return ''
const out = computeOutPellet(data)
const aux = computeAuxOutPellet(data)
if (out && aux) return `主方 ${out}克,辅方 ${aux}克`
return out ? `${out}克` : ''
}
@@ -701,16 +701,16 @@
{{ requiresOriginalEsignPdf(savedPrescription.esign) ? '下载已签原始 PDF' : '下载PDF' }}
</el-button>
<el-tooltip
v-if="savedPrescription.void_status !== 1 && !approvedPreviewOnly"
:disabled="!hasPrescriptionOrderBlockVoid"
content="该处方已存在业务订单,无法作废,请前往已开处方里修改"
v-if="savedPrescription.void_status !== 1 && savedPrescription.can_void !== false"
:disabled="!hasLinkedPrescriptionOrder"
content="作废后,关联的业务订单会在同诊单重新开方时自动关联到新处方"
placement="top"
>
<span class="inline-block">
<el-button
v-perms="['tcm.prescription/void']"
type="danger"
plain
:disabled="hasPrescriptionOrderBlockVoid"
:loading="voiding"
@click="handleVoid"
>
@@ -1080,8 +1080,8 @@ const approvedPreviewOnly = computed(() => {
return Number(s.audit_status) === 1 && Number(s.void_status) !== 1
})
/** 已有关联业务订单(与列表 has_prescription_order 一致)则禁止作废 */
const hasPrescriptionOrderBlockVoid = computed(() => {
/** 已有关联业务订单(与列表 has_prescription_order 一致):作废时提示订单将随重新开方迁移 */
const hasLinkedPrescriptionOrder = computed(() => {
const s = savedPrescription.value
if (!s) return false
return Number(s.has_prescription_order) === 1
@@ -2165,12 +2165,10 @@ const formatVoidTime = (ts: number | null | undefined) => {
const handleVoid = async () => {
const id = savedPrescription.value?.id
if (!id) return
if (Number(savedPrescription.value?.has_prescription_order) === 1) {
feedback.msgWarning('该处方已存在业务订单,无法作废')
return
}
try {
await feedback.confirm('确定要作废该处方吗?作废后不可恢复。')
await feedback.confirm(Number(savedPrescription.value?.has_prescription_order) === 1
? '确定要作废该处方吗?作废后不可恢复;关联的业务订单将退回待审核,同诊单重新开方后自动关联到新处方。'
: '确定要作废该处方吗?作废后不可恢复。')
voiding.value = true
await prescriptionVoid({ id })
feedback.msgSuccess('作废成功')
+50 -29
View File
@@ -283,7 +283,7 @@
审核
</el-button>
<el-button
v-if="canVoidPendingPrescription(row)"
v-if="canVoidPrescription(row)"
v-perms="['tcm.prescription/void']"
type="danger"
link
@@ -440,16 +440,26 @@
@click="handleReissue(slipView)"
>重新开方</el-button>
<el-button v-if="!requiresOriginalEsignPdf(slipView?.esign)" :icon="Printer" size="small" @click="handlePrintSlip">打印</el-button>
<el-button
type="primary"
:icon="Download"
size="small"
:loading="downloadingSlip"
:disabled="viewDetailLoading || (requiresOriginalEsignPdf(slipView?.esign) && !slipView?.esign?.can_download)"
@click="handleDownloadSlip"
<el-dropdown
trigger="click"
:disabled="viewDetailLoading || downloadingSlip"
@command="handleDownloadSlip"
>
{{ requiresOriginalEsignPdf(slipView?.esign) ? '下载已签原始 PDF' : '下载 PDF (A4)' }}
</el-button>
<el-button type="primary" :icon="Download" size="small" :loading="downloadingSlip">
下载 PDF (A4)
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item
v-if="requiresOriginalEsignPdf(slipView?.esign)"
command="esign"
:disabled="!slipView?.esign?.can_download"
>CA 签署处方 PDF</el-dropdown-item>
<el-dropdown-item command="internal">药房联 PDF</el-dropdown-item>
<el-dropdown-item command="user">处方联 PDF</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
<!-- 状态提示(不进入打印区) -->
@@ -1750,7 +1760,7 @@ import PrescriptionSlip from '@/components/prescription-slip/index.vue'
import PrescriptionAuditLayout from '@/components/PrescriptionAuditLayout.vue'
import EsignPrescriptionPanel from '@/components/EsignPrescriptionPanel.vue'
import { usePrescriptionEsignConfig } from '@/hooks/usePrescriptionEsignConfig'
import { canApprovePrescriptionEsign, downloadPrescriptionPdfIfRequired, pendingPrescriptionReviewLabel, requiresOriginalEsignPdf, updatePrescriptionSlipEsign } from '@/utils/prescription-esign'
import { canApprovePrescriptionEsign, downloadOriginalEsignPdf, pendingPrescriptionReviewLabel, requiresOriginalEsignPdf, updatePrescriptionSlipEsign } from '@/utils/prescription-esign'
import type { PrescriptionEsignStatus } from '@/api/tcm'
import { prescriptionListSigningStatus } from './components/prescription-list-signing-status'
import { Search, Download, Printer, EditPen } from '@element-plus/icons-vue'
@@ -2859,18 +2869,25 @@ function handlePrintSlip() {
})
}
/* === 下载 PDF(A4) === */
async function handleDownloadSlip() {
if (downloadingSlip.value) return
downloadingSlip.value = true
try {
if (await downloadPrescriptionPdfIfRequired(Number(slipView.value?.id))) return
} catch (e: any) {
feedback.msgError(e?.message || '下载签署文件失败')
return
} finally {
downloadingSlip.value = false
}
/* === 下载 PDF(A4):CA 签署原件,或按当前笺面样式导出药房联 / 处方联 === */
async function handleDownloadSlip(command: 'esign' | 'internal' | 'user') {
if (downloadingSlip.value || !slipView.value) return
if (command === 'esign') {
downloadingSlip.value = true
try {
await downloadOriginalEsignPdf(Number(slipView.value.id))
} catch (e: any) {
feedback.msgError(e?.message || '下载签署文件失败')
} finally {
downloadingSlip.value = false
}
return
}
// 切到对应联次再截图,导出与页面一致的样式(含医师 / 药师签章)。
if (prescriptionTabType.value !== command) {
prescriptionTabType.value = command
await nextTick()
}
const node = getRxPaperEl()
if (!node) {
feedback.msgWarning('处方笺尚未渲染完成')
@@ -2957,7 +2974,8 @@ async function handleDownloadSlip() {
const name = (slipView.value as any)?.patient_name || '处方'
const id = (slipView.value as any)?.id || ''
const date = (slipView.value as any)?.prescription_date || ''
pdf.save(`处方-${name}${date ? '-' + date : ''}${id ? '-' + id : ''}.pdf`)
const copy = command === 'internal' ? '药房联' : '处方联'
pdf.save(`${copy}-${name}${date ? '-' + date : ''}${id ? '-' + id : ''}.pdf`)
} catch (e: any) {
console.error('下载处方 PDF 失败:', e)
feedback.msgError(e?.message || '下载失败,请重试')
@@ -3338,17 +3356,20 @@ type VoidablePrescriptionRow = Parameters<typeof isPendingPrescriptionAudit>[0]
can_review_prescription?: boolean
}
function canVoidPendingPrescription(row: VoidablePrescriptionRow) {
return isPendingPrescriptionAudit(row) && row.can_void === true
/** 作废不再限于待审核:签署、审核通过或已有业务订单后也可作废(以服务端 can_void 为准) */
function canVoidPrescription(row: VoidablePrescriptionRow) {
return Number(row.void_status) !== 1 && row.can_void === true
}
async function voidPendingPrescription(row: VoidablePrescriptionRow) {
const id = Number(row.id)
if (!Number.isSafeInteger(id) || id <= 0 || voidingPrescriptionId.value || !canVoidPendingPrescription(row)) return
if (!Number.isSafeInteger(id) || id <= 0 || voidingPrescriptionId.value || !canVoidPrescription(row)) return
voidingPrescriptionId.value = id
try {
await feedback.confirm('确定作废这张处方吗?作废后可重新开方。')
await prescriptionVoid({ id, pending_only: true })
await feedback.confirm(Number((row as { has_prescription_order?: number }).has_prescription_order) === 1
? '确定作废这张处方吗?关联的业务订单将退回待审核,同诊单重新开方后自动关联到新处方。'
: '确定作废这张处方吗?作废后可重新开方。')
await prescriptionVoid({ id })
row.void_status = 1
row.can_void = false
row.can_submit_for_review = false