提交
This commit is contained in:
1 parent
54b27a3f0e
commit
31be9bfd95
41 files changed
+8981
-5121
No files matched your search
@@ -51,6 +51,12 @@ interface Props {
|
||||
toolbar?: boolean;
|
||||
contractNo?: string; // 合同编号,用于提取供方编码
|
||||
supplierCode?: string; // 供应商编码,直接传入(优先级高于从contractNo提取)
|
||||
/** TinyMCE 编辑区 body 内边距,默认 20px;入库单等紧凑预览可传 0 */
|
||||
contentBodyPadding?: string;
|
||||
/** TinyMCE 表格单元格内边距,默认 10px;入库单等可传 4px */
|
||||
tableCellPadding?: string;
|
||||
/** 追加到 TinyMCE content_style(如入库单打印专用 CSS) */
|
||||
contentStyleExtra?: string;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
@@ -59,7 +65,10 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
height: 600,
|
||||
toolbar: true,
|
||||
contractNo: '',
|
||||
supplierCode: ''
|
||||
supplierCode: '',
|
||||
contentBodyPadding: '20px',
|
||||
tableCellPadding: '10px',
|
||||
contentStyleExtra: ''
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update:modelValue']);
|
||||
@@ -188,7 +197,7 @@ const editorInit = computed(() => {
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
padding: 20px;
|
||||
padding: ${props.contentBodyPadding};
|
||||
position: relative;
|
||||
min-height: 100vh;
|
||||
width: 100%;
|
||||
@@ -206,7 +215,7 @@ const editorInit = computed(() => {
|
||||
}
|
||||
table td, table th {
|
||||
border: 1px solid #ddd !important;
|
||||
padding: 10px !important;
|
||||
padding: ${props.tableCellPadding} !important;
|
||||
}
|
||||
table th {
|
||||
background-color: #f5f5f5 !important;
|
||||
@@ -250,6 +259,7 @@ const editorInit = computed(() => {
|
||||
position: absolute !important;
|
||||
z-index: 999 !important;
|
||||
}
|
||||
${props.contentStyleExtra || ''}
|
||||
`,
|
||||
|
||||
// 保留所有 HTML
|
||||
|
||||
@@ -126,8 +126,10 @@
|
||||
min-width="160"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="licensePlate" label="车牌号" min-width="110" align="center">
|
||||
<template #default="{ row }">{{ row.licensePlate || '—' }}</template>
|
||||
<el-table-column prop="licensePlate" label="车牌号" min-width="160" show-overflow-tooltip align="center">
|
||||
<template #default="{ row }">
|
||||
{{ formatPlVehiclePlateDisplay(row.licensePlate, row.trailerNo) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="driverName" label="司机" min-width="90" align="center">
|
||||
<template #default="{ row }">{{ row.driverName || '—' }}</template>
|
||||
@@ -178,6 +180,7 @@
|
||||
import { Check, Close } from '@element-plus/icons-vue'
|
||||
import { freightApi, type FreightSettlement } from '@/api/pl'
|
||||
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
|
||||
import { formatPlVehiclePlateDisplay } from '@/utils/pl-display'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
|
||||
const emit = defineEmits<{ success: [] }>()
|
||||
|
||||
@@ -100,8 +100,10 @@
|
||||
min-width="160"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="licensePlate" label="车牌号" min-width="110" align="center">
|
||||
<template #default="{ row }">{{ row.licensePlate || '—' }}</template>
|
||||
<el-table-column prop="licensePlate" label="车牌号" min-width="160" show-overflow-tooltip align="center">
|
||||
<template #default="{ row }">
|
||||
{{ formatPlVehiclePlateDisplay(row.licensePlate, row.trailerNo, vehicleTrailerLookup) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="driverName" label="司机" min-width="90" align="center">
|
||||
<template #default="{ row }">{{ row.driverName || '—' }}</template>
|
||||
@@ -244,11 +246,14 @@
|
||||
<el-table-column
|
||||
prop="licensePlate"
|
||||
label="车牌号"
|
||||
min-width="110"
|
||||
min-width="160"
|
||||
show-overflow-tooltip
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">{{ row.licensePlate || '—' }}</template>
|
||||
<template #default="{ row }">
|
||||
{{ formatPlVehiclePlateDisplay(row.licensePlate, row.trailerNo, vehicleTrailerLookup) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="driverName"
|
||||
@@ -376,10 +381,15 @@
|
||||
<el-table-column
|
||||
prop="licensePlate"
|
||||
label="车牌号"
|
||||
min-width="110"
|
||||
min-width="160"
|
||||
show-overflow-tooltip
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ formatPlVehiclePlateDisplay(row.licensePlate, undefined, vehicleTrailerLookup) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="transportCompany"
|
||||
label="运输公司"
|
||||
@@ -440,11 +450,15 @@
|
||||
import { Check, Close, Delete, Plus, RefreshLeft, Search } from '@element-plus/icons-vue'
|
||||
import {
|
||||
freightApi,
|
||||
vehicleApi,
|
||||
type FreightSettlement,
|
||||
type Transport,
|
||||
type UnsettledPlanItem
|
||||
type UnsettledPlanItem,
|
||||
type Vehicle
|
||||
} from '@/api/pl'
|
||||
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
|
||||
import { pickBxList } from '@/utils/http/bx'
|
||||
import { buildVehicleTrailerLookup, formatPlVehiclePlateDisplay } from '@/utils/pl-display'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
import { getPlanTypeLabel, getPlanTypeTagType, isEditableDraftSettlement } from '@/views/pl/freight/freight-status'
|
||||
@@ -456,6 +470,7 @@ type EditableTransport = Pick<
|
||||
| 'id'
|
||||
| 'transportNo'
|
||||
| 'licensePlate'
|
||||
| 'trailerNo'
|
||||
| 'driverName'
|
||||
| 'carrierName'
|
||||
| 'transportMedium'
|
||||
@@ -473,6 +488,8 @@ const attachmentRef = ref<InstanceType<typeof AttachmentUploadField>>()
|
||||
const invoiceAttachmentUrlsStr = ref('')
|
||||
const editableTransports = ref<EditableTransport[]>([])
|
||||
const removedTransports = ref<EditableTransport[]>([])
|
||||
const vehicleOptions = ref<Vehicle[]>([])
|
||||
const vehicleTrailerLookup = computed(() => buildVehicleTrailerLookup(vehicleOptions.value))
|
||||
|
||||
const addDialogVisible = ref(false)
|
||||
const addLoading = ref(false)
|
||||
@@ -529,6 +546,7 @@ function cloneTransportRows(rows: Transport[] = []): EditableTransport[] {
|
||||
id: row.id,
|
||||
transportNo: row.transportNo,
|
||||
licensePlate: row.licensePlate,
|
||||
trailerNo: row.trailerNo,
|
||||
driverName: row.driverName,
|
||||
carrierName: row.carrierName,
|
||||
transportMedium: row.transportMedium,
|
||||
@@ -552,12 +570,22 @@ function planToTransportRow(plan: UnsettledPlanItem): EditableTransport {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadVehicleOptions() {
|
||||
try {
|
||||
const res = await vehicleApi.list({ page: 1, pageSize: 500 })
|
||||
vehicleOptions.value = pickBxList(res)
|
||||
} catch {
|
||||
vehicleOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
async function open(id: string) {
|
||||
visible.value = true
|
||||
loading.value = true
|
||||
invoiceAttachmentUrlsStr.value = ''
|
||||
removedTransports.value = []
|
||||
try {
|
||||
await loadVehicleOptions()
|
||||
const res = await freightApi.get(id)
|
||||
settlement.value = (res.data ?? res) as FreightSettlement
|
||||
form.invoiceNo = settlement.value.invoiceNo || ''
|
||||
|
||||
@@ -93,8 +93,10 @@
|
||||
min-width="160"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="licensePlate" label="车牌号" min-width="110" align="center">
|
||||
<template #default="{ row }">{{ row.licensePlate || '—' }}</template>
|
||||
<el-table-column prop="licensePlate" label="车牌号" min-width="160" show-overflow-tooltip align="center">
|
||||
<template #default="{ row }">
|
||||
{{ formatPlVehiclePlateDisplay(row.licensePlate, row.trailerNo) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="driverName" label="司机" min-width="90" align="center">
|
||||
<template #default="{ row }">{{ row.driverName || '—' }}</template>
|
||||
@@ -199,6 +201,7 @@ import {
|
||||
getSettlementStatusTagType,
|
||||
mapApprovalFlowToNodes
|
||||
} from '@/views/pl/freight/freight-status'
|
||||
import { formatPlVehiclePlateDisplay } from '@/utils/pl-display'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
|
||||
|
||||
@@ -0,0 +1,324 @@
|
||||
<!-- 入库单打印:富文本预览/编辑 + 打印/PDF -->
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="isPreviewMode ? '预览入库单' : '编辑入库单'"
|
||||
width="1500px"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
class="dialog-form-layout pl-inbound-slip-print-dialog"
|
||||
modal-class="order-module-dialog-mask"
|
||||
:close-on-click-modal="false"
|
||||
@closed="handleClosed"
|
||||
>
|
||||
<TinyMceEditor
|
||||
v-model="slipContent"
|
||||
:height="editorHeight"
|
||||
:disabled="isPreviewMode"
|
||||
:toolbar="!isPreviewMode"
|
||||
content-body-padding="0"
|
||||
table-cell-padding="4px"
|
||||
:content-style-extra="INBOUND_SLIP_PRINT_CSS"
|
||||
/>
|
||||
<template #footer>
|
||||
<div class="inbound-slip-print-actions">
|
||||
<el-button class="btn-ghost" @click="visible = false">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
<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-icon><DocumentChecked /></el-icon>保存模板
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" @click="handlePrint">
|
||||
<el-icon><Printer /></el-icon>打印
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="pdfGenerating" @click="handleGeneratePdf">
|
||||
<el-icon><Download /></el-icon>生成 PDF
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Close, DocumentChecked, Download, Printer, View } from '@element-plus/icons-vue'
|
||||
import html2canvas from 'html2canvas'
|
||||
import jsPDF from 'jspdf'
|
||||
import { fetchProductDetail } from '@/api/crm/product'
|
||||
import { planApi, type Plan } from '@/api/pl'
|
||||
import TinyMceEditor from '@/components/TinyMceEditor/index.vue'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import {
|
||||
generateInboundSlipTemplate,
|
||||
INBOUND_SLIP_DOC_MAX_WIDTH,
|
||||
INBOUND_SLIP_PRINT_CSS,
|
||||
prepareInboundSlipPdfGridCells,
|
||||
replaceInboundSlipPlaceholders,
|
||||
restoreInboundSlipPlaceholders,
|
||||
type InboundSlipRenderContext
|
||||
} from '@/utils/pl-inbound-slip-template'
|
||||
|
||||
const visible = ref(false)
|
||||
const slipContent = ref('')
|
||||
const isPreviewMode = ref(false)
|
||||
const saveLoading = ref(false)
|
||||
const pdfGenerating = ref(false)
|
||||
const currentPlanId = ref('')
|
||||
const currentPlan = ref<Plan | null>(null)
|
||||
|
||||
const editorHeight = computed(() => {
|
||||
if (typeof window === 'undefined') return 780
|
||||
return Math.min(860, Math.max(720, window.innerHeight - 200))
|
||||
})
|
||||
|
||||
async function waitForImagesLoaded(container: HTMLElement) {
|
||||
const imgs = Array.from(container.querySelectorAll('img'))
|
||||
await Promise.all(
|
||||
imgs.map(
|
||||
(img) =>
|
||||
new Promise<void>((resolve) => {
|
||||
if (img.complete && img.naturalWidth > 0) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
img.onload = () => resolve()
|
||||
img.onerror = () => resolve()
|
||||
})
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
function getPdfCanvasScale() {
|
||||
const dpr = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1
|
||||
return Math.min(4, Math.max(3, dpr * 2))
|
||||
}
|
||||
|
||||
async function buildSlipRenderContext(plan: Plan): Promise<InboundSlipRenderContext> {
|
||||
const dictStore = useDictStore()
|
||||
await dictStore.loadAllDict()
|
||||
|
||||
const productIds = [...new Set((plan.products || []).map(item => String(item.productId || '').trim()).filter(Boolean))]
|
||||
const productCodeById: Record<string, string> = {}
|
||||
|
||||
await Promise.all(
|
||||
productIds.map(async (productId) => {
|
||||
try {
|
||||
const res = await fetchProductDetail({ id: productId })
|
||||
const data = (res as { data?: { productNo?: string }; productNo?: string }).data ?? res
|
||||
const productNo = String((data as { productNo?: string }).productNo || '').trim()
|
||||
if (productNo) {
|
||||
productCodeById[productId] = productNo
|
||||
}
|
||||
} catch {
|
||||
// 单个产品查询失败时保留计划明细中的冗余字段
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
productCodeById,
|
||||
getUnitLabel: (unitCode: string) => dictStore.getLabel('crm_product_unit', unitCode) || unitCode
|
||||
}
|
||||
}
|
||||
|
||||
async function open(planId: string) {
|
||||
currentPlanId.value = planId
|
||||
isPreviewMode.value = false
|
||||
try {
|
||||
ElMessage.info({ message: '正在生成入库单...', duration: 800 })
|
||||
const res = await planApi.get(planId)
|
||||
const plan = (res.data ?? res) as Plan
|
||||
currentPlan.value = plan
|
||||
|
||||
let htmlContent = ''
|
||||
try {
|
||||
const templateRes = await planApi.getInboundSlipTemplate(planId)
|
||||
const saved = (templateRes.data ?? templateRes) as string
|
||||
if (saved?.trim()) {
|
||||
htmlContent = saved
|
||||
} else {
|
||||
htmlContent = generateInboundSlipTemplate(plan)
|
||||
}
|
||||
} catch {
|
||||
htmlContent = generateInboundSlipTemplate(plan)
|
||||
}
|
||||
|
||||
const renderCtx = await buildSlipRenderContext(plan)
|
||||
slipContent.value = replaceInboundSlipPlaceholders(htmlContent, plan, renderCtx)
|
||||
visible.value = true
|
||||
} catch (error) {
|
||||
console.error('打开入库单打印失败', error)
|
||||
ElMessage.error('加载入库单失败')
|
||||
}
|
||||
}
|
||||
|
||||
function handleClosed() {
|
||||
slipContent.value = ''
|
||||
currentPlanId.value = ''
|
||||
currentPlan.value = null
|
||||
isPreviewMode.value = false
|
||||
}
|
||||
|
||||
async function refreshPlan() {
|
||||
if (!currentPlanId.value) return null
|
||||
const res = await planApi.get(currentPlanId.value)
|
||||
const plan = (res.data ?? res) as Plan
|
||||
currentPlan.value = plan
|
||||
return plan
|
||||
}
|
||||
|
||||
async function handleSaveTemplate() {
|
||||
if (!currentPlanId.value) {
|
||||
ElMessage.warning('无法获取计划ID')
|
||||
return
|
||||
}
|
||||
saveLoading.value = true
|
||||
try {
|
||||
const plan = (await refreshPlan()) || currentPlan.value
|
||||
if (!plan) throw new Error('计划数据无效')
|
||||
const finalTemplate = restoreInboundSlipPlaceholders(slipContent.value, plan)
|
||||
await planApi.saveInboundSlipTemplate(currentPlanId.value, finalTemplate)
|
||||
ElMessage.success('模板保存成功')
|
||||
} catch (error) {
|
||||
console.error('保存入库单模板失败', error)
|
||||
ElMessage.error('保存模板失败')
|
||||
} finally {
|
||||
saveLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handlePrint() {
|
||||
const printWindow = window.open('', '_blank')
|
||||
if (!printWindow) {
|
||||
ElMessage.error('无法打开打印窗口,请检查浏览器拦截设置')
|
||||
return
|
||||
}
|
||||
|
||||
printWindow.document.write(`
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>打印入库单</title>
|
||||
<style>
|
||||
body { margin: 0 auto; padding: 0; background: #fff; width: ${INBOUND_SLIP_DOC_MAX_WIDTH}; box-sizing: border-box; }
|
||||
${INBOUND_SLIP_PRINT_CSS}
|
||||
@media print {
|
||||
body { margin: 0; padding: 0; }
|
||||
img { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>${slipContent.value}</body>
|
||||
</html>
|
||||
`)
|
||||
printWindow.document.close()
|
||||
|
||||
setTimeout(() => {
|
||||
printWindow.focus()
|
||||
printWindow.print()
|
||||
}, 600)
|
||||
}
|
||||
|
||||
async function handleGeneratePdf() {
|
||||
if (!currentPlan.value) {
|
||||
ElMessage.error('计划信息不存在')
|
||||
return
|
||||
}
|
||||
|
||||
pdfGenerating.value = true
|
||||
try {
|
||||
let htmlContent = slipContent.value
|
||||
if (htmlContent.includes('{{')) {
|
||||
const plan = (await refreshPlan()) || currentPlan.value
|
||||
if (plan) {
|
||||
const renderCtx = await buildSlipRenderContext(plan)
|
||||
htmlContent = replaceInboundSlipPlaceholders(htmlContent, plan, renderCtx)
|
||||
}
|
||||
}
|
||||
|
||||
const tempDiv = document.createElement('div')
|
||||
tempDiv.style.cssText = `position:absolute;left:-9999px;top:0;width:${INBOUND_SLIP_DOC_MAX_WIDTH};background:#fff;padding:0;`
|
||||
tempDiv.innerHTML = htmlContent
|
||||
const styleEl = document.createElement('style')
|
||||
styleEl.textContent = INBOUND_SLIP_PRINT_CSS
|
||||
tempDiv.prepend(styleEl)
|
||||
document.body.appendChild(tempDiv)
|
||||
|
||||
await waitForImagesLoaded(tempDiv)
|
||||
await new Promise<void>((resolve) => {
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => resolve()))
|
||||
})
|
||||
|
||||
prepareInboundSlipPdfGridCells(tempDiv)
|
||||
await new Promise<void>((resolve) => {
|
||||
requestAnimationFrame(() => resolve())
|
||||
})
|
||||
|
||||
const canvas = await html2canvas(tempDiv, {
|
||||
scale: getPdfCanvasScale(),
|
||||
useCORS: true,
|
||||
allowTaint: true,
|
||||
backgroundColor: '#ffffff',
|
||||
onclone: (_doc, clone) => {
|
||||
prepareInboundSlipPdfGridCells(clone as HTMLElement)
|
||||
}
|
||||
})
|
||||
document.body.removeChild(tempDiv)
|
||||
|
||||
const imgWidth = 210
|
||||
const pageHeight = 297
|
||||
const imgHeight = (canvas.height * imgWidth) / canvas.width
|
||||
const pdf = new jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' })
|
||||
const imgData = canvas.toDataURL('image/png')
|
||||
|
||||
if (imgHeight <= pageHeight) {
|
||||
pdf.addImage(imgData, 'PNG', 0, 0, imgWidth, imgHeight)
|
||||
} else {
|
||||
let heightLeft = imgHeight
|
||||
let position = 0
|
||||
pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight)
|
||||
heightLeft -= pageHeight
|
||||
while (heightLeft > 0) {
|
||||
position = -(imgHeight - heightLeft)
|
||||
pdf.addPage()
|
||||
pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight)
|
||||
heightLeft -= pageHeight
|
||||
}
|
||||
}
|
||||
|
||||
const fileName = (currentPlan.value.planNo || '入库单').replace(/[/\\:*?"<>|]/g, '-')
|
||||
pdf.save(`${fileName}入库单.pdf`)
|
||||
ElMessage.success('PDF 生成成功')
|
||||
} catch (error) {
|
||||
console.error('生成 PDF 失败', error)
|
||||
ElMessage.error('生成 PDF 失败,请重试')
|
||||
} finally {
|
||||
pdfGenerating.value = false
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.inbound-slip-print-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
.el-dialog.pl-inbound-slip-print-dialog.dialog-form-layout {
|
||||
max-height: var(--dialog-max-height, calc(100vh - 32px));
|
||||
}
|
||||
|
||||
.el-dialog.pl-inbound-slip-print-dialog.dialog-form-layout .el-dialog__body {
|
||||
min-height: min(820px, calc(100vh - 150px));
|
||||
}
|
||||
</style>
|
||||
@@ -249,6 +249,8 @@
|
||||
:bundle="vehicleBundle"
|
||||
/>
|
||||
|
||||
<PlInboundSlipPrintDialog ref="inboundSlipPrintRef" />
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer pl-arrange-footer">
|
||||
<template v-if="arrangeSuccess">
|
||||
@@ -286,6 +288,12 @@
|
||||
>
|
||||
<el-icon><CopyDocument /></el-icon>复制磅单二维码
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="showInboundSlipPrint"
|
||||
@click="handlePrintInboundSlip"
|
||||
>
|
||||
<el-icon><Printer /></el-icon>入库单打印
|
||||
</el-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-button @click="innerVisible = false">
|
||||
@@ -301,7 +309,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Check, Close, CopyDocument } from '@element-plus/icons-vue'
|
||||
import { Check, Close, CopyDocument, Printer } from '@element-plus/icons-vue'
|
||||
import {
|
||||
carrierApi,
|
||||
planApi,
|
||||
@@ -316,6 +324,7 @@ import {
|
||||
type VehiclePersonnelRow
|
||||
} from '@/api/pl'
|
||||
import DbPoundSlipQrcodeDialog from '@/components/business/db/DbPoundSlipQrcodeDialog.vue'
|
||||
import PlInboundSlipPrintDialog from '@/components/business/pl-inbound-slip-print-dialog/index.vue'
|
||||
import PlAddressWithLibrary from '@/components/business/pl-address-with-library/index.vue'
|
||||
import PlVehicleSummaryStrip from '@/components/business/pl-vehicle-summary-strip/index.vue'
|
||||
import PlVehicleViewDialog from '@/components/business/pl-vehicle-view-dialog/index.vue'
|
||||
@@ -329,6 +338,7 @@ import { useDictStore } from '@/store/modules/dict'
|
||||
import { isTonProductUnit } from '@/utils/crm-product-display'
|
||||
import { formatDate } from '@/utils/format'
|
||||
import { pickBxData, pickBxList } from '@/utils/http/bx'
|
||||
import { canPrintInboundSlip } from '@/utils/pl-inbound-slip-template'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
|
||||
@@ -371,6 +381,7 @@ const {
|
||||
copyPoundSlipQrcode
|
||||
} = usePlPlanArrangeActions()
|
||||
const tabsRef = ref<InstanceType<typeof PlPlanViewTabs> | null>(null)
|
||||
const inboundSlipPrintRef = ref<InstanceType<typeof PlInboundSlipPrintDialog> | null>(null)
|
||||
const formRef = ref()
|
||||
const plan = ref<Partial<Plan>>({})
|
||||
const products = ref<PlanProduct[]>([])
|
||||
@@ -417,6 +428,9 @@ const dialogTitle = computed(() => {
|
||||
})
|
||||
|
||||
const isRearrange = computed(() => plan.value.transportStatus === 'arranged')
|
||||
const showInboundSlipPrint = computed(
|
||||
() => arrangeSuccess.value && canPrintInboundSlip(plan.value as Plan)
|
||||
)
|
||||
|
||||
function getUnitLabel(unit: string) {
|
||||
return dictStore.getLabel('crm_product_unit', unit) || unit
|
||||
@@ -819,6 +833,15 @@ async function handleSubmit() {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handlePrintInboundSlip() {
|
||||
const planId = plan.value.id
|
||||
if (!planId) {
|
||||
ElMessage.warning('计划信息无效')
|
||||
return
|
||||
}
|
||||
inboundSlipPrintRef.value?.open(planId)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in new issue
Block a user