将每一步的钢卷二维码进行保存,新步骤采用新码
This commit is contained in:
@@ -44,8 +44,17 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 历史码提示 -->
|
||||
<view class="warning-card" v-if="form.coilId && qrcodeStatus === 0">
|
||||
<view class="warning-icon">⚠️</view>
|
||||
<view class="warning-content">
|
||||
<text class="warning-title">历史二维码</text>
|
||||
<text class="warning-desc">此二维码已失效,已为您加载最新物料信息,仅可查看,无法修改</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 历史数据提示 -->
|
||||
<view class="warning-card" v-if="form.coilId && coilDetail.dataType === 0">
|
||||
<view class="warning-card" v-if="form.coilId && coilDetail.dataType === 0 && qrcodeStatus !== 0">
|
||||
<view class="warning-icon">⚠️</view>
|
||||
<view class="warning-content">
|
||||
<text class="warning-title">历史数据</text>
|
||||
@@ -67,8 +76,8 @@
|
||||
v-model="form.currentCoilNo"
|
||||
placeholder="请输入当前钢卷号"
|
||||
class="form-input"
|
||||
:disabled="coilDetail.dataType === 0"
|
||||
:class="{ 'form-input-disabled': coilDetail.dataType === 0 }"
|
||||
:disabled="coilDetail.dataType === 0 || qrcodeStatus === 0"
|
||||
:class="{ 'form-input-disabled': coilDetail.dataType === 0 || qrcodeStatus === 0 }"
|
||||
/>
|
||||
</view>
|
||||
|
||||
@@ -79,8 +88,8 @@
|
||||
v-model="form.team"
|
||||
placeholder="请输入班组名称"
|
||||
class="form-input"
|
||||
:disabled="coilDetail.dataType === 0"
|
||||
:class="{ 'form-input-disabled': coilDetail.dataType === 0 }"
|
||||
:disabled="coilDetail.dataType === 0 || qrcodeStatus === 0"
|
||||
:class="{ 'form-input-disabled': coilDetail.dataType === 0 || qrcodeStatus === 0 }"
|
||||
/>
|
||||
</view>
|
||||
|
||||
@@ -89,13 +98,13 @@
|
||||
<text class="form-label-optional">目标库区</text>
|
||||
<view
|
||||
class="picker-input"
|
||||
@click="coilDetail.dataType !== 0 && showWarehousePicker()"
|
||||
:class="{ 'picker-input-disabled': coilDetail.dataType === 0 }"
|
||||
@click="(coilDetail.dataType !== 0 && qrcodeStatus !== 0) && showWarehousePicker()"
|
||||
:class="{ 'picker-input-disabled': coilDetail.dataType === 0 || qrcodeStatus === 0 }"
|
||||
>
|
||||
<text class="picker-text" :class="{ 'picker-placeholder': !currentWarehouseName }">
|
||||
{{ currentWarehouseName || '请选择目标库区' }}
|
||||
</text>
|
||||
<text class="picker-arrow" v-if="coilDetail.dataType !== 0">▼</text>
|
||||
<text class="picker-arrow" v-if="coilDetail.dataType !== 0 && qrcodeStatus !== 0">▼</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -107,8 +116,8 @@
|
||||
type="digit"
|
||||
placeholder="请输入毛重(选填)"
|
||||
class="form-input"
|
||||
:disabled="coilDetail.dataType === 0"
|
||||
:class="{ 'form-input-disabled': coilDetail.dataType === 0 }"
|
||||
:disabled="coilDetail.dataType === 0 || qrcodeStatus === 0"
|
||||
:class="{ 'form-input-disabled': coilDetail.dataType === 0 || qrcodeStatus === 0 }"
|
||||
/>
|
||||
</view>
|
||||
|
||||
@@ -120,8 +129,8 @@
|
||||
type="digit"
|
||||
placeholder="请输入净重(选填)"
|
||||
class="form-input"
|
||||
:disabled="coilDetail.dataType === 0"
|
||||
:class="{ 'form-input-disabled': coilDetail.dataType === 0 }"
|
||||
:disabled="coilDetail.dataType === 0 || qrcodeStatus === 0"
|
||||
:class="{ 'form-input-disabled': coilDetail.dataType === 0 || qrcodeStatus === 0 }"
|
||||
/>
|
||||
</view>
|
||||
|
||||
@@ -135,7 +144,7 @@
|
||||
<view class="action-buttons">
|
||||
<button class="btn btn-secondary" @click="handleReset">重新扫码</button>
|
||||
<button
|
||||
v-if="coilDetail.dataType === 1"
|
||||
v-if="coilDetail.dataType === 1 && qrcodeStatus === 1"
|
||||
class="btn btn-primary"
|
||||
@click="handleConfirm"
|
||||
:disabled="loading"
|
||||
@@ -237,7 +246,8 @@ import { getRawMaterial } from '@/api/wms/rawMaterial.js'
|
||||
currentWarehouseName: '',
|
||||
warehouseSearchKeyword: '',
|
||||
filteredWarehousesInPicker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
qrcodeStatus: 1 // 二维码状态:0=历史码,1=当前有效码
|
||||
}
|
||||
},
|
||||
|
||||
@@ -337,8 +347,8 @@ import { getRawMaterial } from '@/api/wms/rawMaterial.js'
|
||||
},
|
||||
|
||||
// 扫码
|
||||
handleScan() {
|
||||
uni.scanCode({
|
||||
handleScan() {
|
||||
uni.scanCode({
|
||||
success: async (res) => {
|
||||
console.log('扫码结果:', res.result);
|
||||
try {
|
||||
@@ -357,23 +367,46 @@ import { getRawMaterial } from '@/api/wms/rawMaterial.js'
|
||||
const enterCoilNo = content.enter_coil_no;
|
||||
const currentCoilNo = content.current_coil_no;
|
||||
|
||||
// 保存二维码状态(0=历史码,1=当前有效码)
|
||||
this.qrcodeStatus = qrcodeRecord.status || 1;
|
||||
|
||||
if (!enterCoilNo) {
|
||||
throw new Error('二维码中未包含有效的入场钢卷号');
|
||||
}
|
||||
|
||||
// 3. 通过入场钢卷号和当前钢卷号查询最新的钢卷详情
|
||||
// 使用追溯接口来获取准确的钢卷信息
|
||||
const traceRes = await getMaterialCoilTrace(enterCoilNo, currentCoilNo);
|
||||
// 3. 如果是历史码,提示用户并加载最新数据
|
||||
if (this.qrcodeStatus === 0) {
|
||||
uni.showToast({
|
||||
title: '历史二维码,已加载最新信息',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
|
||||
// 4. 通过入场钢卷号查询最新的钢卷详情(不传currentCoilNo,获取所有相关钢卷)
|
||||
// 如果是历史码,查询该入场钢卷号的最新数据
|
||||
const traceRes = await getMaterialCoilTrace(enterCoilNo, this.qrcodeStatus === 0 ? null : currentCoilNo);
|
||||
if (traceRes.code !== 200 || !traceRes.data || !traceRes.data.records || traceRes.data.records.length === 0) {
|
||||
throw new Error('未找到钢卷信息');
|
||||
}
|
||||
|
||||
// 4. 从追溯结果中找到当前数据(dataType = 1)且匹配当前钢卷号的记录
|
||||
// 5. 从追溯结果中找到当前数据(dataType = 1)
|
||||
let coilData = null;
|
||||
for (const record of traceRes.data.records) {
|
||||
if (record.dataType === 1 && record.currentCoilNo === currentCoilNo) {
|
||||
coilData = record;
|
||||
break;
|
||||
if (this.qrcodeStatus === 0) {
|
||||
// 历史码:找到最新的当前数据(dataType = 1)
|
||||
for (const record of traceRes.data.records) {
|
||||
if (record.dataType === 1) {
|
||||
coilData = record;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 当前码:找到匹配当前钢卷号的记录
|
||||
for (const record of traceRes.data.records) {
|
||||
if (record.dataType === 1 && record.currentCoilNo === currentCoilNo) {
|
||||
coilData = record;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,7 +454,7 @@ import { getRawMaterial } from '@/api/wms/rawMaterial.js'
|
||||
}
|
||||
|
||||
console.log('钢卷详情:', coilData);
|
||||
uni.showToast({
|
||||
uni.showToast({
|
||||
title: '扫码成功',
|
||||
icon: 'success'
|
||||
});
|
||||
@@ -436,9 +469,9 @@ import { getRawMaterial } from '@/api/wms/rawMaterial.js'
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('扫码失败:', err);
|
||||
uni.showToast({
|
||||
title: '扫码失败,请重试',
|
||||
icon: 'none'
|
||||
uni.showToast({
|
||||
title: '扫码失败,请重试',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -483,6 +516,7 @@ import { getRawMaterial } from '@/api/wms/rawMaterial.js'
|
||||
this.warehouseKeyword = '';
|
||||
this.currentWarehouseName = '';
|
||||
this.filteredWarehouses = this.warehouses;
|
||||
this.qrcodeStatus = 1; // 重置二维码状态
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -496,6 +530,12 @@ import { getRawMaterial } from '@/api/wms/rawMaterial.js'
|
||||
return;
|
||||
}
|
||||
|
||||
// 历史二维码不允许修改
|
||||
if (this.qrcodeStatus === 0) {
|
||||
uni.showToast({ title: '历史二维码不允许修改', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证必填项
|
||||
if (!this.form.currentCoilNo) {
|
||||
uni.showToast({ title: '请输入当前钢卷号', icon: 'none' });
|
||||
|
||||
Reference in New Issue
Block a user