1
This commit is contained in:
parent
b7826027b9
commit
2fbe0c2f8e
@ -30,15 +30,6 @@
|
||||
|
||||
<div class="print-preview-main">
|
||||
<div class="print-settings-bar">
|
||||
<el-select
|
||||
v-if="!hideBusinessTypeSelect"
|
||||
v-model="printSettings.businessType"
|
||||
placeholder="请选择业务类型"
|
||||
size="small"
|
||||
@change="handleBusinessTypeChange"
|
||||
>
|
||||
<el-option v-for="item in businessTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<el-select v-model="printSettings.station" placeholder="请选择打印台" size="small" @change="handleStationChange">
|
||||
<el-option v-for="item in stationOptions" :key="item.id" :label="item.name" :value="item.computer_id" />
|
||||
</el-select>
|
||||
@ -154,15 +145,13 @@ const props = withDefaults(defineProps<{
|
||||
dialogTitle?: string
|
||||
queueNoField?: string
|
||||
documentLabel?: string
|
||||
hideBusinessTypeSelect?: boolean
|
||||
fetchPrintData?: (row: RowItem, index: number) => Promise<any>
|
||||
}>(), {
|
||||
selectionRows: () => [],
|
||||
businessType: 'RECEIPT',
|
||||
dialogTitle: '批量打印收货单',
|
||||
queueNoField: 'receiving_number',
|
||||
documentLabel: '单据',
|
||||
hideBusinessTypeSelect: false
|
||||
documentLabel: '单据'
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
@ -193,13 +182,6 @@ const stationOptions = ref<any[]>([])
|
||||
const printerOptions = ref<any[]>([])
|
||||
const templateOptions = ref<any[]>([])
|
||||
const printerLoading = ref(false)
|
||||
const businessTypeOptions = [
|
||||
{ label: '收货单 (RECEIPT)', value: 'RECEIPT' },
|
||||
{ label: '库存单 (STOCK)', value: 'STOCK' },
|
||||
{ label: '出库单 (OUTBOUND)', value: 'OUTBOUND' },
|
||||
{ label: '拣货单 (PICKING)', value: 'PICKING' }
|
||||
]
|
||||
|
||||
const barcodeImg = {
|
||||
props: ['text'],
|
||||
setup(innerProps: any) {
|
||||
@ -380,7 +362,9 @@ function getPreviewValue(item: any): string {
|
||||
}
|
||||
}
|
||||
|
||||
// 回退到模板预设内容
|
||||
// 有 field_code 但无数据时显示空,不回退到占位文字
|
||||
if (item.field_code) return ''
|
||||
// 无 field_code 的自定义元素(如固定文字、图片)显示 content
|
||||
return item.content || ''
|
||||
}
|
||||
|
||||
@ -578,12 +562,7 @@ function resolveBusinessType() {
|
||||
}
|
||||
|
||||
function isSupportedBusinessType(value: string) {
|
||||
return ['STOCK', 'OUTBOUND', 'RECEIPT', 'PICKING'].includes(value)
|
||||
}
|
||||
|
||||
async function handleBusinessTypeChange() {
|
||||
printSettings.template = ''
|
||||
await loadTemplatesByBusinessType()
|
||||
return ['STOCK', 'OUTBOUND', 'RECEIPT', 'PICKING', 'ENTRY_ORDER'].includes(value)
|
||||
}
|
||||
|
||||
function isApiSuccess(res: any) {
|
||||
@ -726,9 +705,37 @@ function browserPrint() {
|
||||
</html>
|
||||
`)
|
||||
printWindow.document.close()
|
||||
printWindow.focus()
|
||||
printWindow.print()
|
||||
printWindow.close()
|
||||
|
||||
// 等所有图片(二维码/条码)加载完成后再打印
|
||||
const images = printWindow.document.querySelectorAll('img')
|
||||
if (images.length > 0) {
|
||||
let loaded = 0
|
||||
const onLoad = () => {
|
||||
loaded++
|
||||
if (loaded >= images.length) {
|
||||
printWindow.focus()
|
||||
printWindow.print()
|
||||
printWindow.close()
|
||||
}
|
||||
}
|
||||
images.forEach((img) => {
|
||||
if ((img as HTMLImageElement).complete) {
|
||||
loaded++
|
||||
} else {
|
||||
img.addEventListener('load', onLoad)
|
||||
}
|
||||
img.addEventListener('error', onLoad)
|
||||
})
|
||||
if (loaded >= images.length) {
|
||||
printWindow.focus()
|
||||
printWindow.print()
|
||||
printWindow.close()
|
||||
}
|
||||
} else {
|
||||
printWindow.focus()
|
||||
printWindow.print()
|
||||
printWindow.close()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
<el-button size="small" @click="handleImport">导入</el-button>
|
||||
<el-button size="small" @click="openColumnConfigPanel">字段设置</el-button>
|
||||
<el-button size="small" @click="toggleDetailVisible">{{ detailVisible ? '隐藏详情' : '显示详情' }}</el-button>
|
||||
<el-button size="small" type="warning" :disabled="!hasSelection" @click="handleOpenPrintDialog">打印入库单</el-button>
|
||||
<!-- <el-button
|
||||
size="small"
|
||||
:disabled="!selectedEntryId"
|
||||
@ -305,6 +306,18 @@
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 打印对话框 -->
|
||||
<BatchReceivingPrintDialog
|
||||
v-model="printDialogVisible"
|
||||
:selection-rows="selectionRows"
|
||||
business-type="ENTRY_ORDER"
|
||||
dialog-title="打印入库单"
|
||||
:queue-no-field="'entry_order_code'"
|
||||
document-label="入库单"
|
||||
:fetch-print-data="fetchEntryPrintData"
|
||||
:business-type-options="[{ label: '入库单 (ENTRY_ORDER)', value: 'ENTRY_ORDER' }]"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -343,6 +356,7 @@ import BindReceivingToEntryDialog from './component/BindReceivingToEntryDialog.v
|
||||
import DirectInboundLogs from './component/DirectInboundLogs.vue'
|
||||
import EntryBindingRelations from './component/EntryBindingRelations.vue'
|
||||
import ExportModeDropdown from '@/components/ExportModeDropdown.vue'
|
||||
import BatchReceivingPrintDialog from '@/components/BatchReceivingPrintDialog.vue'
|
||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
|
||||
@ -446,6 +460,42 @@ const reviewSubmitting = ref(false)
|
||||
const reviewCompareLoading = ref(false)
|
||||
const reviewCompareRows = ref<any[]>([])
|
||||
|
||||
// 打印相关
|
||||
const printDialogVisible = ref(false)
|
||||
|
||||
async function handleOpenPrintDialog() {
|
||||
if (!selectionRows.value.length) {
|
||||
ElMessage.warning('请先选择要打印的入库单')
|
||||
return
|
||||
}
|
||||
printDialogVisible.value = true
|
||||
}
|
||||
|
||||
/** 获取单个入库单的打印数据(复用 entry.get 接口) */
|
||||
async function fetchEntryPrintData(row: any, _index: number): Promise<Record<string, unknown>> {
|
||||
const id = Number(row?.id)
|
||||
if (!id || !Number.isFinite(id)) {
|
||||
throw new Error('入库单ID无效')
|
||||
}
|
||||
const res = await entryApi.getEntryDetail({ id })
|
||||
if (res?.code !== 200 || !res.data?.entryOrder) {
|
||||
throw new Error(res?.message || '获取入库单详情失败')
|
||||
}
|
||||
const entryOrder = res.data.entryOrder as Record<string, unknown>
|
||||
const result: Record<string, unknown> = { ...entryOrder }
|
||||
// 表格渲染使用 details 字段,将 items 映射过去
|
||||
if (Array.isArray(entryOrder.items)) {
|
||||
result.details = (entryOrder.items as any[]).map((item: any, idx: number) => ({
|
||||
...item,
|
||||
// 条码:取 barcodes 数组第一条的 barcode
|
||||
barcode: item.barcode ?? item.barcodes?.[0]?.barcode ?? '',
|
||||
// 序号
|
||||
seq_no: idx + 1,
|
||||
}))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function openBindDialog(row: any) {
|
||||
if (!canBindEntryOrder(row?.order_status)) return
|
||||
bindTargetRow.value = row
|
||||
|
||||
@ -157,8 +157,8 @@
|
||||
:style="computeItemStyle(value, idx)" @mousedown.prevent="onItemMouseDown($event, value)"
|
||||
@click.stop="selectElement(value.id)">
|
||||
<template v-if="value.type == 'text'">
|
||||
<span v-if="value.field_code">{{ '{' + value.content + '}' }}</span>
|
||||
<span v-else>{{ value.content }}</span>
|
||||
<span v-if="value.field_code">{{ '{' + (value.content || value.title || value.field_code) + '}' }}</span>
|
||||
<span v-else>{{ value.content || value.title || '' }}</span>
|
||||
</template>
|
||||
<template v-else-if="value.type == 'image'">
|
||||
<img v-if="value.custom" :src="value.content" alt=""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user