1505 lines
41 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="page">
<top-nav v-if="!embedded" />
<view class="page-main order-review-one">
<view class="container container--compact-top">
<view class="search-bar">
<input
class="search-input"
v-model="keyword"
placeholder="请输入快递号/商品条码/拣货车/数量等关键词搜索订单"
:focus="false"
:adjust-position="false"
confirm-type="search"
@confirm="handleSearch"
/>
<button class="search-btn" type="primary" @click="handleSearch">搜索</button>
</view>
<view class="content-panel">
<view class="panel-left">
<view class="left-summary">
<text class="left-summary-text">待处理:{{ pendingCount }};当前波次:{{ currentWaveCount }}</text>
</view>
<view class="left-header-actions">
<view
:class="['header-action-btn', activeLeftAction === 'currentWave' ? 'header-action-btn--active' : '']"
@click="handleLeftActionClick('currentWave')"
>
<text class="header-action-text">当前波次</text>
</view>
<view
:class="['header-action-btn', activeLeftAction === 'settings' ? 'header-action-btn--active' : '']"
@click="handleLeftActionClick('settings')"
>
<text class="header-action-text">设置</text>
</view>
<view
:class="['header-action-btn', activeLeftAction === 'printInfo' ? 'header-action-btn--active' : '']"
@click="handleLeftActionClick('printInfo')"
>
<text class="header-action-text">打印信息</text>
</view>
<view
:class="['header-action-btn', 'header-action-btn--reviewed', activeLeftAction === 'reviewedList' ? 'header-action-btn--active' : '']"
@click="handleLeftActionClick('reviewedList')"
>
<text class="header-action-text">已复核列表</text>
</view>
</view>
<view
v-if="activeLeftAction === 'currentWave' && displayCurrentWaveOrders.length > 0"
class="table-wrap table-wrap--current-wave table-wrap--current-wave-sticky"
>
<view class="table-header table-header--sticky">
<text class="table-cell cell-index">序号</text>
<text class="table-cell cell-pending-order">待处理订单号</text>
</view>
<scroll-view class="left-reviewed-list left-reviewed-list--current-wave left-reviewed-list--current-wave-body" scroll-y>
<view class="table-body">
<view
v-for="(item, index) in displayCurrentWaveOrders"
:key="`${item.pendingOrderNo}-${index}`"
:class="[
'table-row',
index % 2 === 1 ? 'table-row--alt' : '',
selectedPendingOrderKey === getPendingOrderKey(item) ? 'table-row--selected' : '',
]"
@click="handlePendingOrderClick(item)"
>
<text class="table-cell cell-index">{{ (orderPagination.page - 1) * orderPagination.pageSize + index + 1 }}</text>
<text class="table-cell cell-pending-order">{{ item.pendingOrderNo }}</text>
</view>
</view>
</scroll-view>
</view>
<view v-else-if="activeLeftAction === 'currentWave'" class="empty-panel empty-panel--left">暂无匹配数据</view>
<view v-if="activeLeftAction === 'currentWave'" class="pagination-bar pagination-bar--left">
<text class="pagination-info">
第{{ orderPagination.page }}页 / 共{{ orderPagination.totalPages || 1 }}页
</text>
<view class="pagination-actions">
<button class="pagination-btn" :disabled="!orderPagination.hasPrevious" @click="handlePrevPage">上一页</button>
<button class="pagination-btn" :disabled="!orderPagination.hasNext" @click="handleNextPage">下一页</button>
</view>
</view>
<view
v-else-if="activeLeftAction === 'reviewedList' && displayReviewedOrders.length > 0"
class="table-wrap table-wrap--reviewed table-wrap--reviewed-sticky"
>
<view class="table-header table-header--sticky">
<text class="table-cell cell-index">序号</text>
<text class="table-cell cell-order-no">订单号</text>
<text class="table-cell cell-wave-no">波次号</text>
</view>
<scroll-view class="left-reviewed-list left-reviewed-list--reviewed" scroll-y>
<view class="table-body">
<view
v-for="(item, index) in displayReviewedOrders"
:key="`${item.orderNo}-${index}`"
:class="['table-row', index % 2 === 1 ? 'table-row--alt' : '']"
>
<text class="table-cell cell-index">{{ index + 1 }}</text>
<text class="table-cell cell-order-no">{{ item.orderNo }}</text>
<text class="table-cell cell-wave-no">{{ item.waveNo }}</text>
</view>
</view>
</scroll-view>
</view>
<view v-else-if="activeLeftAction === 'reviewedList'" class="empty-panel empty-panel--left">暂无匹配数据</view>
<view v-else-if="activeLeftAction === 'settings'" class="settings-panel">
<view class="settings-row">
<text class="settings-label">默认打印机</text>
<input class="settings-input" v-model="defaultPrinter" />
</view>
<view class="settings-row">
<text class="settings-label">预出单</text>
<view class="settings-switch-wrap">
<switch :checked="prePrintEnabled" color="#34c759" @change="handlePrePrintChange" />
</view>
</view>
<view v-for="item in courierPrinters" :key="item.key" class="settings-row">
<text class="settings-label">{{ item.label }}</text>
<input class="settings-input" v-model="item.value" />
</view>
<button class="settings-save-btn" type="primary" @click="handleSaveSettings">保存</button>
</view>
</view>
<view class="panel-right">
<view class="camera-preview-panel">
<view id="camera-preview-frame" ref="cameraPreviewFrame" class="camera-preview-frame" :style="{ aspectRatio: cameraFrameAspectRatio }">
<view id="camera-preview-host" ref="cameraHost" class="camera-preview-host"></view>
<view v-if="!cameraReady" class="camera-preview-placeholder">
<text class="camera-preview-text">{{ cameraLoading ? '摄像头启动中...' : cameraError || '暂无摄像头画面' }}</text>
</view>
<view class="camera-controls camera-controls--inside">
<button class="camera-control-btn" :disabled="!cameraReady" @click="toggleCameraPause">
<text class="camera-control-icon">{{ cameraPaused ? '▶' : '⏸' }}</text>
</button>
<slider
class="camera-pause-progress"
:value="cameraPaused ? 100 : 0"
:min="0"
:max="100"
:step="1"
activeColor="#2f7dff"
backgroundColor="#e6ebf5"
block-size="10"
disabled
/>
<view class="camera-zoom-controls">
<button class="camera-control-btn camera-control-btn--small" :disabled="!cameraReady" @click="handleZoomOut">-</button>
<text class="camera-zoom-text">{{ Math.round(cameraZoom * 100) }}%</text>
<button class="camera-control-btn camera-control-btn--small" :disabled="!cameraReady" @click="handleZoomIn">+</button>
</view>
<button class="camera-control-btn camera-control-btn--small" :disabled="!cameraReady" @click="toggleFullscreen">
<text class="camera-control-icon">{{ cameraFullscreen ? '🡼' : '⛶' }}</text>
</button>
</view>
</view>
</view>
<view class="table-wrap table-wrap--detail table-wrap--detail-sticky">
<view class="table-header table-header--sticky">
<text class="table-cell cell-blue-no">蓝号</text>
<text class="table-cell cell-qty">数量</text>
<text class="table-cell cell-scan">扫描记</text>
<text class="table-cell cell-barcode">条码</text>
<text class="table-cell cell-name">商品名称</text>
<text class="table-cell cell-color">颜色</text>
<text class="table-cell cell-spec">规格</text>
</view>
<scroll-view v-if="selectedPendingOrderKey && displayOrders.length > 0" class="table-scroll table-scroll--detail table-scroll--detail-body" scroll-y>
<view class="table-body">
<view
v-for="(order, index) in displayOrders"
:key="order.barcode"
:class="['table-row', index % 2 === 1 ? 'table-row--alt' : '']"
>
<text class="table-cell cell-blue-no">{{ order.blueNo }}</text>
<text class="table-cell cell-qty">{{ order.quantity }}</text>
<text class="table-cell cell-scan">{{ order.scanMark }}</text>
<text class="table-cell cell-barcode">{{ order.barcode }}</text>
<text class="table-cell cell-name">{{ order.productName }}</text>
<text class="table-cell cell-color">{{ order.color }}</text>
<text class="table-cell cell-spec">{{ order.spec }}</text>
</view>
</view>
</scroll-view>
<view v-else class="empty-panel empty-panel--right-inline">暂无匹配数据</view>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import TopNav from '@/components/top-nav.vue'
import { fetchOrderDetail, fetchOrderList } from '@/api/order'
export default {
name: 'OrderReviewOnePage',
components: {
TopNav,
},
props: {
// 在布局壳内渲染时为 true,隐藏内嵌顶栏;独立访问时不传,显示顶栏
embedded: {
type: Boolean,
default: false,
},
},
data() {
return {
pendingCount: 134,
currentWaveCount: 0,
activeLeftAction: 'currentWave',
keyword: '',
displayOrders: [],
displayCurrentWaveOrders: [],
displayReviewedOrders: [],
orderPagination: {
page: 1,
pageSize: 20,
total: 0,
totalPages: 0,
hasPrevious: false,
hasNext: false,
},
defaultPrinter: '1',
prePrintEnabled: true,
courierPrinters: [
{ key: 'yt', label: '圆通打印机', value: '1' },
{ key: 'st', label: '申通打印机', value: '1' },
{ key: 'yd', label: '韵达打印机', value: '1' },
{ key: 'zt', label: '中通打印机', value: '1' },
{ key: 'yz', label: '邮政小包打印机', value: '1' },
],
allReviewedOrders: [
{ orderNo: 'DD202605190001', waveNo: 'WC001' },
{ orderNo: 'DD202605190002', waveNo: 'WC001' },
{ orderNo: 'DD202605190003', waveNo: 'WC002' },
],
allCurrentWaveOrders: [
{ id: '1', pendingOrderNo: 'DD202605190101' },
{ id: '2', pendingOrderNo: 'DD202605190102' },
{ id: '3', pendingOrderNo: 'DD202605190103' },
],
selectedPendingOrderKey: '',
currentOrderHeader: null,
currentWaybillInfo: null,
cameraStream: null,
cameraVideoElement: null,
cameraLoading: false,
cameraReady: false,
cameraError: '',
cameraInitializing: false,
cameraInitToken: 0,
cameraStartTimer: null,
cameraPaused: false,
cameraZoom: 1,
cameraZoomMin: 1,
cameraZoomMax: 3,
cameraZoomStep: 0.1,
cameraFullscreen: false,
cameraFrameAspectRatio: '16 / 9',
}
},
created() {
this.loadOrderList()
this.displayCurrentWaveOrders = this.allCurrentWaveOrders
this.displayReviewedOrders = this.allReviewedOrders
},
mounted() {
this.requestCameraPreview()
this.bindFullscreenEvents()
},
activated() {
// keep-alive 从缓存恢复时重新初始化摄像头
this.requestCameraPreview()
},
deactivated() {
// 切走时释放摄像头,避免设备被持续占用
this.stopCameraPreview()
},
beforeUnmount() {
this.unbindFullscreenEvents()
this.stopCameraPreview()
},
methods: {
requestCameraPreview() {
if (this.cameraInitializing || this.cameraLoading || this.cameraReady) {
return
}
clearTimeout(this.cameraStartTimer)
this.cameraStartTimer = setTimeout(() => {
this.initCameraPreview()
}, 180)
},
handleLeftActionClick(action) {
this.activeLeftAction = action
this.handleSearch()
},
handlePrePrintChange(event) {
this.prePrintEnabled = !!event.detail.value
},
handleSaveSettings() {
uni.showToast({
title: '保存成功',
icon: 'success',
})
},
toggleCameraPause() {
const videoElement = this.cameraVideoElement
if (!videoElement) {
return
}
if (this.cameraPaused) {
const playPromise = videoElement.play ? videoElement.play() : null
if (playPromise && typeof playPromise.then === 'function') {
playPromise.catch(() => {
this.cameraError = '恢复播放失败'
})
}
this.cameraPaused = false
return
}
if (typeof videoElement.pause === 'function') {
videoElement.pause()
}
this.cameraPaused = true
},
handleZoomOut() {
const nextZoom = Math.max(this.cameraZoomMin, Number((this.cameraZoom - this.cameraZoomStep).toFixed(2)))
this.cameraZoom = nextZoom
this.applyCameraViewState()
},
handleZoomIn() {
const nextZoom = Math.min(this.cameraZoomMax, Number((this.cameraZoom + this.cameraZoomStep).toFixed(2)))
this.cameraZoom = nextZoom
this.applyCameraViewState()
},
toggleFullscreen() {
const frameRef = this.$refs.cameraPreviewFrame
const frameTarget = Array.isArray(frameRef) ? frameRef[0] : frameRef
const frameElement =
(frameTarget && typeof frameTarget.requestFullscreen === 'function' && frameTarget) ||
(frameTarget?.$el && typeof frameTarget.$el.requestFullscreen === 'function' && frameTarget.$el) ||
(typeof document !== 'undefined' ? document.getElementById('camera-preview-frame') : null)
if (!frameElement) {
uni.showToast({ title: '全屏不可用', icon: 'none' })
return
}
const fullscreenElement = this.getFullscreenElement()
if (fullscreenElement) {
this.exitFullscreen()
return
}
const requestFullscreen =
frameElement.requestFullscreen ||
frameElement.webkitRequestFullscreen ||
frameElement.mozRequestFullScreen ||
frameElement.msRequestFullscreen
if (typeof requestFullscreen === 'function') {
requestFullscreen.call(frameElement)
}
},
bindFullscreenEvents() {
if (typeof document === 'undefined') {
return
}
if (!this._onFullscreenChange) {
this._onFullscreenChange = () => {
this.cameraFullscreen = !!this.getFullscreenElement()
}
}
document.addEventListener('fullscreenchange', this._onFullscreenChange)
document.addEventListener('webkitfullscreenchange', this._onFullscreenChange)
document.addEventListener('mozfullscreenchange', this._onFullscreenChange)
document.addEventListener('MSFullscreenChange', this._onFullscreenChange)
},
unbindFullscreenEvents() {
if (typeof document === 'undefined' || !this._onFullscreenChange) {
return
}
document.removeEventListener('fullscreenchange', this._onFullscreenChange)
document.removeEventListener('webkitfullscreenchange', this._onFullscreenChange)
document.removeEventListener('mozfullscreenchange', this._onFullscreenChange)
document.removeEventListener('MSFullscreenChange', this._onFullscreenChange)
},
getFullscreenElement() {
if (typeof document === 'undefined') {
return null
}
return document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement || null
},
exitFullscreen() {
if (typeof document === 'undefined') {
return
}
const exitHandler = document.exitFullscreen || document.webkitExitFullscreen || document.mozCancelFullScreen || document.msExitFullscreen
if (typeof exitHandler === 'function') {
exitHandler.call(document)
}
},
applyCameraViewState() {
const videoElement = this.cameraVideoElement
if (!videoElement) {
return
}
videoElement.style.transform = `scale(${this.cameraZoom})`
videoElement.style.transformOrigin = 'center center'
},
async initCameraPreview() {
if (typeof navigator === 'undefined' || !navigator?.mediaDevices?.getUserMedia) {
this.cameraError = '当前环境不支持摄像头预览'
this.cameraReady = false
return
}
if (this.cameraInitializing) {
return
}
await this.stopCameraPreview()
const currentToken = ++this.cameraInitToken
this.cameraInitializing = true
await new Promise((resolve) => setTimeout(resolve, 200))
this.cameraLoading = true
this.cameraError = ''
try {
const getStream = async () => {
try {
return await navigator.mediaDevices.getUserMedia({
video: {
width: { ideal: 1280 },
height: { ideal: 720 },
},
audio: false,
})
} catch (firstError) {
return await navigator.mediaDevices.getUserMedia({
video: true,
audio: false,
})
}
}
let stream = await getStream()
if (currentToken !== this.cameraInitToken) {
stream.getTracks().forEach((track) => track.stop())
return
}
this.cameraStream = stream
await this.$nextTick()
const hostRef = this.$refs.cameraHost
const hostElement = this.resolveCameraHostElement(hostRef)
const videoElement = this.ensureCameraVideoElement(hostElement)
if (videoElement) {
if (!('srcObject' in videoElement)) {
throw new Error('UNSUPPORTED_STREAM_SOURCE')
}
videoElement.srcObject = stream
const playPromise = videoElement.play ? videoElement.play() : null
if (playPromise && typeof playPromise.then === 'function') {
await playPromise
}
if (videoElement.readyState >= 2) {
this.markCameraReady()
}
this.applyCameraViewState()
} else {
throw new Error('VIDEO_ELEMENT_NOT_FOUND')
}
this.markCameraReady()
} catch (error) {
if (error?.name === 'NotReadableError') {
try {
await this.stopCameraPreview()
await new Promise((resolve) => setTimeout(resolve, 500))
const retryStream = await navigator.mediaDevices.getUserMedia({
video: true,
audio: false,
})
if (currentToken !== this.cameraInitToken) {
retryStream.getTracks().forEach((track) => track.stop())
return
}
this.cameraStream = retryStream
await this.$nextTick()
const hostRef = this.$refs.cameraHost
const hostElement = this.resolveCameraHostElement(hostRef)
const videoElement = this.ensureCameraVideoElement(hostElement)
if (!videoElement || !('srcObject' in videoElement)) {
throw new Error('VIDEO_ELEMENT_NOT_FOUND')
}
videoElement.srcObject = retryStream
const playPromise = videoElement.play ? videoElement.play() : null
if (playPromise && typeof playPromise.then === 'function') {
await playPromise
}
this.applyCameraViewState()
this.cameraReady = true
this.cameraError = ''
return
} catch (retryError) {
error = retryError
}
}
this.cameraReady = false
if (error?.name === 'NotAllowedError' || error?.name === 'PermissionDeniedError') {
this.cameraError = '摄像头权限被拒绝'
} else if (error?.name === 'NotFoundError' || error?.name === 'DevicesNotFoundError') {
this.cameraError = '未检测到可用摄像头设备'
} else if (error?.name === 'NotReadableError') {
this.cameraError = '摄像头正被其他程序占用,请关闭后重试'
} else if (error?.name === 'NotSupportedError') {
this.cameraError = '当前视频源格式不受支持'
} else if (error?.message === 'UNSUPPORTED_STREAM_SOURCE' || error?.message === 'VIDEO_ELEMENT_NOT_FOUND') {
this.cameraError = '当前视频组件不支持实时流预览'
} else {
this.cameraError = `摄像头启动失败(${error?.name || 'Unknown'}${error?.message ? `: ${error.message}` : ''})`
}
} finally {
this.cameraLoading = false
this.cameraInitializing = false
}
},
async stopCameraPreview() {
this.cameraInitToken += 1
clearTimeout(this.cameraStartTimer)
const stream = this.cameraStream
if (stream && typeof stream.getTracks === 'function') {
stream.getTracks().forEach((track) => {
if (track && typeof track.stop === 'function') {
track.stop()
}
})
}
const videoElement = this.cameraVideoElement
if (videoElement) {
videoElement.srcObject = null
videoElement.removeAttribute('src')
if (typeof videoElement.load === 'function') {
videoElement.load()
}
}
this.cameraStream = null
this.cameraVideoElement = null
this.cameraReady = false
this.cameraLoading = false
this.cameraInitializing = false
this.cameraStartTimer = null
this.cameraPaused = false
this.cameraFullscreen = false
},
resolveCameraHostElement(hostRef) {
const target = Array.isArray(hostRef) ? hostRef[0] : hostRef
if (!target && typeof document !== 'undefined') {
return document.getElementById('camera-preview-host')
}
if (target && typeof target.appendChild === 'function') {
return target
}
if (target?.$el && typeof target.$el.appendChild === 'function') {
return target.$el
}
if (target?.$el?.querySelector) {
const innerElement = target.$el.querySelector('.camera-preview-host')
if (innerElement && typeof innerElement.appendChild === 'function') {
return innerElement
}
}
if (target?.querySelector) {
const innerElement = target.querySelector('.camera-preview-host')
if (innerElement && typeof innerElement.appendChild === 'function') {
return innerElement
}
}
if (typeof document !== 'undefined') {
return document.getElementById('camera-preview-host')
}
return null
},
ensureCameraVideoElement(hostElement) {
if (typeof document === 'undefined' || !hostElement) {
return null
}
if (this.cameraVideoElement && hostElement.contains(this.cameraVideoElement)) {
this.bindCameraVideoEvents(this.cameraVideoElement)
return this.cameraVideoElement
}
hostElement.innerHTML = ''
const videoElement = document.createElement('video')
videoElement.className = 'camera-preview-video'
videoElement.muted = true
videoElement.autoplay = false
videoElement.playsInline = true
videoElement.setAttribute('playsinline', 'true')
videoElement.setAttribute('webkit-playsinline', 'true')
videoElement.style.width = '100%'
videoElement.style.height = '100%'
videoElement.style.objectFit = 'contain'
videoElement.style.objectPosition = 'center'
this.bindCameraVideoEvents(videoElement)
hostElement.appendChild(videoElement)
this.cameraVideoElement = videoElement
return videoElement
},
bindCameraVideoEvents(videoElement) {
if (!videoElement) {
return
}
videoElement.onplaying = () => {
this.markCameraReady()
this.cameraPaused = false
}
videoElement.onpause = () => {
if (this.cameraReady) {
this.cameraPaused = true
}
}
videoElement.onloadedmetadata = () => {
if (videoElement.videoWidth > 0 && videoElement.videoHeight > 0) {
this.syncCameraAspectRatio(videoElement)
this.markCameraReady()
}
}
videoElement.onerror = () => {
if (!this.cameraReady && !this.cameraLoading) {
this.cameraError = '摄像头画面加载失败'
}
}
},
markCameraReady() {
this.cameraReady = true
this.cameraLoading = false
this.cameraError = ''
this.cameraPaused = false
},
syncCameraAspectRatio(videoElement) {
const width = Number(videoElement?.videoWidth || 0)
const height = Number(videoElement?.videoHeight || 0)
if (!width || !height) {
return
}
this.cameraFrameAspectRatio = `${width} / ${height}`
},
getRowValue(row, keys = []) {
for (const key of keys) {
const value = row?.[key]
if (value !== undefined && value !== null && value !== '') {
return value
}
}
return ''
},
getPendingOrderKey(order) {
return String(this.getRowValue(order, ['id', 'pendingOrderNo']))
},
normalizeOrderRow(row) {
return {
blueNo: this.getRowValue(row, ['blueNo', 'blue_no', 'lanhao', 'lan_hao', 'blue_no_code']),
quantity: this.getRowValue(row, ['plan_qty', 'quantity', 'qty', 'num', 'count']),
scanMark: this.getRowValue(row, ['scanMark', 'scan_mark', 'scanStatus', 'scan_status']),
barcode: this.getRowValue(row, ['barcode', 'bar_code', 'goods_barcode', 'sku_barcode']),
productName: this.getRowValue(row, ['productName', 'product_name', 'goods_name', 'sku_name', 'item_name']),
color: this.getRowValue(row, ['color', 'color_name']),
spec: this.getRowValue(row, ['sku_property', 'spec', 'spec_name', 'size', 'sku_spec']),
}
},
parseItemSnapshot(snapshotRaw) {
if (!snapshotRaw) {
return {}
}
if (typeof snapshotRaw === 'string') {
try {
const parsed = JSON.parse(snapshotRaw)
return typeof parsed === 'object' && parsed ? parsed : {}
} catch (error) {
return {}
}
}
return typeof snapshotRaw === 'object' ? snapshotRaw : {}
},
normalizeOrderDetailItem(item) {
const snapshot = this.parseItemSnapshot(this.getRowValue(item, ['item_snapshot', 'itemSnapshot']))
return this.normalizeOrderRow({
...item,
...snapshot,
})
},
buildOrderWhere() {
const query = this.keyword.trim()
if (!query) {
return {}
}
return {
keyword: {
operator: 'like',
value: query,
type: 'string',
},
}
},
async loadOrderList(page = 1) {
try {
const body = await fetchOrderList({
pagination: {
page,
pageSize: this.orderPagination.pageSize,
},
where: this.buildOrderWhere(),
sort: {
sortField: 'id',
sortOrder: 'desc',
},
})
const payload = body?.data || body?.result || body || {}
const list = Array.isArray(payload?.list) ? payload.list : []
const pagination = payload?.pagination || {}
const pendingOrders = list
.map((item) => {
return {
id: this.getRowValue(item, ['id', 'order_id']),
pendingOrderNo: this.getRowValue(item, ['delivery_order_code']),
}
})
.filter((item) => !!item.pendingOrderNo)
this.displayOrders = []
this.selectedPendingOrderKey = ''
this.currentOrderHeader = null
this.currentWaybillInfo = null
this.allCurrentWaveOrders = pendingOrders
this.displayCurrentWaveOrders = pendingOrders
this.orderPagination = {
page: Number(pagination.page || page || 1),
pageSize: Number(pagination.pageSize || this.orderPagination.pageSize || 20),
total: Number(pagination.total || 0),
totalPages: Number(pagination.totalPages || 0),
hasPrevious: !!pagination.hasPrevious,
hasNext: !!pagination.hasNext,
}
} catch (error) {
this.displayOrders = []
uni.showToast({
title: '订单加载失败',
icon: 'none',
})
}
},
handlePrevPage() {
if (!this.orderPagination.hasPrevious) {
return
}
const targetPage = Math.max(1, Number(this.orderPagination.page || 1) - 1)
this.loadOrderList(targetPage)
},
handleNextPage() {
if (!this.orderPagination.hasNext) {
return
}
const currentPage = Number(this.orderPagination.page || 1)
this.loadOrderList(currentPage + 1)
},
handleSearch() {
const query = this.keyword.trim().toLowerCase()
if (this.activeLeftAction === 'currentWave') {
if (!query) {
this.displayCurrentWaveOrders = this.allCurrentWaveOrders
return
}
this.displayCurrentWaveOrders = this.allCurrentWaveOrders.filter((order) => {
return Object.values(order).some((value) => String(value || '').toLowerCase().includes(query))
})
if (this.displayCurrentWaveOrders.length === 0) {
this.selectedPendingOrderKey = ''
this.currentOrderHeader = null
this.currentWaybillInfo = null
this.displayOrders = []
}
return
}
if (this.activeLeftAction === 'reviewedList') {
if (!query) {
this.displayReviewedOrders = this.allReviewedOrders
return
}
this.displayReviewedOrders = this.allReviewedOrders.filter((order) => {
return Object.values(order).some((value) => String(value || '').toLowerCase().includes(query))
})
return
}
this.loadOrderList(1)
},
async handlePendingOrderClick(order) {
this.selectedPendingOrderKey = this.getPendingOrderKey(order)
const id = this.getRowValue(order, ['id'])
if (!id) {
uni.showToast({
title: '订单ID缺失',
icon: 'none',
})
return
}
try {
const body = await fetchOrderDetail(id)
const payload = body?.data || body?.result || body || {}
const items = Array.isArray(payload?.items) ? payload.items : []
this.currentOrderHeader = payload?.order || payload?.orderHeader || null
this.currentWaybillInfo = payload?.waybill || payload?.waybillInfo || null
this.displayOrders = items.map((item) => this.normalizeOrderDetailItem(item))
} catch (error) {
uni.showToast({
title: '订单详情加载失败',
icon: 'none',
})
}
},
},
}
</script>
<style>
.page {
height: 100%;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
box-sizing: border-box;
background-color: #f8f8f8;
}
.page-main {
flex: 1;
min-height: 0;
overflow-y: auto;
padding: 8rpx 32rpx 32rpx;
box-sizing: border-box;
}
.order-review-one {
width: 100%;
}
.container {
background: #fff;
border-radius: 16rpx;
padding: 28rpx;
}
.container--compact-top {
padding-top: 0;
}
.content-panel {
display: flex;
align-items: flex-start;
gap: 20rpx;
}
.panel-left {
width: 700rpx;
flex-shrink: 0;
}
.panel-right {
flex: 1;
min-width: 0;
}
.camera-preview-panel {
width: 50%;
margin-bottom: 14rpx;
margin-left: auto;
margin-right: auto;
border: 1rpx solid #e6ebf5;
border-radius: 8rpx;
background-color: #fff;
padding: 12rpx;
box-sizing: border-box;
}
.camera-preview-frame {
position: relative;
width: 100%;
min-height: 120rpx;
aspect-ratio: 16 / 9;
border-radius: 8rpx;
overflow: hidden;
background-color: #000;
}
.camera-preview-video {
width: 100%;
height: 100%;
display: block;
object-fit: contain;
object-position: center;
background-color: transparent;
}
.camera-preview-host {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.camera-controls {
margin-top: 12rpx;
display: flex;
align-items: center;
gap: 10rpx;
}
.camera-controls--inside {
position: absolute;
left: 8rpx;
right: 8rpx;
bottom: 8rpx;
z-index: 3;
margin-top: 0;
padding: 8rpx;
border-radius: 8rpx;
}
.camera-controls--inside .camera-zoom-text {
color: #fff;
}
.camera-control-btn {
min-width: 116rpx;
height: 64rpx;
line-height: 64rpx;
font-size: 28rpx;
margin: 0;
padding: 0 16rpx;
border: none;
border-radius: 0;
background-color: transparent;
color: #ffffff;
}
.camera-control-btn::after {
border: none;
}
.camera-controls .camera-control-btn:first-child {
min-width: 64rpx;
width: 64rpx;
padding: 0;
}
.camera-control-icon {
font-size: 28rpx;
line-height: 1;
color: #ffffff;
}
.camera-control-btn--small {
min-width: 64rpx;
width: 64rpx;
padding: 0;
}
.camera-pause-progress {
flex: 1;
margin: 0;
}
.camera-zoom-controls {
display: flex;
align-items: center;
gap: 8rpx;
}
.camera-zoom-text {
width: 88rpx;
text-align: center;
font-size: 28rpx;
color: #333;
}
.camera-preview-placeholder {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
padding: 0 20rpx;
box-sizing: border-box;
background-color: #f9fbff;
}
.camera-preview-text {
font-size: 28rpx;
color: #9098a4;
line-height: 1.5;
text-align: center;
}
.left-summary {
margin-bottom: 12rpx;
}
.left-summary-text {
font-size: 28rpx;
color: #333;
line-height: 1.4;
}
.left-header-actions {
display: flex;
align-items: center;
flex-wrap: nowrap;
gap: 12rpx;
}
.left-reviewed-list {
margin-top: 14rpx;
max-height: 1100rpx;
}
.left-reviewed-list--current-wave {
margin-top: 0;
flex: 1;
max-height: none;
}
.left-reviewed-list--current-wave-body {
width: 100%;
min-height: 0;
}
.left-reviewed-list--reviewed {
margin-top: 0;
width: 100%;
flex: 1;
max-height: none;
min-height: 0;
}
.settings-panel {
margin-top: 14rpx;
border: 1rpx solid #e6ebf5;
border-radius: 8rpx;
padding: 18rpx;
box-sizing: border-box;
}
.settings-row {
display: flex;
align-items: center;
gap: 16rpx;
margin-bottom: 16rpx;
}
.settings-row:last-of-type {
margin-bottom: 24rpx;
}
.settings-label {
width: 200rpx;
font-size: 28rpx;
color: #333;
}
.settings-input {
flex: 1;
height: 64rpx;
border: 1rpx solid #e5e5e5;
border-radius: 8rpx;
padding: 0 16rpx;
font-size: 28rpx;
background-color: #fff;
box-sizing: border-box;
}
.settings-switch-wrap {
display: flex;
align-items: center;
gap: 12rpx;
}
.settings-save-btn {
width: 100%;
height: 68rpx;
line-height: 68rpx;
font-size: 28rpx;
}
.header-action-btn {
flex: 1;
min-width: 0;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
height: 60rpx;
border-radius: 8rpx;
border: 1rpx solid #d9dde8;
background-color: #fff;
padding: 0 8rpx;
white-space: nowrap;
}
.header-action-btn--active {
background-color: #34c759;
border-color: #34c759;
}
.header-action-text {
width: 100%;
text-align: center;
font-size: 28rpx;
line-height: 1;
color: #333;
}
.header-action-btn--active .header-action-text {
color: #fff;
}
.header-action-btn--reviewed {
letter-spacing: 0;
}
.search-bar {
display: flex;
align-items: center;
gap: 16rpx;
margin-bottom: 24rpx;
}
.search-input {
flex: 1;
height: 72rpx;
border: 1rpx solid #e5e5e5;
border-radius: 10rpx;
padding: 0 20rpx;
font-size: 28rpx;
background-color: #fff;
}
.search-btn {
width: 160rpx;
height: 72rpx;
line-height: 72rpx;
font-size: 28rpx;
}
.table-scroll {
width: 100%;
}
.table-scroll--detail {
max-height: none;
}
.pagination-bar {
margin-top: 16rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
.pagination-bar--left {
width: 100%;
}
.pagination-info {
font-size: 28rpx;
color: #666;
}
.pagination-actions {
display: flex;
align-items: center;
gap: 12rpx;
}
.pagination-btn {
width: 140rpx;
height: 56rpx;
line-height: 56rpx;
font-size: 28rpx;
margin: 0;
}
.table-wrap {
min-width: 980rpx;
}
.table-wrap--reviewed {
min-width: 620rpx;
}
.table-wrap--current-wave {
min-width: 620rpx;
}
.table-wrap--current-wave-sticky {
margin-top: 14rpx;
height: 60vh;
display: flex;
flex-direction: column;
}
.table-wrap--current-wave-sticky .table-header {
flex-shrink: 0;
}
.table-wrap--reviewed-sticky {
margin-top: 14rpx;
height: 60vh;
display: flex;
flex-direction: column;
}
.table-wrap--reviewed-sticky .table-header {
flex-shrink: 0;
}
.table-wrap--detail-sticky {
height: 520rpx;
display: flex;
flex-direction: column;
overflow-x: auto;
}
.empty-panel {
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
border: 1rpx solid #e6ebf5;
background-color: #fff;
color: #999;
font-size: 28rpx;
}
.empty-panel--left {
margin-top: 14rpx;
height: 60vh;
}
.empty-panel--right {
height: 520rpx;
}
.empty-panel--right-inline {
flex: 1;
min-height: 0;
min-width: 980rpx;
border-top: none;
}
.table-wrap--detail-sticky .table-header,
.table-wrap--detail-sticky .table-body {
min-width: 980rpx;
}
.table-wrap--detail-sticky .table-header {
flex-shrink: 0;
}
.table-scroll--detail-body {
flex: 1;
min-height: 0;
}
.table-wrap--detail .table-cell {
align-self: stretch;
display: flex;
align-items: center;
border-right: 1rpx solid #eef2f8;
box-sizing: border-box;
}
.table-wrap--detail .table-cell:last-child {
border-right: none;
}
.table-header,
.table-row {
display: flex;
align-items: center;
}
.table-header {
height: 64rpx;
border: 1rpx solid #e6ebf5;
border-bottom: none;
background-color: #f6f8fc;
}
.table-header--sticky {
position: sticky;
top: 0;
z-index: 2;
}
.table-body {
border: 1rpx solid #e6ebf5;
}
.table-row {
min-height: 68rpx;
border-top: 1rpx solid #eef2f8;
border-left: 6rpx solid transparent;
box-sizing: border-box;
}
.table-row:first-child {
border-top: none;
}
.table-row--alt {
background-color: #fafafa;
}
.table-row--selected {
background-color: #d6e8ff;
border-left-color: #1f63d3;
box-shadow: inset 0 0 0 2rpx rgba(31, 99, 211, 0.22);
}
.table-cell {
padding: 0 12rpx;
font-size: 28rpx;
color: #333;
line-height: 1.4;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.cell-blue-no {
width: 110rpx;
}
.cell-qty {
width: 90rpx;
}
.cell-scan {
width: 110rpx;
}
.cell-barcode {
width: 200rpx;
}
.cell-name {
flex: 1;
min-width: 180rpx;
}
.cell-color {
width: 110rpx;
}
.cell-spec {
width: 240rpx;
}
.cell-index {
width: 120rpx;
}
.cell-order-no {
flex: 1;
min-width: 280rpx;
}
.cell-wave-no {
width: 180rpx;
}
.cell-pending-order {
flex: 1;
min-width: 0;
}
.empty {
text-align: center;
color: #999;
font-size: 28rpx;
padding: 24rpx 0;
}
@media screen and (max-width: 1024px) {
.page {
min-width: 760px;
}
.page-main {
padding: 8rpx 20rpx 18rpx;
}
.container {
padding: 20rpx;
}
.content-panel {
gap: 14rpx;
}
.panel-left {
width: 620rpx;
}
.search-bar {
margin-bottom: 18rpx;
}
.table-wrap--detail-sticky {
height: 460rpx;
}
.empty-panel--right {
height: 460rpx;
}
}
</style>