|
|
|
|
@ -3,18 +3,10 @@ |
|
|
|
|
<uni-forms ref="wrForm" class="formBox" label-position="top"> |
|
|
|
|
<uni-forms-item label="扫描模式:" label-width="100px" class="label-left"> |
|
|
|
|
<view class="mode-switch"> |
|
|
|
|
<view |
|
|
|
|
class="switch-btn" |
|
|
|
|
:class="{ active: scanMode === 'bind' }" |
|
|
|
|
@click="handleModeChange('bind')" |
|
|
|
|
> |
|
|
|
|
<view class="switch-btn" :class="{ active: scanMode === 'bind' }" @click="handleModeChange('bind')"> |
|
|
|
|
绑定 |
|
|
|
|
</view> |
|
|
|
|
<view |
|
|
|
|
class="switch-btn" |
|
|
|
|
:class="{ active: scanMode === 'unbind' }" |
|
|
|
|
@click="handleModeChange('unbind')" |
|
|
|
|
> |
|
|
|
|
<view class="switch-btn" :class="{ active: scanMode === 'unbind' }" @click="handleModeChange('unbind')"> |
|
|
|
|
解绑 |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
@ -25,11 +17,7 @@ |
|
|
|
|
<template #label> |
|
|
|
|
<view class="custom-label"> |
|
|
|
|
<text class="label-text">物料箱条码:</text> |
|
|
|
|
<text |
|
|
|
|
v-if="scanMode === 'unbind'" |
|
|
|
|
class="one-click-unbind-btn" |
|
|
|
|
@click="handleOneClickUnbind" |
|
|
|
|
> |
|
|
|
|
<text v-if="scanMode === 'unbind'" class="one-click-unbind-btn" @click="handleOneClickUnbind"> |
|
|
|
|
一键解绑 |
|
|
|
|
</text> |
|
|
|
|
</view> |
|
|
|
|
@ -37,17 +25,10 @@ |
|
|
|
|
<view class="bottom-input-row"> |
|
|
|
|
<view class="weight-input-wrapper"> |
|
|
|
|
<view class="input-box"> |
|
|
|
|
<!-- 修改点 1: 使用 mixin 的 oneInput 和 oneInputBlur --> |
|
|
|
|
<input |
|
|
|
|
type="text" |
|
|
|
|
v-model="oneInput" |
|
|
|
|
@input="oneInputBlur" |
|
|
|
|
placeholder="物料箱条码" |
|
|
|
|
class="uni-input-border" |
|
|
|
|
:focus="boxInputFocus" |
|
|
|
|
:key="'box-' + boxInputFocus" |
|
|
|
|
/> |
|
|
|
|
<view v-if="oneInput" class="clear-icon" @click="clearBoxInput">清空</view> |
|
|
|
|
<!-- 修改: 移除 @confirm,保留 v-model 和 focus --> |
|
|
|
|
<input type="text" v-model="boxCode" placeholder="物料箱条码" class="uni-input-border" :focus="boxInputFocus" |
|
|
|
|
@focus="onBoxFocus" @confirm="handleBoxConfirm" /> |
|
|
|
|
<view v-if="boxCode" class="clear-icon" @click="clearBoxInput">清空</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
@ -60,36 +41,22 @@ |
|
|
|
|
<view class="stats-right"> |
|
|
|
|
<view class="stats-item"> |
|
|
|
|
<text class="stats-label">配送终点</text> |
|
|
|
|
<text class="stats-value" |
|
|
|
|
>{{ boxInfo.wcName |
|
|
|
|
}}{{ |
|
|
|
|
<text class="stats-value">{{ boxInfo.wcName |
|
|
|
|
}}{{ |
|
|
|
|
boxInfo.stationRegion ? "-" + boxInfo.stationRegion : "" |
|
|
|
|
}}</text |
|
|
|
|
> |
|
|
|
|
}}</text> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</uni-forms-item> |
|
|
|
|
|
|
|
|
|
<!-- 流程卡输入 --> |
|
|
|
|
<uni-forms-item |
|
|
|
|
:label=" |
|
|
|
|
scanMode === 'bind' ? `扫描流程卡(装箱):` : `扫描流程卡(解绑):` |
|
|
|
|
" |
|
|
|
|
label-width="200px" |
|
|
|
|
> |
|
|
|
|
<!-- 修改点 2: 使用 mixin 的 twoInput 和 twoInputBlur --> |
|
|
|
|
<input |
|
|
|
|
type="text" |
|
|
|
|
v-model="twoInput" |
|
|
|
|
@input="twoInputBlur" |
|
|
|
|
:disabled="!activeBox" |
|
|
|
|
placeholder="流程卡号" |
|
|
|
|
class="uni-input-border" |
|
|
|
|
:class="{ 'input-disabled': !activeBox }" |
|
|
|
|
:focus="cardInputFocus" |
|
|
|
|
:key="'card-' + cardInputFocus" |
|
|
|
|
/> |
|
|
|
|
<uni-forms-item :label="scanMode === 'bind' ? `扫描流程卡(装箱):` : `扫描流程卡(解绑):` |
|
|
|
|
" label-width="200px"> |
|
|
|
|
<!-- 修改: 移除 @confirm,保留 v-model 和 focus --> |
|
|
|
|
<input type="text" v-model="cardCode" :disabled="!activeBox" placeholder="流程卡号" class="uni-input-border" |
|
|
|
|
:class="{ 'input-disabled': !activeBox }" :focus="cardInputFocus" @focus="onCardFocus" |
|
|
|
|
@confirm="handleCardConfirm" /> |
|
|
|
|
</uni-forms-item> |
|
|
|
|
</uni-forms> |
|
|
|
|
|
|
|
|
|
@ -97,11 +64,9 @@ |
|
|
|
|
<view class="orders-header"> |
|
|
|
|
<view class="orders-left"> |
|
|
|
|
<text class="orders-icon"></text> |
|
|
|
|
<text class="orders-title" |
|
|
|
|
>箱内明细 ({{ |
|
|
|
|
boxInfo.yieldOrderList ? boxInfo.yieldOrderList.length : 0 |
|
|
|
|
}})</text |
|
|
|
|
> |
|
|
|
|
<text class="orders-title">箱内明细 ({{ |
|
|
|
|
boxInfo.yieldOrderList ? boxInfo.yieldOrderList.length : 0 |
|
|
|
|
}})</text> |
|
|
|
|
</view> |
|
|
|
|
<view class="orders-right"> |
|
|
|
|
<text class="orders-weight-label">总重量:</text> |
|
|
|
|
@ -116,24 +81,19 @@ |
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
<view v-else class="orders-list"> |
|
|
|
|
<view |
|
|
|
|
v-for="(order, index) in boxInfo.yieldOrderList" |
|
|
|
|
:key="order.id" |
|
|
|
|
class="order-card" |
|
|
|
|
:class="{ 'order-latest': index === 0 }" |
|
|
|
|
> |
|
|
|
|
<view v-for="(order, index) in boxInfo.yieldOrderList" :key="order.id" class="order-card" |
|
|
|
|
:class="{ 'order-latest': index === 0 }"> |
|
|
|
|
<view class="order-header"> |
|
|
|
|
<text class="order-no">{{ order.woOrder }}流程卡号</text> |
|
|
|
|
<text class="order-no">{{ order.cardNo }}</text> |
|
|
|
|
</view> |
|
|
|
|
<view class="order-footer"> |
|
|
|
|
<text class="order-part">{{ order.partCode }}</text> |
|
|
|
|
<text class="order-weight" |
|
|
|
|
>{{ |
|
|
|
|
order.actualWeighing >= 0 || order.actualWeighing != null |
|
|
|
|
? order.actualWeighing + "g" |
|
|
|
|
: 0 + "g" |
|
|
|
|
}} |
|
|
|
|
<text class="order-weight">{{ |
|
|
|
|
order.actualWeighing >= 0 || order.actualWeighing != null |
|
|
|
|
? order.actualWeighing + "g" |
|
|
|
|
: 0 + "g" |
|
|
|
|
}} |
|
|
|
|
</text> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
@ -144,31 +104,34 @@ |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import ifrm from "@/pages/index/ifrm"; |
|
|
|
|
import inputBlur from '@/mixin/inputBlur.js'; |
|
|
|
|
import scan from '../../mixin/scan.js'; |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
mixins: [inputBlur], // 引入 mixin |
|
|
|
|
components: { |
|
|
|
|
ifrm, |
|
|
|
|
}, |
|
|
|
|
mixins: [scan], // 引入 scan mixin |
|
|
|
|
onNavigationBarButtonTap(btn) { |
|
|
|
|
this.$refs.ifrm.topMenuClick(btn); |
|
|
|
|
}, |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
// 注意:oneInput, twoInput, oldOneInput 等已由 mixin 提供,无需在此重复定义 |
|
|
|
|
list: ["绑定", "解绑"], |
|
|
|
|
current: 1, |
|
|
|
|
boxInfo: { |
|
|
|
|
yieldOrderList: [], |
|
|
|
|
}, |
|
|
|
|
// 移除 boxCode 和 cardCode,改用 mixin 的 oneInput/twoInput |
|
|
|
|
boxCode: "", |
|
|
|
|
cardCode: "", |
|
|
|
|
activeBox: null, |
|
|
|
|
orders: [], |
|
|
|
|
boxInputFocus: true, |
|
|
|
|
cardInputFocus: false, |
|
|
|
|
scanMode: "bind", |
|
|
|
|
hasData: false, |
|
|
|
|
|
|
|
|
|
// 新增:标记当前扫码目标 'box' 或 'card' |
|
|
|
|
currentScanTarget: 'box' |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
computed: { |
|
|
|
|
@ -192,28 +155,45 @@ export default { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
// 清空物料箱输入 |
|
|
|
|
clearBoxInput() { |
|
|
|
|
this.clearOneInput(); // 调用 mixin 的清空方法 |
|
|
|
|
this.boxInputFocus = false; |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
this.boxInputFocus = true; |
|
|
|
|
}); |
|
|
|
|
// --- 焦点监听与目标切换 --- |
|
|
|
|
onBoxFocus() { |
|
|
|
|
this.currentScanTarget = 'box'; |
|
|
|
|
}, |
|
|
|
|
onCardFocus() { |
|
|
|
|
this.currentScanTarget = 'card'; |
|
|
|
|
}, |
|
|
|
|
// --- 手动输入回车处理 --- |
|
|
|
|
handleBoxConfirm() { |
|
|
|
|
if (!this.boxCode) return; |
|
|
|
|
// 调用核心扫码/处理逻辑 |
|
|
|
|
this.handleBoxScan(this.boxCode.trim()); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 【核心修改】实现 mixin 要求的回调方法:处理物料箱扫码结果 |
|
|
|
|
oneInputData(val) { |
|
|
|
|
// val 是 mixin 截取后的新扫码内容 |
|
|
|
|
if (!val) return; |
|
|
|
|
handleCardConfirm() { |
|
|
|
|
if (!this.cardCode) return; |
|
|
|
|
// 调用核心扫码/处理逻辑 |
|
|
|
|
this.handleCardScan(this.cardCode.trim()); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// --- 核心扫码回调 (由 scan mixin 触发) --- |
|
|
|
|
getBarCode(code) { |
|
|
|
|
if (!code) return; |
|
|
|
|
const trimCode = code.trim(); |
|
|
|
|
|
|
|
|
|
const code = val.trim(); |
|
|
|
|
this.handleBoxConfirmLogic(code); |
|
|
|
|
if (this.currentScanTarget === 'box') { |
|
|
|
|
this.handleBoxScan(trimCode); |
|
|
|
|
} else { |
|
|
|
|
this.handleCardScan(trimCode); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 原 handleBoxConfirm 的逻辑抽取 |
|
|
|
|
handleBoxConfirmLogic(code) { |
|
|
|
|
// --- 物料箱扫码逻辑 --- |
|
|
|
|
handleBoxScan(code) { |
|
|
|
|
if (!code) return; |
|
|
|
|
|
|
|
|
|
// 更新显示 |
|
|
|
|
this.boxCode = code; |
|
|
|
|
|
|
|
|
|
this.$u.api |
|
|
|
|
.boxbarcodeDetails({ boxBarcode: code, isDetail: false }) |
|
|
|
|
.then((res) => { |
|
|
|
|
@ -222,48 +202,39 @@ export default { |
|
|
|
|
this.boxInfo.yieldOrderList = []; |
|
|
|
|
} |
|
|
|
|
this.activeBox = code; |
|
|
|
|
|
|
|
|
|
this.boxCode = ''; |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: `物料箱 ${code} 已就绪`, |
|
|
|
|
icon: "none", |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 扫码成功后,自动切换到流程卡输入框 |
|
|
|
|
this.boxInputFocus = false; |
|
|
|
|
this.cardInputFocus = true; |
|
|
|
|
// 成功则自动切换到流程卡 |
|
|
|
|
this.cardCode = ''; |
|
|
|
|
this.switchToCard(); |
|
|
|
|
}) |
|
|
|
|
.catch(err => { |
|
|
|
|
uni.showToast({ title: err || '查询失败', icon: 'none' }); |
|
|
|
|
// 失败时保持焦点在物料箱,方便重扫 |
|
|
|
|
this.oneInput = ''; |
|
|
|
|
this.oldOneInput = ''; |
|
|
|
|
this.boxInputFocus = false; |
|
|
|
|
this.$nextTick(() => { this.boxInputFocus = true; }); |
|
|
|
|
uni.showToast({ title: err || '查询失败', icon: 'none' }); |
|
|
|
|
this.boxCode = ''; |
|
|
|
|
this.switchToBox(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 【核心修改】实现 mixin 要求的回调方法:处理流程卡扫码结果 |
|
|
|
|
twoInputData(val) { |
|
|
|
|
// val 是 mixin 截取后的新扫码内容 |
|
|
|
|
if (!val) return; |
|
|
|
|
|
|
|
|
|
const code = val.trim(); |
|
|
|
|
this.handleCardConfirmLogic(code); |
|
|
|
|
}, |
|
|
|
|
// --- 流程卡扫码逻辑 --- |
|
|
|
|
handleCardScan(code) { |
|
|
|
|
if (!code) return; |
|
|
|
|
|
|
|
|
|
// 原 handleCardConfirm 的逻辑抽取 |
|
|
|
|
handleCardConfirmLogic(code) { |
|
|
|
|
if (!this.activeBox) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: "请先扫描物料箱条码", |
|
|
|
|
icon: "none", |
|
|
|
|
}); |
|
|
|
|
// 跳回物料箱 |
|
|
|
|
this.cardInputFocus = false; |
|
|
|
|
this.boxInputFocus = true; |
|
|
|
|
this.switchToBox(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 更新显示 |
|
|
|
|
this.cardCode = code; |
|
|
|
|
|
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: "查询中...", |
|
|
|
|
mask: true, |
|
|
|
|
@ -358,12 +329,8 @@ export default { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 无论成功失败,清空输入框并保持焦点在流程卡,以便连续扫码 |
|
|
|
|
this.twoInput = ''; |
|
|
|
|
this.oldTwoInput = ''; |
|
|
|
|
this.cardInputFocus = false; |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
this.cardInputFocus = true; |
|
|
|
|
}); |
|
|
|
|
this.cardCode = ''; |
|
|
|
|
this.switchToCard(); |
|
|
|
|
}) |
|
|
|
|
.catch((err) => { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
@ -371,15 +338,34 @@ export default { |
|
|
|
|
title: err, |
|
|
|
|
icon: "error", |
|
|
|
|
}); |
|
|
|
|
this.twoInput = ''; |
|
|
|
|
this.oldTwoInput = ''; |
|
|
|
|
this.cardInputFocus = false; |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
this.cardInputFocus = true; |
|
|
|
|
}); |
|
|
|
|
this.cardCode = ''; |
|
|
|
|
this.switchToCard(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// --- 辅助方法 --- |
|
|
|
|
switchToBox() { |
|
|
|
|
this.cardInputFocus = false; |
|
|
|
|
this.currentScanTarget = 'box'; |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
this.boxInputFocus = true; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
switchToCard() { |
|
|
|
|
this.boxInputFocus = false; |
|
|
|
|
this.currentScanTarget = 'card'; |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
this.cardInputFocus = true; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
clearBoxInput() { |
|
|
|
|
this.boxCode = ""; |
|
|
|
|
this.activeBox = null; |
|
|
|
|
this.boxInfo = { yieldOrderList: [] }; |
|
|
|
|
this.switchToBox(); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
handleOneClickUnbind() { |
|
|
|
|
if (!this.activeBox) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
@ -398,13 +384,12 @@ export default { |
|
|
|
|
.then(() => { |
|
|
|
|
this.boxInfo.yieldOrderList = []; |
|
|
|
|
this.activeBox = null; |
|
|
|
|
this.clearOneInput(); // 使用 mixin 清空 |
|
|
|
|
this.boxCode = ""; |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: "解绑成功", |
|
|
|
|
icon: "success", |
|
|
|
|
}); |
|
|
|
|
this.boxInputFocus = true; |
|
|
|
|
this.cardInputFocus = false; |
|
|
|
|
this.switchToBox(); |
|
|
|
|
}) |
|
|
|
|
.catch((err) => { |
|
|
|
|
uni.showToast({ |
|
|
|
|
@ -423,11 +408,11 @@ export default { |
|
|
|
|
this.boxInfo = { |
|
|
|
|
yieldOrderList: [], |
|
|
|
|
}; |
|
|
|
|
this.clearInput(); // 使用 mixin 的 clearInput 清空所有 |
|
|
|
|
this.boxCode = ""; |
|
|
|
|
this.cardCode = ""; |
|
|
|
|
this.activeBox = null; |
|
|
|
|
this.orders = []; |
|
|
|
|
this.boxInputFocus = true; |
|
|
|
|
this.cardInputFocus = false; |
|
|
|
|
this.switchToBox(); |
|
|
|
|
|
|
|
|
|
uni.showToast({ |
|
|
|
|
title: `已切换到${mode === "bind" ? "绑定" : "解绑"}模式`, |
|
|
|
|
@ -436,6 +421,7 @@ export default { |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
refreshBoxInfo() { |
|
|
|
|
if (!this.activeBox) return; |
|
|
|
|
this.$u.api |
|
|
|
|
.boxbarcodeDetails({ boxBarcode: this.activeBox, isDetail: false }) |
|
|
|
|
.then((res) => { |
|
|
|
|
@ -445,8 +431,6 @@ export default { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 原有的 handleBoxConfirm 和 handleCardConfirm 已被拆分逻辑替代,可删除或保留作为备用 |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
</script> |
|
|
|
|
@ -661,6 +645,7 @@ export default { |
|
|
|
|
.tip-text { |
|
|
|
|
font-size: 20rpx; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.bottom-input-row { |
|
|
|
|
display: flex; |
|
|
|
|
gap: 10px; |
|
|
|
|
@ -692,6 +677,7 @@ export default { |
|
|
|
|
.submit-btn.disabled { |
|
|
|
|
opacity: 0.5; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* 在 style scoped 中添加 */ |
|
|
|
|
.delete-btn { |
|
|
|
|
position: absolute; |
|
|
|
|
@ -749,6 +735,7 @@ export default { |
|
|
|
|
flex-direction: row !important; |
|
|
|
|
margin-top: 20rpx; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.barcode-header { |
|
|
|
|
position: relative; |
|
|
|
|
width: 100%; |
|
|
|
|
@ -806,18 +793,21 @@ export default { |
|
|
|
|
.uni-forms-item { |
|
|
|
|
margin-bottom: 40rpx; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.input-box { |
|
|
|
|
position: relative; |
|
|
|
|
display: flex; |
|
|
|
|
align-items: center; |
|
|
|
|
} |
|
|
|
|
.input-box .uni-input-border{ |
|
|
|
|
|
|
|
|
|
.input-box .uni-input-border { |
|
|
|
|
flex: 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.clear-icon { |
|
|
|
|
position: absolute; |
|
|
|
|
right: 10rpx; |
|
|
|
|
color:#999; |
|
|
|
|
color: #999; |
|
|
|
|
padding: 5rpx 10rpx 5rpx 5rpx; |
|
|
|
|
} |
|
|
|
|
</style> |
|
|
|
|
|