|
|
@@ -70,6 +70,7 @@ import {
|
|
|
setupSubpackSlipEditorCheckboxes,
|
|
|
type SubpackSlipRenderContext
|
|
|
} from '@/utils/pl-subpack-slip-template'
|
|
|
+import { buildBatchPrintPlanView, normalizePlanIds } from '@/utils/pl-batch-print'
|
|
|
import { injectSlipSealImages, stripSlipSealImages } from '@/utils/pl-slip-red-seal'
|
|
|
import { getPlSlipPdfCanvasScale } from '@/utils/pl-slip-pdf-render'
|
|
|
|
|
|
@@ -127,22 +128,32 @@ async function buildSlipRenderContext(plan: Plan): Promise<SubpackSlipRenderCont
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-async function open(planId: string) {
|
|
|
- currentPlanId.value = planId
|
|
|
+async function open(planIdOrIds: string | string[]) {
|
|
|
+ const ids = normalizePlanIds(planIdOrIds)
|
|
|
+ if (!ids.length) {
|
|
|
+ ElMessage.warning('无法获取计划ID')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ currentPlanId.value = ids[0]
|
|
|
isPreviewMode.value = false
|
|
|
showRedSeal.value = true
|
|
|
try {
|
|
|
- ElMessage.info({ message: '正在生成分装单...', duration: 800 })
|
|
|
- const res = await planApi.get(planId)
|
|
|
- const plan = (res.data ?? res) as Plan
|
|
|
+ ElMessage.info({ message: ids.length > 1 ? '正在生成合打分装单...' : '正在生成分装单...', duration: 800 })
|
|
|
+ const plans = await Promise.all(
|
|
|
+ ids.map(async (id) => {
|
|
|
+ const res = await planApi.get(id)
|
|
|
+ return (res.data ?? res) as Plan
|
|
|
+ })
|
|
|
+ )
|
|
|
+ const plan = ids.length === 1 ? plans[0] : buildBatchPrintPlanView(plans)
|
|
|
currentPlan.value = plan
|
|
|
|
|
|
- const slipNoRes = await planApi.ensureSubpackSlipNo(planId)
|
|
|
+ const slipNoRes = await planApi.ensureSubpackSlipNo(ids[0])
|
|
|
currentSubpackSlipNo.value = String((slipNoRes as { data?: string }).data ?? slipNoRes ?? '').trim()
|
|
|
|
|
|
let htmlContent = ''
|
|
|
try {
|
|
|
- const templateRes = await planApi.getSubpackSlipTemplate(planId)
|
|
|
+ const templateRes = await planApi.getSubpackSlipTemplate(ids[0])
|
|
|
const saved = (templateRes.data ?? templateRes) as string
|
|
|
if (saved?.trim()) {
|
|
|
htmlContent = saved
|