From 3f8b6e46956d893aebeb75f7cac8402120998d43 Mon Sep 17 00:00:00 2001 From: zc Date: Mon, 9 Mar 2026 20:34:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/weightManage/weightManage.ts | 8 +- src/apis/workOrder/workOrder.ts | 1 + src/types/components.d.ts | 5 + src/views/barcodePrint/index.vue | 181 ++++++++++++++---- src/views/system/sysConfig/ConfigAddModal.vue | 2 +- src/views/weightManage/index.vue | 79 +++----- 6 files changed, 187 insertions(+), 89 deletions(-) diff --git a/src/apis/weightManage/weightManage.ts b/src/apis/weightManage/weightManage.ts index 2d8feaa..b4c3f1a 100644 --- a/src/apis/weightManage/weightManage.ts +++ b/src/apis/weightManage/weightManage.ts @@ -1,6 +1,6 @@ import http from '@/utils/http' -const BASE_URL = '/weighManage/material' +const BASE_URL = '/weighManage/workOrder' export interface WeighManageResp { id: string @@ -21,7 +21,7 @@ export function getMaterialDetail(code: string) { return http.get(`/admin/materialInfo/code/${code}`) } -/** @desc 新增人员管理 */ -export function addPeople(data: any) { - return http.post(`${BASE_URL}`, data) +/** @desc 校验称重信息 */ +export function validateWeighing(data: any) { + return http.post(`${BASE_URL}/validateWeighing`, data) } diff --git a/src/apis/workOrder/workOrder.ts b/src/apis/workOrder/workOrder.ts index eaa3cc1..64be349 100644 --- a/src/apis/workOrder/workOrder.ts +++ b/src/apis/workOrder/workOrder.ts @@ -18,6 +18,7 @@ export interface WorkOrderResp { updateUserString: string matchResult: string workOrderInfos: Array + qrCodeData: string } export interface WorkOrderInfoResp { diff --git a/src/types/components.d.ts b/src/types/components.d.ts index 19adc08..b565da9 100644 --- a/src/types/components.d.ts +++ b/src/types/components.d.ts @@ -26,6 +26,8 @@ declare module 'vue' { AEmpty: typeof import('@arco-design/web-vue')['Empty'] AForm: typeof import('@arco-design/web-vue')['Form'] AFormItem: typeof import('@arco-design/web-vue')['FormItem'] + AGrid: typeof import('@arco-design/web-vue')['Grid'] + AGridItem: typeof import('@arco-design/web-vue')['GridItem'] AIcon: typeof import('@arco-design/web-vue')['Icon'] AImage: typeof import('@arco-design/web-vue')['Image'] AInput: typeof import('@arco-design/web-vue')['Input'] @@ -41,8 +43,10 @@ declare module 'vue' { AModal: typeof import('@arco-design/web-vue')['Modal'] APagination: typeof import('@arco-design/web-vue')['Pagination'] APopover: typeof import('@arco-design/web-vue')['Popover'] + AProgress: typeof import('@arco-design/web-vue')['Progress'] ARadio: typeof import('@arco-design/web-vue')['Radio'] ARadioGroup: typeof import('@arco-design/web-vue')['RadioGroup'] + ARangePicker: typeof import('@arco-design/web-vue')['RangePicker'] ARow: typeof import('@arco-design/web-vue')['Row'] AScrollbar: typeof import('@arco-design/web-vue')['Scrollbar'] ASelect: typeof import('@arco-design/web-vue')['Select'] @@ -56,6 +60,7 @@ declare module 'vue' { ATag: typeof import('@arco-design/web-vue')['Tag'] ATooltip: typeof import('@arco-design/web-vue')['Tooltip'] ATreeSelect: typeof import('@arco-design/web-vue')['TreeSelect'] + AUpload: typeof import('@arco-design/web-vue')['Upload'] Avatar: typeof import('./../components/Avatar/index.vue')['default'] AWatermark: typeof import('@arco-design/web-vue')['Watermark'] Breadcrumb: typeof import('./../components/Breadcrumb/index.vue')['default'] diff --git a/src/views/barcodePrint/index.vue b/src/views/barcodePrint/index.vue index 692b0c2..3518e12 100644 --- a/src/views/barcodePrint/index.vue +++ b/src/views/barcodePrint/index.vue @@ -36,18 +36,23 @@
+

标签预览

-
零件名称
-
{{ labelData.partName }}
+
+
零件名称
+
{{ labelData.partName }}
+
-
生产日期
-
{{ labelData.productionDate }}
+
+
生产日期
+
{{ labelData.productionDate }}
+
@@ -57,32 +62,44 @@
-
零件号
-
{{ labelData.partNumber }}
+
+
零件号
+
{{ labelData.partNumber }}
+
-
数量
-
{{ labelData.totalCount }}
+
+
数量
+
{{ labelData.totalCount }}
+
-
标重(kg)
-
{{ labelData.totalCalculatedWeight }}
+
+
标重(kg)
+
{{ labelData.totalCalculatedWeight }}
+
-
包装签字
-
{{ labelData.packingSignature || '' }}
+
+
包装签字
+
{{ labelData.packingSignature || '' }}
+
-
实重(kg)
-
{{ labelData.totalWeight || '' }}
+
+
实重(kg)
+
{{ labelData.totalWeight || '' }}
+
-
检验签字
-
{{ labelData.inspectionSignature || '' }}
+
+
检验签字
+
{{ labelData.inspectionSignature || '' }}
+
@@ -113,7 +130,8 @@ const formData = reactive({ totalCalculatedWeight: '', totalWeight: '', totalCount: '', - productionBatch: '' + productionBatch: '', + qrCodeData: '', }) // 标签数据 @@ -129,6 +147,19 @@ const labelData = reactive({ qrCodeData: '', }) +// 标签数据 +// const labelData = reactive({ +// partName: '物料3', +// partNumber: '1', +// totalCalculatedWeight: '100', +// totalWeight: '100', +// productionDate: '202401010000', +// totalCount: '100', +// packingSignature: '', +// inspectionSignature: '', +// qrCodeData: '10#$$DY', +// }) + // 标签容器引用 const labelContainer = ref(null) @@ -151,6 +182,10 @@ const generateLabel = async () => { 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'); // 直接从 formData 中获取数据 Object.assign(labelData, { @@ -162,7 +197,8 @@ const generateLabel = async () => { totalCount: formData.totalCount || '', packingSignature: '', inspectionSignature: '', - qrCodeData: `PART:${formData.encoding || 'PP0449002'},NAME:${formData.materialName || 'PP0449002护套'},DATE:${formattedDate},QTY:200`, + //10#零件号$11#供应商代码$12#生产批次$17#数量$20#包装日期$31#唯一号$DY + qrCodeData: `10#${formData.materialName}$11#9DP$12#${formData.productionBatch}$17#${formData.totalCount}$20#${formattedDate2}$31#${formData.orderNo}$DY` }) Message.success('标签生成成功') @@ -187,7 +223,6 @@ onMounted(() => { formData.totalCalculatedWeight = res.data.totalCalculatedWeight formData.totalWeight = res.data.totalWeight formData.totalCount = res.data.totalCount - } else { Message.error('获取详情失败') } @@ -202,38 +237,111 @@ onMounted(() => { const printLabel = async () => { await nextTick() if (labelContainer.value) { - // 克隆标签容器内容用于打印 - const printContent = labelContainer.value.cloneNode(true) as HTMLElement - // 创建打印窗口 const printWindow = window.open('', '_blank') if (printWindow) { - printWindow.document.write(` + // 直接构建打印内容,确保二维码图片正确生成 + const printHTML = ` 标签打印 - ${printContent.innerHTML} +
+
+ + + + + + + + + + + + + + + + + + +
+
+
零件名称
+
${labelData.partName}
+
+
+
+
生产日期
+
${labelData.productionDate}
+
+
+
+ QR Code +
+
+
+
零件号
+
${labelData.partNumber}
+
+
+
+
数量
+
${labelData.totalCount}
+
+
+
+
标重(kg)
+
${labelData.totalCalculatedWeight}
+
+
+
+
包装签字
+
${labelData.packingSignature || ''}
+
+
+
+
实重(kg)
+
${labelData.totalWeight || ''}
+
+
+
+
检验签字
+
${labelData.inspectionSignature || ''}
+
+
+
+
- `) + ` + + printWindow.document.write(printHTML) printWindow.document.close() - printWindow.focus() - printWindow.print() - printWindow.close() + + // 等待图片加载完成后再打印 + printWindow.onload = () => { + setTimeout(() => { + printWindow.focus() + printWindow.print() + printWindow.close() + }, 500) + } } } } @@ -330,14 +438,21 @@ defineOptions({ name: 'BarcodePrint' }) vertical-align: middle; } +.label-row { + display: flex; + align-items: center; +} + .label-field { font-size: 12px; font-weight: bold; - margin-bottom: 2px; + margin-right: 10px; + min-width: 60px; } .label-value { font-size: 12px; + flex: 1; } .qr-code img { diff --git a/src/views/system/sysConfig/ConfigAddModal.vue b/src/views/system/sysConfig/ConfigAddModal.vue index b3ec214..3eb1e1d 100644 --- a/src/views/system/sysConfig/ConfigAddModal.vue +++ b/src/views/system/sysConfig/ConfigAddModal.vue @@ -49,7 +49,7 @@ const columns: ColumnItem[] = reactive([ field: 'configKey', type: 'input', span: 24, - disabled: true, + disabled: isUpdate.value, }, { label: '参数键值', diff --git a/src/views/weightManage/index.vue b/src/views/weightManage/index.vue index 5434a93..f9742f7 100644 --- a/src/views/weightManage/index.vue +++ b/src/views/weightManage/index.vue @@ -271,8 +271,8 @@ import { nextTick, onBeforeUnmount, onMounted, onUnmounted, reactive, ref } from 'vue' import { Message, Modal, Notification } from '@arco-design/web-vue' -import { getMaterialDetail } from '@/apis/weightManage/weightManage' -import { type WorkOrderResp, addWorkOrder } from '@/apis/workOrder/workOrder' +import {getMaterialDetail, validateWeighing} from '@/apis/weightManage/weightManage' +import {type WorkOrderResp, addWorkOrder, getWorkOrder} from '@/apis/workOrder/workOrder' import { catchPhoto } from '@/apis/material/materialInfo' defineOptions({ name: 'WeightManage' }) @@ -304,8 +304,8 @@ const cameraVideo = ref(null) // FLV播放器实例 let player: any = null -const reconnectCount = ref(0) -const maxReconnectAttempts = 5 +const reconnectCount = ref(1) +const maxReconnectAttempts = 3 const reconnectTimer = ref(null) // 直接写死FLV流地址(根据你的实际地址修改) @@ -367,12 +367,13 @@ const initCamera = () => { player.load() player.play().then(() => { cameraStatus.value = 'connected' - reconnectCount.value = 0 // 连接成功,重置重连计数 + reconnectCount.value = 1 // 连接成功,重置重连计数 }).catch((error: any) => { cameraStatus.value = 'error' Message.error('摄像头播放失败,正在重连') // 触发自动重连 handleReconnect() + return }) // 监听各种事件 @@ -404,7 +405,6 @@ const handleReconnect = () => { // 检查重连次数 if (reconnectCount.value >= maxReconnectAttempts) { - Message.error('摄像头连接失败,请手动重试') return } @@ -427,7 +427,7 @@ const handleReconnect = () => { // 重新连接摄像头(手动) const reconnectCamera = () => { - reconnectCount.value = 0 // 手动重连时重置计数 + reconnectCount.value = 1 // 手动重连时重置计数 initCamera() } @@ -454,7 +454,7 @@ let statusCheckTimer: any = null watch(activeStep, (newVal) => { if (newVal === 2) { // 进入称重登记页面,启动摄像头 - reconnectCount.value = 0 // 重置重连计数 + reconnectCount.value = 1 // 重置重连计数 nextTick(() => { initCamera() }) @@ -472,7 +472,7 @@ watch(activeStep, (newVal) => { clearTimeout(reconnectTimer.value) reconnectTimer.value = null } - reconnectCount.value = 0 + reconnectCount.value = 1 } }) @@ -514,7 +514,7 @@ const stopCamera = () => { clearTimeout(reconnectTimer.value) reconnectTimer.value = null } - reconnectCount.value = 0 + reconnectCount.value = 1 } // 监听步骤变化 @@ -556,11 +556,12 @@ const workOrderResp = ref({ totalCalculatedWeight: '', workOrderInfos: [], matchResult: 'failed', + qrCodeData: '', }) // 称重登记页面数据 const inputQuantity = ref('') -const ahDeviceWeight = ref('10') +const ahDeviceWeight = ref('') const calculatedWeight = ref('') const weighingCount = ref(1) @@ -786,7 +787,7 @@ const handleBackToFirst = () => { // 重置称重登记页面数据 inputQuantity.value = '' - ahDeviceWeight.value = '10' + ahDeviceWeight.value = '' calculatedWeight.value = '' weighingCount.value = 1 // 清空称重列表 @@ -812,45 +813,8 @@ const calculateWeight = () => { } } -// 处理确定 -/* const handleConfirm = async () => { - // 校验输入数量是否为空 - if (!inputQuantity.value || inputQuantity.value.trim() === '') { - Message.error('请输入数量') - return - } - if (!ahDeviceWeight.value || ahDeviceWeight.value.trim() === '') { - Message.error('电子秤称重结果为空!') - return - } - - // 2. 抓拍当前画面 - let captureUrl = '' - if (cameraVideo.value && cameraStatus.value === 'connected') { - captureUrl = await capturePhoto() - } - console.log(captureUrl) - // 生成新的列表数据 - const newItem = { - key: (weighingList.value.length + 1).toString(), - weightTime: weighingCount.value, - materialId: formData.id, - quantity: inputQuantity.value, - weight: ahDeviceWeight.value, - calculatedWeight: calculatedWeight.value, - image: captureUrl || '未抓拍', - } - // 添加到列表 - weighingList.value.push(newItem) - // 重置输入 - inputQuantity.value = '' - ahDeviceWeight.value = '10' - calculatedWeight.value = '' - // 称重次数累加 - weighingCount.value = weighingList.value.length + 1 - Message.success('添加成功') -} */ +//处理确定 const handleConfirm = () => { // 校验输入数量是否为空 if (!inputQuantity.value || inputQuantity.value.trim() === '') { @@ -862,6 +826,19 @@ const handleConfirm = () => { return } + const data = { + materialId: formData.id, + inputQuantity: inputQuantity.value, + ahDeviceWeight: ahDeviceWeight.value, + } + + validateWeighing(data).then(res => { + if (res.code != '0') { + Message.error(res.msg || '系统异常!') + } + }); + return; + // 立即创建一个新项的基本数据 const newItem = { key: (weighingList.value.length + 1).toString(), @@ -878,7 +855,7 @@ const handleConfirm = () => { // 重置输入(让用户能继续输入) inputQuantity.value = '' - ahDeviceWeight.value = '10' + ahDeviceWeight.value = '' calculatedWeight.value = '' weighingCount.value = weighingList.value.length + 1