|
|
@@ -16,6 +16,35 @@
|
|
|
</template>
|
|
|
<template #gBody>
|
|
|
<view class="list-content">
|
|
|
+ <view class="scan" v-if="scanTie">
|
|
|
+ <view class="scan-card" style="margin-top:8px;">
|
|
|
+ <uni-easyinput
|
|
|
+ ref="tmInput"
|
|
|
+ v-model="tmId"
|
|
|
+ :input-border="false"
|
|
|
+ :clearable="false"
|
|
|
+ type="text"
|
|
|
+ placeholder="请扫描或输入贴纸ID"
|
|
|
+ @confirm="setTmOnly"
|
|
|
+ />
|
|
|
+ <text class="font-icons" @click="setTmOnly"></text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="scan" v-if="scanTie">
|
|
|
+ <view class="scan-card" style="margin-top:8px;">
|
|
|
+ <uni-easyinput
|
|
|
+ ref="partInput"
|
|
|
+ v-model="tmMaterialNo"
|
|
|
+ :input-border="false"
|
|
|
+ :clearable="false"
|
|
|
+ type="text"
|
|
|
+ placeholder="请输入料号"
|
|
|
+ @confirm="handlePartKeydown"
|
|
|
+ />
|
|
|
+ <text class="font-icons" @click="handleQueryPart"></text>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ </view>
|
|
|
<view class="scan">
|
|
|
<view class="scan-card">
|
|
|
<!-- 禁用软键盘 -->
|
|
|
@@ -165,6 +194,11 @@ export default defineComponent({
|
|
|
const errorTip = ref('')
|
|
|
const errorTipMessage = ref('')
|
|
|
const easyinput = ref('')
|
|
|
+ const partInput = ref(null) // ref 指向料号输入框
|
|
|
+ const tmMaterialNo = ref('') // 料号
|
|
|
+ const tmId = ref('') // 贴纸ID
|
|
|
+ const tmInput = ref(null) // ref 指向贴纸ID输入框
|
|
|
+ const scanTie = ref(0) // 控制贴纸和料号扫描框显示
|
|
|
const errorState = ref(0)
|
|
|
const modalForm = ref()
|
|
|
const parentRow = uni.getStorageSync('masterId') ?? {}
|
|
|
@@ -252,9 +286,10 @@ export default defineComponent({
|
|
|
uni.setStorageSync('ids', JSON.stringify(data?.inoutRequestDetailPDARespVOList?.[0] || {}))
|
|
|
// saveId.value = data?.id
|
|
|
receiveList.value = data
|
|
|
+ scanTie.value = data?.scanTie
|
|
|
currentWarehouseId.value = data?.warehouseId
|
|
|
tableData.value = data?.inoutRequestDetailPDARespVOList || []
|
|
|
-
|
|
|
+ console.log('获取到的scanTie:', scanTie.value)
|
|
|
// 1. 先清空本地已扫列表,准备重新填充
|
|
|
localScannedList.value = []
|
|
|
|
|
|
@@ -267,6 +302,17 @@ export default defineComponent({
|
|
|
|
|
|
// 3. 调用flushBeforeTableData(),以localScannedList为准重新生成beforeTableData
|
|
|
flushBeforeTableData()
|
|
|
+
|
|
|
+ // 新增:根据 scanTie 决定首次焦点
|
|
|
+ nextTick(() => {
|
|
|
+ if (Number(scanTie.value) === 1) {
|
|
|
+ // 先让贴纸 ID 框聚焦
|
|
|
+ tmInput.value.onBlur()
|
|
|
+ tmInput.value.onFocus()
|
|
|
+ } else {
|
|
|
+ setInputFocus()
|
|
|
+ }
|
|
|
+ })
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
title: msg,
|
|
|
@@ -309,19 +355,35 @@ export default defineComponent({
|
|
|
|
|
|
/* 2. FIFO 校验 */
|
|
|
const ok = await checkFifo(qrCode);
|
|
|
- if (!ok && !fifoGo.value) return;
|
|
|
+ if (!ok && !fifoGo.value) {
|
|
|
+ // 新增:清空二维码框并重新聚焦
|
|
|
+ resetAllInputs() // 如果你只想清二维码,也可以只写 scanBatchNumber.value = ''
|
|
|
+ nextTick(() => easyinput.value.onFocus())
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
/* 3. 业务接口 */
|
|
|
- uni.$reqGet('scanPrepareMaterial', { qrCode,requestNo: receiveList.value.requestNo,businessType:receiveList.value.businessType })
|
|
|
+ uni.$reqGet('scanPrepareMaterial', {
|
|
|
+ qrCode,
|
|
|
+ requestNo: receiveList.value.requestNo,
|
|
|
+ businessType: receiveList.value.businessType,
|
|
|
+ tmMaterialNo: tmMaterialNo.value.trim(),
|
|
|
+ tmId: tmId.value.trim()
|
|
|
+ })
|
|
|
.then(({ code, data, msg }) => {
|
|
|
fifoGo.value = false;
|
|
|
if (code !== 0) {
|
|
|
// #ifdef APP-PLUS
|
|
|
plus.device.beep(2);
|
|
|
// #endif
|
|
|
+ resetAllInputs(); // ← 新增
|
|
|
errorTipMessage.value = msg;
|
|
|
errorTip.value.open();
|
|
|
errorState.value = 0;
|
|
|
+ /* 补焦点 */
|
|
|
+ nextTick(() => {
|
|
|
+ Number(scanTie.value) === 1 ? tmInput.value.onFocus() : easyinput.value.onFocus()
|
|
|
+ });
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -367,7 +429,16 @@ export default defineComponent({
|
|
|
supplierName: currentScanMaterial.value.supplierName || '',
|
|
|
});
|
|
|
flushBeforeTableData();
|
|
|
- setInputFocus();
|
|
|
+
|
|
|
+ /* 唯一成功出口:全部清空 */
|
|
|
+ resetAllInputs();
|
|
|
+
|
|
|
+ /* 再决定下一个焦点 */
|
|
|
+ nextTick(() => {
|
|
|
+ Number(scanTie.value) === 1
|
|
|
+ ? tmInput.value.onFocus() // 贴纸模式→回到贴纸框
|
|
|
+ : easyinput.value.onFocus() // 原模式→回到二维码框
|
|
|
+ });
|
|
|
} else {
|
|
|
// #ifdef APP-PLUS
|
|
|
plus.device.beep(2);
|
|
|
@@ -457,10 +528,20 @@ export default defineComponent({
|
|
|
const qrCode = e;
|
|
|
/* ===== 新增 FIFO 校验 ===== */
|
|
|
const ok = await checkFifo(qrCode);
|
|
|
- if (!ok && !fifoGo.value) return;
|
|
|
+ if (!ok && !fifoGo.value) {
|
|
|
+ resetAllInputs()
|
|
|
+ nextTick(() => easyinput.value.onFocus())
|
|
|
+ return;
|
|
|
+ }
|
|
|
/* ========================= */
|
|
|
|
|
|
- uni.$reqGet('scanPrepareMaterial', { qrCode,requestNo: receiveList.value.requestNo,businessType:receiveList.value.businessType })
|
|
|
+ uni.$reqGet('scanPrepareMaterial', {
|
|
|
+ qrCode,
|
|
|
+ requestNo: receiveList.value.requestNo,
|
|
|
+ businessType: receiveList.value.businessType,
|
|
|
+ tmMaterialNo: tmMaterialNo.value.trim(),
|
|
|
+ tmId: tmId.value.trim(),
|
|
|
+ })
|
|
|
.then(async ({ code, data, msg }) => {
|
|
|
scanBatchNumber.value = qrCode;
|
|
|
fifoGo.value = false;
|
|
|
@@ -468,9 +549,15 @@ export default defineComponent({
|
|
|
// #ifdef APP-PLUS
|
|
|
plus.device.beep(2);
|
|
|
// #endif
|
|
|
+ /* 1. 全部输入框清空(含二维码) */
|
|
|
+ resetAllInputs()
|
|
|
errorTipMessage.value = msg;
|
|
|
errorTip.value.open();
|
|
|
errorState.value = 0;
|
|
|
+ /* 2. 焦点回到正确的输入框 */
|
|
|
+ nextTick(() => {
|
|
|
+ Number(scanTie.value) === 1 ? tmInput.value.onFocus() : easyinput.value.onFocus()
|
|
|
+ });
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -546,9 +633,82 @@ export default defineComponent({
|
|
|
}
|
|
|
|
|
|
const setInputFocus = function() {
|
|
|
+ if (Number(scanTie.value) === 1) {
|
|
|
+ // 闭环:回到贴纸 ID
|
|
|
+ nextTick(() => {
|
|
|
+ tmInput.value.onBlur()
|
|
|
+ tmInput.value.onFocus()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 原逻辑:继续在二维码框循环
|
|
|
+ easyinput.value.onBlur()
|
|
|
+ easyinput.value.onFocus()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 统一出口:清空所有输入框 */
|
|
|
+ const resetAllInputs = () => {
|
|
|
scanBatchNumber.value = ''
|
|
|
- easyinput.value.onBlur()
|
|
|
- easyinput.value.onFocus()
|
|
|
+ tmMaterialNo.value = ''
|
|
|
+ tmId.value = ''
|
|
|
+ }
|
|
|
+
|
|
|
+ /* ===== 2. 键盘回车 ===== */
|
|
|
+ const handlePartKeydown = async (e) => {
|
|
|
+ const desc = tmMaterialNo.value.trim()
|
|
|
+ if (!desc) return
|
|
|
+ await queryPart(desc)
|
|
|
+ }
|
|
|
+
|
|
|
+ /* ===== 3. 右侧图标点击 ===== */
|
|
|
+ const handleQueryPart = async () => {
|
|
|
+ const desc = tmMaterialNo.value.trim()
|
|
|
+ if (!desc) return
|
|
|
+ await queryPart(desc)
|
|
|
+ }
|
|
|
+
|
|
|
+ /* ===== 4. 真正查料号 ===== */
|
|
|
+ /* ===== 料号框:只保存,不调接口 ===== */
|
|
|
+ const queryPart = (desc) => {
|
|
|
+ tmMaterialNo.value = desc.trim() // 1. 保存
|
|
|
+ if (Number(scanTie.value) === 1) {
|
|
|
+ nextTick(() => { // 2. 跳二维码框
|
|
|
+ easyinput.value.onBlur()
|
|
|
+ easyinput.value.onFocus()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ nextTick(() => easyinput.value.onFocus())
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* ===== 5. 料号框重新聚焦 ===== */
|
|
|
+ const setPartFocus = () => {
|
|
|
+ if (Number(scanTie.value) === 1) {
|
|
|
+ nextTick(() => {
|
|
|
+ easyinput.value.onBlur()
|
|
|
+ easyinput.value.onFocus()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 非贴纸模式保持原逻辑(仅保存)
|
|
|
+ partInput.value.onBlur()
|
|
|
+ partInput.value.onFocus()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* ===== 2. 仅保存贴纸ID,不请求 ===== */
|
|
|
+ const setTmOnly = () => {
|
|
|
+ tmId.value = tmId.value.trim()
|
|
|
+ if (Number(scanTie.value) === 1) {
|
|
|
+ // 只在贴纸模式下才自动跳料号
|
|
|
+ nextTick(() => {
|
|
|
+ partInput.value.onBlur()
|
|
|
+ partInput.value.onFocus()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 非贴纸模式保持原逻辑(仅保存)
|
|
|
+ tmInput.value.onBlur()
|
|
|
+ tmInput.value.onFocus()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 相同物料+相同批号才合并数量,否则新增一行
|
|
|
@@ -890,6 +1050,16 @@ const checkFifo = (qrCode) => {
|
|
|
touchMove,
|
|
|
touchEnd,
|
|
|
deleteItem,
|
|
|
+ scanTie,
|
|
|
+ // 料号输入相关
|
|
|
+ tmMaterialNo,
|
|
|
+ partInput,
|
|
|
+ handlePartKeydown,
|
|
|
+ handleQueryPart,
|
|
|
+ // 贴纸ID输入相关
|
|
|
+ tmId,
|
|
|
+ tmInput,
|
|
|
+ setTmOnly,
|
|
|
// FIFO相关
|
|
|
fifoPopup,
|
|
|
fifoMsg,
|