修改订单复核页面
This commit is contained in:
parent
797aacd748
commit
0274ce46aa
@ -2,6 +2,7 @@
|
||||
"version" : "1.0",
|
||||
"configurations" : [
|
||||
{
|
||||
"customPlaygroundType" : "device",
|
||||
"playground" : "standard",
|
||||
"type" : "uni-app:app-android"
|
||||
}
|
||||
|
||||
@ -21,4 +21,13 @@ uni-picker .uni-picker-container .uni-picker-custom,
|
||||
width: 260rpx !important;
|
||||
box-shadow: 0 0 20px 5px rgba(0, 0, 0, 0.1) !important;
|
||||
}
|
||||
|
||||
/* H5/Electron 下 picker 下拉选项居左显示(覆盖库默认居中 text-align:center) */
|
||||
uni-picker .uni-picker-container.uni-selector-select .uni-picker-select .uni-picker-item,
|
||||
.uni-picker-container.uni-selector-select .uni-picker-select .uni-picker-item,
|
||||
uni-picker .uni-picker-container .uni-picker-view-content .uni-picker-item,
|
||||
.uni-picker-container .uni-picker-view-content .uni-picker-item {
|
||||
text-align: left;
|
||||
padding-left: 20rpx;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -122,3 +122,30 @@ export function scanReviewTask(
|
||||
options
|
||||
)
|
||||
}
|
||||
|
||||
type PrintListParams = {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
where?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印台列表(print.getList)
|
||||
* 查询当前仓库下的打印台列表,支持分页与 where 条件筛选。
|
||||
* 支持字段:id(等值)、name、computer_id、custom_barcode;
|
||||
* where 推荐使用 { operator, value, type } 标准结构。
|
||||
* 响应:data 包含 list 与 pagination。
|
||||
*/
|
||||
export function fetchPrintList(
|
||||
params: PrintListParams = {},
|
||||
options?: RequestOptions
|
||||
) {
|
||||
return request<ApiBody>(
|
||||
'print.getList',
|
||||
{
|
||||
...workerPayload,
|
||||
...params,
|
||||
},
|
||||
options
|
||||
)
|
||||
}
|
||||
|
||||
@ -20,10 +20,12 @@
|
||||
class="search-input"
|
||||
v-model="keyword"
|
||||
:placeholder="searchPlaceholder"
|
||||
:focus="false"
|
||||
:focus="searchFocus"
|
||||
:adjust-position="false"
|
||||
confirm-type="search"
|
||||
@confirm="handleConfirm"
|
||||
@focus="handleSearchFocus"
|
||||
@blur="handleSearchBlur"
|
||||
/>
|
||||
</view>
|
||||
<!-- 扫描复核结果(order.recheckOrder.scanOrder) -->
|
||||
@ -42,6 +44,7 @@
|
||||
<text class="table-cell cell-wave-index">{{ formatWaveIndex(item) }}</text>
|
||||
<text class="table-cell cell-wave-no">{{ getScanOrderNo(item) }}</text>
|
||||
<text :class="['table-cell', 'cell-print-status', getWavePrintStatus(item) === '未打印' ? 'cell-print-status--unprinted' : '']">{{ getWavePrintStatus(item) }}</text>
|
||||
<view v-if="isIntercepted(item)" class="cell-intercept" @click.stop="handleIntercept(item)">拦截</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@ -83,7 +86,7 @@
|
||||
<view class="panel-right">
|
||||
<!-- 顶部操作区:按钮 / 下拉框 / 提示信息 -->
|
||||
<view class="review-toolbar">
|
||||
<button class="tool-btn tool-btn--confirm" @click="handleConfirmReview">确认复核</button>
|
||||
<button :class="['tool-btn', interceptMode ? 'tool-btn--intercept' : 'tool-btn--confirm']" @click="handleConfirmReview">{{ interceptMode ? '确认拦截' : '确认复核' }}</button>
|
||||
<button class="tool-btn" @click="handleClear">清空</button>
|
||||
<button class="tool-btn tool-btn--blue-outline" @click="handleBatchQuickReview">批量快捷复核</button>
|
||||
<button class="tool-btn tool-btn--blue-outline" @click="handleSingleReviewList">散单复核列表</button>
|
||||
@ -206,12 +209,32 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 真机扫码捕获:保持隐藏 input 聚焦,WebView 才会持续派发按键 -->
|
||||
<input
|
||||
v-if="enableHiddenInputCapture"
|
||||
class="scan-hidden-input"
|
||||
v-model="scanHiddenValue"
|
||||
:focus="scanInputFocus"
|
||||
:adjust-position="false"
|
||||
confirm-type="done"
|
||||
@focus="handleHiddenScanFocus"
|
||||
@input="handleHiddenScanInput"
|
||||
@confirm="handleHiddenScanConfirm"
|
||||
@blur="handleHiddenScanBlur"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TopNav from '@/components/top-nav.vue'
|
||||
import { scanReviewOrder, scanReviewTask } from '@/api/order'
|
||||
import { scanReviewOrder, scanReviewTask, fetchPrintList } from '@/api/order'
|
||||
|
||||
// 扫码枪识别参数
|
||||
// 无回车结束符时:停止输入超过该毫秒数视为一次完整扫码,自动提交
|
||||
const SCAN_IDLE_TIMEOUT = 300
|
||||
// 自动提交所需的最短内容长度,避免正常输入过程中的短暂停顿触发误识别
|
||||
const SCAN_MIN_LENGTH = 2
|
||||
|
||||
export default {
|
||||
name: 'OrderReviewOnePage',
|
||||
@ -230,6 +253,35 @@ export default {
|
||||
keyword: '',
|
||||
// 当前生效的查询关键词(搜索成功后保存,供刷新按钮回退使用)
|
||||
activeKeyword: '',
|
||||
// 条码输入框激活状态:进入商品条码流程时自动聚焦,键盘输入时保持激活
|
||||
searchFocus: false,
|
||||
searchFocused: false,
|
||||
// 扫码枪无结束符自动识别:静默计时器与最后按键时间
|
||||
scanTimer: null,
|
||||
lastScanKeyTime: 0,
|
||||
// ---- 扫码枪真机兼容(移植自 login.vue)----
|
||||
// 页面激活状态:keep-alive 切换 / 页面隐藏时暂停扫码聚焦抢占
|
||||
pageActive: true,
|
||||
// 原生层(plus.key)监听
|
||||
plusKeyListener: null,
|
||||
plusKeyBuffer: '',
|
||||
plusKeyTimer: null,
|
||||
plusKeyStartedAt: 0,
|
||||
plusKeyLastAt: 0,
|
||||
// DOM 全局监听目标
|
||||
globalKeyListener: null,
|
||||
globalKeyTargets: [],
|
||||
// 隐藏 input 捕获(真机 WebView 未聚焦不派发 keydown 的兜底)
|
||||
enableHiddenInputCapture: false,
|
||||
scanInputFocus: false,
|
||||
scanHiddenValue: '',
|
||||
scanHiddenTimer: null,
|
||||
scanHiddenRefocusTimer: null,
|
||||
scanFocusResumeTimer: null,
|
||||
scanKeyboardSuppressTimers: [],
|
||||
scanHiddenFocused: false,
|
||||
// 去重:同一扫码内容短时间内的重复提交保护
|
||||
lastSubmittedScan: { code: '', at: 0 },
|
||||
// 当前拣货任务 ID(搜索成功后保存,供刷新按钮按 task_id 调用 scanTask)
|
||||
currentTaskId: null,
|
||||
// 复核扫描数量(默认 1)
|
||||
@ -254,14 +306,18 @@ export default {
|
||||
currentWaybillInfo: null,
|
||||
// 右侧顶部操作区
|
||||
selectedPrinter: '',
|
||||
selectedPrinterId: '',
|
||||
printerOpened: false,
|
||||
printerList: [],
|
||||
selectedReviewProcess: '',
|
||||
reviewProcessOpened: false,
|
||||
selectedWeigh: '不称重',
|
||||
weighOpened: false,
|
||||
printerOptions: ['打印台1', '打印台2', '打印台3'],
|
||||
reviewProcessOptions: ['先打印后复核', '先复核后打印'],
|
||||
weighOptions: ['不称重', '称重'],
|
||||
// 拦截确认模式(点击左侧"拦截"后,确认按钮变为"确认拦截")
|
||||
interceptMode: false,
|
||||
interceptTarget: null,
|
||||
// 顶部提示信息
|
||||
pickerName: '',
|
||||
storeRemark: '',
|
||||
@ -283,6 +339,19 @@ export default {
|
||||
totalQuantity() {
|
||||
return this.displayOrders.reduce((sum, order) => sum + (Number(order.quantity) || 0), 0)
|
||||
},
|
||||
printerOptions() {
|
||||
return this.printerList.map(
|
||||
(item) => item?.name || (item?.id ? `打印台${item.id}` : '未命名打印台')
|
||||
)
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
hasSelection(val) {
|
||||
// 进入商品条码流程(已选中订单)时,激活条码输入框(真机隐藏捕获时不抢占焦点)
|
||||
if (val && !this.enableHiddenInputCapture) {
|
||||
this.activateSearchInput()
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getRowValue(row, keys = []) {
|
||||
@ -343,6 +412,441 @@ export default {
|
||||
this.handleSearch()
|
||||
}
|
||||
},
|
||||
handleSearchFocus() {
|
||||
this.searchFocused = true
|
||||
},
|
||||
handleSearchBlur() {
|
||||
this.searchFocused = false
|
||||
// 输入框失焦后重置,便于后续键盘输入再次激活
|
||||
this.searchFocus = false
|
||||
},
|
||||
activateSearchInput() {
|
||||
// 请求聚焦条码输入框(实际焦点由 @focus 事件确认)
|
||||
this.searchFocus = true
|
||||
},
|
||||
/**
|
||||
* 全局键盘监听:扫码枪识别
|
||||
* 扫码枪本质是模拟键盘的 HID 设备,字符走浏览器标准 keydown 事件。
|
||||
* 策略:非聚焦时对可打印字符 / Tab / Enter(前缀键)主动抢焦点;
|
||||
* 可打印字符同时手动缓冲进 keyword,避免"聚焦发生在该字符 keydown 之后"导致首字符丢失;
|
||||
* 回车且有内容时作为结束符立即提交;无回车结束符则由静默防抖自动提交。
|
||||
*/
|
||||
handleGlobalKeydown(event) {
|
||||
if (!this.isPageActive()) {
|
||||
return
|
||||
}
|
||||
const key = event.key
|
||||
const activeEl = typeof document !== 'undefined' ? document.activeElement : null
|
||||
const inInput = !!(activeEl && (activeEl.tagName === 'INPUT' || activeEl.tagName === 'TEXTAREA'))
|
||||
|
||||
// 焦点已在输入框内(搜索/条码输入框或数量步进器):走浏览器默认输入,仅刷新防抖计时
|
||||
if (inInput) {
|
||||
this.touchScanInput()
|
||||
return
|
||||
}
|
||||
|
||||
// 真机使用隐藏 input 捕获时,非聚焦态由隐藏 input 处理,DOM 不再回填(避免双写)
|
||||
if (this.enableHiddenInputCapture) {
|
||||
return
|
||||
}
|
||||
|
||||
// 组合键(Ctrl/Alt/Meta)不处理,避免误抢焦点
|
||||
if (event.ctrlKey || event.altKey || event.metaKey) {
|
||||
return
|
||||
}
|
||||
|
||||
// 只对可打印字符(key.length === 1)和 Tab/Enter(扫码枪前缀键)响应
|
||||
const isPrintable = !!key && key.length === 1
|
||||
const isPrefixKey = key === 'Tab' || key === 'Enter'
|
||||
if (!isPrintable && !isPrefixKey) {
|
||||
return
|
||||
}
|
||||
|
||||
event.preventDefault()
|
||||
|
||||
// 可打印字符:手动缓冲进输入框,保证首字符不丢失
|
||||
if (isPrintable) {
|
||||
this.keyword = (this.keyword || '') + key
|
||||
}
|
||||
|
||||
// 主动聚焦输入框,后续字符走浏览器默认输入
|
||||
this.searchFocus = true
|
||||
|
||||
// 回车且已有缓冲内容:视为扫码结束符,立即提交
|
||||
if (key === 'Enter' && (this.keyword || '').trim()) {
|
||||
this.handleConfirm()
|
||||
}
|
||||
|
||||
this.touchScanInput()
|
||||
},
|
||||
/** 刷新扫码静默计时:记录最后按键时间并重置防抖定时器 */
|
||||
touchScanInput() {
|
||||
this.lastScanKeyTime = Date.now()
|
||||
if (this.scanTimer) {
|
||||
clearTimeout(this.scanTimer)
|
||||
}
|
||||
this.scanTimer = setTimeout(() => this.checkScanIdle(), SCAN_IDLE_TIMEOUT)
|
||||
},
|
||||
/** 静默防抖:距最后按键超过阈值且缓冲内容达标时,视为一次完整扫码并自动提交 */
|
||||
checkScanIdle() {
|
||||
this.scanTimer = null
|
||||
const elapsed = Date.now() - this.lastScanKeyTime
|
||||
const buffer = (this.keyword || '').trim()
|
||||
if (elapsed >= SCAN_IDLE_TIMEOUT && buffer.length >= SCAN_MIN_LENGTH) {
|
||||
this.handleConfirm()
|
||||
}
|
||||
},
|
||||
// ---- 真机兼容:捕获模式 / plus.key / 隐藏 input / 聚焦保持 ----
|
||||
/** 页面是否激活(keep-alive 切换 / 页面隐藏时暂停扫码聚焦抢占) */
|
||||
isPageActive() {
|
||||
return this.pageActive !== false
|
||||
},
|
||||
/** APP-PLUS 平台判断(uni-app 条件编译) */
|
||||
isAppPlus() {
|
||||
// #ifdef APP-PLUS
|
||||
return true
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
return false
|
||||
// #endif
|
||||
},
|
||||
hasPlusKeyboardSupport() {
|
||||
// #ifdef APP-PLUS
|
||||
return typeof plus !== 'undefined' && !!plus?.key?.addEventListener
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
return false
|
||||
// #endif
|
||||
},
|
||||
hasDomKeyboardSupport() {
|
||||
return typeof window !== 'undefined' || typeof document !== 'undefined'
|
||||
},
|
||||
/**
|
||||
* 选择扫码捕获模式:
|
||||
* - 桌面 H5/Electron:DOM 全局 keydown 监听(document/window,capture)
|
||||
* - 真机(App / 平板浏览器):未聚焦时 WebView/浏览器不派发 keydown,改用隐藏 input 捕获 + 强制聚焦 + plus.key 原生监听
|
||||
*/
|
||||
setupScanCaptureMode() {
|
||||
this.enableHiddenInputCapture = this.isRealDevice()
|
||||
},
|
||||
/** 是否真机(App 或移动端浏览器/平板) */
|
||||
isRealDevice() {
|
||||
// #ifdef APP-PLUS
|
||||
return true
|
||||
// #endif
|
||||
return this.isMobileBrowser()
|
||||
},
|
||||
/** 移动端浏览器/平板检测:uni 运行环境平台 + UA 双保险 */
|
||||
isMobileBrowser() {
|
||||
try {
|
||||
const info =
|
||||
typeof uni !== 'undefined' && uni.getSystemInfoSync ? uni.getSystemInfoSync() : null
|
||||
if (info && info.platform) {
|
||||
const p = String(info.platform).toLowerCase()
|
||||
if (p === 'android' || p === 'ios') {
|
||||
return true
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// 忽略:继续用 UA 判断
|
||||
}
|
||||
try {
|
||||
if (typeof navigator !== 'undefined' && navigator.userAgent) {
|
||||
return /Android|iPhone|iPad|iPod|Mobile|Tablet/i.test(navigator.userAgent)
|
||||
}
|
||||
} catch (e) {
|
||||
// 忽略
|
||||
}
|
||||
return false
|
||||
},
|
||||
attachGlobalKeyboardListener() {
|
||||
if (this.globalKeyListener) {
|
||||
return
|
||||
}
|
||||
const hasWindow = typeof window !== 'undefined'
|
||||
const hasDocument = typeof document !== 'undefined'
|
||||
const targets = []
|
||||
if (hasDocument) {
|
||||
targets.push(document)
|
||||
} else if (hasWindow) {
|
||||
targets.push(window)
|
||||
}
|
||||
if (!targets.length) {
|
||||
return
|
||||
}
|
||||
this.globalKeyTargets = targets
|
||||
this.globalKeyListener = this.handleGlobalKeydown
|
||||
this.globalKeyTargets.forEach((target) => {
|
||||
target.addEventListener('keydown', this.globalKeyListener, true)
|
||||
})
|
||||
},
|
||||
removeGlobalKeyboardListener() {
|
||||
if (!this.globalKeyTargets || !this.globalKeyListener) {
|
||||
return
|
||||
}
|
||||
this.globalKeyTargets.forEach((target) => {
|
||||
target.removeEventListener('keydown', this.globalKeyListener, true)
|
||||
})
|
||||
this.globalKeyTargets = []
|
||||
this.globalKeyListener = null
|
||||
},
|
||||
parsePlusKeyCodeToChar(keyCode) {
|
||||
if (keyCode >= 48 && keyCode <= 57) {
|
||||
return String.fromCharCode(keyCode)
|
||||
}
|
||||
if (keyCode >= 65 && keyCode <= 90) {
|
||||
return String.fromCharCode(keyCode)
|
||||
}
|
||||
if (keyCode >= 96 && keyCode <= 105) {
|
||||
return String(keyCode - 96)
|
||||
}
|
||||
if (keyCode === 189 || keyCode === 109) {
|
||||
return '-'
|
||||
}
|
||||
if (keyCode === 190 || keyCode === 110) {
|
||||
return '.'
|
||||
}
|
||||
if (keyCode === 191 || keyCode === 111) {
|
||||
return '/'
|
||||
}
|
||||
return ''
|
||||
},
|
||||
attachPlusKeyboardListener() {
|
||||
if (!this.hasPlusKeyboardSupport()) {
|
||||
return
|
||||
}
|
||||
if (this.plusKeyListener) {
|
||||
return
|
||||
}
|
||||
this.plusKeyListener = (event) => {
|
||||
if (!this.isPageActive()) {
|
||||
return
|
||||
}
|
||||
const keyCode = Number(event?.keyCode || 0)
|
||||
const isEnter = keyCode === 13 || keyCode === 66
|
||||
const text = this.parsePlusKeyCodeToChar(keyCode)
|
||||
if (text) {
|
||||
const now = Date.now()
|
||||
if (!this.plusKeyBuffer) {
|
||||
this.plusKeyStartedAt = now
|
||||
}
|
||||
this.plusKeyLastAt = now
|
||||
this.plusKeyBuffer += text
|
||||
this.clearPlusKeyTimer()
|
||||
this.plusKeyTimer = setTimeout(() => this.flushPlusKeyBuffer('timer'), 420)
|
||||
return
|
||||
}
|
||||
if (isEnter) {
|
||||
this.flushPlusKeyBuffer('enter')
|
||||
}
|
||||
}
|
||||
// #ifdef APP-PLUS
|
||||
plus.key.addEventListener('keydown', this.plusKeyListener)
|
||||
// #endif
|
||||
},
|
||||
removePlusKeyboardListener() {
|
||||
this.clearPlusKeyTimer()
|
||||
this.plusKeyBuffer = ''
|
||||
this.plusKeyStartedAt = 0
|
||||
this.plusKeyLastAt = 0
|
||||
if (!this.plusKeyListener) {
|
||||
return
|
||||
}
|
||||
// #ifdef APP-PLUS
|
||||
if (this.hasPlusKeyboardSupport()) {
|
||||
plus.key.removeEventListener('keydown', this.plusKeyListener)
|
||||
}
|
||||
// #endif
|
||||
this.plusKeyListener = null
|
||||
},
|
||||
flushPlusKeyBuffer(trigger = 'timer') {
|
||||
if (!this.isPageActive()) {
|
||||
return
|
||||
}
|
||||
const code = (this.plusKeyBuffer || '').trim()
|
||||
this.plusKeyBuffer = ''
|
||||
this.plusKeyStartedAt = 0
|
||||
this.plusKeyLastAt = 0
|
||||
this.clearPlusKeyTimer()
|
||||
if (!code) {
|
||||
return
|
||||
}
|
||||
this.submitScanCode(code, 'plus')
|
||||
},
|
||||
handleHiddenScanFocus() {
|
||||
if (!this.isPageActive() || !this.enableHiddenInputCapture) {
|
||||
return
|
||||
}
|
||||
this.scanHiddenFocused = true
|
||||
this.scanInputFocus = true
|
||||
this.clearHiddenRefocusTimer()
|
||||
this.suppressSoftKeyboardBurst()
|
||||
},
|
||||
handleHiddenScanBlur() {
|
||||
if (!this.isPageActive() || !this.enableHiddenInputCapture) {
|
||||
return
|
||||
}
|
||||
this.scanHiddenFocused = false
|
||||
this.scanInputFocus = false
|
||||
this.clearHiddenRefocusTimer()
|
||||
this.scanHiddenRefocusTimer = setTimeout(() => {
|
||||
if (!this.isPageActive() || !this.enableHiddenInputCapture) {
|
||||
return
|
||||
}
|
||||
// 用户已手动聚焦其它输入框(搜索框/数量步进器)时,不抢回焦点
|
||||
const activeEl = typeof document !== 'undefined' ? document.activeElement : null
|
||||
if (activeEl && (activeEl.tagName === 'INPUT' || activeEl.tagName === 'TEXTAREA')) {
|
||||
return
|
||||
}
|
||||
if (!this.scanHiddenFocused) {
|
||||
this.scheduleScanInputFocus(220)
|
||||
}
|
||||
}, 500)
|
||||
},
|
||||
handleHiddenScanInput(event) {
|
||||
if (!this.isPageActive() || !this.enableHiddenInputCapture) {
|
||||
return
|
||||
}
|
||||
const value = event?.detail?.value || ''
|
||||
this.scanHiddenValue = value
|
||||
// 回填到可见搜索/条码输入框,与浏览器模式表现一致
|
||||
this.keyword = value
|
||||
this.clearHiddenScanTimer()
|
||||
this.scanHiddenTimer = setTimeout(() => {
|
||||
if (!this.isPageActive() || !this.enableHiddenInputCapture) {
|
||||
return
|
||||
}
|
||||
this.processHiddenScanValue('timer')
|
||||
}, 320)
|
||||
},
|
||||
handleHiddenScanConfirm(event) {
|
||||
if (!this.isPageActive() || !this.enableHiddenInputCapture) {
|
||||
return
|
||||
}
|
||||
const value = event?.detail?.value || this.scanHiddenValue || ''
|
||||
this.scanHiddenValue = value
|
||||
this.processHiddenScanValue('confirm')
|
||||
},
|
||||
processHiddenScanValue(trigger = 'timer') {
|
||||
if (!this.isPageActive() || !this.enableHiddenInputCapture) {
|
||||
return
|
||||
}
|
||||
const code = (this.scanHiddenValue || '').trim()
|
||||
this.clearHiddenScanTimer()
|
||||
if (!code) {
|
||||
return
|
||||
}
|
||||
this.scanHiddenValue = ''
|
||||
this.dismissSoftKeyboard()
|
||||
this.submitScanCode(code, 'hidden')
|
||||
this.ensureScanInputFocus()
|
||||
},
|
||||
ensureScanInputFocus() {
|
||||
if (!this.isPageActive()) {
|
||||
return
|
||||
}
|
||||
if (!this.enableHiddenInputCapture) {
|
||||
this.scanInputFocus = false
|
||||
this.suppressSoftKeyboardBurst()
|
||||
return
|
||||
}
|
||||
if (!this.scanInputFocus) {
|
||||
this.scanInputFocus = true
|
||||
}
|
||||
},
|
||||
scheduleScanInputFocus(delay = 0) {
|
||||
if (!this.isPageActive()) {
|
||||
return
|
||||
}
|
||||
this.clearScanFocusResumeTimer()
|
||||
this.scanFocusResumeTimer = setTimeout(() => {
|
||||
if (!this.isPageActive()) {
|
||||
return
|
||||
}
|
||||
this.ensureScanInputFocus()
|
||||
}, delay)
|
||||
},
|
||||
suppressSoftKeyboardBurst() {
|
||||
if (!this.isPageActive()) {
|
||||
return
|
||||
}
|
||||
this.clearKeyboardSuppressTimers()
|
||||
uni.hideKeyboard?.()
|
||||
;[80, 180, 320].forEach((delay) => {
|
||||
const timer = setTimeout(() => {
|
||||
if (!this.isPageActive()) {
|
||||
return
|
||||
}
|
||||
uni.hideKeyboard?.()
|
||||
}, delay)
|
||||
this.scanKeyboardSuppressTimers.push(timer)
|
||||
})
|
||||
},
|
||||
dismissSoftKeyboard() {
|
||||
if (!this.isPageActive()) {
|
||||
return
|
||||
}
|
||||
if (typeof document !== 'undefined') {
|
||||
document.activeElement?.blur?.()
|
||||
}
|
||||
uni.hideKeyboard?.()
|
||||
},
|
||||
/** 统一扫码提交入口:回填 keyword 并走现有确认流程(搜索/商品条码) */
|
||||
submitScanCode(code, source) {
|
||||
if (!this.isPageActive()) {
|
||||
return
|
||||
}
|
||||
const trimmed = (code || '').trim()
|
||||
if (!trimmed) {
|
||||
return
|
||||
}
|
||||
// 去重:plus.key 与隐藏 input 可能同时捕获同一扫码,短时间重复内容忽略
|
||||
const now = Date.now()
|
||||
if (
|
||||
this.lastSubmittedScan &&
|
||||
this.lastSubmittedScan.code === trimmed &&
|
||||
now - this.lastSubmittedScan.at < 600
|
||||
) {
|
||||
return
|
||||
}
|
||||
this.lastSubmittedScan = { code: trimmed, at: now }
|
||||
this.keyword = trimmed
|
||||
this.handleConfirm()
|
||||
},
|
||||
clearPlusKeyTimer() {
|
||||
if (this.plusKeyTimer) {
|
||||
clearTimeout(this.plusKeyTimer)
|
||||
this.plusKeyTimer = null
|
||||
}
|
||||
},
|
||||
clearHiddenScanTimer() {
|
||||
if (this.scanHiddenTimer) {
|
||||
clearTimeout(this.scanHiddenTimer)
|
||||
this.scanHiddenTimer = null
|
||||
}
|
||||
},
|
||||
clearHiddenRefocusTimer() {
|
||||
if (this.scanHiddenRefocusTimer) {
|
||||
clearTimeout(this.scanHiddenRefocusTimer)
|
||||
this.scanHiddenRefocusTimer = null
|
||||
}
|
||||
},
|
||||
clearScanFocusResumeTimer() {
|
||||
if (this.scanFocusResumeTimer) {
|
||||
clearTimeout(this.scanFocusResumeTimer)
|
||||
this.scanFocusResumeTimer = null
|
||||
}
|
||||
},
|
||||
clearKeyboardSuppressTimers() {
|
||||
if (!Array.isArray(this.scanKeyboardSuppressTimers)) {
|
||||
this.scanKeyboardSuppressTimers = []
|
||||
return
|
||||
}
|
||||
this.scanKeyboardSuppressTimers.forEach((timer) => {
|
||||
clearTimeout(timer)
|
||||
})
|
||||
this.scanKeyboardSuppressTimers = []
|
||||
},
|
||||
handleBarcodeMatch() {
|
||||
const barcode = this.keyword.trim()
|
||||
if (!barcode) {
|
||||
@ -455,6 +959,8 @@ export default {
|
||||
this.currentTaskId = this.extractTaskId(payload, list)
|
||||
},
|
||||
clearSelection() {
|
||||
this.interceptMode = false
|
||||
this.interceptTarget = null
|
||||
this.selectedPendingOrderKey = ''
|
||||
this.selectedWaveKey = ''
|
||||
this.selectedOrderNo = ''
|
||||
@ -502,6 +1008,14 @@ export default {
|
||||
this.storeRemark = this.getRowValue(source, ['store_remark', 'storeRemark']) || ''
|
||||
},
|
||||
handleConfirmReview() {
|
||||
// 拦截确认模式下,执行确认拦截;否则执行确认复核
|
||||
if (this.interceptMode) {
|
||||
const orderNo = this.interceptTarget?.orderNo || this.selectedOrderNo || ''
|
||||
uni.showToast({ title: `确认拦截:${orderNo}`, icon: 'none' })
|
||||
this.interceptMode = false
|
||||
this.interceptTarget = null
|
||||
return
|
||||
}
|
||||
uni.showToast({ title: '确认复核', icon: 'none' })
|
||||
},
|
||||
handleClear() {
|
||||
@ -570,6 +1084,10 @@ export default {
|
||||
uni.showToast({ title: '称重', icon: 'none' })
|
||||
},
|
||||
handlePrinterSelectStart() {
|
||||
// 打印台列表为空时,重新拉取
|
||||
if (this.printerList.length === 0) {
|
||||
this.loadPrinters()
|
||||
}
|
||||
this.printerOpened = true
|
||||
},
|
||||
handlePrinterPickStart() {
|
||||
@ -579,7 +1097,9 @@ export default {
|
||||
this.printerOpened = false
|
||||
},
|
||||
handlePrinterChange(event) {
|
||||
this.selectedPrinter = this.printerOptions[Number(event.detail.value)] || ''
|
||||
const printer = this.printerList[Number(event.detail.value)] || null
|
||||
this.selectedPrinter = printer ? this.getPrinterName(printer) : ''
|
||||
this.selectedPrinterId = printer ? this.getPrinterId(printer) : ''
|
||||
this.printerOpened = false
|
||||
},
|
||||
handlePrinterCancel() {
|
||||
@ -617,6 +1137,23 @@ export default {
|
||||
handleWeighCancel() {
|
||||
this.weighOpened = false
|
||||
},
|
||||
getPrinterId(item) {
|
||||
return item?.id ?? item?.printer_id ?? ''
|
||||
},
|
||||
getPrinterName(item) {
|
||||
return item?.name || item?.printer_name || ''
|
||||
},
|
||||
// 拉取当前仓库打印台列表(print.getList)
|
||||
async loadPrinters() {
|
||||
try {
|
||||
const body = await fetchPrintList({ page: 1, pageSize: 100 })
|
||||
const payload = body?.data || body?.result || body || {}
|
||||
const list = Array.isArray(payload?.list) ? payload.list : []
|
||||
this.printerList = list
|
||||
} catch (error) {
|
||||
// 拉取失败时静默处理,打印台下拉为空
|
||||
}
|
||||
},
|
||||
getScanOrderSource(item) {
|
||||
if (item && typeof item === 'object' && item.detail && typeof item.detail === 'object') {
|
||||
return item.detail
|
||||
@ -687,7 +1224,31 @@ export default {
|
||||
}
|
||||
return this.getRowValue(wave, ['review_status', 'reviewStatus', 'wave_status', 'waveStatus']) || '-'
|
||||
},
|
||||
// 是否有拦截(intercept_status === 'requested')
|
||||
isIntercepted(item) {
|
||||
const src = this.getScanOrderSource(item)
|
||||
return this.getRowValue(src, ['intercept_status', 'interceptStatus']) === 'requested'
|
||||
},
|
||||
// 拦截按钮点击:进入拦截确认模式,确认按钮变为"确认拦截"
|
||||
handleIntercept(item) {
|
||||
// 选中该订单,右侧展示明细
|
||||
this.handleScanOrderClick(item)
|
||||
const src = this.getScanOrderSource(item)
|
||||
const orderNo = this.getScanOrderNo(item) || this.getRowValue(src, ['order_id', 'orderId'])
|
||||
this.interceptMode = true
|
||||
this.interceptTarget = {
|
||||
orderNo,
|
||||
orderId: this.getRowValue(src, ['order_id', 'orderId']),
|
||||
}
|
||||
uni.showToast({
|
||||
title: `已进入拦截确认:${orderNo}`,
|
||||
icon: 'none',
|
||||
})
|
||||
},
|
||||
handleScanOrderClick(item) {
|
||||
// 切换选中订单时退出拦截确认模式
|
||||
this.interceptMode = false
|
||||
this.interceptTarget = null
|
||||
const src = this.getScanOrderSource(item)
|
||||
this.selectedPendingOrderKey = this.getScanOrderKey(item)
|
||||
this.selectedOrderNo = this.getScanOrderNo(item)
|
||||
@ -729,7 +1290,9 @@ export default {
|
||||
return String(value)
|
||||
},
|
||||
handleWaveClick(wave) {
|
||||
// 团购模式:点击波次在右侧展示该波次的商品明细(stocks)
|
||||
// 团购模式:点击波次在右侧展示该波次的商品明细(stocks);切换时退出拦截确认模式
|
||||
this.interceptMode = false
|
||||
this.interceptTarget = null
|
||||
this.selectedWaveKey = this.getWaveKey(wave)
|
||||
this.selectedPendingOrderKey = ''
|
||||
this.selectedOrderNo = this.getRowValue(wave, ['wave_no', 'waveNo']) || ''
|
||||
@ -749,8 +1312,58 @@ export default {
|
||||
this.syncDetailStats(wave, this.displayOrders)
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.loadPrinters()
|
||||
// 扫码枪识别:真机/H5 双链路(隐藏 input + plus.key + DOM 全局监听)
|
||||
this.setupScanCaptureMode()
|
||||
this.attachPlusKeyboardListener()
|
||||
this.attachGlobalKeyboardListener()
|
||||
this.suppressSoftKeyboardBurst()
|
||||
this.scheduleScanInputFocus(260)
|
||||
// 页面进入即聚焦搜索框(H5 无隐藏捕获时)
|
||||
this.$nextTick(() => {
|
||||
if (!this.enableHiddenInputCapture) {
|
||||
this.activateSearchInput()
|
||||
}
|
||||
})
|
||||
},
|
||||
activated() {
|
||||
// keep-alive 从其它页切回时:恢复扫码链路与隐藏 input 焦点
|
||||
this.pageActive = true
|
||||
this.setupScanCaptureMode()
|
||||
this.attachPlusKeyboardListener()
|
||||
this.attachGlobalKeyboardListener()
|
||||
this.suppressSoftKeyboardBurst()
|
||||
this.scheduleScanInputFocus(260)
|
||||
},
|
||||
deactivated() {
|
||||
// keep-alive 切到其它页时:暂停扫码链路,避免隐藏 input 抢占其它页焦点
|
||||
this.pageActive = false
|
||||
this.removePlusKeyboardListener()
|
||||
this.removeGlobalKeyboardListener()
|
||||
this.clearScanFocusResumeTimer()
|
||||
this.clearKeyboardSuppressTimers()
|
||||
this.clearHiddenScanTimer()
|
||||
this.clearPlusKeyTimer()
|
||||
this.clearHiddenRefocusTimer()
|
||||
this.scanHiddenFocused = false
|
||||
this.scanInputFocus = false
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.pageActive = false
|
||||
this.onResizeEnd()
|
||||
this.removePlusKeyboardListener()
|
||||
this.removeGlobalKeyboardListener()
|
||||
this.clearScanFocusResumeTimer()
|
||||
this.clearKeyboardSuppressTimers()
|
||||
this.clearHiddenScanTimer()
|
||||
this.clearPlusKeyTimer()
|
||||
this.clearHiddenRefocusTimer()
|
||||
// 清理扫码静默防抖定时器,避免泄漏
|
||||
if (this.scanTimer) {
|
||||
clearTimeout(this.scanTimer)
|
||||
this.scanTimer = null
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@ -767,6 +1380,15 @@ export default {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.scan-hidden-input {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
opacity: 0;
|
||||
left: -9999px;
|
||||
top: -9999px;
|
||||
}
|
||||
|
||||
.page-main {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
@ -777,6 +1399,18 @@ export default {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* 订单复核页:锁定高度链,仅列表区内部滚动,页面不整体滚动 */
|
||||
.page-main.order-review-one {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.page-main.order-review-one > .container {
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
flex: 1 1 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.order-review-one {
|
||||
width: 100%;
|
||||
}
|
||||
@ -833,12 +1467,14 @@ export default {
|
||||
.left-reviewed-list--current-wave {
|
||||
margin-top: 0;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
max-height: none;
|
||||
}
|
||||
|
||||
.left-reviewed-list--current-wave-body {
|
||||
width: 100%;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.search-bar {
|
||||
@ -925,6 +1561,12 @@ export default {
|
||||
max-height: none;
|
||||
}
|
||||
|
||||
.table-scroll--detail-body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
min-width: 980rpx;
|
||||
}
|
||||
@ -939,6 +1581,7 @@ export default {
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table-wrap--current-wave-sticky .table-header {
|
||||
@ -1217,14 +1860,16 @@ export default {
|
||||
width: 90rpx;
|
||||
}
|
||||
|
||||
/* 散单行:复核状态、波次序号、运单号三列间隔完全贴合 */
|
||||
/* 散单行:复核状态、波次序号、运单号三列间隔 8rpx */
|
||||
.scan-row .cell-review-status {
|
||||
padding-right: 0;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
|
||||
.scan-row .cell-wave-index {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
|
||||
.scan-row .cell-wave-no {
|
||||
@ -1260,6 +1905,32 @@ export default {
|
||||
color: #34c759;
|
||||
}
|
||||
|
||||
/* 左侧列表:拦截按钮(intercept_status=requested 时显示) */
|
||||
.cell-intercept {
|
||||
flex-shrink: 0;
|
||||
height: 40rpx;
|
||||
line-height: 40rpx;
|
||||
padding: 0 16rpx;
|
||||
margin: 0 12rpx 0 4rpx;
|
||||
font-size: 24rpx;
|
||||
color: #fff;
|
||||
background-color: #e64340;
|
||||
border-radius: 8rpx;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.cell-intercept:active {
|
||||
background-color: #c9302c;
|
||||
}
|
||||
|
||||
/* 左侧订单/波次列表:整行内容完整显示不省略;需换行时优先对运单号/波次号列换行 */
|
||||
.table-wrap--current-wave .table-cell:not(.cell-wave-no) {
|
||||
white-space: nowrap;
|
||||
overflow: visible;
|
||||
text-overflow: clip;
|
||||
}
|
||||
|
||||
.wave-group-header {
|
||||
cursor: pointer;
|
||||
background-color: #f6f8fc;
|
||||
@ -1321,6 +1992,12 @@ export default {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tool-btn--intercept {
|
||||
background-color: #e64340;
|
||||
border-color: #e64340;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tool-select {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user