Compare commits
2 Commits
2bf7b6872a
...
47463c9b14
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47463c9b14 | ||
|
|
3f8b6e4695 |
@@ -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<WeighManageResp>(`/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)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ export interface WorkOrderResp {
|
||||
updateUserString: string
|
||||
matchResult: string
|
||||
workOrderInfos: Array<WorkOrderInfoResp>
|
||||
qrCodeData: string
|
||||
}
|
||||
|
||||
export interface WorkOrderInfoResp {
|
||||
|
||||
5
src/types/components.d.ts
vendored
5
src/types/components.d.ts
vendored
@@ -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']
|
||||
|
||||
@@ -36,18 +36,23 @@
|
||||
|
||||
<!-- 标签预览 -->
|
||||
<div v-if="labelData.partName" class="label-preview-section">
|
||||
<!-- <div class="label-preview-section">-->
|
||||
<h3>标签预览</h3>
|
||||
<div class="label-container" ref="labelContainer">
|
||||
<div class="label" v-for="index in 1" :key="index">
|
||||
<table class="label-table">
|
||||
<tr>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">零件名称</div>
|
||||
<div class="label-value">{{ labelData.partName }}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">生产日期</div>
|
||||
<div class="label-value">{{ labelData.productionDate }}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="label-cell qr-cell" rowspan="4">
|
||||
<div class="qr-code">
|
||||
@@ -57,32 +62,44 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">零件号</div>
|
||||
<div class="label-value">{{ labelData.partNumber }}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">数量</div>
|
||||
<div class="label-value">{{ labelData.totalCount }}</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">标重(kg)</div>
|
||||
<div class="label-value">{{ labelData.totalCalculatedWeight }}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">包装签字</div>
|
||||
<div class="label-value">{{ labelData.packingSignature || '' }}</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">实重(kg)</div>
|
||||
<div class="label-value">{{ labelData.totalWeight || '' }}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">检验签字</div>
|
||||
<div class="label-value">{{ labelData.inspectionSignature || '' }}</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -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<HTMLElement | null>(null)
|
||||
|
||||
@@ -152,6 +183,10 @@ const generateLabel = async () => {
|
||||
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, {
|
||||
partName: formData.materialName || '',
|
||||
@@ -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 = `
|
||||
<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: 36mm; border: 1px solid #000; padding: 0; box-sizing: border-box; page-break-inside: avoid; }
|
||||
.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; }
|
||||
.label-field { font-size: 7pt; font-weight: bold; margin-bottom: 0.5mm; }
|
||||
.label-value { font-size: 7pt; }
|
||||
.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: 7pt; font-weight: bold; margin-right: 2mm; min-width: 25pt; }
|
||||
.label-value { font-size: 7pt; flex: 1; }
|
||||
.qr-code img { width: 20mm; height: 20mm; margin: 1mm 0; }
|
||||
.serial-number { font-size: 7pt; margin-top: 1mm; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
${printContent.innerHTML}
|
||||
<div class="label-container">
|
||||
<div class="label">
|
||||
<table class="label-table">
|
||||
<tr>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">零件名称</div>
|
||||
<div class="label-value">${labelData.partName}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">生产日期</div>
|
||||
<div class="label-value">${labelData.productionDate}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="label-cell qr-cell" rowspan="4">
|
||||
<div class="qr-code">
|
||||
<img src="https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${encodeURIComponent(labelData.qrCodeData)}" alt="QR Code" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">零件号</div>
|
||||
<div class="label-value">${labelData.partNumber}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">数量</div>
|
||||
<div class="label-value">${labelData.totalCount}</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">标重(kg)</div>
|
||||
<div class="label-value">${labelData.totalCalculatedWeight}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">包装签字</div>
|
||||
<div class="label-value">${labelData.packingSignature || ''}</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">实重(kg)</div>
|
||||
<div class="label-value">${labelData.totalWeight || ''}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="label-cell">
|
||||
<div class="label-row">
|
||||
<div class="label-field">检验签字</div>
|
||||
<div class="label-value">${labelData.inspectionSignature || ''}</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`)
|
||||
`
|
||||
|
||||
printWindow.document.write(printHTML)
|
||||
printWindow.document.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 {
|
||||
|
||||
@@ -49,7 +49,7 @@ const columns: ColumnItem[] = reactive([
|
||||
field: 'configKey',
|
||||
type: 'input',
|
||||
span: 24,
|
||||
disabled: true,
|
||||
disabled: isUpdate.value,
|
||||
},
|
||||
{
|
||||
label: '参数键值',
|
||||
|
||||
@@ -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<HTMLVideoElement | null>(null)
|
||||
// FLV播放器实例
|
||||
let player: any = null
|
||||
|
||||
const reconnectCount = ref(0)
|
||||
const maxReconnectAttempts = 5
|
||||
const reconnectCount = ref(1)
|
||||
const maxReconnectAttempts = 3
|
||||
const reconnectTimer = ref<any>(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<WorkOrderResp>({
|
||||
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,18 @@ 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 || '系统异常!')
|
||||
}
|
||||
});
|
||||
|
||||
// 立即创建一个新项的基本数据
|
||||
const newItem = {
|
||||
key: (weighingList.value.length + 1).toString(),
|
||||
@@ -878,7 +854,7 @@ const handleConfirm = () => {
|
||||
|
||||
// 重置输入(让用户能继续输入)
|
||||
inputQuantity.value = ''
|
||||
ahDeviceWeight.value = '10'
|
||||
ahDeviceWeight.value = ''
|
||||
calculatedWeight.value = ''
|
||||
weighingCount.value = weighingList.value.length + 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user