Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f571704614 | ||
|
|
c3da8055ec | ||
|
|
852b446901 | ||
|
|
225a7a1932 | ||
|
|
466ac71f80 | ||
|
|
e7ac5f3bbf | ||
|
|
a173cf7044 |
@@ -7,6 +7,7 @@ export interface FullWorkOrderResp {
|
||||
title: string
|
||||
orderNo: string
|
||||
materialCode: string
|
||||
encodingPrint: string
|
||||
materialName: string
|
||||
batch: string
|
||||
mark: string
|
||||
|
||||
@@ -6,6 +6,7 @@ export interface MaterialInfoResp {
|
||||
id: string
|
||||
materialName: string
|
||||
encoding: string
|
||||
encodingPrint: string
|
||||
unitWeight: string
|
||||
materialSpec: string
|
||||
photoUrl: string
|
||||
@@ -22,6 +23,7 @@ export interface MaterialInfoResp {
|
||||
export interface MaterialInfoQuery {
|
||||
materialName: string | undefined
|
||||
encoding: string | undefined
|
||||
encodingPrint: string | undefined
|
||||
batch: string | undefined
|
||||
mark: string | undefined
|
||||
sort: Array<string>
|
||||
|
||||
@@ -5,6 +5,7 @@ const BASE_URL = '/weighManage/workOrder'
|
||||
export interface WeighManageResp {
|
||||
id: string
|
||||
encoding: string
|
||||
encodingPrint: string
|
||||
materialName: string
|
||||
materialSpec: string
|
||||
unitWeight: number
|
||||
|
||||
@@ -79,3 +79,8 @@ export function deleteWorkOrder(ids: string | Array<string>) {
|
||||
export function exportWorkOrder(query: WorkOrderQuery) {
|
||||
return http.download(`${BASE_URL}/export`, query)
|
||||
}
|
||||
|
||||
/** @desc 保存打印记录 */
|
||||
export function savePrintRecord(data: any) {
|
||||
return http.post(`/print/print`, data)
|
||||
}
|
||||
|
||||
@@ -27,6 +27,17 @@
|
||||
<a-input v-model="formData.batch" placeholder="未获取到生产批次" :disabled="true" />
|
||||
</a-form-item>
|
||||
</div>
|
||||
|
||||
<div class="form-grid-item">
|
||||
<a-form-item label="打印编码(国产替代)">
|
||||
<a-input v-model="formData.encodingPrint" allow-clear placeholder="请输入打印编码" @change="getMaterialName"/>
|
||||
</a-form-item>
|
||||
</div>
|
||||
<div class="form-grid-item">
|
||||
<a-form-item label="打印物料名称(国产替代)">
|
||||
<a-input v-model="formData.materialNamePrint" allow-clear placeholder="请输入打印物料名称"/>
|
||||
</a-form-item>
|
||||
</div>
|
||||
</div>
|
||||
</a-form>
|
||||
<div class="form-actions">
|
||||
@@ -190,8 +201,9 @@
|
||||
import { ref, reactive, nextTick, onMounted } from 'vue'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import {getWorkOrder, type WorkOrderInfoResp} from "@/apis/workOrder/workOrder"
|
||||
import {getWorkOrder, savePrintRecord, type WorkOrderInfoResp} from "@/apis/workOrder/workOrder"
|
||||
import QRCode from 'qrcode';
|
||||
import {getMaterialDetail} from "@/apis/weightManage/weightManage";
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
@@ -199,6 +211,8 @@ const route = useRoute()
|
||||
const formData = reactive({
|
||||
workerOrderId: '',
|
||||
encoding: '',
|
||||
encodingPrint: '',
|
||||
materialNamePrint: '',
|
||||
materialName: '',
|
||||
orderNo: '',
|
||||
totalCalculatedWeight: '',
|
||||
@@ -243,6 +257,21 @@ const labelData = reactive({
|
||||
// 标签容器引用
|
||||
const labelContainer = ref<HTMLElement | null>(null)
|
||||
|
||||
const getMaterialName = async (value: string) => {
|
||||
try {
|
||||
const res = await getMaterialDetail(value)
|
||||
if (res.code == '0') {
|
||||
formData.materialNamePrint = res.data.materialName || ''
|
||||
} else {
|
||||
formData.materialNamePrint = '';
|
||||
Message.error('获取物料信息失败')
|
||||
}
|
||||
} catch (error) {
|
||||
formData.materialNamePrint = '';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 生成二维码
|
||||
const generateQRCode = async (data: string) => {
|
||||
try {
|
||||
@@ -268,7 +297,6 @@ const generateDetailLabel = async () => {
|
||||
}
|
||||
|
||||
if (!formData.batch) {
|
||||
console.log("11111", formData.batch);
|
||||
Message.error('未获取到批次信息')
|
||||
return
|
||||
}
|
||||
@@ -297,15 +325,15 @@ const generateDetailLabel = async () => {
|
||||
for (const workOrderInfo of formData.workOrderInfos) {
|
||||
// 计算二维码数据
|
||||
const orderNo = formData.orderNo + workOrderInfo.id;
|
||||
const qrCodeData = `10#${formData.encoding}$11#9DP$12#${formData.batch}$17#${workOrderInfo.quantity}$20#${formattedDate2}$31#${orderNo}$DY`
|
||||
const qrCodeData = `10#${formData.encodingPrint || formData.encoding}$11#9DP$12#${formData.batch}$17#${workOrderInfo.quantity}$20#${formattedDate2}$31#${orderNo}$DY`;
|
||||
|
||||
// 生成二维码图片
|
||||
const qrCodeImage = await generateQRCode(qrCodeData)
|
||||
|
||||
// 添加标签数据
|
||||
labelDataList.push({
|
||||
partName: formData.materialName || '',
|
||||
partNumber: formData.encoding || '',
|
||||
partName: formData.materialNamePrint || formData.materialName || '',
|
||||
partNumber: formData.encodingPrint || formData.encoding || '',
|
||||
totalCalculatedWeight: workOrderInfo.calculatedWeight || '',
|
||||
totalWeight: workOrderInfo.weight || '',
|
||||
productionDate: formattedDate,
|
||||
@@ -353,15 +381,15 @@ const generateOverallLabel = async () => {
|
||||
String(now.getDate()).padStart(2, '0')
|
||||
|
||||
// 计算二维码数据
|
||||
const qrCodeData = `10#${formData.encoding}$11#9DP$12#${formData.batch}$17#${formData.totalCount}$20#${formattedDate2}$31#${formData.orderNo}$DY`
|
||||
const qrCodeData = `10#${formData.encodingPrint || formData.encoding}$11#9DP$12#${formData.batch}$17#${formData.totalCount}$20#${formattedDate2}$31#${formData.orderNo}$DY`
|
||||
|
||||
// 生成二维码图片
|
||||
const qrCodeImage = await generateQRCode(qrCodeData)
|
||||
|
||||
// 直接从 formData 中获取数据
|
||||
Object.assign(labelData, {
|
||||
partName: formData.materialName || '',
|
||||
partNumber: formData.encoding || '',
|
||||
partName: formData.materialNamePrint || formData.materialName || '',
|
||||
partNumber: formData.encodingPrint || formData.encoding || '',
|
||||
totalCalculatedWeight: formData.totalCalculatedWeight || '',
|
||||
totalWeight: formData.totalWeight || '',
|
||||
productionDate: formattedDate,
|
||||
@@ -415,7 +443,7 @@ const printLabel = async () => {
|
||||
// 判断是打印明细标签还是整体标签
|
||||
const isDetailLabels = labelDataList.length > 0
|
||||
const labelsToPrint = isDetailLabels ? labelDataList : [labelData]
|
||||
|
||||
|
||||
// 生成标签HTML
|
||||
const labelsHTML = labelsToPrint.map(item => `
|
||||
<div class="label">
|
||||
@@ -485,31 +513,52 @@ const printLabel = async () => {
|
||||
</table>
|
||||
</div>
|
||||
`).join('')
|
||||
|
||||
// 构建打印内容
|
||||
|
||||
// 构建打印内容,通过 matchMedia 监听打印确认事件(仅在确认打印时保存记录)
|
||||
const printHTML = `
|
||||
<html>
|
||||
<head>
|
||||
<title>标签打印</title>
|
||||
<style>
|
||||
body { margin: 0; padding: 10mm; font-family: Arial, sans-serif; }
|
||||
.label-container { display: flex; flex-wrap: wrap; gap: 10mm; justify-content: center; }
|
||||
.label { width: 90mm; height: 38.5mm; border: 1px solid #000; padding: 0; box-sizing: border-box; page-break-inside: avoid; }
|
||||
.label-table { width: 100%; height: 100%; border-collapse: collapse; }
|
||||
.label-cell { border: 1px solid #000; padding: 1mm; vertical-align: top; }
|
||||
.qr-cell { width: 24mm; text-align: center; vertical-align: middle; border: 1px solid #000; }
|
||||
@page { size: 80mm 50mm; margin: 0; }
|
||||
body { margin: 0; padding: 1mm; font-family: Arial, sans-serif; }
|
||||
.label-container { display: flex; flex-wrap: wrap; gap: 1mm; justify-content: center; align-items: center; transform-origin: center; }
|
||||
.label { width: 75mm; height: 45mm; border: 1px solid #000; padding: 0; box-sizing: border-box; page-break-inside: avoid; overflow: hidden; margin: 0 auto; }
|
||||
.label-table { width: 100%; height: 100%; border-collapse: collapse; table-layout: fixed; }
|
||||
.label-cell { border: 1px solid #000; padding: 0.8mm; vertical-align: top; }
|
||||
.qr-cell { width: 22mm; text-align: center; vertical-align: middle; border: 1px solid #000; }
|
||||
.label-row { display: flex; align-items: center; }
|
||||
.label-field { font-size: 8pt; font-weight: bold; margin-right: 2mm; min-width: 25pt; }
|
||||
.label-value { font-size: 8pt; font-weight: bold; flex: 1; }
|
||||
.qr-code img { width: 20mm; height: 20mm; margin: 1mm 0; }
|
||||
.mark-number { font-size: 8pt; font-weight: bold; margin-top: 1mm; text-align: center; }
|
||||
.serial-number { font-size: 8pt; font-weight: bold; margin-top: 1mm; }
|
||||
.label-field { font-size: 7.5pt; font-weight: bold; margin-right: 1mm; min-width: 22pt; white-space: nowrap; }
|
||||
.label-value { font-size: 7.5pt; font-weight: bold; flex: 1; overflow-wrap: break-word; word-break: break-word; }
|
||||
.qr-code img { width: 22mm; height: 22mm; margin: 0.5mm 0; }
|
||||
.mark-number { font-size: 7pt; font-weight: bold; margin-top: 0.5mm; text-align: center; }
|
||||
.serial-number { font-size: 7.5pt; font-weight: bold; margin-top: 0.5mm; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="label-container">
|
||||
${labelsHTML}
|
||||
</div>
|
||||
<script>
|
||||
// 标记是否已保存打印记录(避免重复触发)
|
||||
var printRecordSaved = false;
|
||||
// 通过 matchMedia 监听打印状态变化
|
||||
// mediaQuery.matches === true 表示浏览器进入"打印"渲染状态(用户点击了"打印/确认"按钮)
|
||||
// 取消或关闭窗口不会触发此状态切换
|
||||
var mediaQuery = window.matchMedia('print');
|
||||
var handlePrintChange = function(mql) {
|
||||
if (mql.matches && !printRecordSaved) {
|
||||
printRecordSaved = true;
|
||||
// 向父窗口发送消息,通知保存打印记录
|
||||
window.opener && window.opener.postMessage({ type: 'PRINT_CONFIRMED' }, '*');
|
||||
}
|
||||
};
|
||||
if (mediaQuery.addEventListener) {
|
||||
mediaQuery.addEventListener('change', handlePrintChange);
|
||||
} else if (mediaQuery.addListener) {
|
||||
mediaQuery.addListener(handlePrintChange);
|
||||
}
|
||||
<\/script>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
@@ -517,6 +566,46 @@ const printLabel = async () => {
|
||||
printWindow.document.write(printHTML)
|
||||
printWindow.document.close()
|
||||
|
||||
// 监听子窗口发来的打印确认消息,保存打印记录
|
||||
const onPrintConfirmed = async (event: MessageEvent) => {
|
||||
if (event.data && event.data.type === 'PRINT_CONFIRMED') {
|
||||
try {
|
||||
const printRecords = labelsToPrint.map(item => ({
|
||||
workerOrderId: formData.workerOrderId,
|
||||
materialNamePrint: item.partName,
|
||||
encodingPrint: item.partNumber,
|
||||
totalCount: item.totalCount,
|
||||
totalCalculatedWeight: item.totalCalculatedWeight,
|
||||
totalWeight: item.totalWeight,
|
||||
qrCodeData: item.qrCodeData,
|
||||
batch: formData.batch,
|
||||
mark: item.mark,
|
||||
productionDate: item.productionDate,
|
||||
packingSignature: item.packingSignature == '' ? null : item.packingSignature,
|
||||
inspectionSignature: item.inspectionSignature == '' ? null : item.inspectionSignature,
|
||||
}))
|
||||
await savePrintRecord({
|
||||
workerOrderId: formData.workerOrderId,
|
||||
orderNo: formData.orderNo,
|
||||
encoding: formData.encoding,
|
||||
materialName: formData.materialName,
|
||||
materialNamePrint: formData.materialNamePrint,
|
||||
encodingPrint: formData.encodingPrint,
|
||||
batch: formData.batch,
|
||||
labelType: isDetailLabels ? 0 : 1,
|
||||
labelCount: labelsToPrint.length,
|
||||
printInfoList: printRecords,
|
||||
})
|
||||
Message.success('打印记录已保存')
|
||||
} catch (err) {
|
||||
console.error('保存打印记录失败:', err)
|
||||
Message.error('保存打印记录失败')
|
||||
}
|
||||
window.removeEventListener('message', onPrintConfirmed)
|
||||
}
|
||||
}
|
||||
window.addEventListener('message', onPrintConfirmed)
|
||||
|
||||
// 等待图片加载完成后再打印
|
||||
printWindow.onload = () => {
|
||||
setTimeout(() => {
|
||||
@@ -638,12 +727,13 @@ defineOptions({ name: 'print' })
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
flex: 1;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.qr-code img {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
margin: 5px 0;
|
||||
width: 115px;
|
||||
height: 120px;
|
||||
margin: 0 0;
|
||||
}
|
||||
|
||||
.qr-code .loading {
|
||||
|
||||
@@ -132,6 +132,7 @@ const weighingPageStatus = ref<'idle' | 'entering' | 'entered' | 'error'>('idle'
|
||||
|
||||
const [form, resetForm] = useResetReactive({
|
||||
materialCode: '',
|
||||
encodingPrint: '',
|
||||
imgUrl: '',
|
||||
materialName: '',
|
||||
batch: '',
|
||||
@@ -178,6 +179,7 @@ const originalHandleMaterialCodeChange = async () => {
|
||||
form.materialName = ''
|
||||
form.inputMaterialCode2 = ''
|
||||
form.batch = ''
|
||||
form.encodingPrint = ''
|
||||
form.count = undefined
|
||||
form.mark = undefined
|
||||
|
||||
@@ -205,6 +207,7 @@ const fetchMaterialData = async (code: string) => {
|
||||
if (res.code === '0') {
|
||||
// 更新表单数据
|
||||
form.materialCode = res.data?.encoding || ''
|
||||
form.encodingPrint = res.data?.encodingPrint || ''
|
||||
form.materialName = res.data?.materialName || ''
|
||||
form.batch = res.data?.batch || ''
|
||||
}
|
||||
@@ -213,6 +216,7 @@ const fetchMaterialData = async (code: string) => {
|
||||
const handleMaterialCodeChange2 = async (code: string) => {
|
||||
if (!code || code?.trim()=== '') {
|
||||
form.materialCode = ''
|
||||
form.encodingPrint = ''
|
||||
form.materialName = ''
|
||||
form.batch = ''
|
||||
form.mark = undefined
|
||||
@@ -227,6 +231,7 @@ const handleMaterialCodeChange2 = async (code: string) => {
|
||||
if (res.code === '0') {
|
||||
// 更新表单数据
|
||||
form.materialCode = res.data?.encoding || ''
|
||||
form.encodingPrint = res.data?.encodingPrint || ''
|
||||
form.materialName = res.data?.materialName || ''
|
||||
form.batch = res.data?.batch || ''
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
<template>
|
||||
<div class="gi_table_page">
|
||||
<GiTable
|
||||
title="整箱领取记录管理"
|
||||
row-key="id"
|
||||
:data="dataList"
|
||||
:columns="columns"
|
||||
:loading="loading"
|
||||
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
|
||||
:pagination="pagination"
|
||||
:disabled-tools="['size']"
|
||||
:disabled-column-keys="['name']"
|
||||
@refresh="search"
|
||||
title="整箱领取记录管理"
|
||||
row-key="id"
|
||||
:data="dataList"
|
||||
:columns="columns"
|
||||
:loading="loading"
|
||||
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
|
||||
:pagination="pagination"
|
||||
:disabled-tools="['size']"
|
||||
:disabled-column-keys="['name']"
|
||||
@refresh="search"
|
||||
>
|
||||
<template #toolbar-left>
|
||||
<a-input-search v-model="queryForm.orderNo" placeholder="请输入任务工单号" allow-clear @search="search" />
|
||||
<a-input-search v-model="queryForm.materialCode" placeholder="请输入物料编码" allow-clear @search="search" />
|
||||
<a-input-search v-model="queryForm.materialName" placeholder="请输入物料名称" allow-clear @search="search" />
|
||||
<a-input-search v-model="queryForm.batch" placeholder="请输入批次号" allow-clear @search="search" />
|
||||
<a-input-search v-model="queryForm.orderNo" placeholder="请输入任务工单号" allow-clear @search="search" />
|
||||
<a-input-search v-model="queryForm.materialCode" placeholder="请输入物料编码" allow-clear @search="search" />
|
||||
<a-input-search v-model="queryForm.materialName" placeholder="请输入物料名称" allow-clear @search="search" />
|
||||
<a-input-search v-model="queryForm.batch" placeholder="请输入批次号" allow-clear @search="search" />
|
||||
<a-range-picker
|
||||
v-model="queryForm.createTime"
|
||||
:show-time="true"
|
||||
@@ -51,26 +51,26 @@
|
||||
<template #action="{ record }">
|
||||
<a-space>
|
||||
<a-link
|
||||
@click="onAddDetail(record.id)"
|
||||
@click="onAddDetail(record.id)"
|
||||
>
|
||||
新增
|
||||
</a-link>
|
||||
<a-link
|
||||
@click="onViewDetail(record)"
|
||||
@click="onViewDetail(record)"
|
||||
>
|
||||
详情
|
||||
</a-link>
|
||||
<a-link
|
||||
@click="onPrint(record)"
|
||||
@click="onPrint(record)"
|
||||
>
|
||||
打印
|
||||
</a-link>
|
||||
<a-link
|
||||
v-permission="['fullWorkOrder:fullWorkOrder:delete']"
|
||||
status="danger"
|
||||
:disabled="record.disabled"
|
||||
:title="record.disabled ? '不可删除' : '删除'"
|
||||
@click="onDelete(record)"
|
||||
v-permission="['fullWorkOrder:fullWorkOrder:delete']"
|
||||
status="danger"
|
||||
:disabled="record.disabled"
|
||||
:title="record.disabled ? '不可删除' : '删除'"
|
||||
@click="onDelete(record)"
|
||||
>
|
||||
删除
|
||||
</a-link>
|
||||
@@ -191,46 +191,47 @@ const onPrint = async (record: FullWorkOrderResp) => {
|
||||
try {
|
||||
// 格式化生产日期为 yyyyMMddHHmm 格式
|
||||
const now = new Date()
|
||||
const formattedDate = now.getFullYear().toString() +
|
||||
String(now.getMonth() + 1).padStart(2, '0') +
|
||||
String(now.getDate()).padStart(2, '0') +
|
||||
String(now.getHours()).padStart(2, '0') +
|
||||
String(now.getMinutes()).padStart(2, '0')
|
||||
const formattedDate = now.getFullYear().toString() +
|
||||
String(now.getMonth() + 1).padStart(2, '0') +
|
||||
String(now.getDate()).padStart(2, '0') +
|
||||
String(now.getHours()).padStart(2, '0') +
|
||||
String(now.getMinutes()).padStart(2, '0')
|
||||
|
||||
const formattedDate2 = now.getFullYear().toString() +
|
||||
String(now.getMonth() + 1).padStart(2, '0') +
|
||||
String(now.getDate()).padStart(2, '0')
|
||||
|
||||
|
||||
// 计算二维码数据
|
||||
const qrCodeData = `10#${record.materialCode || ''}$11#9DP$12#${record.batch || ''}$17#${record.count || ''}$20#${formattedDate2}$31#${record.orderNo || ''}$DY`
|
||||
|
||||
|
||||
// 生成二维码图片
|
||||
const qrCodeImage = await generateQRCode(qrCodeData)
|
||||
|
||||
|
||||
// 直接生成打印标签
|
||||
const printWindow = window.open('', '_blank');
|
||||
if (!printWindow) return;
|
||||
|
||||
|
||||
// 构建打印内容
|
||||
const printContent = `
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>标签打印</title>
|
||||
<style>
|
||||
body { margin: 0; padding: 10mm; font-family: Arial, sans-serif; }
|
||||
.label-container { display: flex; flex-wrap: wrap; gap: 10mm; justify-content: center; }
|
||||
.label { width: 90mm; height: 38.5mm; border: 1px solid #000; padding: 0; box-sizing: border-box; page-break-inside: avoid; }
|
||||
.label-table { width: 100%; height: 100%; border-collapse: collapse; }
|
||||
.label-cell { border: 1px solid #000; padding: 1mm; vertical-align: top; }
|
||||
.qr-cell { width: 24mm; text-align: center; vertical-align: middle; border: 1px solid #000; }
|
||||
.label-row { display: flex; align-items: center; }
|
||||
.label-field { font-size: 8pt; font-weight: bold; margin-right: 2mm; min-width: 25pt; }
|
||||
.label-value { font-size: 8pt; font-weight: bold; flex: 1; }
|
||||
.qr-code img { width: 20mm; height: 20mm; margin: 1mm 0; }
|
||||
.mark-number { font-size: 8pt; font-weight: bold; margin-top: 1mm; text-align: center; }
|
||||
.serial-number { font-size: 8pt; font-weight: bold; margin-top: 1mm; }
|
||||
</style>
|
||||
<style>
|
||||
@page { size: 80mm 50mm; margin: 0; }
|
||||
body { margin: 0; padding: 1mm; font-family: Arial, sans-serif; }
|
||||
.label-container { display: flex; flex-wrap: wrap; gap: 1mm; justify-content: center; align-items: center; transform-origin: center; }
|
||||
.label { width: 75mm; height: 45mm; border: 1px solid #000; padding: 0; box-sizing: border-box; page-break-inside: avoid; overflow: hidden; margin: 0 auto; }
|
||||
.label-table { width: 100%; height: 100%; border-collapse: collapse; table-layout: fixed; }
|
||||
.label-cell { border: 1px solid #000; padding: 0.8mm; vertical-align: top; }
|
||||
.qr-cell { width: 22mm; text-align: center; vertical-align: middle; border: 1px solid #000; }
|
||||
.label-row { display: flex; align-items: center; }
|
||||
.label-field { font-size: 7.5pt; font-weight: bold; margin-right: 1mm; min-width: 22pt; white-space: nowrap; }
|
||||
.label-value { font-size: 7.5pt; font-weight: bold; flex: 1; overflow-wrap: break-word; word-break: break-word; }
|
||||
.qr-code img { width: 22mm; height: 22mm; margin: 0.5mm 0; }
|
||||
.mark-number { font-size: 7pt; font-weight: bold; margin-top: 0.5mm; text-align: center; }
|
||||
.serial-number { font-size: 7.5pt; font-weight: bold; margin-top: 0.5mm; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="label-container">
|
||||
@@ -304,10 +305,10 @@ const onPrint = async (record: FullWorkOrderResp) => {
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
|
||||
|
||||
printWindow.document.write(printContent);
|
||||
printWindow.document.close();
|
||||
|
||||
|
||||
// 等待页面加载完成后打印
|
||||
printWindow.onload = function() {
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -44,11 +44,6 @@ const loading = ref(false)
|
||||
// 登录
|
||||
const handleLogin = async () => {
|
||||
console.log("卡号登录handleLogin")
|
||||
// 检查用户是否已经登录
|
||||
if (userStore.token) {
|
||||
console.log("卡号-用户已登录")
|
||||
return
|
||||
}
|
||||
|
||||
const isInvalid = await formRef.value?.validate()
|
||||
if (isInvalid) return
|
||||
@@ -75,6 +70,8 @@ const handleLogin = async () => {
|
||||
Message.success('欢迎使用')
|
||||
} catch (error) {
|
||||
// 登录失败处理
|
||||
console.error('刷卡登录失败:', error)
|
||||
Message.error( '登录失败,请刷新页面')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@@ -59,9 +59,6 @@
|
||||
:src="record.photoUrl"
|
||||
/>
|
||||
</template>
|
||||
<!-- <template #lightLevel="{ record }">-->
|
||||
<!-- <GiCellTag :value="record.lightLevel" :dict="light_level" />-->
|
||||
<!-- </template>-->
|
||||
|
||||
<template #action="{ record }">
|
||||
<a-space>
|
||||
@@ -100,12 +97,6 @@ import {Message} from "@arco-design/web-vue";
|
||||
|
||||
defineOptions({ name: 'MaterialInfo' })
|
||||
|
||||
// const { light_level } = useDict('light_level')
|
||||
|
||||
interface MaterialInfoRespWithStatus extends MaterialInfoResp {
|
||||
photoLoadError?: boolean;
|
||||
}
|
||||
|
||||
const queryForm = reactive<MaterialInfoQuery>({
|
||||
materialName: undefined,
|
||||
encoding: undefined,
|
||||
@@ -128,14 +119,14 @@ const {
|
||||
const columns = ref<TableInstanceColumns[]>([
|
||||
{ title: '物料名称', dataIndex: 'materialName', slotName: 'materialName' },
|
||||
{ title: '物料编码', dataIndex: 'encoding', slotName: 'encoding' },
|
||||
{ title: '物料照片', dataIndex: 'photoUrl', slotName: 'photoUrl', width: 120, align: 'center' },
|
||||
{ title: '物料单位重量(g)', dataIndex: 'unitWeight', slotName: 'unitWeight' },
|
||||
{ title: '物料品类', dataIndex: 'typeName' },
|
||||
{ title: '批次', dataIndex: 'batch' },
|
||||
{ title: '物料直径', dataIndex: 'materialSpec', slotName: 'materialSpec', show: false },
|
||||
{ title: '物料颜色', dataIndex: 'color', slotName: 'color', show: false },
|
||||
{ title: '物料流程', dataIndex: 'materialProcess', slotName: 'materialProcess' },
|
||||
{ title: '灯光等级', dataIndex: 'lightLevel', slotName: 'lightLevel' },
|
||||
{ title: '物料照片', dataIndex: 'photoUrl', slotName: 'photoUrl', width: 120, align: 'center' },
|
||||
{ title: '物料流程', dataIndex: 'materialProcess', slotName: 'materialProcess', show: false },
|
||||
{ title: '灯光等级', dataIndex: 'lightLevel', slotName: 'lightLevel', show: false },
|
||||
{ title: '创建人', dataIndex: 'createUserString', slotName: 'createUser' },
|
||||
{ title: '创建时间', dataIndex: 'createTime', slotName: 'createTime' },
|
||||
{
|
||||
@@ -177,17 +168,6 @@ const onExport = () => {
|
||||
useDownload(() => exportMaterialInfo(queryForm))
|
||||
}
|
||||
|
||||
// 【修改点】图片加载处理逻辑
|
||||
const handleImgLoad = (record: MaterialInfoRespWithStatus) => {
|
||||
record.photoLoadError = false
|
||||
}
|
||||
|
||||
const handleImgError = (record: MaterialInfoRespWithStatus, e: Event) => {
|
||||
// 标记为加载错误,触发模板渲染 "照片异常"
|
||||
record.photoLoadError = true
|
||||
console.warn(`物料照片加载失败: ${record.photoUrl}`)
|
||||
}
|
||||
|
||||
const MaterialInfoAddModalRef = ref<InstanceType<typeof MaterialInfoAddModal>>()
|
||||
const onAdd = () => {
|
||||
MaterialInfoAddModalRef.value?.onAdd()
|
||||
|
||||
@@ -477,18 +477,19 @@ const printLabel = async () => {
|
||||
<head>
|
||||
<title>标签打印</title>
|
||||
<style>
|
||||
body { margin: 0; padding: 10mm; font-family: Arial, sans-serif; }
|
||||
.label-container { display: flex; flex-wrap: wrap; gap: 10mm; justify-content: center; }
|
||||
.label { width: 90mm; height: 38.5mm; border: 1px solid #000; padding: 0; box-sizing: border-box; page-break-inside: avoid; }
|
||||
.label-table { width: 100%; height: 100%; border-collapse: collapse; }
|
||||
.label-cell { border: 1px solid #000; padding: 1mm; vertical-align: top; }
|
||||
.qr-cell { width: 24mm; text-align: center; vertical-align: middle; border: 1px solid #000; }
|
||||
@page { size: 80mm 50mm; margin: 0; }
|
||||
body { margin: 0; padding: 1mm; font-family: Arial, sans-serif; }
|
||||
.label-container { display: flex; flex-wrap: wrap; gap: 1mm; justify-content: center; align-items: center; transform-origin: center; }
|
||||
.label { width: 75mm; height: 45mm; border: 1px solid #000; padding: 0; box-sizing: border-box; page-break-inside: avoid; overflow: hidden; margin: 0 auto; }
|
||||
.label-table { width: 100%; height: 100%; border-collapse: collapse; table-layout: fixed; }
|
||||
.label-cell { border: 1px solid #000; padding: 0.8mm; vertical-align: top; }
|
||||
.qr-cell { width: 22mm; text-align: center; vertical-align: middle; border: 1px solid #000; }
|
||||
.label-row { display: flex; align-items: center; }
|
||||
.label-field { font-size: 8pt; font-weight: bold; margin-right: 2mm; min-width: 25pt; }
|
||||
.label-value { font-size: 8pt; font-weight: bold; flex: 1; }
|
||||
.qr-code img { width: 20mm; height: 20mm; margin: 1mm 0; }
|
||||
.mark-number { font-size: 8pt; font-weight: bold; margin-top: 1mm; text-align: center; }
|
||||
.serial-number { font-size: 8pt; font-weight: bold; margin-top: 1mm; }
|
||||
.label-field { font-size: 7.5pt; font-weight: bold; margin-right: 1mm; min-width: 22pt; white-space: nowrap; }
|
||||
.label-value { font-size: 7.5pt; font-weight: bold; flex: 1; overflow-wrap: break-word; word-break: break-word; }
|
||||
.qr-code img { width: 22mm; height: 22mm; margin: 0.5mm 0; }
|
||||
.mark-number { font-size: 7pt; font-weight: bold; margin-top: 0.5mm; text-align: center; }
|
||||
.serial-number { font-size: 7.5pt; font-weight: bold; margin-top: 0.5mm; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -644,12 +645,13 @@ defineOptions({ name: 'LabelPrint' })
|
||||
font-size: 10pt;
|
||||
flex: 1;
|
||||
font-weight: bold;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.qr-code img {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
margin: 5px 0;
|
||||
width: 115px;
|
||||
height: 120px;
|
||||
margin: 0 0;
|
||||
}
|
||||
|
||||
.loading {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<!-- 左侧表单 -->
|
||||
<div class="left-section">
|
||||
<a-image v-if="formData.photoUrl" :src="formData.photoUrl" width="240"/>
|
||||
<!-- <img v-else :src="formData.photoUrl" class="sample-image square-image" alt="样图">-->
|
||||
<!-- <img v-else :src="formData.photoUrl" class="sample-image square-image" alt="样图">-->
|
||||
|
||||
<a-form :model="formData" layout="vertical">
|
||||
<div class="form-row">
|
||||
@@ -83,9 +83,9 @@
|
||||
<!-- 图片展示 -->
|
||||
<div class="image-placeholder square-image">
|
||||
<img
|
||||
:src="imgData.imgUrl"
|
||||
alt="图片展示"
|
||||
style="width: 100%; height: 100%; object-fit: cover; border-radius: 4px;"
|
||||
:src="imgData.imgUrl"
|
||||
alt="图片展示"
|
||||
style="width: 100%; height: 100%; object-fit: cover; border-radius: 4px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -176,9 +176,9 @@
|
||||
<!-- 图片展示 -->
|
||||
<div class="image-placeholder square-image">
|
||||
<img
|
||||
:src="weighingImgData.imgUrl"
|
||||
alt="称重图片"
|
||||
style="width: 100%; height: 100%; object-fit: cover; border-radius: 4px;"
|
||||
:src="weighingImgData.imgUrl"
|
||||
alt="称重图片"
|
||||
style="width: 100%; height: 100%; object-fit: cover; border-radius: 4px;"
|
||||
/>
|
||||
<!-- 错误状态 -->
|
||||
<div v-if="weighingPageStatus === 'error'" class="video-overlay error">
|
||||
@@ -225,9 +225,9 @@
|
||||
<!-- 完成并打印页面 -->
|
||||
<div v-else-if="activeStep === 3" class="step-content">
|
||||
<LabelPrint
|
||||
ref="labelPrintRef"
|
||||
:worker-order-id="workOrderId"
|
||||
@previous="handlePrevious2"
|
||||
ref="labelPrintRef"
|
||||
:worker-order-id="workOrderId"
|
||||
@previous="handlePrevious2"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -450,7 +450,7 @@ const enterStep2 = () => {
|
||||
}
|
||||
})
|
||||
}, 30 * 60 * 1000) // 30分钟
|
||||
|
||||
|
||||
// 启动电子称连接线程并建立WebSocket连接
|
||||
weighAHStart().catch(error => {
|
||||
Message.error('与电子称的连接建立失败')
|
||||
@@ -469,7 +469,7 @@ const leaveWeighingPage = () => {
|
||||
clearTimeout(weighingTimeoutTimer)
|
||||
weighingTimeoutTimer = null
|
||||
}
|
||||
|
||||
|
||||
// 停用电子称并关闭WebSocket连接
|
||||
weighAHStop().catch(error => {
|
||||
console.error('停用电子称失败:', error)
|
||||
@@ -644,13 +644,13 @@ const handleKeyDown = (event: KeyboardEvent) => {
|
||||
isScanning = false
|
||||
// 不阻止默认行为,让表单可以正常提交
|
||||
}
|
||||
// 检查是否是新的扫码开始
|
||||
// 检查是否是新的扫码开始
|
||||
// 当时间间隔大于300ms,且不是修饰键,且不是功能键时,认为是新的扫码开始
|
||||
else if (timeDiff > 300 && !event.ctrlKey && !event.altKey && !event.metaKey) {
|
||||
// 清空输入框,准备接收新的扫码数据
|
||||
formData.inputMaterialCode = ''
|
||||
// 标记为开始扫描
|
||||
isScanning = true
|
||||
// 清空输入框,准备接收新的扫码数据
|
||||
formData.inputMaterialCode = ''
|
||||
// 标记为开始扫描
|
||||
isScanning = true
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -664,21 +664,21 @@ const handleMaterialCodeChange = debounce(originalHandleMaterialCodeChange, 500)
|
||||
// 扫码核验获取物料信息
|
||||
const fetchMaterialData = async (code: string) => {
|
||||
const res = await getMaterialDetail(code);
|
||||
if (res.code === '0') {
|
||||
// 更新表单数据
|
||||
formData.id = res.data?.id || ''
|
||||
formData.encoding = res.data?.encoding || ''
|
||||
formData.materialName = res.data?.materialName || ''
|
||||
formData.materialSpec = res.data?.materialSpec || ''
|
||||
formData.materialProcess = res.data?.materialProcess || ''
|
||||
formData.unitWeight = res.data?.unitWeight || 0
|
||||
formData.photoUrl = res.data?.photoUrl || ''
|
||||
formData.batch = res.data?.batch || ''
|
||||
formData.weightRange = (res.data?.downFloatRatio ?? '-') + '% ~ ' + (res.data?.upFloatRatio ?? '-') + '%'
|
||||
}
|
||||
if(res.data && res.data.id) {
|
||||
await brightness(res.data.id);
|
||||
}
|
||||
if (res.code === '0') {
|
||||
// 更新表单数据
|
||||
formData.id = res.data?.id || ''
|
||||
formData.encoding = res.data?.encoding || ''
|
||||
formData.materialName = res.data?.materialName || ''
|
||||
formData.materialSpec = res.data?.materialSpec || ''
|
||||
formData.materialProcess = res.data?.materialProcess || ''
|
||||
formData.unitWeight = res.data?.unitWeight || 0
|
||||
formData.photoUrl = res.data?.photoUrl || ''
|
||||
formData.batch = res.data?.batch || ''
|
||||
formData.weightRange = (res.data?.downFloatRatio ?? '-') + '% ~ ' + (res.data?.upFloatRatio ?? '-') + '%'
|
||||
}
|
||||
if(res.data && res.data.id) {
|
||||
await brightness(res.data.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -726,11 +726,11 @@ const handleNext = async () => {
|
||||
materialId: formData.id,
|
||||
workOrderInfos: weighingList.value,
|
||||
}
|
||||
|
||||
|
||||
// 调用后端接口
|
||||
const res = await addWorkOrder(workOrderData)
|
||||
console.log('工单创建响应:', res)
|
||||
|
||||
|
||||
if (res.code === '0') {
|
||||
Notification.success({
|
||||
title: '操作成功',
|
||||
@@ -992,7 +992,7 @@ const closeWebSocket = () => {
|
||||
|
||||
// 播放音频文件
|
||||
const playAudio = (filename: string) => {
|
||||
console.log(filename)
|
||||
console.log(filename)
|
||||
try {
|
||||
// 创建音频对象并播放
|
||||
const audio = new Audio(`/src/assets/wav/${filename}.wav`)
|
||||
|
||||
@@ -169,8 +169,6 @@ const processColumns = (columns: TableInstanceColumns[]): TableInstanceColumns[]
|
||||
// 定义列配置,使用工具函数处理
|
||||
const columns = ref<TableInstanceColumns[]>(processColumns([
|
||||
{ title: '标题', dataIndex: 'title', width: 180 },
|
||||
{ title: '创建人', dataIndex: 'createUserString' },
|
||||
{ title: '人员卡号', dataIndex: 'cardNo' },
|
||||
{ title: '任务工单号', dataIndex: 'orderNo' },
|
||||
{ title: '批次', dataIndex: 'batch' },
|
||||
{ title: '物料图片', dataIndex: 'photoUrl', slotName: 'photoUrl', minWidth: 180, ellipsis: true, tooltip: true },
|
||||
@@ -180,6 +178,8 @@ const columns = ref<TableInstanceColumns[]>(processColumns([
|
||||
{ title: '总数量', dataIndex: 'totalCount' },
|
||||
{ title: '标准总重量', dataIndex: 'totalCalculatedWeight' ,slotName: 'totalCalculatedWeight'},
|
||||
{ title: '实际总重量', dataIndex: 'totalWeight' ,slotName: 'totalWeight'},
|
||||
{ title: '人员卡号', dataIndex: 'cardNo' },
|
||||
{ title: '创建人', dataIndex: 'createUserString' },
|
||||
{ title: '创建时间', dataIndex: 'createTime', width: 180 },
|
||||
{
|
||||
title: '操作',
|
||||
|
||||
Reference in New Issue
Block a user