Commit 799be948 authored by wangwenjie's avatar wangwenjie

接口对接

parent 091ea1b1
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
:key="item.BrandId || index" :key="item.BrandId || index"
:class="{ :class="{
'selected-item': fieldValue && item.boxBarProductLineDeviceCode === fieldValue, 'selected-item': fieldValue && item.boxBarProductLineDeviceCode === fieldValue,
'scanned-item': isScannedItem(item, index) 'scanned-item': isScannedItem(item)
}" }"
> >
<p class="item-index">{{ (currentPage - 1) * pageSize + index + 1 }}</p> <p class="item-index">{{ (currentPage - 1) * pageSize + index + 1 }}</p>
...@@ -132,16 +132,17 @@ export default { ...@@ -132,16 +132,17 @@ export default {
[Field.name]: Field, [Field.name]: Field,
}, },
mounted() { mounted() {
// 实际使用时,打开下方注释,关闭硬编码的测试调用 // 扫码回调函数
this.$nativeQRCode.setCallBackFun((res) => { this.$nativeQRCode.setCallBackFun((res) => {
let qrCode = getStringByTwo(res) let qrCode = getStringByTwo(res)
this.queryQrCodeMap(qrCode); if(!this.scanned){
this.queryQrCodeMap(qrCode);
}else {
this.handleScannedQrCode(qrCode);
}
}); });
ScanOverlay.show('请扫描二维码')
// 测试调用:传入固定二维码,实际使用时删除这行 // 测试调用:传入固定二维码,实际使用时删除这行
// this.queryQrCodeMap("HTTPS://T2DC.CN/99.1000.1/AC30938762037000169010280752062202603240016460168A00296K16LRN1YQUVLOWZHHZMOVJ2C"); // this.queryQrCodeMap("HTTPS://T2DC.CN/99.1000.1/AC30938762037000169010280752062202604020016460168A00296L4DUJDGOLTNA38RAN5XBRJ7T");
}, },
data() { data() {
...@@ -152,6 +153,7 @@ export default { ...@@ -152,6 +153,7 @@ export default {
pickerValue: "", pickerValue: "",
showPicker: false, showPicker: false,
scanned: false, scanned: false,
scannedCodes: [], // 新增:存储已扫描的条码
// 仅保留基础结构,无静态数据 // 仅保留基础结构,无静态数据
data: { data: {
qrCode: "", qrCode: "",
...@@ -191,11 +193,6 @@ export default { ...@@ -191,11 +193,6 @@ export default {
const start = (this.currentPage - 1) * this.pageSize; const start = (this.currentPage - 1) * this.pageSize;
const end = start + this.pageSize; const end = start + this.pageSize;
return list.slice(start, end); return list.slice(start, end);
},
// 选中机台号对应的所有条码项(匹配 boxBarProductLineDeviceCode 字段)
targetItems() {
if (!this.fieldValue) return [];
return (this.data.childrenList || []).filter(item => item.boxBarProductLineDeviceCode === this.fieldValue);
} }
}, },
methods: { methods: {
...@@ -227,6 +224,7 @@ export default { ...@@ -227,6 +224,7 @@ export default {
} else { } else {
Notify({ type: 'danger', message: response.msg || '查询件码失败' }); Notify({ type: 'danger', message: response.msg || '查询件码失败' });
} }
}).catch(error => { }).catch(error => {
console.error("查询接口异常:", error); console.error("查询接口异常:", error);
Notify({type: 'danger', message: '网络异常或服务错误'}); Notify({type: 'danger', message: '网络异常或服务错误'});
...@@ -253,6 +251,7 @@ export default { ...@@ -253,6 +251,7 @@ export default {
Reset() { Reset() {
this.fieldValue = ""; this.fieldValue = "";
this.scanned = false; this.scanned = false;
this.scannedCodes = []; // 清空已扫描的条码
this.currentPage = 1; // 重置回到第一页 this.currentPage = 1; // 重置回到第一页
}, },
// 格式化条码:截取后10位,前面拼接... // 格式化条码:截取后10位,前面拼接...
...@@ -268,19 +267,46 @@ export default { ...@@ -268,19 +267,46 @@ export default {
return; return;
} }
this.scanned = true; this.scanned = true;
Notify({type: 'success', message: '扫码确认成功'}); // 显示扫码提示
ScanOverlay.show('请扫描条码');
Notify({type: 'success', message: '请扫描条码'});
},
// 处理扫描到的条码
handleScannedQrCode(scannedQrCode) {
if (!this.scanned) {
Notify({type: 'warning', message: '请先点击扫码确认按钮'});
return;
}
console.log("扫描到的条码:", scannedQrCode);
// 检查条码是否属于当前选择的机台号
const scannedItem = this.data.childrenList.find(item =>
item.qrCode === scannedQrCode &&
item.boxBarProductLineDeviceCode === this.fieldValue
);
if (!scannedItem) {
Notify({type: 'warning', message: '条码不属于当前机台号'});
return;
}
// 检查是否已扫描过
if (!this.scannedCodes.includes(scannedQrCode)) {
this.scannedCodes.push(scannedQrCode);
Notify({type: 'success', message: '扫描成功'});
} else {
Notify({type: 'warning', message: '条码已扫描'});
}
}, },
// 判断是否高亮:扫码后选中机台号的前8个项(匹配 boxBarProductLineDeviceCode 字段) // 判断是否高亮:条码是否在已扫描列表中
isScannedItem(item, index) { isScannedItem(item) {
if (!this.scanned || item.boxBarProductLineDeviceCode !== this.fieldValue) return false; return this.scannedCodes.includes(item.qrCode);
const targetIndex = this.targetItems.findIndex(i => i.BrandId === item.BrandId);
return targetIndex >= 0 && targetIndex < 8;
} }
}, },
}; };
</script> </script>
<style scoped> <style scoped>
/* CSS样式保持不变 */
:deep(.van-nav-bar__right) { :deep(.van-nav-bar__right) {
font-size: 0.45rem; font-size: 0.45rem;
color: #ffffff; color: #ffffff;
...@@ -467,4 +493,4 @@ export default { ...@@ -467,4 +493,4 @@ export default {
.query-btns { .query-btns {
bottom: 1.2rem; bottom: 1.2rem;
} }
</style> </style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment