diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/StorageForm.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/StorageForm.vue index 1ccd741d..3eac003e 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/StorageForm.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/StorageForm.vue @@ -390,98 +390,7 @@ link type="primary" size="small" :disabled="ctrView || ctrDelete" - - - - + @@ -512,6 +421,7 @@ import projects from './subproject.vue' import {Search} from "@element-plus/icons-vue"; import purchaseorderDialog from '@/views/heli/outsourcestock/purchaseorderDialog.vue' import MaterialForm from '@/views/heli/material/MaterialForm.vue' +import PrintRef from './print.vue' import * as StorageinApi from "@/api/heli/storagein"; import * as storageInventoryApi from "@/api/heli/storageinventory"; @@ -628,120 +538,33 @@ function formatDate(val) { } const printLoading = ref(false) -// 打印弹窗内容 -const printDialogVisible = ref(false) -const printData = ref({}) +const printFormRef = ref() -function openPrintDialog(data) { - printData.value = data - printDialogVisible.value = true -} const isPrint = async () => { - printLoading.value = true - printLoading.value = true + printLoading.value = true try { - var newVar = await StorageApi.isPrint(query.id); - console.log(newVar) - openPrintDialog(newVar) + const newVar = await StorageApi.isPrint(query.id) + const data = newVar.storageMatDOList?.map((item, idx) => ({ + 编号: idx + 1, + 物料号: item.matCode || '', + 零件名称: item.matName ? (item.matName.length > 20 ? item.matName.slice(0, 20) : item.matName) : '', + 规格: item.mtSpec || '', + 单位: item.matUnit || '', + 入库数量: item.storageOkQty || '', + 单价: item.unitPrice || '', + 小计: item.totalPrice || '', + 项目名称: item.projectName || '', + 备注: item.description || '' + })) || [] + // 补齐到17行 + const emptyRow = { 编号: '', 物料号: '', 零件名称: '', 规格: '', 单位: '', 入库数量: '', 单价: '', 小计: '', 项目名称: '', 备注: '' } + while (data.length < 17) { + data.push({ ...emptyRow, 编号: data.length + 1 }) + } + printFormRef.value?.open(data, '', 'detail') } finally { printLoading.value = false } - -} - - -function doPrint() { - // 创建新的打印窗口 - const printContent = document.getElementById('printArea') - if (!printContent) return - - const iframe = document.createElement('iframe') - iframe.style.position = 'absolute' - iframe.style.width = '0' - iframe.style.height = '0' - iframe.style.border = 'none' - document.body.appendChild(iframe) - - const doc = iframe.contentWindow?.document - doc?.open() - doc?.write(` - - - - 入库单 - - - - ${printContent.innerHTML} - - - `) - doc?.close() - - iframe.onload = () => { - iframe.contentWindow?.focus() - iframe.contentWindow?.print() - setTimeout(() => document.body.removeChild(iframe), 1000) - } - -} - -function limitTo20Chars(input) { - if (typeof input !== 'string') return ''; - return input.length > 20 ? input.slice(0, 20) : input; } @@ -1444,77 +1267,4 @@ a { color: #409eff; text-decoration: none; } - -/* 打印样式 */ -@media print { - /* 隐藏所有非打印内容 */ - body * { - visibility: hidden; - } - - /* 只显示打印区域 */ - #printArea, #printArea * { - visibility: visible; - } - - /* 打印区域定位 */ - #printArea { - position: absolute; - left: 0; - top: 0; - width: 100%; - } - - /* 隐藏弹窗相关元素 */ - .el-dialog, .el-dialog__wrapper, .el-dialog__header, .el-dialog__footer { - display: none !important; - } -} - -.order-info { - display: flex; - flex-wrap: wrap; - align-items: center; - justify-content: space-between; - -} - -.order-info span { - font-size: 15px !important; - margin-right: 10px !important; -} -.stamp-info { - margin-top: 10px; - -} -.stamp-info span{ - font-size: 15px !important; - -} -.print-table { - width: 100%; - border-collapse: collapse; - margin-top: 10px; - border: 1px solid #ccc; - } - -.print-table th, -.print-table td { - border: 1px solid #ccc; - padding: 6px 8px; - text-align: center; - font-size: 13px !important; - height: 30px; /* 设置固定高度 */ - line-height: 30px; /* 垂直居中 */ - -} - -.print-table th { - background-color: #f5f7fa; - color: #303133; - font-weight: 600; - font-size: 13px !important; -} - - diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/print.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/print.vue index c9bb3bd7..84208000 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/print.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/storage/print.vue @@ -4,52 +4,28 @@
杭州合立模具有限公司 - 入库管理单 + {{ titleText }}
审核:
-
委外加工经手人:
-
收货人:
+
{{ handlerLabel }}:
+
{{ receiverLabel }}:
订单编号:{{ purchaseNo }}
- - - - - - - - - - + - - - - - - - - - + - - - - - - - - - - - + +
编号入库单号入库类型上游单号入库仓库即入即出单据状态创建时间提交时间{{ col.label }}
{{ row['编号'] }}{{ row['入库单号'] }}{{ row['入库类型'] }}{{ row['上游单号'] }}{{ row['入库仓库'] }}{{ row['即入即出'] }}{{ row['单据状态'] }}{{ fmtDate(row['创建时间']) }}{{ fmtDate(row['提交时间']) }}
+ {{ col.formatter ? col.formatter(row[col.key]) : row[col.key] }} +
@@ -60,7 +36,7 @@ {{ duEmpName }}
审核人:
-
委外加工经手人:
+
{{ handlerLabel }}:
@@ -77,13 +53,15 @@ import { useRoute } from 'vue-router' import dayjs from 'dayjs' import { useUserStore } from '@/store/modules/user' const userStore = useUserStore(); -const userName = userStore.getUser.nickname//nickname +const userName = userStore.getUser.nickname console.log(userStore,`userStore`); - - const dialogVisible = ref(false) const rows = ref[]>([]) +const columns = ref([]) +const titleText = ref('入库管理单') +const handlerLabel = ref('') +const receiverLabel = ref('') const duEmpName = computed(() => userName) @@ -91,16 +69,55 @@ const fmtDate = (v: any) => (v ? dayjs(v).format('YYYY-MM-DD') : '') const purchaseNo = ref('') const { query } = useRoute() import * as PurchaseOrderNoApi from '@/api/heli/purchaseorderno' + +// 列表打印列配置(index.vue 用) +const listColumns = [ + { key: '编号', label: '编号', width: '4%', align: 'center' }, + { key: '入库单号', label: '入库单号', width: '13%', align: 'left' }, + { key: '入库类型', label: '入库类型', width: '8%', align: 'left' }, + { key: '上游单号', label: '上游单号', width: '12%', align: 'left' }, + { key: '入库仓库', label: '入库仓库', width: '8%', align: 'left' }, + { key: '即入即出', label: '即入即出', width: '6%', align: 'center' }, + { key: '单据状态', label: '单据状态', width: '7%', align: 'center' }, + { key: '创建时间', label: '创建时间', width: '11%', align: 'center', formatter: fmtDate }, + { key: '提交时间', label: '提交时间', width: '11%', align: 'center', formatter: fmtDate }, +] + +// 单据详情打印列配置(StorageForm.vue 用) +const detailColumns = [ + { key: '编号', label: '序号', width: '6%', align: 'center' }, + { key: '物料号', label: '物料号', width: '12%', align: 'left' }, + { key: '零件名称', label: '零件名称', width: '10%', align: 'left' }, + { key: '规格', label: '规格', width: '8%', align: 'left' }, + { key: '单位', label: '单位', width: '6%', align: 'center' }, + { key: '入库数量', label: '入库数量', width: '8%', align: 'center' }, + { key: '单价', label: '单价(元)', width: '8%', align: 'center' }, + { key: '小计', label: '小计(元)', width: '8%', align: 'center' }, + { key: '项目名称', label: '项目名称', width: '12%', align: 'left' }, + { key: '备注', label: '备注', width: '12%', align: 'left' }, +] + /** - * - * @param data 打印数据 - * @param str 采购订单号=订单编号 零件采购收货时,订单编号为空。 零件采购订单管理 不为空 + * @param data 打印数据(数组) + * @param str 采购订单号(列表打印用) + * @param mode 'list' 列表打印 | 'detail' 单据详情打印 */ -const open = (data: Record[],str: string) => { +const open = (data: Record[], str: string, mode: string = 'list') => { rows.value = Array.isArray(data) ? data : [] - dialogVisible.value = true; - purchaseNo.value = str; - console.log(query.id); + purchaseNo.value = str + dialogVisible.value = true + + if (mode === 'detail') { + columns.value = detailColumns + titleText.value = '入库管理单' + handlerLabel.value = '委外加工经手人' + receiverLabel.value = '收货人' + } else { + columns.value = listColumns + titleText.value = '入库管理单' + handlerLabel.value = '委外加工经手人' + receiverLabel.value = '收货人' + } } defineExpose({ open }) @@ -162,24 +179,24 @@ const onPrint = () => { margin-left: 12px; } - /* 合计行样式 */ - .sum-row { - border-top: none; - font-weight: bold; - } - .sum-label { - text-align: right; - font-weight: bold; - } - .sum-value { - font-weight: bold; - } - .sign-space { - display: inline-block; - width: 50px; - height: 18px; - margin-left: 4px; - } + /* 合计行样式 */ + .sum-row { + border-top: none; + font-weight: bold; + } + .sum-label { + text-align: right; + font-weight: bold; + } + .sum-value { + font-weight: bold; + } + .sign-space { + display: inline-block; + width: 50px; + height: 18px; + margin-left: 4px; + } .sheet { width:100%; border-collapse:collapse; font-size:12px; table-layout: fixed; } .sheet th, .sheet td { border:1.5pt solid #333; padding:4px 0px; text-align:center; line-height:1; vertical-align: middle; } @@ -201,7 +218,7 @@ const onPrint = () => { iframe.contentWindow!.focus() iframe.contentWindow!.print() setTimeout(() => document.body.removeChild(iframe), 500) - if(query.id){//用来判断零件采购订单管理 id=true,=false零件采购收货 + if(query.id){ PurchaseOrderNoApi.updateIsPrint(query.id); } } @@ -209,7 +226,6 @@ const onPrint = () => {