Compare commits
3 Commits
630a98af65
...
2bf7b6872a
| Author | SHA1 | Date | |
|---|---|---|---|
| 2bf7b6872a | |||
|
|
a3cb2263fd | ||
|
|
d8273464c5 |
@@ -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<WorkOrderInfoResp>
|
||||
}
|
||||
|
||||
export interface WorkOrderInfoResp {
|
||||
@@ -46,9 +48,14 @@ export function listWorkOrder(query: WorkOrderPageQuery) {
|
||||
return http.get<PageRes<WorkOrderResp[]>>(`${BASE_URL}`, query)
|
||||
}
|
||||
|
||||
/** @desc 查询工作订单详情 */
|
||||
export function getWorkOrderInfos(id: string) {
|
||||
return http.get<Array<WorkOrderInfoResp>>(`${BASE_URL}/info/${id}`)
|
||||
}
|
||||
|
||||
/** @desc 查询工作订单详情 */
|
||||
export function getWorkOrder(id: string) {
|
||||
return http.get<Array<WorkOrderInfoResp>>(`${BASE_URL}/${id}`)
|
||||
return http.get<WorkOrderResp>(`${BASE_URL}/${id}`)
|
||||
}
|
||||
|
||||
/** @desc 新增工作订单 */
|
||||
|
||||
@@ -9,17 +9,17 @@
|
||||
<div class="form-grid">
|
||||
<div class="form-grid-item">
|
||||
<a-form-item label="物料名称">
|
||||
<a-input v-model="formData.materialName" placeholder="请输入物料名称" :disabled="isFromWorkOrder" />
|
||||
<a-input v-model="formData.materialName" placeholder="未获取到物料名称" :disabled="true" />
|
||||
</a-form-item>
|
||||
</div>
|
||||
<div class="form-grid-item">
|
||||
<a-form-item label="物料编码">
|
||||
<a-input v-model="formData.encoding" placeholder="请输入物料编码" :disabled="isFromWorkOrder" />
|
||||
<a-input v-model="formData.encoding" placeholder="未获取到物料编码" :disabled="true" />
|
||||
</a-form-item>
|
||||
</div>
|
||||
<div class="form-grid-item">
|
||||
<a-form-item label="工单编号">
|
||||
<a-input v-model="formData.orderNo" placeholder="请输入工单编号" :disabled="isFromWorkOrder" />
|
||||
<a-input v-model="formData.orderNo" placeholder="未获取到工单编号" :disabled="true" />
|
||||
</a-form-item>
|
||||
</div>
|
||||
<div class="form-grid-item">
|
||||
@@ -62,13 +62,13 @@
|
||||
</td>
|
||||
<td class="label-cell">
|
||||
<div class="label-field">数量</div>
|
||||
<div class="label-value">{{ labelData.quantity }}</div>
|
||||
<div class="label-value">{{ labelData.totalCount }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">
|
||||
<div class="label-field">标重(kg)</div>
|
||||
<div class="label-value">{{ labelData.standardWeight }}</div>
|
||||
<div class="label-value">{{ labelData.totalCalculatedWeight }}</div>
|
||||
</td>
|
||||
<td class="label-cell">
|
||||
<div class="label-field">包装签字</div>
|
||||
@@ -78,19 +78,13 @@
|
||||
<tr>
|
||||
<td class="label-cell">
|
||||
<div class="label-field">实重(kg)</div>
|
||||
<div class="label-value">{{ labelData.actualWeight || '' }}</div>
|
||||
<div class="label-value">{{ labelData.totalWeight || '' }}</div>
|
||||
</td>
|
||||
<td class="label-cell">
|
||||
<div class="label-field">检验签字</div>
|
||||
<div class="label-value">{{ labelData.inspectionSignature || '' }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- <tr>-->
|
||||
<!-- <td class="label-cell" colspan="2"></td>-->
|
||||
<!-- <td class="label-cell qr-cell">-->
|
||||
<!-- <div class="serial-number">序号: {{ labelData.serialNumber }}</div>-->
|
||||
<!-- </td>-->
|
||||
<!-- </tr>-->
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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<HTMLElement | null>(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()
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ref, reactive, onMounted, onUnmounted } from 'vue'
|
||||
import { type FormInstance, Message } from '@arco-design/web-vue'
|
||||
import { useTabsStore, useUserStore } from '@/stores'
|
||||
|
||||
@@ -42,12 +42,24 @@ const loading = ref(false)
|
||||
|
||||
// 登录
|
||||
const handleLogin = async () => {
|
||||
// 检查用户是否已经登录
|
||||
if (userStore.token) {
|
||||
return
|
||||
}
|
||||
|
||||
const isInvalid = await formRef.value?.validate()
|
||||
if (isInvalid) return
|
||||
try {
|
||||
loading.value = true
|
||||
// 调用后端接口校验卡号
|
||||
await userStore.cardLogin(form)
|
||||
|
||||
// 登录成功后移除事件监听器
|
||||
if (keyDownListener) {
|
||||
document.removeEventListener('keydown', keyDownListener)
|
||||
keyDownListener = null
|
||||
}
|
||||
|
||||
tabsStore.reset()
|
||||
const { redirect, ...othersQuery } = router.currentRoute.value.query
|
||||
await router.push({
|
||||
@@ -64,24 +76,30 @@ const handleLogin = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 键盘事件监听器引用
|
||||
let keyDownListener: ((e: KeyboardEvent) => void) | null = null
|
||||
|
||||
// 监听键盘输入,实现自动识别卡号
|
||||
onMounted(() => {
|
||||
// 监听全局键盘事件,用于识别刷卡输入
|
||||
document.addEventListener('keydown', (e) => {
|
||||
// 只监听Enter键,用于自动登录
|
||||
keyDownListener = (e) => {
|
||||
// 刷卡器通常会快速输入卡号并以Enter键结束
|
||||
if (e.key === 'Enter') {
|
||||
// 遇到Enter键,尝试登录
|
||||
if (form.cardNumber.trim()) {
|
||||
handleLogin()
|
||||
}
|
||||
} else if (e.key.length === 1 && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
||||
// 只捕获单个字符的按键,忽略控制键和功能键
|
||||
form.cardNumber += e.key
|
||||
} else if (e.key === 'Backspace') {
|
||||
// 处理退格键
|
||||
form.cardNumber = form.cardNumber.slice(0, -1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', keyDownListener)
|
||||
})
|
||||
|
||||
// 组件卸载时移除事件监听器
|
||||
onUnmounted(() => {
|
||||
if (keyDownListener) {
|
||||
document.removeEventListener('keydown', keyDownListener)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<div class="form-item">
|
||||
<a-form-item label="物料编码">
|
||||
<a-input
|
||||
v-model="formData.inputMaterialCode"
|
||||
v-model="formData.inputMaterialCode"
|
||||
placeholder="请点击此处确保光标闪烁,并使用扫码枪扫描物料编码"
|
||||
@keydown="handleKeyDown"
|
||||
@input="handleMaterialCodeChange"
|
||||
@@ -74,7 +74,7 @@
|
||||
<div class="image-placeholder square-image">实时画面 相机1</div>
|
||||
<div class="image-placeholder square-image">实时画面 相机2</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="info-section">
|
||||
<div class="info-card">
|
||||
<h4>识别信息</h4>
|
||||
@@ -92,13 +92,15 @@
|
||||
<h4>比对结果</h4>
|
||||
<div class="info-item">
|
||||
<span class="label">比对结果:</span>
|
||||
<span class="value match-result" :class="{
|
||||
'match-success': formData.matchResult === 'success',
|
||||
'match-failed': formData.matchResult === 'failed',
|
||||
'match-pending': !formData.matchResult
|
||||
}">
|
||||
<icon-check-circle-fill v-if="formData.matchResult === 'success'" style="color: #52c41a; margin-right: 8px; font-size: 25px;"/>
|
||||
<icon-close-circle-fill v-else-if="formData.matchResult === 'failed'" style="color: #ff4d4f; margin-right: 8px; font-size: 25px;"/>
|
||||
<span
|
||||
class="value match-result" :class="{
|
||||
'match-success': formData.matchResult === 'success',
|
||||
'match-failed': formData.matchResult === 'failed',
|
||||
'match-pending': !formData.matchResult,
|
||||
}"
|
||||
>
|
||||
<icon-check-circle-fill v-if="formData.matchResult === 'success'" style="color: #52c41a; margin-right: 8px; font-size: 25px;" />
|
||||
<icon-close-circle-fill v-else-if="formData.matchResult === 'failed'" style="color: #ff4d4f; margin-right: 8px; font-size: 25px;" />
|
||||
|
||||
{{ formData.matchResult === 'success' ? '成功' : formData.matchResult === 'failed' ? '失败' : '-' }}
|
||||
</span>
|
||||
@@ -135,7 +137,7 @@
|
||||
<div class="form-row">
|
||||
<div class="form-item">
|
||||
<label>对应重量(g):</label>
|
||||
<a-input v-model="ahDeviceWeight" placeholder="-" disabled/>
|
||||
<a-input v-model="ahDeviceWeight" placeholder="-" disabled />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -246,17 +248,17 @@
|
||||
<div class="action-buttons">
|
||||
<a-button
|
||||
v-if="activeStep > 1 && activeStep < 3"
|
||||
@click="handlePrevious"
|
||||
class="previous-button"
|
||||
@click="handlePrevious"
|
||||
>
|
||||
上一步
|
||||
</a-button>
|
||||
<a-button
|
||||
v-if="activeStep < 3"
|
||||
type="primary"
|
||||
@click="handleNext"
|
||||
<a-button
|
||||
v-if="activeStep < 3"
|
||||
type="primary"
|
||||
:disabled="activeStep === 1 && formData.matchResult !== 'success'"
|
||||
class="next-button"
|
||||
@click="handleNext"
|
||||
>
|
||||
{{ activeStep === 2 ? '完成' : '下一步' }}
|
||||
</a-button>
|
||||
@@ -266,16 +268,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { nextTick, onBeforeUnmount, onMounted, ref, reactive, onUnmounted } from 'vue'
|
||||
import { Modal, Message } from '@arco-design/web-vue'
|
||||
import { getMaterialDetail } from "@/apis/weightManage/weightManage";
|
||||
import {addWorkOrder, type WorkOrderResp} from "@/apis/workOrder/workOrder";
|
||||
import { Notification } from "@arco-design/web-vue"
|
||||
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 { catchPhoto } from '@/apis/material/materialInfo'
|
||||
|
||||
|
||||
|
||||
|
||||
defineOptions({ name: 'WeightManage' })
|
||||
|
||||
// 动态导入flv.js
|
||||
@@ -554,10 +553,11 @@ const workOrderResp = ref<WorkOrderResp>({
|
||||
totalCount: '',
|
||||
createUserString: '',
|
||||
updateUserString: '',
|
||||
matchResult: 'failed'
|
||||
totalCalculatedWeight: '',
|
||||
workOrderInfos: [],
|
||||
matchResult: 'failed',
|
||||
})
|
||||
|
||||
|
||||
// 称重登记页面数据
|
||||
const inputQuantity = ref('')
|
||||
const ahDeviceWeight = ref('10')
|
||||
@@ -578,25 +578,25 @@ const columns = [
|
||||
{
|
||||
title: '称重次数',
|
||||
dataIndex: 'weightTime',
|
||||
key: 'weightTime'
|
||||
key: 'weightTime',
|
||||
},
|
||||
{
|
||||
title: '数量',
|
||||
dataIndex: 'quantity',
|
||||
key: 'quantity',
|
||||
className: 'green-bg'
|
||||
className: 'green-bg',
|
||||
},
|
||||
{
|
||||
title: '重量(g)',
|
||||
dataIndex: 'weight',
|
||||
key: 'weight',
|
||||
className: 'green-bg'
|
||||
className: 'green-bg',
|
||||
},
|
||||
{
|
||||
title: '计算重量(g)',
|
||||
dataIndex: 'calculatedWeight',
|
||||
key: 'calculatedWeight',
|
||||
className: 'green-bg'
|
||||
className: 'green-bg',
|
||||
},
|
||||
{
|
||||
title: '抓拍图片',
|
||||
@@ -622,33 +622,33 @@ const columns = [
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
key: 'action',
|
||||
slotName: 'action'
|
||||
}
|
||||
slotName: 'action',
|
||||
},
|
||||
]
|
||||
|
||||
// 防抖函数
|
||||
const debounce = <T extends (...args: any[]) => any>(func: T, delay: number): ((...args: Parameters<T>) => void) => {
|
||||
let timer: ReturnType<typeof setTimeout> | null = null;
|
||||
return function(...args: Parameters<T>) {
|
||||
if (timer) clearTimeout(timer);
|
||||
let timer: ReturnType<typeof setTimeout> | null = null
|
||||
return function (...args: Parameters<T>) {
|
||||
if (timer) clearTimeout(timer)
|
||||
timer = setTimeout(() => {
|
||||
func(...args);
|
||||
}, delay);
|
||||
};
|
||||
};
|
||||
func(...args)
|
||||
}, delay)
|
||||
}
|
||||
}
|
||||
|
||||
// 原始的物料编码变化处理函数
|
||||
const originalHandleMaterialCodeChange = async () => {
|
||||
// 确保输入框内容是完整的物料编码
|
||||
const materialCode = formData.inputMaterialCode?.trim();
|
||||
const materialCode = formData.inputMaterialCode?.trim()
|
||||
|
||||
// 无论是否有输入,先重置所有物料相关字段,确保新数据能完全覆盖旧数据
|
||||
formData.encoding = "";
|
||||
formData.materialName = "";
|
||||
formData.materialSpec = "";
|
||||
formData.unitWeight = 0;
|
||||
formData.photoUrl = "";
|
||||
formData.matchResult = "";
|
||||
formData.encoding = ''
|
||||
formData.materialName = ''
|
||||
formData.materialSpec = ''
|
||||
formData.unitWeight = 0
|
||||
formData.photoUrl = ''
|
||||
formData.matchResult = ''
|
||||
|
||||
// 如果有物料编码输入,获取物料数据
|
||||
if (materialCode) {
|
||||
@@ -659,17 +659,17 @@ const originalHandleMaterialCodeChange = async () => {
|
||||
// 即使获取失败,也保持字段为空,避免显示旧数据
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 记录上次输入时间,用于判断是否是扫码枪输入
|
||||
let lastInputTime = 0;
|
||||
let lastInputTime = 0
|
||||
// 记录输入内容,用于判断是否是新的扫码
|
||||
let previousInput = '';
|
||||
const previousInput = ''
|
||||
|
||||
// 处理键盘按下事件
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
// 获取当前时间
|
||||
const currentTime = Date.now();
|
||||
const currentTime = Date.now()
|
||||
|
||||
// 如果输入速度非常快(小于100ms),认为是扫码枪输入
|
||||
if (currentTime - lastInputTime < 100 && formData.inputMaterialCode) {
|
||||
@@ -677,33 +677,33 @@ const handleKeyDown = (event: KeyboardEvent) => {
|
||||
} else if (event.key.length === 1 && !event.ctrlKey && !event.altKey) {
|
||||
// 如果是新的输入(不是快速连续输入),清空输入框
|
||||
// 这样可以确保每次扫码都从空输入框开始
|
||||
formData.inputMaterialCode = '';
|
||||
formData.inputMaterialCode = ''
|
||||
}
|
||||
|
||||
// 更新上次输入时间
|
||||
lastInputTime = currentTime;
|
||||
};
|
||||
lastInputTime = currentTime
|
||||
}
|
||||
|
||||
// 带防抖的物料编码变化处理函数
|
||||
const handleMaterialCodeChange = debounce(originalHandleMaterialCodeChange, 500); // 500ms防抖延迟
|
||||
const handleMaterialCodeChange = debounce(originalHandleMaterialCodeChange, 500) // 500ms防抖延迟
|
||||
|
||||
// 扫码核验获取物料信息
|
||||
const fetchMaterialData = async (code: string) => {
|
||||
getMaterialDetail(code).then(res => {
|
||||
if (res.code == '0') {
|
||||
getMaterialDetail(code).then((res) => {
|
||||
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.unitWeight = res.data?.unitWeight || 0;
|
||||
formData.photoUrl = res.data?.photoUrl || "";
|
||||
formData.id = res.data?.id || ''
|
||||
formData.encoding = res.data?.encoding || ''
|
||||
formData.materialName = res.data?.materialName || ''
|
||||
formData.materialSpec = res.data?.materialSpec || ''
|
||||
formData.unitWeight = res.data?.unitWeight || 0
|
||||
formData.photoUrl = res.data?.photoUrl || ''
|
||||
// 假设后端返回比对结果
|
||||
// formData.matchResult = res.data.matchResult || 'failed' // 这里根据实际接口返回调整
|
||||
formData.matchResult = res.data?.matchResult || 'success' // 这里根据实际接口返回调整
|
||||
return true
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
// 处理下一步
|
||||
@@ -720,20 +720,20 @@ const handleNext = async () => {
|
||||
const workOrderData = {
|
||||
materialId: formData.id,
|
||||
materialName: formData.materialName,
|
||||
workOrderInfos: weighingList.value
|
||||
workOrderInfos: weighingList.value,
|
||||
}
|
||||
// 调用后端接口
|
||||
addWorkOrder(workOrderData).then(res => {
|
||||
if (res.code == '0') {
|
||||
addWorkOrder(workOrderData).then((res) => {
|
||||
if (res.code === '0') {
|
||||
Notification.success({
|
||||
title: '操作成功',
|
||||
content: `工单创建成功!`
|
||||
content: `工单创建成功!`,
|
||||
})
|
||||
workOrderResp.value.matchResult = 'success';
|
||||
workOrderResp.value.title = res.data?.title || "";
|
||||
workOrderResp.value.orderNo = res.data?.orderNo || "";
|
||||
workOrderResp.value.totalWeight = res.data?.totalWeight || "";
|
||||
workOrderResp.value.totalCount = res.data?.totalCount || "";
|
||||
workOrderResp.value.matchResult = 'success'
|
||||
workOrderResp.value.title = res.data?.title || ''
|
||||
workOrderResp.value.orderNo = res.data?.orderNo || ''
|
||||
workOrderResp.value.totalWeight = res.data?.totalWeight || ''
|
||||
workOrderResp.value.totalCount = res.data?.totalCount || ''
|
||||
|
||||
// 关闭WebSocket连接
|
||||
closeWebSocket()
|
||||
@@ -741,12 +741,12 @@ const handleNext = async () => {
|
||||
activeStep.value++
|
||||
return true
|
||||
}
|
||||
});
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('创建工作订单失败:', error)
|
||||
Message.error('创建工作订单失败')
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
} else {
|
||||
activeStep.value++
|
||||
@@ -771,7 +771,30 @@ const handlePrevious = () => {
|
||||
|
||||
// 返回第一步
|
||||
const handleBackToFirst = () => {
|
||||
// 重置所有数据
|
||||
activeStep.value = 1
|
||||
|
||||
// 重置表单数据
|
||||
formData.inputMaterialCode = ''
|
||||
formData.id = ''
|
||||
formData.encoding = ''
|
||||
formData.materialName = ''
|
||||
formData.materialSpec = ''
|
||||
formData.unitWeight = 0
|
||||
formData.photoUrl = ''
|
||||
formData.matchResult = ''
|
||||
|
||||
// 重置称重登记页面数据
|
||||
inputQuantity.value = ''
|
||||
ahDeviceWeight.value = '10'
|
||||
calculatedWeight.value = ''
|
||||
weighingCount.value = 1
|
||||
// 清空称重列表
|
||||
weighingList.value = []
|
||||
|
||||
// 重置工作订单响应数据
|
||||
workOrderResp.value = {}
|
||||
|
||||
// 离开称重页面时关闭WebSocket连接
|
||||
closeWebSocket()
|
||||
}
|
||||
@@ -779,8 +802,8 @@ const handleBackToFirst = () => {
|
||||
// 计算重量
|
||||
const calculateWeight = () => {
|
||||
if (inputQuantity.value && formData.unitWeight) {
|
||||
const singleWeight = parseFloat(formData.unitWeight.toString())
|
||||
const quantity = parseFloat(inputQuantity.value)
|
||||
const singleWeight = Number.parseFloat(formData.unitWeight.toString())
|
||||
const quantity = Number.parseFloat(inputQuantity.value)
|
||||
if (!isNaN(singleWeight) && !isNaN(quantity)) {
|
||||
calculatedWeight.value = (singleWeight * quantity).toFixed(2)
|
||||
}
|
||||
@@ -789,10 +812,8 @@ const calculateWeight = () => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 处理确定
|
||||
const handleConfirm = () => {
|
||||
/* const handleConfirm = async () => {
|
||||
// 校验输入数量是否为空
|
||||
if (!inputQuantity.value || inputQuantity.value.trim() === '') {
|
||||
Message.error('请输入数量')
|
||||
@@ -803,6 +824,12 @@ const handleConfirm = () => {
|
||||
return
|
||||
}
|
||||
|
||||
// 2. 抓拍当前画面
|
||||
let captureUrl = ''
|
||||
if (cameraVideo.value && cameraStatus.value === 'connected') {
|
||||
captureUrl = await capturePhoto()
|
||||
}
|
||||
console.log(captureUrl)
|
||||
// 生成新的列表数据
|
||||
const newItem = {
|
||||
key: (weighingList.value.length + 1).toString(),
|
||||
@@ -821,11 +848,69 @@ const handleConfirm = () => {
|
||||
calculatedWeight.value = ''
|
||||
// 称重次数累加
|
||||
weighingCount.value = weighingList.value.length + 1
|
||||
Message.success('添加成功')
|
||||
} */
|
||||
|
||||
const handleConfirm = () => {
|
||||
// 校验输入数量是否为空
|
||||
if (!inputQuantity.value || inputQuantity.value.trim() === '') {
|
||||
Message.error('请输入数量')
|
||||
return
|
||||
}
|
||||
if (!ahDeviceWeight.value || ahDeviceWeight.value.trim() === '') {
|
||||
Message.error('电子秤称重结果为空!')
|
||||
return
|
||||
}
|
||||
|
||||
// 立即创建一个新项的基本数据
|
||||
const newItem = {
|
||||
key: (weighingList.value.length + 1).toString(),
|
||||
weightTime: weighingCount.value,
|
||||
materialId: formData.id,
|
||||
quantity: inputQuantity.value,
|
||||
weight: ahDeviceWeight.value,
|
||||
calculatedWeight: calculatedWeight.value,
|
||||
image: '加载中...', // 先显示加载状态
|
||||
}
|
||||
|
||||
// 先添加到列表,让用户能立即看到记录
|
||||
weighingList.value.push(newItem)
|
||||
|
||||
// 重置输入(让用户能继续输入)
|
||||
inputQuantity.value = ''
|
||||
ahDeviceWeight.value = '10'
|
||||
calculatedWeight.value = ''
|
||||
weighingCount.value = weighingList.value.length + 1
|
||||
|
||||
// 异步执行抓拍,不阻塞主流程
|
||||
if (cameraVideo.value && cameraStatus.value === 'connected') {
|
||||
// 立即执行异步抓拍
|
||||
capturePhoto().then((captureUrl) => {
|
||||
// 找到刚刚添加的项,更新图片URL
|
||||
const addedItem = weighingList.value.find((item) => item.key === newItem.key)
|
||||
if (addedItem) {
|
||||
addedItem.image = captureUrl || '抓拍失败'
|
||||
// 触发视图更新
|
||||
weighingList.value = [...weighingList.value]
|
||||
}
|
||||
Message.success('图片抓拍成功')
|
||||
}).catch((error) => {
|
||||
})
|
||||
} else {
|
||||
// 摄像头未连接,直接显示未抓拍
|
||||
const addedItem = weighingList.value.find((item) => item.key === newItem.key)
|
||||
if (addedItem) {
|
||||
addedItem.image = '未抓拍'
|
||||
weighingList.value = [...weighingList.value]
|
||||
}
|
||||
}
|
||||
|
||||
Message.success('添加成功')
|
||||
}
|
||||
|
||||
// 抓拍功能 - 内部方法,不暴露按钮
|
||||
const capturePhoto = async (): Promise<string> => {
|
||||
const capturePhoto = (): Promise<string> => {
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const video = cameraVideo.value
|
||||
@@ -852,8 +937,7 @@ const capturePhoto = async (): Promise<string> => {
|
||||
|
||||
// 调用后端接口
|
||||
const response = await catchPhoto(formData)
|
||||
if (!response.code === '200') {
|
||||
reject(new Error('上传失败'))
|
||||
if (response.msg !== 'ok') {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -892,7 +976,7 @@ const handleReset = () => {
|
||||
// 处理删除
|
||||
const handleDelete = (key) => {
|
||||
// 过滤掉要删除的项
|
||||
weighingList.value = weighingList.value.filter(item => item.key !== key)
|
||||
weighingList.value = weighingList.value.filter((item) => item.key !== key)
|
||||
// 重新排序称重次数
|
||||
weighingList.value.forEach((item, index) => {
|
||||
item.weightTime = index + 1
|
||||
@@ -1368,4 +1452,4 @@ onUnmounted(() => {
|
||||
font-size: 14px;
|
||||
margin-right: 12px;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -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
|
||||
@@ -172,7 +172,7 @@ const columns = ref<TableInstanceColumns[]>(processColumns([
|
||||
{ title: '物料编码', dataIndex: 'encoding' },
|
||||
{ title: '单位克重', dataIndex: 'unitWeight' ,slotName: 'unitWeight'},
|
||||
{ title: '总重量', dataIndex: 'totalWeight' ,slotName: 'totalWeight'},
|
||||
{ title: '称重次数', dataIndex: 'totalCount' },
|
||||
{ title: '总数量', dataIndex: 'totalCount' },
|
||||
{ title: '创建时间', dataIndex: 'createTime', width: 180 },
|
||||
{
|
||||
title: '操作',
|
||||
@@ -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,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user