Просмотр исходного кода

feat(web-admin): allow multi planIds in transport slip print dialogs

Co-authored-by: Cursor <cursoragent@cursor.com>
zlwu 3 месяцев назад
Родитель
Сommit
25978401e1

+ 20 - 6
web-admin/src/components/business/pl-delivery-slip-print-dialog/index.vue

@@ -69,6 +69,7 @@ import {
   setupDeliverySlipEditorTypeCheckboxes,
   type DeliverySlipRenderContext
 } from '@/utils/pl-delivery-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'
 
@@ -136,19 +137,32 @@ async function buildSlipRenderContext(plan: Plan): Promise<DeliverySlipRenderCon
   }
 }
 
-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
 
     let htmlContent = ''
     try {
-      const templateRes = await planApi.getDeliverySlipTemplate(planId)
+      const templateRes = await planApi.getDeliverySlipTemplate(ids[0])
       const saved = (templateRes.data ?? templateRes) as string
       if (saved?.trim()) {
         htmlContent = saved

+ 17 - 6
web-admin/src/components/business/pl-inbound-slip-print-dialog/index.vue

@@ -67,6 +67,7 @@ import {
   restoreInboundSlipPlaceholders,
   type InboundSlipRenderContext
 } from '@/utils/pl-inbound-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'
 
@@ -134,19 +135,29 @@ async function buildSlipRenderContext(plan: Plan): Promise<InboundSlipRenderCont
   }
 }
 
-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
 
     let htmlContent = ''
     try {
-      const templateRes = await planApi.getInboundSlipTemplate(planId)
+      const templateRes = await planApi.getInboundSlipTemplate(ids[0])
       const saved = (templateRes.data ?? templateRes) as string
       if (saved?.trim()) {
         htmlContent = saved

+ 18 - 7
web-admin/src/components/business/pl-subpack-slip-print-dialog/index.vue

@@ -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