将每一步的钢卷二维码进行保存,新步骤采用新码

This commit is contained in:
2025-10-30 17:07:02 +08:00
parent 7ea75aef84
commit 20481d28a6
3 changed files with 509 additions and 166 deletions

View File

@@ -33,17 +33,9 @@
</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="form-card" v-if="form.coilId && qrcodeStatus === 1" @click="closeWarehouseList">
<view class="form-card" v-if="form.coilId" @click="closeWarehouseList">
<view class="card-title">
<text class="title-dot"></text>
<text class="title-text">分卷配置</text>
@@ -110,6 +102,21 @@
<text class="picker-arrow"></text>
</view>
</view>
<!-- 产品选择仅当该分卷选择了成品库区时显示 -->
<view class="split-field" v-if="item.itemType === 'product'">
<text class="field-label-optional">选择产品</text>
<view
class="picker-input"
@click="showProductPickerForItem(index)"
>
<text class="picker-text" :class="{ 'picker-placeholder': !item.productName }">
{{ item.productName || '请选择产品' }}
</text>
<text class="picker-arrow"></text>
</view>
</view>
<view class="split-field">
<text class="field-label-optional">毛重 (kg)</text>
<input
@@ -178,6 +185,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="closeProductPickerForItem"></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="currentPickerItemIndex !== -1 && splitCoils[currentPickerItemIndex].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>
@@ -185,6 +224,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() {
@@ -223,9 +263,11 @@ export default {
warehouses: [],
warehouseSearchKeyword: '',
filteredWarehousesInPicker: [],
products: [], // 产品列表
productSearchKeyword: '',
filteredProductsInPicker: [],
currentPickerItemIndex: -1,
loading: false,
qrcodeStatus: 1 // 二维码状态0=历史码1=当前有效码
loading: false
}
},
@@ -266,6 +308,111 @@ 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);
}
},
// 过滤库区(在选择器中)
filterWarehousesInPicker() {
const keyword = this.warehouseSearchKeyword.trim().toLowerCase();
if (!keyword) {
this.filteredWarehousesInPicker = [...this.warehouses];
} else {
this.filteredWarehousesInPicker = this.warehouses.filter(warehouse => {
const name = (warehouse.warehouseName || '').toLowerCase();
return name.includes(keyword);
});
}
},
// 从选择器中选择库区
async selectWarehouseFromPicker(warehouse) {
if (this.currentPickerItemIndex === -1) return;
const item = this.splitCoils[this.currentPickerItemIndex];
item.warehouseId = warehouse.warehouseId;
item.warehouseName = warehouse.warehouseName;
this.closeWarehousePickerForItem();
// 检查是否选择了成品库区
if (warehouse.warehouseName && warehouse.warehouseName.includes('成品')) {
// 加载产品列表
await this.loadProducts();
// 弹出产品选择框
this.showProductPickerForItem(this.currentPickerItemIndex);
}
},
// 显示库区选择器(为特定分卷)
showWarehousePickerForItem(index) {
this.currentPickerItemIndex = index;
this.warehouseSearchKeyword = '';
this.filteredWarehousesInPicker = [...this.warehouses];
this.$refs.warehousePopup.open();
},
// 关闭库区选择器
closeWarehousePickerForItem() {
this.$refs.warehousePopup.close();
this.currentPickerItemIndex = -1;
},
// 显示产品选择器(为特定分卷)
showProductPickerForItem(index) {
this.currentPickerItemIndex = index;
this.productSearchKeyword = '';
this.filteredProductsInPicker = [...this.products];
this.$refs.productPopup.open();
},
// 关闭产品选择器
closeProductPickerForItem() {
this.$refs.productPopup.close();
this.currentPickerItemIndex = -1;
},
// 过滤产品(在选择器中)
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) {
if (this.currentPickerItemIndex === -1) return;
const item = this.splitCoils[this.currentPickerItemIndex];
item.itemId = product.productId;
item.itemType = 'product';
item.productName = product.productName; // 保存产品名称用于显示
uni.showToast({
title: `分卷 ${this.currentPickerItemIndex + 1} 已选择产品:${product.productName}`,
icon: 'success'
});
this.closeProductPickerForItem();
},
// 过滤库区(为特定分卷)
filterWarehousesForItem(index) {
console.log(`分卷页面过滤库区,分卷${index + 1},关键词:`, this.splitCoils[index].warehouseKeyword);
@@ -352,56 +499,56 @@ export default {
throw new Error('未找到二维码记录');
}
// 2. 解析content获取enter_coil_nocurrent_coil_no
// 2. 解析content获取enter_coil_nocurrent_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;
// 保存二维码状态
this.qrcodeStatus = qrcodeRecord.status || 1;
// 如果是历史码,直接拒绝
if (this.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;
}
this.coilDetail = coilData;
this.form.coilId = coilData.coilId;
@@ -501,11 +648,11 @@ export default {
// 提交分卷
handleConfirm() {
// 历史二维码不允许分卷
if (this.qrcodeStatus === 0) {
// 历史数据不允许分卷
if (this.coilDetail.dataType === 0) {
uni.showModal({
title: '历史二维码',
content: '此二维码已失效,不允许进行分卷操作,请使用最新二维码',
title: '历史数据',
content: '此为历史记录,不允许进行分卷操作',
showCancel: false
});
return;
@@ -542,8 +689,8 @@ export default {
currentCoilNo: item.currentCoilNo,
team: item.team,
hasMergeSplit: 1,
itemType: this.coilDetail.itemType,
itemId: this.coilDetail.itemId,
itemType: item.itemType || this.coilDetail.itemType, // 优先使用分卷的itemType
itemId: item.itemId || this.coilDetail.itemId, // 优先使用分卷的itemId
warehouseId: item.warehouseId || this.coilDetail.warehouseId, // 使用分卷的库区或原库区
grossWeight: item.grossWeight ? Number(item.grossWeight) : null,
netWeight: item.netWeight ? Number(item.netWeight) : null