|
|
@@ -30,7 +30,12 @@
|
|
|
<el-button class="btn-ghost" @click="isPreviewMode = !isPreviewMode">
|
|
|
<el-icon><View /></el-icon>{{ isPreviewMode ? '编辑模式' : '预览模式' }}
|
|
|
</el-button>
|
|
|
- <el-button class="btn-ghost" :loading="saveLoading" @click="handleSaveTemplate">
|
|
|
+ <el-button
|
|
|
+ v-if="!isBlankMode"
|
|
|
+ class="btn-ghost"
|
|
|
+ :loading="saveLoading"
|
|
|
+ @click="handleSaveTemplate"
|
|
|
+ >
|
|
|
<el-icon><DocumentChecked /></el-icon>保存模板
|
|
|
</el-button>
|
|
|
<el-button class="btn-ghost" @click="toggleRedSeal">
|
|
|
@@ -65,6 +70,7 @@ import {
|
|
|
SUBPACK_SLIP_DOC_MAX_WIDTH,
|
|
|
SUBPACK_SLIP_PRINT_CSS,
|
|
|
prepareSubpackSlipPdfGridCells,
|
|
|
+ renderBlankSubpackSlipHtml,
|
|
|
replaceSubpackSlipPlaceholders,
|
|
|
restoreSubpackSlipPlaceholders,
|
|
|
setupSubpackSlipEditorCheckboxes,
|
|
|
@@ -77,6 +83,7 @@ import { getPlSlipPdfCanvasScale } from '@/utils/pl-slip-pdf-render'
|
|
|
const visible = ref(false)
|
|
|
const slipContent = ref('')
|
|
|
const isPreviewMode = ref(false)
|
|
|
+const isBlankMode = ref(false)
|
|
|
/** 打印弹窗内红章显隐(仅本次弹窗有效,打开时默认显示) */
|
|
|
const showRedSeal = ref(true)
|
|
|
const saveLoading = ref(false)
|
|
|
@@ -128,6 +135,17 @@ async function buildSlipRenderContext(plan: Plan): Promise<SubpackSlipRenderCont
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function openBlank() {
|
|
|
+ currentPlanId.value = ''
|
|
|
+ currentPlan.value = null
|
|
|
+ currentSubpackSlipNo.value = ''
|
|
|
+ isBlankMode.value = true
|
|
|
+ isPreviewMode.value = false
|
|
|
+ showRedSeal.value = false
|
|
|
+ slipContent.value = renderBlankSubpackSlipHtml()
|
|
|
+ visible.value = true
|
|
|
+}
|
|
|
+
|
|
|
async function open(planIdOrIds: string | string[]) {
|
|
|
const ids = normalizePlanIds(planIdOrIds)
|
|
|
if (!ids.length) {
|
|
|
@@ -135,6 +153,7 @@ async function open(planIdOrIds: string | string[]) {
|
|
|
return
|
|
|
}
|
|
|
currentPlanId.value = ids[0]
|
|
|
+ isBlankMode.value = false
|
|
|
isPreviewMode.value = false
|
|
|
showRedSeal.value = true
|
|
|
try {
|
|
|
@@ -180,6 +199,7 @@ function handleClosed() {
|
|
|
currentPlanId.value = ''
|
|
|
currentPlan.value = null
|
|
|
currentSubpackSlipNo.value = ''
|
|
|
+ isBlankMode.value = false
|
|
|
isPreviewMode.value = false
|
|
|
showRedSeal.value = true
|
|
|
}
|
|
|
@@ -263,7 +283,7 @@ function handlePrint() {
|
|
|
}
|
|
|
|
|
|
async function handleGeneratePdf() {
|
|
|
- if (!currentPlan.value) {
|
|
|
+ if (!isBlankMode.value && !currentPlan.value) {
|
|
|
ElMessage.error('计划信息不存在')
|
|
|
return
|
|
|
}
|
|
|
@@ -271,7 +291,7 @@ async function handleGeneratePdf() {
|
|
|
pdfGenerating.value = true
|
|
|
try {
|
|
|
let htmlContent = slipContent.value
|
|
|
- if (htmlContent.includes('{{')) {
|
|
|
+ if (!isBlankMode.value && htmlContent.includes('{{')) {
|
|
|
const plan = (await refreshPlan()) || currentPlan.value
|
|
|
if (plan) {
|
|
|
const renderCtx = await buildSlipRenderContext(plan)
|
|
|
@@ -329,8 +349,12 @@ async function handleGeneratePdf() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const fileName = (currentPlan.value.planNo || '分装单').replace(/[/\\:*?"<>|]/g, '-')
|
|
|
- pdf.save(`${fileName}分装单.pdf`)
|
|
|
+ if (isBlankMode.value) {
|
|
|
+ pdf.save('空白分装单.pdf')
|
|
|
+ } else {
|
|
|
+ const fileName = (currentPlan.value?.planNo || '分装单').replace(/[/\\:*?"<>|]/g, '-')
|
|
|
+ pdf.save(`${fileName}分装单.pdf`)
|
|
|
+ }
|
|
|
ElMessage.success('PDF 生成成功')
|
|
|
} catch (error) {
|
|
|
console.error('生成 PDF 失败', error)
|
|
|
@@ -340,7 +364,7 @@ async function handleGeneratePdf() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-defineExpose({ open })
|
|
|
+defineExpose({ open, openBlank })
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|