WMS_PDA/pages/packing/packMode.vue

260 lines
6.3 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="pack-mode-page">
<!-- 顶部栏 -->
<view class="top-bar">
<view class="status-bar"></view>
<view class="header">
<view class="header-left" @click="handleBack">
<u-icon name="arrow-left" size="36rpx" color="#303133"></u-icon>
<text class="header-left__text">退出</text>
</view>
<text class="header-title">打包模式</text>
<view class="header-right"></view>
</view>
</view>
<view class="content">
<!-- ============ 已绑定态 ============ -->
<template v-if="bound">
<!-- 工作台绑定状态卡 -->
<view class="state-card">
<view class="state-badge">
<text class="state-badge__text">{{ workbenchName || '工作台' }}</text>
</view>
</view>
<!-- 打包模式占位提示 -->
<view class="placeholder-card">
<u-icon name="file-text" size="64rpx" color="#c0c4cc"></u-icon>
<text class="placeholder-title">打包模式接入中</text>
<text class="placeholder-desc">已绑定工作台。当前为占位页面,实际打包作业流程后续将在此接入。</text>
</view>
</template>
<!-- ============ 未绑定态:提示返回登录页 ============ -->
<template v-else>
<view class="state-card">
<view class="state-badge">
<u-icon name="info-circle" size="36rpx" color="#909399"></u-icon>
<text class="state-badge__text">未绑定工作台</text>
</view>
<view class="info-block">
<view class="info-row">
<text class="info-label">提示</text>
<text class="info-value">当前未绑定工作台,请返回登录页使用工作台登录码(wblc 开头)登录后进入打包模式。</text>
</view>
</view>
</view>
<view class="action-area action-area--col">
<u-button text="返回登录页" plain @click="handleBack"></u-button>
</view>
</template>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 当前绑定
bound: false,
workbenchId: '',
workbenchName: '',
workbenchToken: '',
warehouseId: '',
workbenchStatus: '',
workbenchType: ''
}
},
computed: {
maskedToken() {
const token = String(this.workbenchToken || '');
if (!token) return '';
if (token.length <= 12) return token;
return `${token.substring(0, 6)}...${token.substring(token.length - 4)}`;
},
statusText() {
if (this.workbenchStatus === 0 || this.workbenchStatus === '0') return '禁用';
if (this.workbenchStatus === 1 || this.workbenchStatus === '1') return '启用';
return this.workbenchStatus === '' || this.workbenchStatus === null || typeof this.workbenchStatus === 'undefined' ? '--' : String(this.workbenchStatus);
},
typeText() {
if (this.workbenchType === 'personal') return '个人工作台';
if (this.workbenchType === 'group') return '团体工作台';
return this.workbenchType ? this.workbenchType : '--';
}
},
onLoad(options) {
this.loadBound(options);
},
methods: {
// 读取本地已绑定信息(wblc 免登录 / 绑定成功均写入 storage)
loadBound(options) {
const cached = uni.getStorageSync('workbenchInfo') || {};
// 优先使用 storage 中的原始信息(UTF-8),避免真机上 URL 中文参数乱码
this.workbenchId = String(cached?.id || options?.workbenchId || '');
this.workbenchName = String(cached?.name || options?.workbenchName || '');
this.workbenchToken = String(cached?.token || uni.getStorageSync('workbenchToken') || '');
this.warehouseId = String(cached?.warehouse_id ?? cached?.warehouseId ?? '');
this.workbenchStatus = cached?.status ?? '';
this.workbenchType = String(cached?.type || '');
this.bound = !!this.workbenchToken;
},
// 彻底退出打包模式:清除工作台会话与登录态,回到完全未登录状态
async handleBack() {
uni.removeStorageSync('workbenchToken');
uni.removeStorageSync('workbenchInfo');
// 标记:回到登录页后自动聚焦“工作台登录码”输入框,方便直接枪扫再次登录
uni.setStorageSync('loginAutoFocusScan', 1);
try {
// logout 内部 clearSession(store) 会清除 token / isLogin / userInfo 等并跳回登录页
await this.$store.dispatch('logout');
} catch (error) {
console.warn('[packMode] 退出打包模式失败,兜底跳转登录页:', error);
uni.reLaunch({ url: '/pages/login/index' });
}
}
}
}
</script>
<style lang="scss" scoped>
.pack-mode-page {
width: 100vw;
min-height: 100vh;
background: #f5f6f7;
box-sizing: border-box;
}
.status-bar {
height: var(--status-bar-height, 0px);
}
.header {
display: flex;
align-items: center;
justify-content: space-between;
height: 88rpx;
padding: 0 24rpx;
background: #ffffff;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
}
.header-left {
display: flex;
align-items: center;
width: 260rpx;
}
.header-left__text {
margin-left: 8rpx;
font-size: 34rpx;
color: #606266;
}
.header-title {
font-size: 34rpx;
font-weight: 600;
color: #303133;
}
.header-right {
width: 260rpx;
}
.content {
padding: 24rpx;
box-sizing: border-box;
}
.state-card {
background: #ffffff;
border-radius: 20rpx;
padding: 32rpx 28rpx;
box-sizing: border-box;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
}
.state-badge {
display: flex;
align-items: center;
gap: 12rpx;
margin-bottom: 24rpx;
}
.state-badge__text {
font-size: 36rpx;
font-weight: 600;
color: #303133;
}
.info-block {
display: flex;
flex-direction: column;
gap: 20rpx;
border-top: 1rpx solid #f0f0f0;
padding-top: 24rpx;
}
.info-row {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 20rpx;
}
.info-label {
font-size: 26rpx;
color: #909399;
flex-shrink: 0;
}
.info-value {
font-size: 26rpx;
color: #303133;
text-align: right;
word-break: break-all;
}
.info-value--mono {
font-family: monospace;
font-size: 24rpx;
}
.placeholder-card {
margin-top: 24rpx;
background: #ffffff;
border-radius: 20rpx;
padding: 64rpx 40rpx;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
gap: 20rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
}
.placeholder-title {
margin-top: 8rpx;
font-size: 32rpx;
font-weight: 600;
color: #303133;
}
.placeholder-desc {
font-size: 26rpx;
line-height: 1.7;
color: #909399;
text-align: center;
}
.action-area {
margin-top: 48rpx;
display: flex;
flex-direction: column;
gap: 20rpx;
}
</style>