diff --git a/src/apis/workOrder/workOrder.ts b/src/apis/workOrder/workOrder.ts index 009c2bd..eaa3cc1 100644 --- a/src/apis/workOrder/workOrder.ts +++ b/src/apis/workOrder/workOrder.ts @@ -12,10 +12,12 @@ export interface WorkOrderResp { materialSpec: string photoUrl: string totalWeight: string + totalCalculatedWeight: string totalCount: string createUserString: string updateUserString: string matchResult: string + workOrderInfos: Array } export interface WorkOrderInfoResp { @@ -46,9 +48,14 @@ export function listWorkOrder(query: WorkOrderPageQuery) { return http.get>(`${BASE_URL}`, query) } +/** @desc 查询工作订单详情 */ +export function getWorkOrderInfos(id: string) { + return http.get>(`${BASE_URL}/info/${id}`) +} + /** @desc 查询工作订单详情 */ export function getWorkOrder(id: string) { - return http.get>(`${BASE_URL}/${id}`) + return http.get(`${BASE_URL}/${id}`) } /** @desc 新增工作订单 */ diff --git a/src/views/system/barcodePrint/index.vue b/src/views/barcodePrint/index.vue similarity index 77% rename from src/views/system/barcodePrint/index.vue rename to src/views/barcodePrint/index.vue index 3e943ad..692b0c2 100644 --- a/src/views/system/barcodePrint/index.vue +++ b/src/views/barcodePrint/index.vue @@ -9,17 +9,17 @@
- +
- +
- +
@@ -62,13 +62,13 @@
数量
-
{{ labelData.quantity }}
+
{{ labelData.totalCount }}
标重(kg)
-
{{ labelData.standardWeight }}
+
{{ labelData.totalCalculatedWeight }}
包装签字
@@ -78,19 +78,13 @@
实重(kg)
-
{{ labelData.actualWeight || '' }}
+
{{ labelData.totalWeight || '' }}
检验签字
{{ labelData.inspectionSignature || '' }}
- - - - - -
@@ -106,80 +100,71 @@ import { ref, reactive, nextTick, onMounted } from 'vue' import { Message } from '@arco-design/web-vue' import { useRoute } from 'vue-router' +import {getWorkOrder} from "@/apis/workOrder/workOrder"; const route = useRoute() // 表单数据 const formData = reactive({ + workerOrderId: '', encoding: '', materialName: '', orderNo: '', + totalCalculatedWeight: '', + totalWeight: '', + totalCount: '', productionBatch: '' }) -// 是否是从工单页面跳转过来的 -const isFromWorkOrder = ref(false) - // 标签数据 const labelData = reactive({ partName: '', partNumber: '', - standardWeight: '', - actualWeight: '', + totalCalculatedWeight: '', + totalWeight: '', productionDate: '', - quantity: '', + totalCount: '', packingSignature: '', inspectionSignature: '', - serialNumber: '', qrCodeData: '', }) // 标签容器引用 const labelContainer = ref(null) -// 模拟获取标签数据的接口 -const fetchLabelData = async (params: any) => { - // 模拟后端接口延迟 - return new Promise((resolve) => { - setTimeout(() => { - // 格式化生产日期为 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 mockData = { - partName: params.materialName || 'PP0449002护套', - partNumber: params.encoding || 'PP0449002', - standardWeight: '0.39500', - actualWeight: '', - productionDate: formattedDate, - quantity: '200', - packingSignature: '', - inspectionSignature: '', - serialNumber: '4', - qrCodeData: `PART:${params.encoding || 'PP0449002'},NAME:${params.materialName || 'PP0449002护套'},DATE:${formattedDate},QTY:200`, - } - resolve(mockData) - }, 500) - }) -} - // 生成标签 const generateLabel = async () => { - if (!formData.productionBatch) { Message.error('请输入生产批次') return } + if (!formData.materialName) { + Message.error('未获取到物料信息') + return + } try { - // 获取标签数据 - const result = await fetchLabelData(formData) - Object.assign(labelData, result) + // 格式化生产日期为 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') + + // 直接从 formData 中获取数据 + Object.assign(labelData, { + partName: formData.materialName || '', + partNumber: formData.encoding || '', + totalCalculatedWeight: formData.totalCalculatedWeight || '', + totalWeight: formData.totalWeight || '', + productionDate: formattedDate, + totalCount: formData.totalCount || '', + packingSignature: '', + inspectionSignature: '', + qrCodeData: `PART:${formData.encoding || 'PP0449002'},NAME:${formData.materialName || 'PP0449002护套'},DATE:${formattedDate},QTY:200`, + }) + Message.success('标签生成成功') } catch (error) { console.error('生成标签失败:', error) @@ -190,17 +175,24 @@ const generateLabel = async () => { // 组件挂载时,检查是否有参数传递 onMounted(() => { // 从路由参数中获取数据 - const materialName = route.query.materialName as string - const encoding = route.query.encoding as string - const orderNo = route.query.orderNo as string - + const workerOrderId = route.query.workerOrderId as string // 如果有参数传递,设置表单数据并标记为不可修改 - if (materialName && encoding && orderNo) { - formData.materialName = materialName - formData.encoding = encoding - formData.orderNo = orderNo - isFromWorkOrder.value = true - + if (workerOrderId) { + formData.workerOrderId = workerOrderId + getWorkOrder(workerOrderId).then(res => { + if (res.code == '0') { + formData.encoding = res.data.encoding + formData.materialName = res.data.materialName + formData.orderNo = res.data.orderNo + formData.totalCalculatedWeight = res.data.totalCalculatedWeight + formData.totalWeight = res.data.totalWeight + formData.totalCount = res.data.totalCount + + } else { + Message.error('获取详情失败') + } + }); + // 自动生成标签 generateLabel() } diff --git a/src/views/login/components/card/index.vue b/src/views/login/components/card/index.vue index de4749d..a1cad24 100644 --- a/src/views/login/components/card/index.vue +++ b/src/views/login/components/card/index.vue @@ -20,7 +20,7 @@ diff --git a/src/views/weightManage/index.vue b/src/views/weightManage/index.vue index e39c0c6..931a09a 100644 --- a/src/views/weightManage/index.vue +++ b/src/views/weightManage/index.vue @@ -792,7 +792,7 @@ const calculateWeight = () => { // 处理确定 -const handleConfirm = () => { +const handleConfirm = () => { // 校验输入数量是否为空 if (!inputQuantity.value || inputQuantity.value.trim() === '') { Message.error('请输入数量') @@ -803,6 +803,12 @@ const handleConfirm = () => { return } + // 2. 抓拍当前画面 + let captureUrl = '' + if (cameraVideo.value && cameraStatus.value === 'connected') { + captureUrl = capturePhoto(); + } + // 生成新的列表数据 const newItem = { key: (weighingList.value.length + 1).toString(), @@ -825,7 +831,7 @@ const handleConfirm = () => { } // 抓拍功能 - 内部方法,不暴露按钮 -const capturePhoto = async (): Promise => { +const capturePhoto = (): Promise => { return new Promise(async (resolve, reject) => { try { const video = cameraVideo.value @@ -852,7 +858,7 @@ const capturePhoto = async (): Promise => { // 调用后端接口 const response = await catchPhoto(formData) - if (!response.code === '200') { + if (response.code !== '200') { reject(new Error('上传失败')) return } diff --git a/src/views/workOrder/index.vue b/src/views/workOrder/index.vue index 145fe30..1e2fdeb 100644 --- a/src/views/workOrder/index.vue +++ b/src/views/workOrder/index.vue @@ -117,7 +117,7 @@ import {Message} from "@arco-design/web-vue"; import { useRouter } from 'vue-router'; import { deleteWorkOrder, - exportWorkOrder, getWorkOrder, + exportWorkOrder, getWorkOrderInfos, listWorkOrder, type WorkOrderQuery, type WorkOrderResp @@ -218,7 +218,7 @@ const onDetail = async (record: WorkOrderResp) => { detailModalVisible.value = true detailData.value = [] - getWorkOrder(record.id).then(res => { + getWorkOrderInfos(record.id).then(res => { if (res.code == '0') { detailData.value = res.data; detailLoading.value = false @@ -258,9 +258,7 @@ const onPrint = (record: WorkOrderResp) => { router.push({ path: '/print', query: { - materialName: record.materialName, - encoding: record.encoding, - orderNo: record.orderNo + workerOrderId: record.id, } }) }