将每一步的钢卷二维码进行保存,新步骤采用新码
This commit is contained in:
@@ -11,15 +11,6 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 历史码提示 -->
|
||||
<view class="warning-card" v-if="hasHistoryQrcode">
|
||||
<view class="warning-icon">⚠️</view>
|
||||
<view class="warning-content">
|
||||
<text class="warning-title">包含历史二维码</text>
|
||||
<text class="warning-desc">列表中包含已失效的二维码,不允许进行合卷操作,请移除后重试</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 已扫描的钢卷列表 -->
|
||||
<view class="coil-list" v-if="scannedCoils.length > 0">
|
||||
<view class="card-title">
|
||||
@@ -29,12 +20,11 @@
|
||||
|
||||
<view class="coil-item" v-for="(coil, index) in scannedCoils" :key="index">
|
||||
<view class="coil-content">
|
||||
<view class="coil-index" :class="{ 'index-history': coil.qrcodeStatus === 0 }">{{ index + 1 }}</view>
|
||||
<view class="coil-index">{{ index + 1 }}</view>
|
||||
<view class="coil-info">
|
||||
<view class="coil-row">
|
||||
<text class="coil-label">入场钢卷号:</text>
|
||||
<text class="coil-value">{{ coil.enterCoilNo }}</text>
|
||||
<text class="history-tag" v-if="coil.qrcodeStatus === 0">历史码</text>
|
||||
</view>
|
||||
<view class="coil-row">
|
||||
<text class="coil-label">当前钢卷号:</text>
|
||||
@@ -93,6 +83,20 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 产品选择(仅当选择了成品库区时显示) -->
|
||||
<view class="form-item form-item-optional" v-if="itemType === 'product'">
|
||||
<text class="form-label-optional">选择产品</text>
|
||||
<view
|
||||
class="picker-input"
|
||||
@click="showProductPicker()"
|
||||
>
|
||||
<text class="picker-text" :class="{ 'picker-placeholder': !selectedProductName }">
|
||||
{{ selectedProductName || '请选择产品' }}
|
||||
</text>
|
||||
<text class="picker-arrow">▼</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 毛重 -->
|
||||
<view class="form-item form-item-optional">
|
||||
<text class="form-label-optional">毛重 (kg)</text>
|
||||
@@ -166,6 +170,38 @@
|
||||
</scroll-view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
|
||||
<!-- 产品选择弹窗 -->
|
||||
<uni-popup ref="productPopup" type="bottom">
|
||||
<view class="warehouse-popup">
|
||||
<view class="popup-header">
|
||||
<text class="popup-title">选择产品</text>
|
||||
<text class="popup-close" @click="closeProductPicker">✕</text>
|
||||
</view>
|
||||
<view class="popup-search">
|
||||
<input
|
||||
v-model="productSearchKeyword"
|
||||
@input="filterProductsInPicker"
|
||||
placeholder="搜索产品名称"
|
||||
class="search-input"
|
||||
/>
|
||||
</view>
|
||||
<scroll-view class="popup-body" scroll-y>
|
||||
<view
|
||||
class="warehouse-item"
|
||||
v-for="product in filteredProductsInPicker"
|
||||
:key="product.productId"
|
||||
@click="selectProductFromPicker(product)"
|
||||
>
|
||||
<text class="warehouse-name">{{ product.productName }}</text>
|
||||
<text class="warehouse-check" v-if="itemId === product.productId">✓</text>
|
||||
</view>
|
||||
<view class="empty-tip" v-if="!filteredProductsInPicker || filteredProductsInPicker.length === 0">
|
||||
<text>未找到匹配的产品</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -173,6 +209,7 @@
|
||||
import { getGenerateRecord } from '@/api/wms/code.js'
|
||||
import { updateMaterialCoil, getMaterialCoil, getMaterialCoilTrace } from '@/api/wms/coil.js'
|
||||
import { listWarehouse } from '@/api/wms/warehouse.js'
|
||||
import { listProduct } from '@/api/wms/product.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -188,18 +225,18 @@ export default {
|
||||
showWarehouseList: false,
|
||||
warehouseSearchKeyword: '',
|
||||
filteredWarehousesInPicker: [],
|
||||
products: [], // 产品列表
|
||||
productSearchKeyword: '',
|
||||
filteredProductsInPicker: [],
|
||||
itemType: '', // 合卷后的物品类型
|
||||
itemId: undefined, // 合卷后的物品ID
|
||||
selectedProductName: '', // 已选择的产品名称
|
||||
grossWeight: '',
|
||||
netWeight: '',
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
// 是否包含历史二维码
|
||||
hasHistoryQrcode() {
|
||||
return this.scannedCoils.some(coil => coil.qrcodeStatus === 0);
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadWarehouses();
|
||||
@@ -234,6 +271,61 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// 加载产品列表
|
||||
async loadProducts() {
|
||||
console.log('开始加载产品列表...');
|
||||
try {
|
||||
const res = await listProduct({ pageNum: 1, pageSize: 1000 });
|
||||
console.log("产品返回值", res);
|
||||
if (res.code === 200) {
|
||||
this.products = res.rows || res.data || [];
|
||||
this.filteredProductsInPicker = this.products;
|
||||
console.log('产品加载成功,数量:', this.products.length);
|
||||
} else {
|
||||
console.error('产品加载失败:', res.msg);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('加载产品异常:', err);
|
||||
}
|
||||
},
|
||||
|
||||
// 显示产品选择器
|
||||
showProductPicker() {
|
||||
this.productSearchKeyword = '';
|
||||
this.filteredProductsInPicker = [...this.products];
|
||||
this.$refs.productPopup.open();
|
||||
},
|
||||
|
||||
// 关闭产品选择器
|
||||
closeProductPicker() {
|
||||
this.$refs.productPopup.close();
|
||||
},
|
||||
|
||||
// 过滤产品(在选择器中)
|
||||
filterProductsInPicker() {
|
||||
const keyword = this.productSearchKeyword.trim().toLowerCase();
|
||||
if (!keyword) {
|
||||
this.filteredProductsInPicker = [...this.products];
|
||||
} else {
|
||||
this.filteredProductsInPicker = this.products.filter(product => {
|
||||
const name = (product.productName || '').toLowerCase();
|
||||
return name.includes(keyword);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 从选择器中选择产品
|
||||
selectProductFromPicker(product) {
|
||||
this.itemId = product.productId;
|
||||
this.itemType = 'product';
|
||||
this.selectedProductName = product.productName;
|
||||
uni.showToast({
|
||||
title: `已选择产品:${product.productName}`,
|
||||
icon: 'success'
|
||||
});
|
||||
this.closeProductPicker();
|
||||
},
|
||||
|
||||
// 过滤库区
|
||||
filterWarehouses() {
|
||||
console.log('合卷页面过滤库区,关键词:', this.warehouseKeyword);
|
||||
@@ -290,11 +382,21 @@ export default {
|
||||
},
|
||||
|
||||
// 从选择器中选择库区
|
||||
selectWarehouseFromPicker(warehouse) {
|
||||
async selectWarehouseFromPicker(warehouse) {
|
||||
this.warehouseId = warehouse.warehouseId;
|
||||
this.warehouseName = warehouse.warehouseName;
|
||||
this.warehouseKeyword = warehouse.warehouseName;
|
||||
this.closeWarehousePicker();
|
||||
|
||||
// 检查是否选择了成品库区
|
||||
if (warehouse.warehouseName && warehouse.warehouseName.includes('成品')) {
|
||||
// 切换为产品类型
|
||||
this.itemType = 'product';
|
||||
// 加载产品列表
|
||||
await this.loadProducts();
|
||||
// 弹出产品选择框
|
||||
this.showProductPicker();
|
||||
}
|
||||
},
|
||||
|
||||
// 扫码
|
||||
@@ -311,56 +413,57 @@ export default {
|
||||
throw new Error('未找到二维码记录');
|
||||
}
|
||||
|
||||
// 2. 解析content获取enter_coil_no和current_coil_no
|
||||
// 2. 解析content获取enter_coil_no、current_coil_no和coil_id
|
||||
const qrcodeRecord = qrcodeRes.data;
|
||||
const content = JSON.parse(qrcodeRecord.content);
|
||||
const enterCoilNo = content.enter_coil_no;
|
||||
const currentCoilNo = content.current_coil_no;
|
||||
const qrcodeStatus = qrcodeRecord.status || 1;
|
||||
|
||||
// 如果是历史码,提示用户
|
||||
if (qrcodeStatus === 0) {
|
||||
uni.showModal({
|
||||
title: '历史二维码',
|
||||
content: '此二维码已失效,不允许进行合卷操作,请使用最新二维码',
|
||||
showCancel: false
|
||||
});
|
||||
return;
|
||||
}
|
||||
const coilId = content.coil_id && content.coil_id !== 'null' ? content.coil_id : null;
|
||||
|
||||
if (!enterCoilNo) {
|
||||
throw new Error('二维码中未包含有效的入场钢卷号');
|
||||
}
|
||||
|
||||
// 3. 通过追溯接口获取准确的钢卷信息
|
||||
// 3. 通过追溯接口获取钢卷信息
|
||||
const traceRes = await getMaterialCoilTrace(enterCoilNo, currentCoilNo);
|
||||
if (traceRes.code !== 200 || !traceRes.data || !traceRes.data.records || traceRes.data.records.length === 0) {
|
||||
throw new Error('未找到钢卷信息');
|
||||
}
|
||||
|
||||
// 4. 找到当前数据
|
||||
// 4. 根据二维码内容匹配对应的钢卷数据
|
||||
let coilData = null;
|
||||
for (const record of traceRes.data.records) {
|
||||
if (record.dataType === 1 && record.currentCoilNo === currentCoilNo) {
|
||||
coilData = record;
|
||||
break;
|
||||
}
|
||||
const records = traceRes.data.records;
|
||||
|
||||
// 优先使用coil_id精确匹配
|
||||
if (coilId) {
|
||||
coilData = records.find(record => String(record.coilId) === String(coilId));
|
||||
}
|
||||
|
||||
// 如果没找到,使用currentCoilNo匹配
|
||||
if (!coilData && currentCoilNo) {
|
||||
coilData = records.find(record => record.currentCoilNo === currentCoilNo);
|
||||
}
|
||||
|
||||
// 如果还是没找到,取第一条记录
|
||||
if (!coilData && records.length > 0) {
|
||||
coilData = records[0];
|
||||
}
|
||||
|
||||
if (!coilData) {
|
||||
for (const record of traceRes.data.records) {
|
||||
if (record.dataType === 1) {
|
||||
coilData = record;
|
||||
break;
|
||||
}
|
||||
}
|
||||
throw new Error('未找到对应的钢卷数据');
|
||||
}
|
||||
|
||||
if (!coilData) {
|
||||
coilData = traceRes.data.records[0];
|
||||
// 5. 检查是否为历史数据
|
||||
if (coilData.dataType === 0) {
|
||||
uni.showModal({
|
||||
title: '历史数据',
|
||||
content: '此为历史记录,不允许进行合卷操作',
|
||||
showCancel: false
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 5. 检查是否已扫描过
|
||||
// 6. 检查是否已扫描过
|
||||
const exists = this.scannedCoils.some(coil => coil.coilId === coilData.coilId);
|
||||
if (exists) {
|
||||
uni.showToast({
|
||||
@@ -370,9 +473,6 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
// 保存二维码状态到钢卷数据中
|
||||
coilData.qrcodeStatus = qrcodeStatus;
|
||||
|
||||
this.scannedCoils.push(coilData);
|
||||
|
||||
console.log('钢卷详情:', coilData);
|
||||
@@ -425,6 +525,9 @@ export default {
|
||||
this.warehouseId = undefined;
|
||||
this.warehouseName = '';
|
||||
this.warehouseKeyword = '';
|
||||
this.itemType = '';
|
||||
this.itemId = undefined;
|
||||
this.selectedProductName = '';
|
||||
this.grossWeight = '';
|
||||
this.netWeight = '';
|
||||
this.showWarehouseList = false;
|
||||
@@ -435,11 +538,12 @@ export default {
|
||||
|
||||
// 提交合卷
|
||||
handleConfirm() {
|
||||
// 检查是否包含历史二维码
|
||||
if (this.hasHistoryQrcode) {
|
||||
// 检查是否包含历史数据
|
||||
const hasHistoryData = this.scannedCoils.some(coil => coil.dataType === 0);
|
||||
if (hasHistoryData) {
|
||||
uni.showModal({
|
||||
title: '包含历史二维码',
|
||||
content: '列表中包含已失效的二维码,不允许进行合卷操作,请移除后重试',
|
||||
title: '包含历史数据',
|
||||
content: '列表中包含历史记录,不允许进行合卷操作,请移除后重试',
|
||||
showCancel: false
|
||||
});
|
||||
return;
|
||||
@@ -481,8 +585,8 @@ export default {
|
||||
currentCoilNo: this.mergedCoilNo,
|
||||
team: this.team,
|
||||
hasMergeSplit: 2, // 2表示合卷
|
||||
itemType: this.scannedCoils[0].itemType,
|
||||
itemId: this.scannedCoils[0].itemId,
|
||||
itemType: this.itemType || this.scannedCoils[0].itemType, // 优先使用选择的itemType
|
||||
itemId: this.itemId || this.scannedCoils[0].itemId, // 优先使用选择的itemId
|
||||
warehouseId: this.warehouseId || this.scannedCoils[0].warehouseId, // 使用选择的库区或第一个钢卷的库区
|
||||
grossWeight: this.grossWeight ? Number(this.grossWeight) : null,
|
||||
netWeight: this.netWeight ? Number(this.netWeight) : null,
|
||||
|
||||
Reference in New Issue
Block a user