feat(pl): expose openBlank on slip print dialogs
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
dfa033da02
commit
4de82c0805
3 files changed
+88
-18
No files matched your search
@@ -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">
|
||||
@@ -64,6 +69,7 @@ import {
|
||||
DELIVERY_SLIP_DOC_MAX_WIDTH,
|
||||
DELIVERY_SLIP_PRINT_CSS,
|
||||
prepareDeliverySlipPdfGridCells,
|
||||
renderBlankDeliverySlipHtml,
|
||||
replaceDeliverySlipPlaceholders,
|
||||
restoreDeliverySlipPlaceholders,
|
||||
setupDeliverySlipEditorTypeCheckboxes,
|
||||
@@ -76,6 +82,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)
|
||||
@@ -137,6 +144,16 @@ async function buildSlipRenderContext(plan: Plan): Promise<DeliverySlipRenderCon
|
||||
}
|
||||
}
|
||||
|
||||
function openBlank() {
|
||||
currentPlanId.value = ''
|
||||
currentPlan.value = null
|
||||
isBlankMode.value = true
|
||||
isPreviewMode.value = false
|
||||
showRedSeal.value = false
|
||||
slipContent.value = renderBlankDeliverySlipHtml()
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
async function open(planIdOrIds: string | string[]) {
|
||||
const ids = normalizePlanIds(planIdOrIds)
|
||||
if (!ids.length) {
|
||||
@@ -144,6 +161,7 @@ async function open(planIdOrIds: string | string[]) {
|
||||
return
|
||||
}
|
||||
currentPlanId.value = ids[0]
|
||||
isBlankMode.value = false
|
||||
isPreviewMode.value = false
|
||||
showRedSeal.value = true
|
||||
try {
|
||||
@@ -186,6 +204,7 @@ function handleClosed() {
|
||||
slipContent.value = ''
|
||||
currentPlanId.value = ''
|
||||
currentPlan.value = null
|
||||
isBlankMode.value = false
|
||||
isPreviewMode.value = false
|
||||
showRedSeal.value = true
|
||||
}
|
||||
@@ -267,7 +286,7 @@ function handlePrint() {
|
||||
}
|
||||
|
||||
async function handleGeneratePdf() {
|
||||
if (!currentPlan.value) {
|
||||
if (!isBlankMode.value && !currentPlan.value) {
|
||||
ElMessage.error('计划信息不存在')
|
||||
return
|
||||
}
|
||||
@@ -275,7 +294,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)
|
||||
@@ -333,8 +352,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)
|
||||
@@ -344,7 +367,7 @@ async function handleGeneratePdf() {
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
defineExpose({ open, openBlank })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@@ -29,7 +29,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">
|
||||
@@ -63,6 +68,7 @@ import {
|
||||
INBOUND_SLIP_DOC_MAX_WIDTH,
|
||||
INBOUND_SLIP_PRINT_CSS,
|
||||
prepareInboundSlipPdfGridCells,
|
||||
renderBlankInboundSlipHtml,
|
||||
replaceInboundSlipPlaceholders,
|
||||
restoreInboundSlipPlaceholders,
|
||||
type InboundSlipRenderContext
|
||||
@@ -74,6 +80,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)
|
||||
@@ -135,6 +142,16 @@ async function buildSlipRenderContext(plan: Plan): Promise<InboundSlipRenderCont
|
||||
}
|
||||
}
|
||||
|
||||
function openBlank() {
|
||||
currentPlanId.value = ''
|
||||
currentPlan.value = null
|
||||
isBlankMode.value = true
|
||||
isPreviewMode.value = false
|
||||
showRedSeal.value = true
|
||||
slipContent.value = renderBlankInboundSlipHtml()
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
async function open(planIdOrIds: string | string[]) {
|
||||
const ids = normalizePlanIds(planIdOrIds)
|
||||
if (!ids.length) {
|
||||
@@ -142,6 +159,7 @@ async function open(planIdOrIds: string | string[]) {
|
||||
return
|
||||
}
|
||||
currentPlanId.value = ids[0]
|
||||
isBlankMode.value = false
|
||||
isPreviewMode.value = false
|
||||
showRedSeal.value = true
|
||||
try {
|
||||
@@ -181,6 +199,7 @@ function handleClosed() {
|
||||
slipContent.value = ''
|
||||
currentPlanId.value = ''
|
||||
currentPlan.value = null
|
||||
isBlankMode.value = false
|
||||
isPreviewMode.value = false
|
||||
showRedSeal.value = true
|
||||
}
|
||||
@@ -262,7 +281,7 @@ function handlePrint() {
|
||||
}
|
||||
|
||||
async function handleGeneratePdf() {
|
||||
if (!currentPlan.value) {
|
||||
if (!isBlankMode.value && !currentPlan.value) {
|
||||
ElMessage.error('计划信息不存在')
|
||||
return
|
||||
}
|
||||
@@ -270,7 +289,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)
|
||||
@@ -328,8 +347,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)
|
||||
@@ -339,7 +362,7 @@ async function handleGeneratePdf() {
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
defineExpose({ open, openBlank })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in new issue
Block a user