1672 lines
58 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="storage-receiving-container" :style="{ height: containerHeight }">
<scan-box ref="scanBox" width="320px" :tree-props="{ children: 'children', label: 'label' }" :auto-submit="false"
:initial-conditions="initialConditions" :preset-tree="presetTree" :available-fields="availableFieldsRef"
@condition-change="handleConditionChange" @reset="handleConditionReset" @condition-clear="handleConditionClear"
@submit="handleSubmit" />
<div class="main-content">
<div class="toolbar">
<div class="toolbar-left">
<el-button size="small" type="primary" @click="loadData">刷新</el-button>
<!-- <el-button size="small" @click="handleCreateReceiving">新建收货单</el-button> -->
<!-- <el-button type="success" size="small" icon="el-icon-delete" @click="confirmcomplete" title="入库单入库"
:disabled="!hasSelection" class="toolbar-btn">
入库单入库
</el-button> -->
<el-button type="primary" size="small" icon="el-icon-delete" @click="confirmcomplete" title="一键入库"
:disabled="!hasSelection" class="toolbar-btn">
完成收货
</el-button>
<el-button size="small" :disabled="!hasSelection" @click="confirmBatchCancel">批量作废</el-button>
<el-button type="warning" size="small" :disabled="!hasSelection" @click="handleRejectReceiving">批量驳回</el-button>
<el-button type="primary" size="small" :disabled="!hasSelection" :loading="reviewLoading" @click="handleReviewReceiving">批量审核</el-button>
<el-button type="warning" size="small" :disabled="!hasSelection" @click="handleRejectReceiving">批量驳回</el-button>
<el-button type="primary" size="small" :disabled="!hasSelection" :loading="reviewLoading" @click="handleReviewReceiving">批量审核</el-button>
<el-button type="warning" size="small" :disabled="!hasSelection" @click="handleRejectReceiving">批量驳回</el-button>
<el-button type="primary" size="small" :disabled="!hasSelection" :loading="reviewLoading" @click="handleReviewReceiving">批量审核</el-button>
<el-button type="success" size="small" :disabled="selectionRows.length !== 1" :loading="quickPutawayLoading" @click="handleQuickPutaway">快捷入库</el-button>
<el-button type="info" size="small" icon="el-icon-printer" @click="handleOpenPrintDialog" title="打印收货单"
:disabled="!hasSelection" class="toolbar-btn">
打印收货单
</el-button>
<el-button size="small" :loading="exportLoading" @click="handleExport">导出</el-button>
<el-button size="small" @click="openColumnConfigPanel">字段设置</el-button>
<el-button size="small" @click="toggleDetailVisible">{{ detailVisible ? '隐藏详情' : '显示详情' }}</el-button>
</div>
<!-- <div class="toolbar-right">
<el-input size="small" placeholder="搜索收货单号" v-model="quickSearch" style="width:220px" @keyup.enter.native="onQuickSearch" />
</div> -->
</div>
<div class="split-stack" ref="splitStackRef">
<div class="upper-wrapper" :style="detailVisible ? upperPaneStyle : upperPaneFullStyle">
<upper-table ref="upperTable" title="收货单列表" :enable-column-config="true" table-id="storage-receiving-list" :data="list" :columns="columns" :table-size="tableSize"
:pagination="pagination" :show-index="true" :show-actions="true" :show-selection="true" :loading="loading"
:queryTime="queryTime" @current-change="handleRowClick" @page-change="handlePageChange"
@page-size-change="handlePageSizeChange" @sort-change="handleSortChange" @refresh="loadData"
@selection-change="onSelectionChange">
<template #column-status="{ row }">
<el-tag v-if="row.status" :type="statusConfig[row.status as keyof typeof statusConfig]?.tagType || 'info'"
size="small">
{{ statusConfig[row.status as keyof typeof statusConfig]?.text || row.status }}
</el-tag>
</template>
<template #column-detail_status="{ row }">
<el-tag v-if="row.detail_status"
:type="detailStatusConfig[row.detail_status as keyof typeof detailStatusConfig]?.tagType || 'info'"
size="small">
{{ detailStatusConfig[row.detail_status as keyof typeof detailStatusConfig]?.text || row.detail_status }}
</el-tag>
</template>
<template #column-storage_status="{ row }">
<el-tag v-if="row.storage_status"
:type="storageStatusConfig[row.storage_status as keyof typeof storageStatusConfig]?.tagType || 'info'"
size="small">
{{ storageStatusConfig[row.storage_status as keyof typeof storageStatusConfig]?.text || row.storage_status
}}
</el-tag>
</template>
<template #column-is_review="{ row }">
<el-tag :type="row.is_review === 1 || row.is_review === true ? 'success' : 'info'" size="small">
{{ row.is_review === 1 || row.is_review === true ? '已审核' : '未审核' }}
</el-tag>
</template>
<template #column-delivery_method="{ row }">
<el-tag v-if="row.delivery_method"
:type="deliveryMethodConfig[row.delivery_method as keyof typeof deliveryMethodConfig]?.tagType || 'info'"
size="small">
{{ deliveryMethodConfig[row.delivery_method as keyof typeof deliveryMethodConfig]?.text ||
row.delivery_method }}
</el-tag>
</template>
<template #column-loading_method="{ row }">
<el-tag v-if="row.loading_method"
:type="loadingMethodConfig[row.loading_method as keyof typeof loadingMethodConfig]?.tagType || 'info'"
size="small">
{{ loadingMethodConfig[row.loading_method as keyof typeof loadingMethodConfig]?.text || row.loading_method
}}
</el-tag>
</template>
<template #empty>
<div class="empty-tip">暂无收货单</div>
</template>
</upper-table>
</div>
<template v-if="detailVisible">
<div
class="pane-resizer"
title="拖动调整列表与详情区域高度"
@mousedown="beginSplitDrag"
/>
<div class="lower-level" v-if="selectedReceivingId" :class="tableSize" :style="lowerPaneStyle">
<div class="detail-header">
<el-tabs v-model="activeTab" class="detail-tab">
<el-tab-pane label="收货明细" name="details" />
<el-tab-pane label="商品明细" name="product" />
<el-tab-pane label="入库记录" name="storage" />
<el-tab-pane label="操作日志" name="logs" />
</el-tabs>
</div>
<div class="detail-container">
<KeepAlive>
<component
:is="activeComponent"
class="receiving-detail-pane"
:id="selectedReceivingId"
:row="selectedRow"
:product-data="productData"
:product-total="productTotal"
:loading="productLoading"
@refresh-product="loadProductData"
@page-change="handleProductPageChange"
@page-size-change="handleProductSizeChange"
/>
</KeepAlive>
</div>
</div>
<div class="no-selection" v-else :style="lowerPaneStyle">
<div class="empty-tip">
<p>请从上方列表中选择一项查看详情</p>
</div>
</div>
</template>
</div>
</div>
<!-- 打印对话框 -->
<el-dialog v-model="printDialogVisible" title="批量打印收货单" width="1135px" custom-class="print-dialog">
<div class="print-dialog-layout">
<!-- 左侧待打印列表 -->
<div class="print-batch-list">
<div class="list-title">打印队列 ({{ selectionRows.length }})</div>
<div v-for="(row, index) in selectionRows" :key="row.id" class="batch-item"
:class="{ active: currentPrintIndex === index }" @click="switchPrintItem(index)">
<span class="item-index">{{ index + 1 }}</span>
<span class="item-number">{{ row.receiving_number }}</span>
<el-tag size="small"
:type="printStatusMap[row.id] === 'done' ? 'success' : printStatusMap[row.id] === 'error' ? 'danger' : 'info'">
{{ printStatusMap[row.id] === 'done' ? '已打印' : printStatusMap[row.id] === 'error' ? '失败' : '待打印' }}
</el-tag>
</div>
</div>
<!-- 右侧:打印设置 + 模板预览 -->
<div class="print-preview-main">
<!-- 打印设置工具栏 -->
<div class="print-settings-bar">
<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.id" />
</el-select>
<el-select v-model="printSettings.printer" placeholder="请选择打印机" size="small" :loading="printerLoading">
<el-option v-for="item in printerOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<el-select v-model="printSettings.template" placeholder="请选择打印模板" size="small">
<el-option v-for="item in templateOptions" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</div>
<!-- 模板画布预览 -->
<div class="print-canvas-area">
<div v-if="previewInfo.width && previewInfo.height" class="preview-page"
:style="{ width: previewInfo.width + 'mm', height: previewInfo.height + 'mm', position: 'relative' }">
<div v-for="(item, idx) in previewObjects" :key="item.id" :style="computePreviewItemStyle(item, idx)">
<template v-if="item.type === 'text'">
<span>{{ getPreviewValue(item) }}</span>
</template>
<template v-else-if="item.type === 'barcode'">
<barcode-img :text="getPreviewValue(item) || '0123456789'" />
</template>
<template v-else-if="item.type === 'qrcode'">
<img
:src="'https://ye4s.wms.gztbyc.com/qrcode/build?text=' + encodeURIComponent(getPreviewValue(item) || '')"
alt="" style="width: 100%; height: 100%; object-fit: contain;" />
</template>
<template v-else-if="item.type === 'image'">
<img :src="item.content" alt="" style="width: 100%; height: 100%; object-fit: fill;" />
</template>
<template v-else-if="item.type === 'table'">
<table style="border: 1px solid #000; border-collapse: collapse;" border="1" cellspacing="0"
cellpadding="0" width="100%" height="auto">
<thead>
<tr>
<td v-for="c in item.rows" :key="c.id"
:style="{ width: c.width + 'mm', fontSize: '3mm', textAlign: 'center', border: '1px solid #000', height: (item.headerHeight || 4) + 'mm' }">
{{ c.title }}</td>
</tr>
</thead>
<tbody>
<!-- 如果有 details 数据则遍历显示,否则显示一行占位 -->
<tr
v-for="(detailItem, dIdx) in (printForm.details && printForm.details.length ? printForm.details : [printForm])"
:key="dIdx">
<td v-for="c in item.rows" :key="c.id + '_v'"
:style="{ fontSize: '3mm', textAlign: 'center', border: '1px solid #000', height: (item.rowHeight || 4) + 'mm' }">
{{ detailItem[c.field_code] || '' }}
</td>
</tr>
</tbody>
</table>
</template>
<template v-else-if="item.type === 'shape'">
<div style="width: 100%; height: 100%;"></div>
</template>
</div>
</div>
<div v-else class="preview-empty">
<el-empty description="请在上方选择打印模板" :image-size="60" />
</div>
</div>
</div>
</div>
<template #footer>
<div class="dialog-footer">
<span class="progress-tip">进度: {{ completedPrintCount }} / {{ selectionRows.length }}</span>
<div>
<el-button @click="printDialogVisible = false">关闭</el-button>
<el-button type="primary" :loading="printing" @click="doPrint">
{{ currentPrintIndex < selectionRows.length - 1 ? '打印并切换下一个' : '打印当前单据' }} </el-button>
</div>
</div>
</template>
</el-dialog>
<!-- 新建收货单对话框 -->
<el-dialog v-model="createDialogVisible" title="新建收货单" width="600px" align-center
@closed="handleCreateDialogClosed">
<el-form :model="createForm" label-width="100px" size="small">
<el-row :gutter="20">
<el-col v-for="field in addReceivingFieldsRef" :key="field.prop" :span="field.type === 'textarea' ? 24 : 12">
<el-form-item>
<template #label>
<span>{{ field.label }}</span>
<span v-if="['delivery_method','loading_method'].includes(field.prop)" style="color: #f56c6c; margin-left:6px">*</span>
</template>
<el-select v-if="field.type === 'select'" v-model="createForm[field.prop]"
:placeholder="'请选择' + field.label" style="width: 100%" :filterable="field.filterable">
<el-option v-for="opt in field.options" :key="opt.value" :label="opt.label" :value="opt.value" />
</el-select>
<el-input v-else-if="field.type === 'textarea'" v-model="createForm[field.prop]" type="textarea" :rows="3"
:placeholder="'请输入' + field.label" />
<el-input v-else v-model="createForm[field.prop]" :placeholder="'请输入' + field.label" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<el-button size="small" @click="createDialogVisible = false">取消</el-button>
<el-button size="small" type="primary" :loading="createLoading" @click="submitCreateReceiving">确定</el-button>
</template>
</el-dialog>
<!-- 驳回收货单对话框 -->
<el-dialog v-model="rejectDialogVisible" title="批量驳回收货单" width="480px" align-center>
<el-form label-width="80px" size="small">
<el-form-item label="驳回理由">
<el-input
v-model="rejectRemark"
type="textarea"
:rows="3"
placeholder="请输入驳回理由(选填,将覆盖原备注)"
/>
</el-form-item>
</el-form>
<template #footer>
<el-button size="small" @click="rejectDialogVisible = false">取消</el-button>
<el-button size="small" type="warning" :loading="rejectLoading" @click="submitRejectReceiving">确认驳回</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, computed, watch, h } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import Details from './component/DetailsPanel.vue'
import StorageComp from './component/Storage.vue'
import Logs from './component/Logs.vue'
import Product from './component/Product.vue'
import * as indexApi from '@/api/index/index'
import * as receivingApi from '@/api/storage_receiving/receiving'
import { useSettingsStore } from '@/stores/modules/settings'
import {
receivingColumns,
availableFields,
formatReceivingData,
statusConfig,
detailStatusConfig,
storageStatusConfig,
deliveryMethodConfig,
loadingMethodConfig,
printFormConfig,
addReceivingFields
} from './receiving-config'
import * as templateApi from '@/api/setting.printTemplate/printTemplate'
import * as stationApi from '@/api/print/print'
import JsBarcode from 'jsbarcode'
import * as XLSX from 'xlsx'
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
const scanBox = ref<any>(null)
const route = useRoute()
// 用于将初始条件传入 ScanBox(用于根据 URL 参数填充)
const initialConditions = ref<any>(null)
const upperTable = ref<any>(null)
const presetTree = ref<any[]>([])
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(availableFields)))
const addReceivingFieldsRef = reactive(JSON.parse(JSON.stringify(addReceivingFields)))
const settingsStore = useSettingsStore()
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
const containerHeight = computed(() => shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)')
const {
splitStackRef,
beginSplitDrag,
lowerPaneStyle,
upperPaneStyle,
} = useVerticalSplitPane({ defaultLowerPercent: 40 })
const upperPaneFullStyle = computed(() => ({
flex: '1 1 auto',
minHeight: '0',
overflow: 'hidden',
}))
const activeTab = ref('details')
const list = ref<any[]>([])
const loading = ref(false)
const exportLoading = ref(false)
const quickPutawayLoading = ref(false)
const queryTime = ref(0)
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
const tableSize = ref('small')
const columns = ref(receivingColumns)
const selectionRows = ref<any[]>([])
const hasSelection = ref(false)
const selectedReceivingId = ref<number | string | null>(null)
const detailVisible = ref(true)
const quickSearch = ref('')
const currentSort = reactive({ prop: '', order: '' })
const currentCondition = ref<any>(null)
// 保存原始条件(可能包含 operator 等信息)
const currentConditionRaw = ref<any>(null)
const componentMap: Record<string, any> = {
details: Details,
storage: StorageComp,
logs: Logs,
product: Product
}
const activeComponent = computed(() => componentMap[activeTab.value] || componentMap.details)
const selectedRow = computed(() => {
return list.value.find((i: any) => i.id === selectedReceivingId.value) || null
})
function toggleDetailVisible() {
detailVisible.value = !detailVisible.value
}
onMounted(() => {
// 先加载筛选相关数据(例如 store options、presetTree),保证 ScanBox options 可用
loadFilterData()
// 如果 URL 带有 id 参数,则构建初始筛选条件并应用
const idParam = route.query.id || route.query.receiving_number || route.query.q
const id = Array.isArray(idParam) ? idParam[0] : idParam
if (id) {
// 设置 ScanBox 的初始条件以在 UI 中显示
initialConditions.value = {
type: 'custom',
conditions: {
receiving_number: { value: String(id), operator: 'eq', field: 'receiving_number', type: 'text' }
}
}
// 直接使用包含 operator 的完整条件触发搜索(避免丢失 operator)
handleConditionChange(initialConditions.value)
} else {
// 无 URL 参数时正常加载列表
loadData()
}
})
async function loadData() {
if (loading.value) return
loading.value = true
const start = Date.now()
try {
// 直接使用 handleConditionChange 保存的完整条件(含 operator),避免丢失操作符信息
const where = currentCondition.value || {}
console.log('当前筛选条件:', where)
const params: any = {
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
where,
order: currentSort.prop ? { [currentSort.prop]: currentSort.order === 'ascending' ? 'ASC' : 'DESC' } : undefined
}
if (quickSearch.value) {
params.where.receiving_number = { operator: 'like', value: quickSearch.value, type: 'text' }
}
const res: any = await receivingApi.getReceivingList(params)
if (res && res.code === 200) {
console.log('API 返回数据:', res.data.list)
list.value = formatReceivingData(res.data.list || [])
pagination.currentPage = res.data.pagination?.currentPage || pagination.currentPage
pagination.pageSize = res.data.pagination?.pageSize || pagination.pageSize
pagination.total = res.data.pagination?.total || (res.data.pagination?.total || 0)
} else {
ElMessage.error(res?.message || '加载失败')
}
} catch (e) {
console.error(e)
ElMessage.error('加载收货单失败')
} finally {
loading.value = false
queryTime.value = Date.now() - start
}
}
async function loadFilterData() {
try {
const [storesRes, presetRes]: any = await Promise.all([indexApi.loadStores({ type: 'receiving' }), indexApi.fastWhereTree('receiving')])
if (storesRes && storesRes.code === 200) {
const stores = storesRes.stores || []
const f = availableFieldsRef.find((i: any) => i.value === 'store_id')
if (f) f.options = stores
const af = addReceivingFieldsRef.find((i: any) => i.prop === 'store_id')
if (af) af.options = stores
}
if (presetRes && presetRes.code === 200) {
console.log('筛选配置', presetRes)
presetTree.value = presetRes.presetTree || []
}
} catch (e) {
console.error('加载筛选配置失败', e)
}
}
function normalizeToWhere(condition: any) {
if (!condition) return {}
// 如果是字符串或简单值,直接返回为收货单号查询(默认模糊)
if (typeof condition === 'string' || typeof condition === 'number') {
return { receiving_number: { operator: 'like', value: condition, type: 'text' } }
}
// 获取字段定义的辅助函数
const getFieldConfig = (key: string) => {
return availableFields.find(f => f.value === key)
}
// 映射类型到规范格式
const mapType = (type: string, value: any) => {
if (type === 'daterange' || Array.isArray(value)) return 'daterange'
if (type === 'number' || typeof value === 'number') return 'number'
if (type === 'boolean' || typeof value === 'boolean') return 'boolean'
return 'text'
}
const processConditionValue = (k: string, c: any) => {
const config = getFieldConfig(k)
const fieldType = config?.type || 'text'
// 如果 c 本身已经是规范的对象结构 { value, operator, type }
if (c && typeof c === 'object' && !Array.isArray(c)) {
const op = c.operator || (fieldType === 'daterange' ? 'between' : 'eq')
const type = c.type || mapType(fieldType, c.value)
// isnull / isnotnull 无需值,直接传递
if (['isnull', 'isnotnull'].includes(op)) {
return { operator: op, value: null, type }
}
const val = c.value !== undefined ? c.value : c
// 空值跳过(非 isnull/isnotnull)
if (val === null || val === undefined || val === '' || (Array.isArray(val) && val.length === 0)) return null
// daterange 强制 type=daterange, operator=between
if (fieldType === 'daterange' || type === 'daterange') {
return { operator: 'between', value: val, type: 'daterange' }
}
return { operator: op, value: val, type }
}
// 简单空值跳过
if (c === null || c === undefined || c === '' || (Array.isArray(c) && c.length === 0)) return null
// 处理简单值
const simpleOp = fieldType === 'daterange' ? 'between' : 'eq'
const simpleType = mapType(fieldType, c)
return { operator: simpleOp, value: c, type: simpleType }
}
// 如果来自 ScanBox 的 preset(包含 conditions)
if (condition.conditions && typeof condition.conditions === 'object') {
const where: any = {}
Object.keys(condition.conditions).forEach(k => {
const result = processConditionValue(k, condition.conditions[k])
if (result) where[k] = result
})
return where
}
// 普通自定义条件对象,键 -> { value, operator, ... } 或 键 -> 简单值
if (typeof condition === 'object') {
const where: any = {}
Object.keys(condition).forEach(k => {
const result = processConditionValue(k, condition[k])
if (result) where[k] = result
})
return where
}
return {}
}
function handleConditionChange(condition: any) {
// 保留原始条件(含 operator)以备需要
currentConditionRaw.value = condition
// 将复杂条件规范化为后端期望的 where 映射
currentCondition.value = normalizeToWhere(condition)
pagination.currentPage = 1
loadData()
}
function handleSortChange({ prop, order }: any) {
currentSort.prop = prop
currentSort.order = order
pagination.currentPage = 1
loadData()
}
function handleSubmit() {
// condition-change 在 submit 之前已触发并更新了 currentCondition,直接加载即可
pagination.currentPage = 1
loadData()
}
const handleConditionClear = () => {
currentCondition.value = null // 清空已保存的条件
pagination.currentPage = 1
loadData()
}
function handleConditionReset() {
currentCondition.value = null // 清空已保存的条件
pagination.currentPage = 1
// 如果 ScanBox 提供 reset/clear 方法,调用以清空筛选条件
if (scanBox.value?.reset) {
scanBox.value.reset()
} else if (scanBox.value?.clear) {
scanBox.value.clear()
}
loadData()
}
function onSelectionChange(rows: any[]) {
selectionRows.value = rows || []
hasSelection.value = selectionRows.value.length > 0
}
const productData = ref<any[]>([])
const productLoading = ref(false)
const productTotal = ref(0)
const productPagination = reactive({ currentPage: 1, pageSize: 20 })
// 用于取消过期请求的版本号,解决快速切换行时的竞态条件
const productLoadVersion = ref(0)
async function handleRowClick(row: any) {
selectedReceivingId.value = row?.id || null
// 切换行时立即清空明细数据,并递增版本号使旧请求结果失效
productData.value = []
productTotal.value = 0
if (!selectedReceivingId.value) {
return
}
// 重置分页
productPagination.currentPage = 1
loadProductData()
}
async function loadProductData() {
const version = ++productLoadVersion.value
productLoading.value = true
try {
const params = {
id: selectedReceivingId.value,
pagination: {
page: productPagination.currentPage,
pageSize: productPagination.pageSize
}
}
const res: any = await receivingApi.getReceivingDetail(params)
// 版本不匹配说明用户已切换到其他行,丢弃此响应避免覆盖新数据
if (version !== productLoadVersion.value) return
if (res && res.code === 200 && res.data) {
// 兼容多种返回结构:res.data.receiving.details / res.data.list / res.data.details
const receivingData = res.data.receiving || {}
const details = Array.isArray(receivingData.details)
? receivingData.details
: Array.isArray(res.data.list)
? res.data.list
: Array.isArray(res.data.details)
? res.data.details
: []
const total = receivingData.pagination?.total ?? res.data.pagination?.total ?? details.length
productData.value = details
productTotal.value = total
} else {
productData.value = []
productTotal.value = 0
}
} catch (e) {
if (version !== productLoadVersion.value) return
console.error('获取收货单详情失败', e)
productData.value = []
productTotal.value = 0
} finally {
if (version === productLoadVersion.value) {
productLoading.value = false
}
}
}
function handleProductPageChange(page: number) {
productPagination.currentPage = page
loadProductData()
}
function handleProductSizeChange(size: number) {
productPagination.pageSize = size
productPagination.currentPage = 1
loadProductData()
}
function handlePageChange(page: number) {
pagination.currentPage = page
loadData()
}
function handlePageSizeChange(size: number) {
pagination.pageSize = size
pagination.currentPage = 1
loadData()
}
function onQuickSearch() {
pagination.currentPage = 1
loadData()
}
function openColumnConfigPanel() {
upperTable.value?.openColumnConfig?.()
}
function handleCreateReceiving() {
// 重置表单并打开对话框
Object.keys(createForm).forEach(key => createForm[key] = '')
createDialogVisible.value = true
}
// 新建收货单相关
const createDialogVisible = ref(false)
const createLoading = ref(false)
const createForm = reactive<any>({
store_id: '',
delivery_method: '',
loading_method: '',
license_plate: '',
tracking_number: '',
total_boxes: '',
total_pallets: '',
remark: ''
})
function handleCreateDialogClosed() {
Object.keys(createForm).forEach(key => createForm[key] = '')
}
async function submitCreateReceiving() {
// 仅校验指定的必填字段:到货方式与装卸方式
const requiredProps = ['delivery_method', 'loading_method']
for (const prop of requiredProps) {
const val = createForm[prop]
const field = addReceivingFieldsRef.find((f: any) => f.prop === prop)
const label = field ? field.label : prop
if (val === null || val === undefined || val === '') {
ElMessage.warning(`请填写${label}`)
return
}
}
createLoading.value = true
try {
const res: any = await receivingApi.createReceiving(createForm)
console.log('新建收货单返回结果:', res)
if (res && res.code === 200) {
ElMessage.success('新建收货单成功')
createDialogVisible.value = false
loadData()
} else {
ElMessage.error(res?.message || '新建失败')
}
} catch (e) {
console.error('新建收货单出错:', e)
ElMessage.error('新建收货单失败')
} finally {
createLoading.value = false
}
}
// 打印相关
const printDialogVisible = ref(false)
const printing = ref(false)
const currentPrintIndex = ref(0)
const printStatusMap = ref<Record<string, string>>({})
const printForm = reactive<any>({})
const printSettings = reactive({ station: '' as string | number, printer: '', template: '' })
const stationOptions = ref<any[]>([])
const printerOptions = ref<any[]>([])
const templateOptions = ref<any[]>([])
const printerLoading = ref(false)
// --- 模板预览辅助组件(条码) ---
const barcodeImg = {
props: ['text'],
setup(props: any) {
const src = ref('')
const renderBarcode = (val: string) => {
if (!val) { src.value = ''; return }
const canvas = document.createElement('canvas')
try {
JsBarcode(canvas, val, { format: 'CODE128', width: 2, height: 40, displayValue: false, margin: 0 })
src.value = canvas.toDataURL()
} catch (e) { src.value = '' }
}
watch(() => props.text, (val: string) => renderBarcode(val), { immediate: true })
return () => h('img', { src: src.value, style: { display: 'block', width: '100%', height: '100%', objectFit: 'fill' } })
}
}
// 当前选中模板的画布尺寸
const previewInfo = computed(() => {
const t = templateOptions.value.find((t: any) => t.id === printSettings.template)
if (!t) return { width: 0, height: 0 }
return { width: t.page_width || 0, height: t.page_height || 0 }
})
// 当前选中模板的元素列表
const previewObjects = computed(() => {
const t = templateOptions.value.find((t: any) => t.id === printSettings.template)
if (!t || !Array.isArray(t.template_content)) return []
return t.template_content
})
// 获取元素的实际展示值(用 printForm 中的值替换 field_code 占位符)
function getPreviewValue(item: any): string {
if (item.field_code && printForm[item.field_code] !== undefined && printForm[item.field_code] !== '') {
return String(printForm[item.field_code])
}
return item.content || ''
}
// 计算预览元素的绝对定位样式(与 TemplateEditor 保持一致)
function computePreviewItemStyle(value: any, idx: string | number): any {
const idxNum = Number(idx)
const base: any = {
position: 'absolute',
left: value.left + 'mm',
top: value.top + 'mm',
width: value.width + 'mm',
height: value.height + 'mm',
zIndex: idxNum + 1,
textAlign: value.textAlign || 'left',
lineHeight: (value.lineHeight || 6) + 'mm',
transform: `rotate(${(value.rotate || 0) * 90}deg)`,
transformOrigin: 'center center',
overflow: 'hidden',
}
if (value.type === 'text') {
Object.assign(base, {
fontSize: (value.fontSize || 8) + 'pt',
lineHeight: (value.lineHeight || 6) + 'mm',
fontWeight: value.bold ? 'bold' : 'normal',
fontStyle: value.italic ? 'italic' : 'normal',
textDecoration: value.underline ? 'underline' : 'none',
whiteSpace: value.autoWrap ? 'pre-wrap' : 'nowrap',
writingMode: value.direction === 'vertical' ? 'vertical-rl' : 'horizontal-tb'
})
}
if (value.type === 'table') {
base.width = 'auto'
base.height = 'auto'
}
if (value.type === 'shape') {
if (value.shapeType === 'line') {
base.border = 'none'
base.borderTop = `${value.lineWeight || 1}pt ${value.lineStyle || 'solid'} #000`
base.backgroundColor = 'transparent'
base.height = 'auto'
} else if (value.shapeType === 'vertical-line') {
base.border = 'none'
base.borderLeft = `${value.lineWeight || 1}pt ${value.lineStyle || 'solid'} #000`
base.backgroundColor = 'transparent'
base.width = 'auto'
} else if (value.shapeType === 'box') {
base.border = `${value.lineWeight || 1}pt ${value.lineStyle || 'solid'} #000`
base.backgroundColor = 'transparent'
}
}
return base
}
const completedPrintCount = computed(() => {
return Object.values(printStatusMap.value).filter(s => s === 'done').length
})
async function handleOpenPrintDialog() {
if (!selectionRows.value.length) {
ElMessage.warning('请先选择要打印的收货单')
return
}
// 校验收货状态,只有“已完成”的才能打印
const invalidRows = selectionRows.value.filter(row => row.status !== 'completed')
if (invalidRows.length > 0) {
ElMessage.warning(`只有“已完成”状态的单据才能打印。当前选中包含 ${invalidRows.length} 个非已完成单据。`)
return
}
// 重置打印状态
currentPrintIndex.value = 0
printStatusMap.value = {}
selectionRows.value.forEach(row => {
printStatusMap.value[row.id] = 'pending'
})
// 加载第一项数据
await loadPrintFormData(0)
// 加载打印台和模板
loadPrintOptions()
printDialogVisible.value = true
}
async function switchPrintItem(index: number) {
if (printing.value) return
currentPrintIndex.value = index
await loadPrintFormData(index)
}
async function loadPrintFormData(index: number) {
const mainRow = selectionRows.value[index]
if (!mainRow) return
// 1. 从主表填充
const formData: any = {}
printFormConfig.forEach(group => {
group.fields.forEach((field: any) => {
const val = mainRow[field.prop] || ''
// 如果是选择器类型,尝试从 options 中提取 label(翻译后的文本)
if (field.type === 'select' && field.options) {
const opt = field.options.find((o: any) => o.value === val)
formData[field.prop] = opt ? opt.label : val
} else {
formData[field.prop] = val
}
})
})
// 2. 清空旧明细字段
const detailFields = ['product_name', 'barcode', 'box_quantity', 'boxes_per_pallet', 'actual_quantity', 'remark']
detailFields.forEach(f => formData[f] = '')
// 3. 获取详情填充第一个商品的明细(如果有的话)
try {
const res: any = await receivingApi.getReceivingDetail({
id: mainRow.id,
pagination: { page: 1, pageSize: 1000 }
})
if (res && res.code === 200) {
const details = res.data.receiving?.details || []
// 翻译并整理明细列表
const processedDetails = details.map((item: any) => {
const newItem = { ...item }
// 尝试对明细字段进行翻译(如果有配置)
const detailConfig = printFormConfig.find(g => g.group === '商品明细')
if (detailConfig) {
detailConfig.fields.forEach((field: any) => {
const val = newItem[field.prop]
if (field.type === 'select' && field.options) {
const opt = field.options.find((o: any) => o.value === val)
newItem[field.prop] = opt ? opt.label : val
} else if (val === undefined || val === null) {
newItem[field.prop] = ''
}
})
}
return newItem
})
// 将明细列表挂载到 formData,通常命名为 details 以便模板遍历
formData.details = processedDetails
if (processedDetails.length > 0) {
const detail = processedDetails[0]
const detailConfig = printFormConfig.find(g => g.group === '商品明细')
if (detailConfig) {
detailConfig.fields.forEach((field: any) => {
// 使用处理过的数据
formData[field.prop] = detail[field.prop]
})
}
}
}
} catch (e) {
console.error('加载打印明细失败', e)
}
Object.assign(printForm, formData)
}
async function loadPrintOptions() {
try {
const [stations, templates]: any = await Promise.all([
stationApi.getList({ page: 1, pageSize: 100, where: {} }),
templateApi.listTemplates({})
])
// 打印台:兼容 code 0 和 code 200,数据在 data.list 中
if (stations && (stations.code === 200 || stations.code === 0)) {
const rawList: any[] = stations.data?.list || stations.data || []
stationOptions.value = rawList.map((item: any) => ({
id: item.id,
name: item.name || item.label || String(item.id)
}))
} else {
console.warn('获取打印台列表失败:', stations)
}
// 打印模板:与模板编辑页保持一致,从 res.presetTree 中递归提取所有非分类节点
if (templates && templates.code === 200) {
const flattenTree = (nodes: any[]): any[] => {
const result: any[] = []
for (const node of nodes) {
if (node.type !== 'category') {
// 保存原始节点数据,特别是 template_content 等后端需要的字段
result.push({
...node,
id: node.id,
name: node.title || node.name || node.template_name || String(node.id)
})
}
if (node.children && node.children.length > 0) {
result.push(...flattenTree(node.children))
}
}
return result
}
templateOptions.value = flattenTree(templates.presetTree || [])
} else {
console.warn('获取模板列表失败:', templates)
}
} catch (e) {
console.error('加载打印配置失败', e)
}
}
async function handleStationChange(val: string | number) {
printSettings.printer = ''
printerOptions.value = []
if (!val) return
printerLoading.value = true
try {
const res: any = await stationApi.getComputerPrinter(String(val))
if (res && res.code === 0 && res.data) {
// res.data 可能是一个包含打印机列表的对象,具体取决于后端实现
// 这里的逻辑参考 system/setting/printStation 页面的预期数据格式
const printerList = Array.isArray(res.data) ? res.data : (res.data.list || [])
printerOptions.value = printerList.map((p: any) => ({
label: p.name || p.printerName || p,
value: p.name || p.printerName || p
}))
} else {
console.warn('获取打印机列表失败:', res)
}
} catch (e) {
console.error('获取打印机列表出错:', e)
} finally {
printerLoading.value = false
}
}
async function doPrint() {
if (!printSettings.station || !printSettings.template) {
ElMessage.warning('请选择打印台和模板')
return
}
if (!printSettings.printer) {
ElMessage.warning('请选择打印机')
return
}
printing.value = true
const currentRow = selectionRows.value[currentPrintIndex.value]
try {
// 后端字段:computerId (打印台id)、printer (打印机名)、template (模板对象)、data、type、size
const selectedTemplateObj = templateOptions.value.find((t: any) => t.id === printSettings.template) || null
const printPayload = {
type: 'customize',
computerId: printSettings.station,
printer: printSettings.printer,
template: selectedTemplateObj,
data: { ...printForm },
timestamp: Date.now(),
size: 1
}
const res: any = await stationApi.sendPrint(printPayload)
// 兼容 code 0(PDA 风格)和 code 200 两种后端响应
if (res && (res.code === 0 || res.code === 200 || res.status === 'success' || res.flag === 'success')) {
printStatusMap.value[currentRow.id] = 'done'
ElMessage.success(`单据 ${currentRow.receiving_number} 打印成功`)
// 自动切换到下一个待打印单据
if (currentPrintIndex.value < selectionRows.value.length - 1) {
currentPrintIndex.value++
await loadPrintFormData(currentPrintIndex.value)
} else {
ElMessage.info('已完成所有选中单据的打印操作')
}
} else {
printStatusMap.value[currentRow.id] = 'error'
ElMessage.error(res?.msg || res?.message || `单据 ${currentRow.receiving_number} 打印失败`)
}
} catch (e: any) {
console.error('打印出错:', e)
printStatusMap.value[currentRow.id] = 'error'
ElMessage.error('打印请求失败,请检查网络或打印台状态')
} finally {
printing.value = false
}
}
async function confirmcomplete() {
if (!selectionRows.value.length) {
ElMessage.warning('请先选择要操作的收货单')
return
}
try {
await ElMessageBox.confirm(`确定要批量完成 ${selectionRows.value.length} 个收货单的收货吗?`, '确认完成', { type: 'success' })
for (const row of selectionRows.value) {
console.log('正在执行完成收货,请求数据:', { id: row.id, type: 'complete' })
// 传递 id 标识单号,以及 type: 'complete' 来表示完成收货操作(补全请求数据)
const res: any = await receivingApi.completeReceiving({ id: row.id, type: 'complete' })
console.log('完成收货接口返回数据:', res)
if (res && res.code === 200) {
ElMessage.success(`收货单 ${row.receiving_number} 已完成`)
} else {
ElMessage.error(`收货单 ${row.receiving_number} 操作失败: ${res.message || '系统错误'}`)
}
}
selectionRows.value = []
loadData()
} catch (e) {
if (e !== 'cancel') {
console.error('完成收货操作出错:', e)
// ElMessage.error('操作执行失败')
}
}
}
async function confirmBatchCancel() {
if (!selectionRows.value.length) {
ElMessage.warning('请先选择要操作的收货单')
return
}
try {
await ElMessageBox.confirm(`确定要批量作废 ${selectionRows.value.length} 个收货单吗?`, '确认作废', { type: 'warning' })
const ids = selectionRows.value.map(row => row.id)
const res: any = await receivingApi.batchCancelReceiving({ ids })
if (res && res.code === 200) {
ElMessage.success('批量作废成功')
} else {
ElMessage.error(res.message || '批量作废失败')
}
selectionRows.value = []
loadData()
} catch (e) {
if (e !== 'cancel') {
console.error('批量作废操作出错:', e)
// ElMessage.error('操作执行失败')
}
}
}
// 审核收货单相关
const reviewLoading = ref(false)
async function handleReviewReceiving() {
if (!selectionRows.value.length) {
ElMessage.warning('请先选择要审核的收货单')
return
}
try {
await ElMessageBox.confirm(
`确定要批量审核 ${selectionRows.value.length} 个收货单吗?\n审核后将会直接通知货主且不可撤销。`,
'确认审核',
{ type: 'warning' }
)
} catch {
return
}
reviewLoading.value = true
try {
const ids = selectionRows.value.map(row => row.id)
const res: any = await receivingApi.reviewReceiving({ ids })
if (res && res.code === 200) {
ElMessage.success(`已成功审核 ${res.data?.count ?? ids.length} 个收货单`)
selectionRows.value = []
loadData()
} else {
ElMessage.error(res?.message || '批量审核失败')
}
} catch (e) {
console.error('批量审核出错:', e)
ElMessage.error('审核操作执行失败')
} finally {
reviewLoading.value = false
}
}
// 驳回收货单相关
const rejectDialogVisible = ref(false)
const rejectLoading = ref(false)
const rejectRemark = ref('')
function handleRejectReceiving() {
if (!selectionRows.value.length) {
ElMessage.warning('请先选择要驳回的收货单')
return
}
rejectRemark.value = ''
rejectDialogVisible.value = true
}
async function submitRejectReceiving() {
rejectLoading.value = true
try {
const ids = selectionRows.value.map(row => row.id)
const payload: any = { ids }
if (rejectRemark.value) payload.remark = rejectRemark.value
const res: any = await receivingApi.rejectReceiving(payload)
if (res && res.code === 200) {
ElMessage.success(`已成功驳回 ${res.data?.count ?? ids.length} 个收货单`)
rejectDialogVisible.value = false
selectionRows.value = []
loadData()
} else {
ElMessage.error(res?.message || '驳回失败')
}
} catch (e) {
console.error('驳回收货单出错:', e)
ElMessage.error('驳回操作执行失败')
} finally {
rejectLoading.value = false
}
}
function printReceiving() {
if (!selectionRows.value.length) {
ElMessage.warning('请选择要打印的收货单')
return
}
const payload = selectionRows.value.map(r => ({ ...r, businessId: r.receiving_number }))
// 简单打印:在新窗口显示 JSON,后续可替换为正式打印组件
const w = window.open('', '_blank')
if (w) {
w.document.write(`<pre>${JSON.stringify(payload, null, 2)}</pre>`)
w.document.close()
}
}
async function handleQuickPutaway() {
if (selectionRows.value.length !== 1) {
ElMessage.warning('请仅选择一条收货单进行快捷入库')
return
}
// 校验收货单状态:要求收货单已完成(completed)且所有明细已匹配系统商品(all_matched)
const errors: string[] = []
const validRows: any[] = []
selectionRows.value.forEach(row => {
const isCompleted = (row.status || '').toLowerCase() === 'completed'
const isAllMatched = (row.detail_status || '').toLowerCase() === 'all_matched'
if (!isCompleted) {
errors.push(`收货单【${row.receiving_number}】未完成(当前状态:${row.status || '未知'})`)
} else if (!isAllMatched) {
errors.push(`收货单【${row.receiving_number}】明细未全部匹配(当前明细状态:${row.detail_status || '未全部匹配'})`)
} else {
validRows.push(row)
}
})
if (errors.length > 0) {
ElMessageBox.alert(
`<div style="max-height: 300px; overflow: auto;">${errors.join('<br/>')}</div>`,
'校验未通过,无法快捷入库',
{ confirmButtonText: '确定', dangerouslyUseHTMLString: true, type: 'error' }
)
return
}
try {
await ElMessageBox.confirm(
`确定对选中的 ${validRows.length} 条收货单执行快捷入库上架吗?`,
'快捷入库确认',
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }
)
} catch {
return
}
quickPutawayLoading.value = true
const failList: string[] = []
try {
for (const row of validRows) {
try {
const res = await receivingApi.quickPutaway({ receiving_id: row.id })
if (!res || (res.code !== 200 && res.flag !== 'success' && res.status !== 'success')) {
failList.push(`${row.receiving_number}:${res?.message || res?.msg || '接口返回失败'}`)
}
} catch (e: any) {
failList.push(`${row.receiving_number}:${e?.message || '请求异常'}`)
}
}
if (failList.length > 0) {
ElMessageBox.alert(
`<div style="max-height: 300px; overflow: auto;">${failList.join('<br/>')}</div>`,
`${failList.length} 条收货单处理失败`,
{ confirmButtonText: '确定', dangerouslyUseHTMLString: true, type: 'error' }
)
} else {
ElMessage.success('选中的收货单已全部快捷入库成功')
}
loadData()
} finally {
quickPutawayLoading.value = false
}
}
async function handleExport() {
if (selectionRows.value.length === 0) {
ElMessage.warning('请先勾选要导出的收货单')
return
}
exportLoading.value = true
try {
// 遍历勾选的收货单,每个收货单生成一个 excel 文件
for (const row of selectionRows.value) {
const productExportData: any[] = [] // 商品明细行
const receivingExportData: any[] = [] // 收货单摘要行(无明细时回退)
// 收货单摘要行(按 receivingColumns 字段)
receivingExportData.push({
'收货单号': row.receiving_number,
'收货状态': statusConfig[row.status as keyof typeof statusConfig]?.text || row.status || '',
'匹配状态': detailStatusConfig[row.detail_status as keyof typeof detailStatusConfig]?.text || row.detail_status || '',
'入库状态': storageStatusConfig[row.storage_status as keyof typeof storageStatusConfig]?.text || row.storage_status || '',
'货主': row.store_name || '',
'商品种类': row.total_items ?? '',
'总数量': row.total_quantity ?? '',
'总箱数': row.total_boxes ?? '',
'总托盘数': row.total_pallets ?? '',
'车牌号': row.license_plate || '',
'物流单号': row.tracking_number || '',
'来货方式': deliveryMethodConfig[row.delivery_method as keyof typeof deliveryMethodConfig]?.text || row.delivery_method || '',
'装卸方式': loadingMethodConfig[row.loading_method as keyof typeof loadingMethodConfig]?.text || row.loading_method || '',
'创建人': row.creator_name || '',
'收货开始': row.receiving_start_time || '',
'收货结束': row.receiving_end_time || '',
'创建时间': row.created_at || '',
'备注': row.remark || ''
})
// 获取该收货单的商品明细
try {
const res: any = await receivingApi.getReceivingDetail({
id: row.id,
pagination: { page: 1, pageSize: 10000 }
})
if (res && res.code === 200 && res.data) {
// 兼容多种返回结构
const receivingData = res.data.receiving || {}
const list = Array.isArray(receivingData.details)
? receivingData.details
: Array.isArray(res.data.list)
? res.data.list
: Array.isArray(res.data.details)
? res.data.details
: []
// 按 productquick 列导出商品明细,附带收货单号作为关联
list.forEach((item: any) => {
productExportData.push({
'收货单号': row.receiving_number,
'货主': row.store_name || '',
'商品名称': item.product_name || '',
'条码': item.barcode || '',
'匹配状态': item.system_product_id ? '已匹配' : '未匹配',
'实收数量': item.actual_quantity ?? '',
'箱数': item.box_quantity ?? '',
'箱规': item.boxes_per_pallet ?? '',
'批次号': item.batch_number || '',
'生产日期': item.production_date || '',
'有效期': item.expiry_date || '',
'入库状态': storageStatusConfig[item.storage_status as keyof typeof storageStatusConfig]?.text || item.storage_status || '',
'库位': item.space_id || '',
'备注': item.remark || ''
})
})
}
} catch (e) {
console.warn(`获取收货单 ${row.receiving_number} 商品明细失败,跳过`, e)
}
// 优先导出商品明细;若该收货单无明细,则回退导出收货单摘要
const exportData = productExportData.length > 0 ? productExportData : receivingExportData
const sheetName = productExportData.length > 0 ? '收货单商品明细' : '收货单摘要'
if (exportData.length > 0) {
const ws = XLSX.utils.json_to_sheet(exportData)
const wb = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(wb, ws, sheetName)
// 文件名使用收货单号
const fileName = `${row.receiving_number}.xlsx`
XLSX.writeFile(wb, fileName)
}
}
ElMessage.success('导出完成')
} catch (e) {
console.error('导出 Excel 失败:', e)
ElMessage.error('导出失败')
} finally {
exportLoading.value = false
}
}
</script>
<style scoped lang="scss">
.storage-receiving-container {
display: flex;
// height: calc(100vh - 100px); // 移除固定高度,由模板中的 :style 控制
width: 100%;
background-color: #f0f2f5;
.main-content {
flex: 1;
display: flex;
flex-direction: column;
padding: 10px;
overflow: hidden;
.toolbar {
padding: 5px;
border-bottom: 1px solid #ebeef5;
display: flex;
justify-content: space-between;
align-items: center;
background-color: #fff;
}
.toolbar-right {
display: flex;
flex-direction: row;
gap: 15px;
height: 30px;
align-items: center;
}
.split-stack {
flex: 1 1 auto;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
}
.pane-resizer {
flex: 0 0 6px;
min-height: 6px;
background: #e4e7ed;
cursor: row-resize;
flex-shrink: 0;
position: relative;
z-index: 2;
&:hover {
background: #dcdfe6;
}
}
.upper-wrapper {
/* 高度占比由 :style(upperPaneStyle / upperPaneFullStyle)控制 */
overflow: hidden;
}
/* upper-table-container 已在组件内支持弹性高度,此处确保撑满 upper-wrapper */
.upper-wrapper :deep(.upper-table-container) {
height: 100%;
}
.lower-level {
display: flex;
flex-direction: column;
border-top: 1px solid #ebeef5;
overflow: hidden;
background-color: #fff;
.detail-header {
flex-shrink: 0;
padding: 0 10px;
border-bottom: 1px solid #ebeef5;
background-color: #fafafa;
.detail-tab {
margin-bottom: -1px;
:deep(.el-tabs__header) {
margin: 0;
}
:deep(.el-tabs__item) {
height: 28px;
line-height: 28px;
font-size: 12px;
padding: 0 10px;
}
:deep(.el-tabs__nav-wrap::after) {
height: 1px;
}
}
}
.detail-container {
flex: 1;
min-height: 0;
overflow: hidden;
padding: 6px 10px;
display: flex;
flex-direction: column;
box-sizing: border-box;
:deep(.receiving-detail-pane) {
flex: 1;
min-height: 0;
min-width: 0;
width: 100%;
overflow: hidden;
display: flex;
flex-direction: column;
}
}
}
.no-selection {
display: flex;
align-items: center;
justify-content: center;
color: #909399;
background-color: #fff;
padding: 10px;
.empty-tip {
text-align: center;
font-size: 13px;
line-height: 1.5;
max-width: 360px;
.el-icon {
font-size: 36px;
margin-bottom: 8px;
}
}
}
}
}
.print-dialog-layout {
display: flex;
height: 1150px;
border: 1px solid #ebeef5;
.print-batch-list {
width: 250px;
border-right: 1px solid #ebeef5;
background-color: #fafafa;
display: flex;
flex-direction: column;
overflow-y: auto;
/* 限制左侧列表高度,使其在对话框中可滚动 */
max-height: 100%;
.list-title {
padding: 10px;
font-weight: bold;
border-bottom: 1px solid #ebeef5;
background-color: #fff;
}
.batch-item {
padding: 12px 15px;
cursor: pointer;
display: flex;
align-items: center;
gap: 10px;
border-bottom: 1px dotted #eee;
transition: background 0.2s;
&:hover {
background-color: #f0f7ff;
}
&.active {
background-color: #e6f7ff;
border-left: 3px solid #1890ff;
}
.item-index {
color: #999;
font-size: 12px;
}
.item-number {
flex: 1;
font-weight: 500;
font-family: monospace;
}
}
}
.print-preview-main {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
background-color: #fff;
.print-settings-bar {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 15px;
border-bottom: 1px solid #ebeef5;
background-color: #fafafa;
flex-shrink: 0;
.el-select {
flex: 1;
min-width: 130px;
}
}
.print-canvas-area {
flex: 1;
overflow: auto;
display: flex;
justify-content: center;
align-items: flex-start;
padding: 20px;
background-color: #f0f2f5;
.preview-page {
background: #fff;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
border: 1px solid #ddd;
flex-shrink: 0;
}
.preview-empty {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
}
}
}
.dialog-footer {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
.progress-tip {
color: #606266;
font-size: 14px;
font-weight: 500;
}
}
/* 居中打印对话框(垂直居中) */
.print-dialog .el-dialog {
top: 50% !important;
transform: translateY(-50%) !important;
}
</style>