手持机

This commit is contained in:
张怡蓉
2025-10-15 08:45:28 +08:00
parent b884a7164e
commit 38ab04cc79
10 changed files with 233 additions and 204 deletions

View File

@@ -17,63 +17,65 @@
this.updateTabBarText() this.updateTabBarText()
}) })
}, },
onShow: function() { // onShow: function() {
// 检查应用状态,确保从后台恢复时状态一致 // // 检查应用状态,确保从后台恢复时状态一致
this.checkAppState() // this.checkAppState()
}, // },
onDestroy() { onDestroy() {
// 移除事件监听器 // 移除事件监听器
uni.$off('languageChanged') uni.$off('languageChanged')
}, },
methods: { methods: {
// 初始化应用 // 初始化应用
initApp() { initApp() {
// 初始化应用配置 // 初始化应用配置
this.initConfig() this.initConfig()
// 检查用户登录状态 // 检查用户登录状态
//#ifdef H5 //#ifdef H5
this.checkLogin() this.checkLogin()
//#endif //#endif
}, },
initConfig() { initConfig() {
this.globalData.config = config this.globalData.config = config
}, },
checkLogin() { checkLogin() {
if (!getToken()) { if (!getToken()) {
this.$tab.reLaunch('/pages/login') console.log('checkLogin 检查登录状态,token不存在')
}
}, this.$tab.reLaunch('/pages/login')
checkAppState() { }
// 检查Token状态和页面导航栈状态 },
console.log('应用从后台切换到前台,检查应用状态') // checkAppState() {
// // 检查Token状态和页面导航栈状态
// console.log('应用从后台切换到前台,检查应用状态')
// 获取当前页面路径,判断是否在登录页 // // 获取当前页面路径,判断是否在登录页
const pages = getCurrentPages() // const pages = getCurrentPages()
const currentPage = pages[pages.length - 1] // const currentPage = pages[pages.length - 1]
const currentPagePath = currentPage ? currentPage.route : '' // const currentPagePath = currentPage ? currentPage.route : ''
// 如果当前页面是登录页,则不检查token // // 如果当前页面是登录页,则不检查token
if (currentPagePath === 'pages/login') { // if (currentPagePath === 'pages/login') {
console.log('当前已在登录页面,不进行token检查') // console.log('当前已在登录页面,不进行token检查')
return // return
} // }
// 检查Token状态 // // 检查Token状态
if (!getToken()) { // if (!getToken()) {
console.log('Token不存在,提示并跳转到登录页') // console.log('Token不存在,提示并跳转到登录页')
uni.showToast({ // uni.showToast({
icon: 'none', // icon: 'none',
title: '登录已过期,请重新登录' // title: '登录已过期,请重新登录'
}) // })
setTimeout(() => { // setTimeout(() => {
uni.reLaunch({ url: '/pages/login' }) // uni.reLaunch({ url: '/pages/login' })
}, 1500) // }, 1500)
} else { // } else {
console.log('Token存在,不做操作') // console.log('Token存在,不做操作')
} // }
}, // },
updateTabBarText() { updateTabBarText() {
// 使用 nextTick 确保 DOM 更新完成 // 使用 nextTick 确保 DOM 更新完成
this.$nextTick(() => { this.$nextTick(() => {

View File

@@ -352,7 +352,10 @@
"outboundSuccess": "Outbound confirmation successful", "outboundSuccess": "Outbound confirmation successful",
"outboundFailed": "Outbound confirmation failed", "outboundFailed": "Outbound confirmation failed",
"trayInfoNotFound": "No related pallet information found", "trayInfoNotFound": "No related pallet information found",
"getTrayInfoFailed": "Failed to get pallet information" "getTrayInfoFailed": "Failed to get pallet information",
"exit": "Exit",
"exitPlaceholder": "Please select exit",
"selectExit": "Please select exit"
}, },
"bindShelf": { "bindShelf": {
"title": "Bind Shelf", "title": "Bind Shelf",

View File

@@ -353,7 +353,10 @@
"outboundSuccess": "出库确认成功", "outboundSuccess": "出库确认成功",
"outboundFailed": "出库确认失败", "outboundFailed": "出库确认失败",
"trayInfoNotFound": "未找到相关托盘信息", "trayInfoNotFound": "未找到相关托盘信息",
"getTrayInfoFailed": "获取托盘信息失败" "getTrayInfoFailed": "获取托盘信息失败",
"exit": "出口",
"exitPlaceholder": "请选择出口",
"selectExit": "请选择出口"
}, },
"bindShelf": { "bindShelf": {
"title": "绑定料架", "title": "绑定料架",

View File

@@ -1,19 +1,29 @@
<template> <template>
<view class="container"> <view class="container">
<view class="input-group"> <view class="input-group">
<uni-easyinput <uni-easyinput
v-model="trayCode" v-model="trayCode"
:placeholder="$t('outbound.ckMakeSureByTray.trayCodePlaceholder')" :placeholder="$t('outbound.ckMakeSureByTray.trayCodePlaceholder')"
:clearable="true" :clearable="true"
@input="handleInput" @input="handleInput"
@clear="handleClear" @clear="handleClear"
ref="trayCodeInput" ref="trayCodeInput"
> >
<template #right> <template #right>
<text class="scan-icon" @click="handleScan">📷</text> <text class="scan-icon" @click="handleScan">📷</text>
</template> </template>
</uni-easyinput> </uni-easyinput>
</view> </view>
<!-- 条件显示出口下拉框 -->
<view class="select-group" v-if="showEntrySelect">
<view class="select-label">{{ $t('outbound.ckMakeSureByTray.exit') }}</view>
<uni-data-select
v-model="selectedEntry"
:localdata="entryOptions"
:placeholder=" $t('outbound.ckMakeSureByTray.exitPlaceholder')"
></uni-data-select>
</view>
<view class="loading-container" v-if="loading"> <view class="loading-container" v-if="loading">
<uni-load-more status="loading" :content-text="{contentdown: $t('outbound.ckMakeSureByTray.loading'),contentrefresh: $t('outbound.ckMakeSureByTray.loading'),contentnomore: $t('outbound.ckMakeSureByTray.noMoreData')}"></uni-load-more> <uni-load-more status="loading" :content-text="{contentdown: $t('outbound.ckMakeSureByTray.loading'),contentrefresh: $t('outbound.ckMakeSureByTray.loading'),contentnomore: $t('outbound.ckMakeSureByTray.noMoreData')}"></uni-load-more>
@@ -69,19 +79,48 @@
return { return {
trayCode: '', trayCode: '',
materialList: [], materialList: [],
loading: false loading: false,
showEntrySelect: false,
entryOptions: [],
selectedEntry: ''
} }
}, },
methods: { methods: {
// 处理输入事件 // 处理输入事件
handleInput(value) { async handleInput(value) {
if (value) { if (value) {
this.fetchTrayInfo(value) await this.fetchTrayInfo(value)
const first = this.materialList && this.materialList.length > 0 ? this.materialList[0] : null
if (first && (first.warehouseId === '02' || first.warehouseId === '13')) {
this.showEntrySelect = true
if (first.warehouseId === '02') {
this.entryOptions = [
{ text: 'G1001', value: 'G1001' },
{ text: 'G1007', value: 'G1007' }
]
} else {
this.entryOptions = [
{ text: 'G4004', value: 'G4004' },
{ text: 'G4005', value: 'G4005' },
{ text: 'G4006', value: 'G4006' },
{ text: 'G5004', value: 'G5004' },
{ text: 'G5005', value: 'G5005' },
{ text: 'G5006', value: 'G5006' }
]
}
} else {
this.showEntrySelect = false
this.entryOptions = []
this.selectedEntry = ''
}
} }
}, },
// 处理清除事件 // 处理清除事件
handleClear() { handleClear() {
this.materialList = [] this.materialList = []
this.showEntrySelect = false
this.entryOptions = []
this.selectedEntry = ''
}, },
// 处理扫码事件 // 处理扫码事件
handleScan() { handleScan() {
@@ -131,10 +170,20 @@
}) })
return return
} }
// 当入口下拉框显示时,校验是否选择了入口
if (this.showEntrySelect && !this.selectedEntry) {
uni.showToast({
title: this.$t('outbound.ckMakeSureByTray.selectExit'),
icon: 'none'
})
return
}
try { try {
const response=await ckMakeSure({ const response=await ckMakeSure({
trayCode: this.trayCode trayCode: this.trayCode,
exitId: this.selectedEntry
}) })
if (response.code==200) { if (response.code==200) {
@@ -145,14 +194,17 @@
// 清空数据 // 清空数据
this.trayCode = '' this.trayCode = ''
this.materialList = [] this.materialList = []
this.showEntrySelect = false
this.entryOptions = []
this.selectedEntry = ''
}else{ }else{
uni.showToast({ uni.showToast({
title: response.msg, title: response.msg,
icon: 'none' icon: 'none'
}) })
} }
} catch (error) { } catch (error) {
uni.showToast({ uni.showToast({
title: this.$t('outbound.ckMakeSureByTray.outboundFailed'), title: this.$t('outbound.ckMakeSureByTray.outboundFailed'),
@@ -178,6 +230,19 @@
margin-bottom: 30rpx; margin-bottom: 30rpx;
} }
.select-group {
background-color: #fff;
border-radius: 16rpx;
padding: 20rpx;
margin-bottom: 30rpx;
}
.select-label {
font-size: 28rpx;
color: #666;
margin-bottom: 16rpx;
}
.scan-icon { .scan-icon {
font-size: 40rpx; font-size: 40rpx;
padding: 0 20rpx; padding: 0 20rpx;

View File

@@ -12,8 +12,18 @@
<template #right> <template #right>
<text class="scan-icon" @click="handleScan">📷</text> <text class="scan-icon" @click="handleScan">📷</text>
</template> </template>
</uni-easyinput> </uni-easyinput>
</view> </view>
<!-- 条件显示出口下拉框 -->
<view class="select-group" v-if="showExitSelect">
<view class="select-label">出口</view>
<uni-data-select
v-model="selectedExit"
:localdata="exitOptions"
placeholder="请选择出口"
></uni-data-select>
</view>
<view class="materials-list" v-if="materialList.length > 0"> <view class="materials-list" v-if="materialList.length > 0">
<button class="add-button" @click="showAddMaterialPopup">{{ $t('stocktaking.confirm.addMaterial') }}</button> <button class="add-button" @click="showAddMaterialPopup">{{ $t('stocktaking.confirm.addMaterial') }}</button>
@@ -79,7 +89,11 @@
newMaterial: { newMaterial: {
productId: '', productId: '',
inQuantity: '' inQuantity: ''
} },
// 出口选择
showExitSelect: false,
exitOptions: [],
selectedExit: ''
} }
}, },
methods: { methods: {
@@ -92,6 +106,9 @@
// 处理清除事件 // 处理清除事件
handleClear() { handleClear() {
this.materialList = [] this.materialList = []
this.showExitSelect = false
this.exitOptions = []
this.selectedExit = ''
}, },
// 处理扫码事件 // 处理扫码事件
handleScan() { handleScan() {
@@ -110,6 +127,31 @@
...item, ...item,
countQuantity: item.outQuantity countQuantity: item.outQuantity
})) }))
// 根据首条物料的仓库,决定是否显示出口选择
const first = this.materialList && this.materialList.length > 0 ? this.materialList[0] : null
if (first && (first.warehouseId === '02' || first.warehouseId === '13')) {
this.showExitSelect = true
if (first.warehouseId === '02') {
this.exitOptions = [
{ text: 'G1001', value: 'G1001' },
{ text: 'G1007', value: 'G1007' }
]
} else {
this.exitOptions = [
{ text: 'G4004', value: 'G4004' },
{ text: 'G4005', value: 'G4005' },
{ text: 'G4006', value: 'G4006' },
{ text: 'G5004', value: 'G5004' },
{ text: 'G5005', value: 'G5005' },
{ text: 'G5006', value: 'G5006' }
]
}
} else {
this.showExitSelect = false
this.exitOptions = []
this.selectedExit = ''
}
} catch (error) { } catch (error) {
uni.showToast({ uni.showToast({
title: this.$t('stocktaking.confirm.getTrayInfoFailed'), title: this.$t('stocktaking.confirm.getTrayInfoFailed'),
@@ -158,8 +200,17 @@
// 确认盘点 // 确认盘点
async handleConfirm() { async handleConfirm() {
try { try {
// 出口显示时必须选择
if (this.showExitSelect && !this.selectedExit) {
uni.showToast({
title: '请选择出口',
icon: 'none'
})
return
}
const data = { const data = {
trayCode: this.trayCode, trayCode: this.trayCode,
exitId: this.selectedExit,
materials: this.materialList.map(item => ({ materials: this.materialList.map(item => ({
stockId: item.stockId, stockId: item.stockId,
productId:item.productId, productId:item.productId,
@@ -173,10 +224,13 @@
uni.showToast({ uni.showToast({
title: this.$t('stocktaking.confirm.stocktakingSuccess'), title: this.$t('stocktaking.confirm.stocktakingSuccess'),
icon: 'success' icon: 'success'
}) })
// 清空数据 // 清空数据
this.trayCode = '' this.trayCode = ''
this.materialList = [] this.materialList = []
this.showExitSelect = false
this.exitOptions = []
this.selectedExit = ''
} }
@@ -213,6 +267,19 @@
} }
} }
.select-group {
background-color: #fff;
border-radius: 16rpx;
padding: 20rpx;
margin-bottom: 30rpx;
}
.select-label {
font-size: 28rpx;
color: #666;
margin-bottom: 16rpx;
}
.scan-icon { .scan-icon {
font-size: 40rpx; font-size: 40rpx;
padding: 0 20rpx; padding: 0 20rpx;

View File

@@ -3,165 +3,39 @@ import { getToken } from '@/utils/auth'
// 登录页面 // 登录页面
const loginPage = "/pages/login" const loginPage = "/pages/login"
// 首页
const indexPage = "/pages/index"
// 标记是否由navigateBack触发的reLaunch
let isNavigateBackTriggered = false
// 获取当前页面路径
function getCurrentPageUrl() {
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
console.log("当前页面",currentPage.route)
console.log("上一层页面", pages[pages.length - 2].route)
return currentPage ? currentPage.route : ''
}
// 页面白名单 // 页面白名单
const whiteList = [ const whiteList = [
'/pages/login', '/pages/register', '/pages/common/webview/index','/pages/setting' '/pages/login', '/pages/register', '/pages/common/webview/index','/pages/setting'
] ]
// 检查地址白名单 // 检查地址白名单
function checkWhite(url) { function checkWhite(url) {
// 确保url以/开头 const path = url.split('?')[0]
const normalizedUrl = url.startsWith('/') ? url : '/' + url
const path = normalizedUrl.split('?')[0]
return whiteList.indexOf(path) !== -1 return whiteList.indexOf(path) !== -1
} }
// 页面跳转验证拦截器 // 页面跳转验证拦截器
let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"] let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"]
list.forEach(item => { list.forEach(item => {
uni.addInterceptor(item, { uni.addInterceptor(item, {
invoke(to) { invoke(to) {
console.log(`${item} 拦截器被触发,目标页面:`, to.url)
console.log('当前 Token 状态:', getToken() ? '存在' : '不存在')
// 如果是由navigateBack触发的reLaunch,直接放行
if (item === 'reLaunch' && isNavigateBackTriggered) {
console.log('由navigateBack触发的reLaunch,直接放行')
return true
}
if (getToken()) { if (getToken()) {
console.log('Token 存在,检查是否为登录页面')
if (to.url === loginPage) { if (to.url === loginPage) {
console.log('当前为登录页面,重定向到首页')
uni.reLaunch({ url: "/" }) uni.reLaunch({ url: "/" })
} }
return true return true
} else { } else {
console.log('Token 不存在,检查是否在白名单中')
if (checkWhite(to.url)) { if (checkWhite(to.url)) {
console.log('目标页面在白名单中,允许访问')
return true return true
} }
console.log('页面不在白名单中,准备跳转到登录页') uni.reLaunch({ url: loginPage })
uni.showToast({
icon: 'none',
title: '登录已过期,请重新登录'
})
setTimeout(() => {
console.log('执行跳转到登录页')
uni.reLaunch({ url: loginPage })
}, 1500)
return false return false
} }
}, },
fail(err) { fail(err) {
console.error(err) console.log(err)
} }
}) })
}) })
// 单独处理返回按钮操作
uni.addInterceptor('navigateBack', {
invoke(e) {
console.log('navigateBack 拦截器被触发', e)
console.log('当前 Token 状态:', getToken() ? '存在' : '不存在')
// 获取当前页面栈
const pages = getCurrentPages()
// 检查页面导航栈是否为空
if (pages.length <= 1) {
console.log('页面导航栈为空或只有一个页面,无法正常返回')
// 检查Token状态
if (getToken()) {
console.log('Token存在,跳转到首页')
// 设置标志,表明当前的reLaunch是由navigateBack触发的
isNavigateBackTriggered = true
uni.reLaunch({ url: indexPage })
// 重置标志
setTimeout(() => {
isNavigateBackTriggered = false
}, 100)
} else {
console.log('Token不存在,跳转到登录页')
uni.showToast({
icon: 'none',
title: '登录已过期,请重新登录'
})
// 设置标志,表明当前的reLaunch是由navigateBack触发的
isNavigateBackTriggered = true
setTimeout(() => {
console.log('执行跳转到登录页')
uni.reLaunch({ url: loginPage })
// 重置标志
setTimeout(() => {
isNavigateBackTriggered = false
}, 100)
}, 1500)
}
return false
}
// 页面导航栈不为空,检查Token状态
if (!getToken()) {
const currentPage = getCurrentPageUrl()
console.log('当前页面路径:', currentPage)
// 确保currentPage不为空且有内容
if (currentPage && currentPage.trim() && checkWhite(currentPage)) {
console.log('当前页面在白名单中,允许返回')
return true
}
console.log('Token不存在且页面不在白名单中,准备跳转到登录页')
uni.showToast({
icon: 'none',
title: '登录已过期,请重新登录'
})
// 设置标志,表明当前的reLaunch是由navigateBack触发的
isNavigateBackTriggered = true
setTimeout(() => {
console.log('执行跳转到登录页')
uni.reLaunch({ url: loginPage })
// 重置标志
setTimeout(() => {
isNavigateBackTriggered = false
}, 100)
}, 1500)
return false
}
// Token存在且页面导航栈不为空,允许正常返回
const currentPage = pages[pages.length - 1]
console.log("当前页面:", currentPage.route)
if (pages.length > 1) {
console.log("上一层页面:", pages[pages.length - 2].route)
}
console.log('Token存在,允许正常返回')
return true
},
fail(err) {
console.error('navigateBack 拦截器执行失败:', err)
}
})

View File

@@ -128,6 +128,16 @@ public class MydoJobDetail extends BaseEntity
private String pickQuantityReal; private String pickQuantityReal;
//绑定容器物品数量 //绑定容器物品数量
private String pickBindQuantity; private String pickBindQuantity;
private String warehouseId;
public String getWarehouseId() {
return warehouseId;
}
public void setWarehouseId(String warehouseId) {
this.warehouseId = warehouseId;
}
public String getPickBindQuantity() { public String getPickBindQuantity() {
return pickBindQuantity; return pickBindQuantity;

View File

@@ -391,6 +391,7 @@ public class PdaServiceImp implements PdaService {
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
map.put("v_tray_code", trayCodeMakeSure.getTrayCode()); map.put("v_tray_code", trayCodeMakeSure.getTrayCode());
map.put("v_entrance_id",trayCodeMakeSure.getExitId());
map.put("v_type", "1"); map.put("v_type", "1");
pdaMapper.outMakeSure(map); pdaMapper.outMakeSure(map);
//iToWcsService.pushInMydoJob(); //iToWcsService.pushInMydoJob();

View File

@@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="jobDetailId" column="job_detail_id" /> <result property="jobDetailId" column="job_detail_id" />
<result property="jobId" column="job_id" /> <result property="jobId" column="job_id" />
<result property="stockId" column="stock_id" /> <result property="stockId" column="stock_id" />
<result property="warehouseId" column="warehouse_id" />
<result property="lotNo" column="lot_no" /> <result property="lotNo" column="lot_no" />
<result property="inDate" column="in_date" /> <result property="inDate" column="in_date" />
<result property="inOrOutId" column="in_or_out_id" /> <result property="inOrOutId" column="in_or_out_id" />
@@ -75,10 +76,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mjd.pick_quantity, mjd.pick_quantity,
mjd.out_quantity-mjd.pick_quantity as pick_quantity_real, mjd.out_quantity-mjd.pick_quantity as pick_quantity_real,
bp.product_name, bp.spare1 as englishDesc, bp.product_name, bp.spare1 as englishDesc,
bp.spare2 as netWeight,bp.spare5 as length,bp.spare6 as width,bp.spare7 as height,bp.spare8 as volume bp.spare2 as netWeight,bp.spare5 as length,bp.spare6 as width,bp.spare7 as height,bp.spare8 as volume,
mj.warehouse_id
from mydo_job_detail mjd from mydo_job_detail mjd
left join bas_product bp on mjd.product_id = bp.product_id left join bas_product bp on mjd.product_id = bp.product_id
left join mydo_job mj on mjd.job_id = mj.job_id
</sql> </sql>

View File

@@ -7,6 +7,7 @@
{call proc_out_makesure( {call proc_out_makesure(
#{v_tray_code,mode=IN,jdbcType=VARCHAR}, #{v_tray_code,mode=IN,jdbcType=VARCHAR},
#{v_type,mode=IN,jdbcType=VARCHAR}, #{v_type,mode=IN,jdbcType=VARCHAR},
#{v_entrance_id,mode=IN,jdbcType=VARCHAR},
#{v_result,mode=OUT,jdbcType=INTEGER}, #{v_result,mode=OUT,jdbcType=INTEGER},
#{v_resultmsg,mode=OUT,jdbcType=VARCHAR} #{v_resultmsg,mode=OUT,jdbcType=VARCHAR}
)} )}