| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072 |
- <template>
- <div class="container">
- <van-nav-bar
- title="复核-活动单" left-arrow fixed placeholder @click-left="goBack">
- <template #left>
- <van-icon name="arrow-left" size="25" />
- <div style="color: #fff">返回</div>
- </template>
- <template #right>
- <div
- v-if="bluetoothConnected && connectedBluetoothDevice"
- @click="handleDisconnectBluetooth"
- class="nav-bluetooth-connected"
- >
- <div class="bluetooth-device-info">
- <van-icon name="bluetooth" size="14px" />
- <span class="device-name">{{ connectedBluetoothDevice.name }}</span>
- </div>
- <div class="bluetooth-disconnect-text">蓝牙断开</div>
- </div>
- <div
- v-else
- @click="handleOpenBluetoothScan"
- class="nav-bluetooth-scan"
- >
- <van-icon name="bluetooth" size="16px" />
- <span>蓝牙扫描</span>
- </div>
- </template>
- </van-nav-bar>
- <div class="activity">
- <div class="wave-title">
- <div><span style="font-size: 12px">波次/容器号:</span>{{ waveNo || '--' }}</div>
- <div class="wave-tips">
- <van-notice-bar :background="'none'" :speed="50" :text="tips" />
- </div>
- <van-button plain size="mini" type="primary" @click="_setWaveNo()">更换</van-button>
- </div>
- <div class="scan-barcode">
- <van-field v-model.lazy="scanBarcode" label-align="left" placeholder="请扫描商品条码/SKU" label="商品条码:"
- class="input-barcode" autocomplete="off" @keydown.enter="_handlerScan(scanBarcode)" />
- <div class="weight-input-wrapper">
- <van-field v-model.lazy="totalWeight" ref="weightRef" label-align="left" required placeholder="请输入商品重量KG" label="重 量:"
- autocomplete="off" type="number" @input="handleWeightInput" @focus="handleWeightFocus" @keydown="handleWeightKeydown"
- :class="{ 'weight-confirmed': weightConfirmed }">
- <template #button>
- <div>KG</div>
- </template>
- </van-field>
- <van-button
- v-if="bluetoothConnected"
- type="warning"
- size="small"
- class="weight-reset-btn"
- @click="resetWeight"
- >
- 重置
- </van-button>
- <van-button
- v-if="bluetoothConnected"
- type="primary"
- size="small"
- class="weight-confirm-btn"
- @click="confirmWeight"
- >
- 确认
- </van-button>
- </div>
- <!-- :class="[totalWeight>0?'success-input-barcode':'error-input-barcode']"-->
- </div>
- <div class="order-detail">
- <div class="picking-no">
- <div class="picking-code">
- <div><van-icon name="stop-circle-o" /></div>
- <div style="flex: 1"><van-notice-bar :background="'none'" color="#419bff" :speed="50" :text="orderDetail.pickingCode||'--'" /></div>
- </div>
- <div>{{ orderDetail.carrierName || '--' }}</div>
- </div>
- <div class="picking-container ">
- <div class="container-item"><span style="color:#666">拣货容器/波次号:</span><div style="flex:1"> <van-notice-bar :background="'none'" color="#000" :speed="50" :text="formattedOrderDetails" /></div></div>
- <div class="container-item"><span style="color:#666">返拣容器:</span>{{ reversePickingContainerNo || '--' }}</div>
- <div style="display: flex;padding-top: 5px" @click="setPrinter()">
- <div>打印机:</div>
- <div v-if="printer">{{printer.printer}}</div>
- <div style="text-decoration: underline;color: #0077ff">设置打印机<van-icon name="edit" color="#0077ff"/> </div>
- </div>
- <div class="picking-order-count ">
- <div>
- <span style="font-size: 12px">已复核数/总复核数:</span>
- <span style="color: #333;font-weight: bold;font-size: 18px" v-if="orderMap.dataGroup">{{ successNumber }}/{{Object.keys(orderMap.dataGroup).length ||0}}</span>
- <span v-else>0</span>
- </div>
- <div>
- <span style="font-size: 12px">取消单:</span>
- <span style="color: #333;font-weight: bold;font-size: 18px" v-if="orderMap.cancelGroup">{{Object.keys(orderMap.cancelGroup).length ||0}}</span>
- <span v-else>0</span>
- </div>
- <div>
- <span style="font-size: 12px">冻结单:</span>
- <span style="color: #333;font-weight: bold;font-size: 18px" v-if="orderMap.freezeGroup">{{Object.keys(orderMap.freezeGroup).length ||0}}</span>
- <span v-else>0</span>
- </div>
- </div>
- </div>
- <div class="picking-button">
- <div class="picking-button-item" @click="print('A3012_RF_WIFI_HDQD',orderDetail.waveNo)">波次清单</div>
- <div class="picking-button-item" @click="print('PRINT_WAYBILL',orderDetail.waveNo)">打印面单</div>
- <div class="picking-button-item" @click="endCheck()" >结束复核</div>
- <van-popover :actions="actions" placement="bottom-end" @select="onSelect" theme="dark">
- <template #reference>
- <div class="picking-button-item" style="padding: 0 5px">更多操作<van-icon name="play" /></div>
- </template>
- </van-popover>
- </div>
- </div>
- <div class="order-list-box">
- <van-divider style="margin: 0;padding: 5px 15px">订单明细</van-divider>
- <div class="order-list">
- <table class="task-table">
- <thead>
- <tr>
- <th style="width: 40%">商品条码</th>
- <th>数量</th>
- <th>剩余</th>
- <th>状态</th>
- <th v-if="isUniqueCode || isQualityCheck">标记</th>
- </tr>
- </thead>
- <tbody>
- <template v-if="orderList.length>0">
- <tr v-for="(item, index) in orderList" :key="index" :style="rowStyle(item)" >
- <td>{{ item.barcode }} <van-tag type="success" v-if="item.universalCode">万用</van-tag></td>
- <td>{{item.qty}}/{{item.qtyOrdered}}</td>
- <td>{{ item.qty }}</td>
- <td>{{ statusMap[item.status] || '' }}</td>
- <td v-if="isUniqueCode || isQualityCheck">
- <van-tag v-if="item.uniqueRegExp" type="warning" >唯一码</van-tag>
- <van-tag v-if="item.imeiRegExp" type="primary" >IMEI码</van-tag>
- <van-tag v-if="item.qualityCheck" type="warning" >质检</van-tag>
- </td>
- </tr>
- </template>
- <tr v-else>
- <td colspan="4">
- <div>暂无数据</div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- <!-- 条码输入组件 -->
- <input-barcode :back="back" @setBarcode="setBarcode" ref="inputBarcodeRef" />
- <!-- 打印面单-->
- <printer ref="printerRef" @onPrint="onPrint" />
- <!-- 订单列表-->
- <order-list-table ref="orderListRef" />
- <!-- 返拣-->
- <reverse-picking ref="reversePickingRef" :warehouse="warehouse" :reversePickingContainerNo="reversePickingContainerNo" @load-data="loadData" @reversePickingReset="reversePickingReset" />
- <!-- 耗材-->
- <related-materia ref="relatedMateriaRef" @cut-barcode="cutBarcode" />
- <!-- 复核组合商品-->
- <check-barcode-combine ref="checkBarcodeCombineRef" @cutBarcode="cutBarcode" />
- <!-- 蓝牙扫描-->
- <bluetooth-scan :model-value="showBluetoothScan" @update:model-value="showBluetoothScan = $event" @connected="handleBluetoothConnected" @disconnected="handleBluetoothDisconnected" ref="bluetoothScanRef" />
- </div>
- </template>
- <script setup>
- import { computed, onMounted, onUnmounted, ref } from 'vue'
- import { androidFocus, getHeader, goBack, scanError, scanSuccess } from '@/utils/android'
- import { useStore } from '@/store/modules/user'
- import { closeListener, openListener, scanInit } from '@/utils/keydownListener'
- import { getPendingReviewTask, packingReview } from '@/api/check/index'
- import { barcodeToUpperCase, toMap } from '@/utils/dataType.js'
- import { closeToast, showConfirmDialog, showDialog, showLoadingToast, showNotify, showToast } from 'vant'
- import { closeLoading, showLoading } from '@/utils/loading'
- import { fluxPrint, getListCombineSku } from '@/api/picking/index'
- import InputBarcode from '@/views/outbound/picking/components/InputBarcode.vue'
- import Printer from '@/components/Printer.vue'
- import orderListTable from '@/views/outbound/check/components/OrderListTable.vue'
- import ReversePicking from '@/views/outbound/check/components/ReversePicking.vue'
- import RelatedMateria from '@/views/outbound/check/components/RelatedMateria.vue'
- import CheckBarcodeCombine from '@/views/outbound/check/components/CheckBarcodeCombine.vue'
- import BluetoothScan from '@/views/outbound/check/components/BluetoothScan.vue'
- const store = useStore()
- try {
- getHeader()
- androidFocus()
- } catch (error) {
- }
- // 打开蓝牙扫描(立即开始扫描)
- const handleOpenBluetoothScan = () => {
- showBluetoothScan.value = true
- // 延迟一下确保弹窗已打开,然后开始扫描
- setTimeout(() => {
- if (bluetoothScanRef.value) {
- bluetoothScanRef.value.startScan()
- }
- }, 300)
- }
- // 蓝牙连接处理
- const handleBluetoothConnected = (device) => {
- bluetoothConnected.value = true
- connectedBluetoothDevice.value = device
- weightConfirmed.value = false // 连接成功时重置确认状态,允许接收新的重量数据
- // showNotify({ type: 'success', message: `已连接: ${device.name}` })
- }
- // 蓝牙断开处理
- const handleBluetoothDisconnected = () => {
- bluetoothConnected.value = false
- connectedBluetoothDevice.value = null
- weightConfirmed.value = false // 断开时重置确认状态
- }
- // 停止接收蓝牙重量(用户输入或确认时调用)
- const stopReceivingBluetoothWeight = () => {
- if (bluetoothConnected.value) {
- weightConfirmed.value = true
- }
- }
- // 处理重量输入(手动输入时立即停止接收蓝牙重量)
- const handleWeightInput = () => {
- stopReceivingBluetoothWeight()
- }
- // 处理重量输入框获得焦点(用户开始输入时立即停止接收蓝牙重量)
- const handleWeightFocus = () => {
- stopReceivingBluetoothWeight()
- }
- // 处理键盘输入(按下任何键时立即停止接收蓝牙重量)
- const handleWeightKeydown = () => {
- stopReceivingBluetoothWeight()
- }
- // 重置重量(重置后继续接收蓝牙重量)
- const resetWeight = () => {
- weightConfirmed.value = false
- totalWeight.value = ''
- showNotify({ type: 'success', duration: 2000, message: '已重置,继续接收蓝牙重量' })
- }
- // 确认重量(确认后不再接收蓝牙重量)
- const confirmWeight = () => {
- if (!totalWeight.value || Number(totalWeight.value) <= 0) {
- showNotify({ type: 'warning', duration: 3000, message: '请输入有效的重量值' })
- return
- }
- stopReceivingBluetoothWeight()
- showNotify({ type: 'success', duration: 2000, message: '重量已确认' })
- }
- // 蓝牙重量数据回调(仅在未输入且未确认时接收蓝牙重量)
- const handleBluetoothWeight = (weight, unit) => {
- console.log(weight,unit,'handleBluetoothWeight')
- // 只有在未确认重量(未输入且未点击确认)时才自动更新
- if (!weightConfirmed.value && weight !== null && weight !== undefined) {
- totalWeight.value = weight.toString()
- }
- }
- // 蓝牙连接状态回调
- const handleBluetoothConnectionState = (isConnected) => {
- bluetoothConnected.value = isConnected
- if (bluetoothScanRef.value) {
- bluetoothScanRef.value.handleConnectionState(isConnected)
- }
- if (!isConnected) {
- // 断开连接时清除状态
- handleBluetoothDisconnected()
- // 确保组件内的状态也被清除
- if (bluetoothScanRef.value) {
- bluetoothScanRef.value.clearConnectedDevice()
- }
- } else {
- // 连接成功时,从组件获取设备信息
- const saved = localStorage.getItem('bluetooth-device')
- if (saved) {
- try {
- const device = JSON.parse(saved)
- handleBluetoothConnected(device)
- } catch (error) {
- console.error('解析保存的设备失败:', error)
- }
- }
- }
- }
- // 蓝牙错误回调
- const handleBluetoothError = (errorMessage) => {
- showNotify({ type: 'danger', message: `蓝牙错误: ${errorMessage}` })
- }
- // 初始化蓝牙回调
- const initBluetoothCallbacks = () => {
- // 连接状态回调
- window.onScaleConnectionState = handleBluetoothConnectionState
- // 重量数据回调
- window.onScaleWeight = handleBluetoothWeight
- // 错误回调
- window.onScaleError = handleBluetoothError
- }
- // 断开蓝牙连接
- const disconnectBluetooth = () => {
- if (window.AndroidScale && bluetoothConnected.value) {
- try {
- window.AndroidScale.disconnect()
- // 立即清除主页面状态
- handleBluetoothDisconnected()
- // 立即清除组件内的状态
- if (bluetoothScanRef.value) {
- bluetoothScanRef.value.clearConnectedDevice()
- }
- } catch (error) {
- console.error('断开连接失败:', error)
- showNotify({ type: 'danger', message: '断开连接失败' })
- // 即使出错也清除状态
- handleBluetoothDisconnected()
- if (bluetoothScanRef.value) {
- bluetoothScanRef.value.clearConnectedDevice()
- }
- }
- } else {
- // 如果没有 AndroidScale 或未连接,也清除状态
- handleBluetoothDisconnected()
- if (bluetoothScanRef.value) {
- bluetoothScanRef.value.clearConnectedDevice()
- }
- }
- }
- // 处理断开连接(带确认)
- const handleDisconnectBluetooth = () => {
- if (!bluetoothConnected.value) {
- return
- }
- showConfirmDialog({
- title: '温馨提示',
- message: '确定要断开蓝牙连接吗?',
- }).then(() => {
- disconnectBluetooth()
- }).catch(() => {
- // 取消操作
- })
- }
- // 页面初始化
- onMounted(() => {
- openListener()
- scanInit(_handlerScan)
- initBluetoothCallbacks()
- loadData()
- // 延迟加载已保存的蓝牙设备,确保组件已挂载
- setTimeout(() => {
- if (bluetoothScanRef.value) {
- bluetoothScanRef.value.loadSavedDevice()
- }
- }, 100)
- })
- const warehouse = store.warehouse
- //收货容器号
- // JH-WH99-990
- const waveNo = ref('')
- const isUniqueCode=ref(false)
- const isQualityCheck=ref(false)
- // 错误提示
- const tips = ref('')
- //强制返回
- const back = ref(true)
- const scanBarcode=ref('')
- const totalWeight=ref('')
- const showBluetoothScan=ref(false)
- const bluetoothConnected=ref(false)
- const bluetoothScanRef=ref(null)
- const connectedBluetoothDevice=ref(null)
- const weightConfirmed=ref(false) // 重量是否已确认
- const containerNoMap={
- 'WH01':'FJ-WH01-20',
- 'WH02':'FJ-WH02-20',
- 'WH10':'FJ-WH10-01',
- 'WH99':'FJ-WH99-01',
- }
- //返拣容器
- const reversePickingContainerNo=containerNoMap[warehouse]
- // 订单明细
- const orderDetail=ref({})
- //订单详情
- const orderMap=ref({})
- const dataList=ref([])
- const orderList = computed(() => {
- return dataList.value
- .sort((a, b) => {
- const statusPriority = {
- '60': 0,
- '600': 1,
- '50': 2,
- '40': 3,
- '30': 4,
- '20': 5,
- '00': 6,
- }
- if (statusPriority[a.status] !== statusPriority[b.status]) {
- return statusPriority[a.status] - statusPriority[b.status]
- }
- return 0
- })
- })
- // 计算已格式化的拣货容器和波次号字符串
- const formattedOrderDetails = computed(() => {
- const pickingContainer = orderDetail.value.pickingContainer || '--'
- const waveNo = orderDetail.value.waveNo || '--'
- return `${pickingContainer}/${waveNo}`
- })
- const statusMap = {
- '00': '创建',
- '20': '预配',
- '30': '部分分配',
- '40': '已分配',
- '50': '待拣货',
- '60': '已拣货',
- '61': '分拣完成',
- '90': '订单取消',
- }
- //匹配条码
- const matchBarcodeList=ref([])
- const actions = [
- { text: '重新开始',value:'reset' },
- { text: '装箱清单',value:'packing' },
- { text: '取消单列表',value:'cancel' },
- { text: '冻结单列表',value: 'freeze' },
- // { text: '结束复核',value: 'end' },
- ];
- // 扫描条码监听
- const relatedMateriaRef=ref(null)
- const matchedSku=ref([])
- const checkBarcodeCombineRef=ref(null)
- const _handlerScan = (code) => {
- if (code) {
- if (isUniqueCode.value) {
- scanError()
- scanBarcode.value = ''
- showNotify({ type: 'warning', duration: 3000, message: `此单包含唯一码/IMEI码,请到PC复核` })
- return
- }
- const barcode = [...new Set(
- orderList.value
- .filter(item => (item.status == '60'))
- .flatMap(item => [item.barcode, item.barcode2, item.sku, item.universalCode])
- .filter(value => value !== null && value !== '' && value !== undefined),
- )];
- const checkBarcode = barcodeToUpperCase(code);
- if (barcode.some(item => barcodeToUpperCase(item) === checkBarcode)) {
- matchBarcodeList.value=orderList.value.filter(item=>((item.barcode===checkBarcode || item.sku===checkBarcode || item.barcode2===checkBarcode || item.universalCode==checkBarcode) && item.status == '60' && item.qty>0) )
- if(matchBarcodeList.value.length>0){
- const itemActive = matchBarcodeList.value[0]
- scanBarcode.value=code
- if(itemActive.relatedMaterial && itemActive.relatedMaterial.length>0){
- relatedMateriaRef.value.show(itemActive)
- return
- }
- cutBarcode(itemActive,1)
- }else {
- scanBarcode.value=''
- scanError()
- showNotify({ type: 'warning', duration: 3000, message: `商品条码${code},已全部扫描完成`})
- }
- }else {
- //查询组合条码
- matchedSku.value=[]
- getListCombineSku({combineSku:code, workEnvironment:'check'}).then(res=>{
- if(res.data.length>0){
- const combineSkuMap=toMap(res.data,'barcode')
- const matchedSkuList=getBarcodeCombine(orderList.value,combineSkuMap)
- if(matchedSkuList.length>0){
- if(matchedSkuList.length==res.data.length){
- matchedSku.value=matchedSkuList
- checkBarcodeCombineRef.value.show(matchedSku.value,orderList.value)
- }else{
- scanError()
- showDialog({
- title:'温馨提示',
- message:'组合商品与拣货任务不匹配,请检查组合商品配置!'
- })
- }
- }else {
- scanError()
- showDialog({
- title:'温馨提示',
- message:'组合商品与拣货任务不匹配,请检查组合商品配置!'
- })
- }
- }else {
- scanError()
- scanBarcode.value=''
- showNotify({ type: 'warning', duration: 3000, message: `商品条码${code},不匹配请重新扫描!`})
- }
- })
- }
- }
- }
- //组合商品匹配到的商品
- const getBarcodeCombine=(goodsList, combineSkuMap)=>{
- const result = goodsList.map(item => {
- const barcode = item.barcode || item.barcodeAs;
- // 如果有匹配数据添加到 item 中
- if (combineSkuMap[barcode] && item.qty >= combineSkuMap[barcode].quantity ) {
- return {
- ...item,
- matchedJson: combineSkuMap[barcode]
- };
- }
- return null
- })
- .filter(item => item !== null) // 过滤掉 null 元素,保留匹配到的项
- return result.length > 0 ? result : []
- }
- //扣除商品数量
- const weightRef=ref(null)
- const cutBarcode = (itemActive, count) => {
- if (itemActive.qty > 0) {
- itemActive.qty -= count;
- itemActive.qty = Math.max(itemActive.qty, 0)
- itemActive.quantity+=count
- }
- // 计算所有商品的总数量
- const allCount = orderList.value.reduce((sum, item) => sum + Math.max(Number(item.qty), 0), 0);
- // 根据所有商品总数量判断是否继续扫描
- if (allCount > 0) {
- scanBarcode.value = '';
- tips.value = '请继续扫描条码';
- showNotify({ type: 'success', duration: 3000, message: '数量已扣除,请继续扫描条码' });
- } else {
- if (!totalWeight.value) {
- tips.value = '请输入重量';
- weightRef.value?.focus()
- showNotify({ type: 'success', duration: 3000, message: '商品扫描完成,请输入重量' });
- } else {
- endCheck()
- tips.value = '商品扫描完成,请点击结束复核';
- }
- }
- scanSuccess();
- };
- //重新开始
- const reset=()=>{
- showConfirmDialog({
- title: '温馨提示',
- message: '您正在进行重新开始操作,是否继续?',
- }).then(() => {
- waveNo.value=''
- scanBarcode.value=''
- totalWeight.value=''
- weightConfirmed.value = false // 重置确认状态
- orderDetail.value={}
- orderMap.value={}
- dataList.value=[]
- matchBarcodeList.value=[]
- tips.value='请扫描商品条码'
- // 注意:不自动断开蓝牙连接,保持连接状态
- inputBarcodeRef.value?.show('', '请扫描波次/容器号', '')
- })
- }
- const reversePickingReset=()=>{
- orderMap.value.dataGroup=[]
- }
- const printerRef=ref(null)
- //设置打印机
- const setPrinter=()=>{
- printerRef.value?.show(warehouse)
- }
- const printer=ref(null)
- if(localStorage.getItem('check-print')){
- printer.value=JSON.parse(localStorage.getItem('check-print'))
- }
- const onPrint=(code)=>{
- printer.value=code
- localStorage.setItem('check-print',JSON.stringify(code))
- }
- const print=(templateCode,code)=>{
- if(!printer.value){
- scanError()
- showNotify({ type: 'warning', duration: 3000, message: '请先设置打印机' });
- return
- }
- const data = {warehouse,code,printServer: printer.value.server, printName:printer.value.printer,templateCode }
- showLoading()
- fluxPrint(data)
- .then(res => {
- if(res.code==200){
- scanSuccess()
- showNotify({ type: 'success', duration: 3000, message: '打印已发起,请检查打印情况' });
- }else {
- scanError()
- tips.value=res.message || '系统异常,请联系技术支持!'
- showNotify({ type: 'danger', duration: 3000, message: res.message || '系统异常,请联系技术支持!' });
- }
- })
- .catch(err => {
- scanError()
- tips.value=err.message || '系统异常,请联系技术支持!'
- showNotify({ type: 'danger', duration: 3000, message: err.message || '系统异常,请联系技术支持!' });
- }).finally(() => {
- closeLoading()
- })
- }
- const successNumber=ref(0)
- const errorNumber=ref(0)
- //结束复核
- const endCheck=()=>{
- if(!printer.value){
- scanError()
- showNotify({ type: 'warning', duration: 3000, message: '请先设置打印机' });
- return
- }
- const allCount = orderList.value.reduce((sum, item) => sum + Math.max(Number(item.qty), 0), 0);
- if(allCount>0){
- scanError()
- tips.value = '商品未扫描完成,请先扫描商品';
- showNotify({ type: 'warning', duration: 3000, message: '商品未扫描完成,请先扫描商品' });
- return
- }
- const lastNumber=Object.keys(orderMap.value.dataGroup).length
- if (Number(totalWeight.value)<=0 && lastNumber>0) {
- tips.value = '请输入重量';
- scanError()
- showNotify({ type: 'warning', duration: 3000, message: '请输入重量' });
- weightRef.value?.focus()
- return
- }
- showDialog({
- title: '温馨提示',
- message: '是否进行复核操作?',
- theme: 'round-button',
- }).then(() => {
- if (lastNumber > 0) {
- const dataGroup = orderMap.value.dataGroup
- for (const order of Object.values(dataGroup)) {
- for (const item of order) {
- if (item.qty !== 0 && item.status=='60') {
- item.quantity = item.qty
- item.qty = 0
- }
- }
- }
- }
- packingRequests(0,lastNumber)
- successNumber.value=0
- errorNumber.value=0
- })
- }
- //装箱
- const reversePickingRef=ref(null)
- const packingRequests = async (startIndex = 0, lastNumber) => {
- if(startIndex>=lastNumber){
- const cancelOrder= Object.keys(orderMap.value.cancelGroup).length
- const freezeOrder= Object.keys(orderMap.value.freezeGroup).length
- if(cancelOrder>0 || freezeOrder>0) {
- scanError()
- }else {
- scanSuccess()
- }
- reversePickingRef.value.show(successNumber.value,errorNumber.value,orderMap.value.cancelGroup,orderMap.value.freezeGroup)
- return
- }
- const key = Object.keys(orderMap.value.dataGroup)[startIndex];
- const list = orderMap.value.dataGroup[key] || [];
- const groupDetailList = list.map(items => {
- return {
- lotNum: items.lotNum,
- qty: items.quantity,
- };
- });
- const item = list[0] || {};
- try {
- const data = {
- warehouse: item.warehouseId,
- workStation: item.warehouseId,
- code: item.orderNo,
- totalGrossWeight:Number(totalWeight.value),
- groupDetailList,
- activityOrderFlag:true
- };
- showLoadingToast({
- duration: 0,
- forbidClick: true,
- message: `进度:${startIndex+1}/${lastNumber}`,
- });
- const res = await packingReview(data)
- // const res = await getPendingReviewTask(data)
- if (res) {
- if (res.data == '0000'){
- orderMap.value.cancelGroup[item.orderNo] = item.orderNo
- }else if(res.data == '1111'){
- orderMap.value.freezeGroup[item.orderNo] = item.orderNo
- }else {
- successNumber.value+=1
- if(isQualityCheck.value && startIndex==0){
- print('A3014_PACK_CARTON_QC',res.data)
- }
- }
- await packingRequests(startIndex + 1, lastNumber)
- }
- } catch (error) {
- errorNumber.value+=1
- tips.value=`错误信息: ${error.message} (订单号: ${item.orderNo || 'N/A'})`
- if(startIndex>0){
- reversePickingRef.value.show(successNumber.value,lastNumber-successNumber.value,orderMap.value.cancelGroup,orderMap.value.freezeGroup)
- }
- scanError()
- } finally {
- closeToast()
- }
- }
- //更多操作
- const orderListRef=ref(null)
- const onSelect=(item)=>{
- const handleGroup = (groupKey, emptyMessage) => {
- const order = orderMap.value[groupKey];
- if (Object.keys(order).length === 0) {
- showNotify({ message: emptyMessage, duration: 5000, type: 'danger' });
- return;
- }
- orderListRef.value?.show(item.value,order);
- };
- if (item.value == 'cancel') {
- handleGroup('cancelGroup', '暂无取消单');
- } else if (item.value == 'freeze') {
- handleGroup('freezeGroup', '暂无冻结单');
- }else if(item.value=='reset'){
- reset()
- }else if(item.value=='packing'){
- print('A3014_PACK_CARTON_PACKINGLIST',orderDetail.value.waveNo)
- }
- else if(item.value=='end'){
- endCheck()
- }
- }
- // 设置波次号
- const inputBarcodeRef = ref(null)
- const setBarcode = (code) => {
- const data = { warehouse, code, activityOrderFlag: true }
- showLoading()
- getPendingReviewTask(data).then(res => {
- if (res.data.details.length == 0) {
- scanError()
- inputBarcodeRef.value?.show('', '请扫描波次/容器号', '暂未查询到待复核数据,请切换波次/容器号')
- } else {
- if(res.data.waveType!=='*'){
- scanError()
- inputBarcodeRef.value?.show('', '请扫描波次/容器号', '仅支持活动单复核')
- return
- }
- scanSuccess()
- tips.value = '请扫描商品条码'
- waveNo.value = code
- orderDetail.value = res.data
- const allStatus= res.data.details.every(item => item.status == 60);
- if(!allStatus){
- inputBarcodeRef.value?.show('', '请扫描波次/容器号', `${code}:没有拣货完成请拣货`)
- return
- }
- orderMap.value=getDataList(res.data.details)
- if(orderMap.value.dataGroup && Object.keys(orderMap.value.dataGroup).length>0){
- dataList.value=orderMap.value.dataGroup[Object.keys(orderMap.value.dataGroup)[0]]
- isUniqueCode.value = dataList.value.some(item => item.uniqueRegExp || item.imeiRegExp );
- isQualityCheck.value = dataList.value.some(item => item.qualityCheck === true);
- }else {
- dataList.value=[]
- if(Object.keys(orderMap.value.cancelGroup).length>0){
- packingRequests(0,0)
- }
- }
- matchBarcodeList.value=[]
- scanBarcode.value=''
- totalWeight.value=''
- weightConfirmed.value = false // 切换波次时重置确认状态
- successNumber.value=0
- }
- }).catch(err => {
- scanError()
- inputBarcodeRef.value?.show('', '请扫描波次/容器号', err.message)
- }).finally(f=>{
- closeLoading()
- })
- }
- //格式化订单
- const getDataList = (data) => {
- const freezeList = [],cancelList = [],dataList = []
- const groupedData = {
- freezeGroup: {}, // 冻结订单
- cancelGroup: {}, //取消订单
- dataGroup: {} // 普通订单
- };
- const groupOrder = (order, group, groupKey, list) => {
- list.push(order)
- if (!group[groupKey]) {
- group[groupKey] = [] // 如果该订单号的组不存在,创建一个新数组
- }
- group[groupKey].push(order) // 将订单按订单号分组
- };
- data.forEach(curr => {
- curr.serialNoList = []
- curr.secondSerialNoList = []
- if (curr.universalBarcode) {
- curr.universalCode = '#@@@@@@#'
- }
- curr.quantity=0
- if (curr.releaseStatus === 'H') {
- groupOrder(curr, groupedData.freezeGroup, curr.orderNo, freezeList) // 处理冻结订单
- } else if (curr.erpCancelFlag === 'Y') {
- groupOrder(curr, groupedData.cancelGroup, curr.orderNo, cancelList) // 处理取消订单
- } else {
- groupOrder(curr, groupedData.dataGroup, curr.orderNo, dataList) // 处理普通订单
- }
- });
- return groupedData
- };
- const rowStyle=( row )=>{
- if(row.status!='60' ){
- return { background: '#b3b3b3'}
- }
- return ''
- }
- //切换波次
- const _setWaveNo = () => {
- back.value = false
- inputBarcodeRef.value?.show('', '请扫描波次/容器号', '')
- }
- // 数据刷新
- const loadData = () => {
- if (!waveNo.value) {
- inputBarcodeRef.value?.show('', '请扫描波次/容器号', '')
- return
- } else {
- setBarcode(waveNo.value)
- }
- }
- onUnmounted(() => {
- closeListener()
- // 清理蓝牙回调
- disconnectBluetooth()
- window.onScaleConnectionState = null
- window.onScaleWeight = null
- window.onScaleError = null
- })
- window.onRefresh = loadData
- </script>
- <style scoped lang="sass">
- .container
- background: #e9f4ff
- .activity
- .wave-title
- display: flex
- justify-content: space-between
- padding: 8px 10px
- .wave-tips
- color: #ed6a0c
- flex: 1
- .scan-barcode
- ::v-deep(.van-cell)
- padding: 0 15px
- height: 50px
- min-height: 50px
- display: flex
- align-items: center
- ::v-deep(.van-field__body)
- display: flex
- align-items: center
- height: 100%
- ::v-deep(.van-field__control)
- border-bottom: 2px solid #efefef
- font-size: 16px
- line-height: 46px
- ::v-deep(.van-field__label)
- width: unset
- font-size: 16px
- display: flex
- align-items: center
- .weight-input-wrapper
- display: flex
- align-items: center
- gap: 8px
- width: 100%
- ::v-deep(.van-field)
- flex: 1
- ::v-deep(.weight-confirmed)
- .van-field__control
- border-bottom: 2px solid #1ca600 !important
- color: #1ca600
- .weight-reset-btn
- flex-shrink: 0
- height: 36px
- padding: 0 16px
- .weight-confirm-btn
- flex-shrink: 0
- height: 36px
- padding: 0 16px
- margin-right: 15px
- .input-barcode
- ::v-deep(.van-field__control)
- border-bottom: 2px solid #0077ff
- line-height: 46px
- z-index: 2
- .success-input-barcode
- ::v-deep(.van-field__control)
- border-bottom: 2px solid #1ca600
- line-height: 46px
- z-index: 2
- .error-input-barcode
- ::v-deep(.van-field__control)
- border-bottom: 2px solid #ff0000
- line-height: 46px
- z-index: 2
- .order-detail
- margin-top: 2px
- background: #fff
- font-size: 14px
- .picking-no
- display: flex
- justify-content: space-between
- margin: 0 15px
- padding: 3px 0
- border-bottom: 1px solid #eaeaeb
- .picking-code
- flex: 1
- display: flex
- align-items: center
- color: #419bff
- .picking-container
- padding: 0 15px
- text-align: left
- border-bottom: 1px solid #eaeaeb
- .container-item
- line-height: 30px
- display: flex
- align-items: center
- .picking-order-count
- display: flex
- justify-content: space-between
- line-height: 30px
- .picking-button
- display: flex
- justify-content: space-evenly
- align-items: center
- .picking-button-item
- flex: 1
- color: #419bff
- font-weight: bold
- line-height: 35px
- border-right: 1px solid #eaeaeb
- box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1)
- .picking-button-item:last-child
- border-right: none
- .order-list-box
- background: #fff
- margin-top: 2px
- .order-list
- width: 100%
- overflow-y: auto
- max-height: 60vh
- .task-table, .task-table-bin, .task-table-box
- width: 100%
- table-layout: fixed
- border-collapse: collapse
- font-size: 15px
- .task-table th, .task-table-bin th, .task-table td, .task-table-bin td, .task-table-box th, .task-table-box td
- text-align: center
- border: 1px solid #ccc
- word-wrap: break-word
- word-break: break-all
- .task-table thead, .task-table-bin thead, .task-table-box thead
- background-color: #3f8dff
- position: sticky
- top: 0
- color: white
- font-size: 15px
- .task-table-bin thead
- background-color: #3f8dff
- .task-table-bin tbody
- background: #cde7ff
- .nav-bluetooth-scan
- display: flex
- align-items: center
- gap: 4px
- padding: 6px 12px
- background: rgba(255, 255, 255, 0.2)
- border: 1px solid rgba(255, 255, 255, 0.3)
- border-radius: 16px
- font-size: 13px
- color: #fff
- cursor: pointer
- transition: all 0.3s ease
- user-select: none
- white-space: nowrap
- &:active
- background: rgba(255, 255, 255, 0.3)
- transform: scale(0.95)
- .van-icon
- color: #4fc3f7
- .nav-bluetooth-connected
- display: flex
- flex-direction: column
- align-items: flex-end
- gap: 2px
- padding: 4px 10px
- background: rgba(76, 175, 80, 0.2)
- border: 1px solid rgba(76, 175, 80, 0.4)
- border-radius: 12px
- cursor: pointer
- transition: all 0.3s ease
- user-select: none
- min-width: 80px
- &:active
- background: rgba(76, 175, 80, 0.3)
- transform: scale(0.95)
- .bluetooth-device-info
- display: flex
- align-items: center
- gap: 4px
- font-size: 12px
- color: #fff
- font-weight: 500
- line-height: 1.2
- .van-icon
- color: #4caf50
- flex-shrink: 0
- .device-name
- max-width: 100px
- overflow: hidden
- text-overflow: ellipsis
- white-space: nowrap
- .bluetooth-disconnect-text
- font-size: 10px
- color: rgba(255, 255, 255, 0.8)
- line-height: 1.2
- </style>
|