新增配置--绑定工作台、打包模式
This commit is contained in:
parent
b0abe2234e
commit
692d0620a5
28
App.vue
28
App.vue
@ -4,6 +4,9 @@ import { ensureEntry } from '@/core/utils/auth-guard'
|
||||
|
||||
let bootstrapping = false
|
||||
let validatedToken = ''
|
||||
// H5(history 模式)下,整页直接刷新/打开 packMode 等“非入口页”时 uni-app 不创建页面视图(白屏)。
|
||||
// 该状态仅本次整页启动时自愈一次(页面缺失则回跳入口),避免重复触发。
|
||||
let h5WhiteHealDone = false
|
||||
|
||||
export default {
|
||||
onLaunch() {
|
||||
@ -11,6 +14,7 @@ export default {
|
||||
},
|
||||
onShow() {
|
||||
this.bootstrapAuth()
|
||||
this.h5WhiteScreenHeal()
|
||||
},
|
||||
methods: {
|
||||
async bootstrapAuth() {
|
||||
@ -28,6 +32,30 @@ export default {
|
||||
} finally {
|
||||
bootstrapping = false
|
||||
}
|
||||
},
|
||||
// H5 白屏自愈:manifest h5 路由为 history 模式时,若应用是“整页加载”方式
|
||||
// 直接从 packMode 等非 tab、非入口页启动,uni-app 不会渲染出页面视图(uni-page),
|
||||
// 且该会话内后续客户端跳转同样失效,页面会一直白屏(刷新也无法恢复)。
|
||||
// 这里在启动后检测:uni-app 外壳已挂载但 uni-page 缺失 → 判定为白屏态,
|
||||
// 整页回跳根路径让应用从入口正常启动,避免停留在白屏。真机/App 端不参与编译。
|
||||
h5WhiteScreenHeal() {
|
||||
// #ifdef H5
|
||||
if (h5WhiteHealDone) return
|
||||
h5WhiteHealDone = true
|
||||
if (typeof window === 'undefined' || !window.location) return
|
||||
const bootPath = window.location.pathname || '/'
|
||||
// 入口页(根/登录页)本身可正常渲染,无需处理
|
||||
if (bootPath === '/' || bootPath === '/pages/login/index') return
|
||||
setTimeout(() => {
|
||||
// 外壳 uni-app 已存在但页面视图 uni-page 缺失 → 白屏,回跳入口
|
||||
const shell = document.querySelector('uni-app')
|
||||
const page = document.querySelector('uni-page')
|
||||
if (shell && !page) {
|
||||
console.warn('[App] H5 深链接整页启动未渲染页面视图(白屏),自动回跳入口页:', bootPath)
|
||||
window.location.replace('/')
|
||||
}
|
||||
}, 1500)
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,13 @@ export default {
|
||||
auth: false,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 按 token(ye4s 登录临时码)查询用户信息:ye4s_user.tmp_code 命中返回 real_name / wms_account_id(免登录、免鉴权)
|
||||
queryUserByToken: {
|
||||
path: "index.queryUserByToken",
|
||||
auth: false,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
}
|
||||
},
|
||||
/** 公共 ↓ **/
|
||||
@ -110,6 +117,13 @@ export default {
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 工作台绑定(需登录、需权限):绑定码 code + 工作台ID id,成功返回工作台 token
|
||||
bind: {
|
||||
path: "workbench.bind",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 用工作台 token 获取工作台信息(免登录、免鉴权):token 无效/不存在返回 403
|
||||
getWorkbenchInfo: {
|
||||
path: "workbench.getWorkbenchInfo",
|
||||
@ -122,6 +136,34 @@ export default {
|
||||
auth: false,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 移除工作台成员(免登录、免鉴权,以工作台 token 鉴权):ids 为成员行 id(wms_workbench_member.id)
|
||||
removeMember: {
|
||||
path: "workbench.removeMember",
|
||||
auth: false,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 工作台条码查询订单(免登录、免鉴权,以工作台 token 鉴权):token + barcode(运单号)
|
||||
queryOrder: {
|
||||
path: "workbench.queryOrder",
|
||||
auth: false,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 工作台打包上报(免登录、免鉴权,以工作台 token 鉴权):发货单号定位订单创建打包任务
|
||||
packOrder: {
|
||||
path: "workbench.packOrder",
|
||||
auth: false,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 工作台打包完成(免登录、免鉴权,以工作台 token 鉴权):结束该工作台最后一个未结束打包任务
|
||||
finishPack: {
|
||||
path: "workbench.finishPack",
|
||||
auth: false,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
}
|
||||
},
|
||||
storage: {
|
||||
|
||||
@ -292,6 +292,13 @@
|
||||
{
|
||||
"titleNView": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/configuration/Workbench",
|
||||
"style" :
|
||||
{
|
||||
"titleNView": false
|
||||
}
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
666
pages/configuration/Workbench.vue
Normal file
666
pages/configuration/Workbench.vue
Normal file
@ -0,0 +1,666 @@
|
||||
<template>
|
||||
<view class="workbench-page">
|
||||
<view class="normar_container">
|
||||
<!-- 顶部导航:页面标题绑定工作台 -->
|
||||
<page-nav :title="title"></page-nav>
|
||||
|
||||
<!-- 搜索与筛选 -->
|
||||
<view class="search-filter">
|
||||
<view class="search-row">
|
||||
<u-search
|
||||
v-model="searchKeyword"
|
||||
placeholder="输入工作台名称搜索..."
|
||||
shape="round"
|
||||
:show-action="false"
|
||||
:clearabled="true"
|
||||
@search="handleSearch"
|
||||
@clear="handleClearSearch"
|
||||
></u-search>
|
||||
</view>
|
||||
<!-- 状态筛选(等值:1 启用 / 0 禁用) -->
|
||||
<view class="status-filter">
|
||||
<view
|
||||
v-for="opt in statusOptions"
|
||||
:key="String(opt.value)"
|
||||
class="status-filter__chip"
|
||||
:class="{ 'status-filter__chip--active': statusFilter === opt.value }"
|
||||
@click="handleStatusFilter(opt.value)"
|
||||
>{{ opt.label }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<scroll-view class="list-content" scroll-y>
|
||||
<view v-if="!loading && workbenchList.length === 0" class="empty-state">
|
||||
<u-icon name="list-dot" size="100" color="#ccc"></u-icon>
|
||||
<text class="empty-text">暂无工作台</text>
|
||||
<text class="empty-hint">可通过上方搜索框查询工作台</text>
|
||||
</view>
|
||||
|
||||
<view class="workbench-items">
|
||||
<view
|
||||
v-for="item in workbenchList"
|
||||
:key="String(item.id)"
|
||||
class="workbench-card"
|
||||
>
|
||||
<view class="workbench-card__header">
|
||||
<text class="workbench-card__name">{{ item.name || '--' }}</text>
|
||||
<view class="workbench-card__actions">
|
||||
<u-tag :text="getStatusText(item.status)" :type="getStatusType(item.status)" size="mini"></u-tag>
|
||||
<u-button
|
||||
size="mini"
|
||||
type="primary"
|
||||
plain
|
||||
:disabled="Number(item.status) !== 1"
|
||||
@click="openBindPopup(item)"
|
||||
>绑定</u-button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="workbench-card__row">
|
||||
<text class="workbench-card__label">备注</text>
|
||||
<text class="workbench-card__value">{{ item.remark || '--' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="safe-area-bottom"></view>
|
||||
</scroll-view>
|
||||
|
||||
<pagination
|
||||
:pageNum.sync="currentPage"
|
||||
:pageSize="pageSize"
|
||||
:total="totalItems"
|
||||
:showTotal="true"
|
||||
:prevText="'上一页'"
|
||||
:nextText="'下一页'"
|
||||
:showFirstLast="true"
|
||||
:firstText="'首页'"
|
||||
:lastText="'末页'"
|
||||
@change="handlePageChange"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 绑定工作台面板:扫码/输入工作台屏幕上的绑定码(6位) -->
|
||||
<u-popup
|
||||
:show="bindPopup.show"
|
||||
mode="center"
|
||||
round="16"
|
||||
:closeOnClickOverlay="false"
|
||||
@close="closeBindPopup"
|
||||
>
|
||||
<view class="bind-popup">
|
||||
<view class="bind-popup__header">
|
||||
<text class="bind-popup__title">绑定工作台</text>
|
||||
<view class="bind-popup__close" @click="closeBindPopup">
|
||||
<u-icon name="close" size="26" color="#909399"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bind-popup__workbench">
|
||||
<text class="bind-popup__label">工作台:</text>
|
||||
<text class="bind-popup__name">{{ bindPopup.workbench ? (bindPopup.workbench.name || '--') : '--' }}</text>
|
||||
</view>
|
||||
<view class="bind-popup__input-row">
|
||||
<u-input
|
||||
class="bind-popup__input"
|
||||
v-model="bindCode"
|
||||
border="surround"
|
||||
:maxlength="6"
|
||||
placeholder="扫描/输入绑定码(6位)"
|
||||
:focus="bindCodeFocus"
|
||||
@confirm="confirmBind"
|
||||
@blur="bindCodeFocus = false"
|
||||
></u-input>
|
||||
<u-button
|
||||
class="bind-popup__scan-btn"
|
||||
size="medium"
|
||||
type="primary"
|
||||
plain
|
||||
:loading="scanningCode"
|
||||
@click="scanBindCode"
|
||||
>
|
||||
<u-icon name="scan" size="38" color="#2979ff"></u-icon>
|
||||
</u-button>
|
||||
</view>
|
||||
<view class="bind-popup__hint">支持扫码枪广播 / 摄像头扫描工作台屏幕二维码</view>
|
||||
<view class="bind-popup__actions">
|
||||
<u-button size="small" type="primary" plain @click="closeBindPopup">关闭</u-button>
|
||||
<u-button size="small" type="primary" :loading="binding" @click="confirmBind">确认绑定</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<u-loading-page :loading="loading" bg-color="rgba(255,255,255,0.9)"></u-loading-page>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
// 页面标题(与功能菜单名称保持一致)
|
||||
title: '绑定工作台',
|
||||
// 列表数据
|
||||
loading: false,
|
||||
workbenchList: [],
|
||||
searchKeyword: '',
|
||||
// 状态筛选:'' 全部 / 1 启用 / 0 禁用
|
||||
statusFilter: '',
|
||||
statusOptions: [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '禁用', value: 0 }
|
||||
],
|
||||
// 分页
|
||||
pageSize: 20,
|
||||
currentPage: 1,
|
||||
totalItems: 0,
|
||||
// 绑定面板
|
||||
bindPopup: {
|
||||
show: false,
|
||||
workbench: null
|
||||
},
|
||||
bindCode: '',
|
||||
bindCodeFocus: false,
|
||||
binding: false,
|
||||
scanningCode: false
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.safeDispatchBroadcast('setCallbacks', {
|
||||
onResult: this.handleBroadcastResult
|
||||
});
|
||||
this.safeDispatchBroadcast('start');
|
||||
this.loadWorkbenchList();
|
||||
},
|
||||
onShow() {
|
||||
this.safeDispatchBroadcast('setCallbacks', {
|
||||
onResult: this.handleBroadcastResult
|
||||
});
|
||||
this.safeDispatchBroadcast('resume');
|
||||
},
|
||||
onHide() {
|
||||
this.safeDispatchBroadcast('pause');
|
||||
},
|
||||
onUnload() {
|
||||
this.safeDispatchBroadcast('stop');
|
||||
},
|
||||
methods: {
|
||||
safeDispatchBroadcast(action, payload) {
|
||||
try {
|
||||
const task = this.$store.dispatch(`broadcast/${action}`, payload);
|
||||
if (task && typeof task.catch === 'function') {
|
||||
task.catch(error => {
|
||||
console.warn(`[WorkbenchBind] broadcast/${action} 调用失败:`, error);
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`[WorkbenchBind] broadcast/${action} 调用异常:`, error);
|
||||
}
|
||||
},
|
||||
normalizeScanResult(scanResult) {
|
||||
if (!scanResult) return '';
|
||||
if (typeof scanResult === 'string') return scanResult;
|
||||
if (typeof scanResult.result === 'string') return scanResult.result;
|
||||
if (Array.isArray(scanResult.result)) {
|
||||
const first = scanResult.result.find(item => item);
|
||||
if (typeof first === 'string') return first;
|
||||
if (first && typeof first.data === 'string') return first.data;
|
||||
}
|
||||
if (typeof scanResult.data === 'string') return scanResult.data;
|
||||
return '';
|
||||
},
|
||||
handleBroadcastResult(result) {
|
||||
const scanText = this.normalizeScanResult(result);
|
||||
if (!scanText) return;
|
||||
// 仅绑定面板打开时消费广播扫码内容(工作台屏幕绑定码)
|
||||
if (!this.bindPopup?.show) return;
|
||||
const code = this.normalizeBindCode(scanText);
|
||||
if (!this.validateBindCode(code)) {
|
||||
uni.showToast({ title: '扫码内容不是有效绑定码', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
this.bindCode = code;
|
||||
this.confirmBind();
|
||||
},
|
||||
normalizeKeyword(value) {
|
||||
return String(value || '').replace(/\s+/g, '');
|
||||
},
|
||||
buildParams() {
|
||||
const params = {
|
||||
pagination: {
|
||||
page: this.currentPage,
|
||||
pageSize: this.pageSize
|
||||
},
|
||||
where: {}
|
||||
};
|
||||
// name:模糊筛选
|
||||
const keyword = this.normalizeKeyword(this.searchKeyword);
|
||||
if (keyword) {
|
||||
params.where.name = keyword;
|
||||
}
|
||||
// status:等值筛选(1 启用 / 0 禁用),仅在有选择时传入
|
||||
if (this.statusFilter !== '' && this.statusFilter !== null && this.statusFilter !== undefined) {
|
||||
params.where.status = Number(this.statusFilter);
|
||||
}
|
||||
return params;
|
||||
},
|
||||
async loadWorkbenchList() {
|
||||
if (this.loading) return;
|
||||
this.loading = true;
|
||||
try {
|
||||
const res = await this.$http('workbench.list', this.buildParams());
|
||||
// 实际返回:flag=success(code 可能为 1),兼容 200
|
||||
const isSuccess = String(res?.flag || '').toLowerCase() === 'success' || Number(res?.code) === 200 || Number(res?.code) === 1;
|
||||
if (!isSuccess) {
|
||||
this.workbenchList = [];
|
||||
this.totalItems = 0;
|
||||
uni.showToast({ title: res?.message || '查询工作台列表失败', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
// 系统接口可能直接返回顶层 list/pagination,也可能包在 data 下,逐级兼容
|
||||
const payload = this.extractPayload(res);
|
||||
const rawList = Array.isArray(payload.list) ? payload.list : [];
|
||||
const pagination = payload.pagination || {};
|
||||
this.workbenchList = rawList.map(item => this.normalizeWorkbench(item));
|
||||
this.totalItems = Number(pagination.total ?? (rawList.length || 0));
|
||||
// 后端返回了当前页时,以返回为准
|
||||
const returnedPage = Number(pagination.page || 0);
|
||||
if (returnedPage > 0) {
|
||||
this.currentPage = returnedPage;
|
||||
}
|
||||
} catch (error) {
|
||||
const msg = String(error?.message || error?.msg || '查询工作台列表失败');
|
||||
uni.showToast({ title: msg, icon: 'none' });
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
extractPayload(response) {
|
||||
const candidates = [
|
||||
response?.data?.data,
|
||||
response?.data,
|
||||
response
|
||||
];
|
||||
for (let i = 0; i < candidates.length; i += 1) {
|
||||
const current = candidates[i];
|
||||
if (current && typeof current === 'object' && !Array.isArray(current)) {
|
||||
return current;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
},
|
||||
normalizeWorkbench(item) {
|
||||
const source = (item && typeof item === 'object') ? item : {};
|
||||
return {
|
||||
id: source.id ?? source.workbench_id ?? '',
|
||||
name: String(source.name || ''),
|
||||
status: Number(source.status ?? 1),
|
||||
remark: source.remark != null ? String(source.remark) : ''
|
||||
};
|
||||
},
|
||||
openBindPopup(item) {
|
||||
if (!item || Number(item.status) !== 1) {
|
||||
uni.showToast({ title: '仅启用状态的工作台可绑定', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
this.bindPopup = {
|
||||
show: true,
|
||||
workbench: item
|
||||
};
|
||||
this.bindCode = '';
|
||||
// 默认不自动聚焦输入框,避免弹软键盘;扫码枪广播扫码不受影响,点击输入框可手动输入
|
||||
this.bindCodeFocus = false;
|
||||
},
|
||||
closeBindPopup() {
|
||||
this.bindPopup = {
|
||||
show: false,
|
||||
workbench: null
|
||||
};
|
||||
this.bindCode = '';
|
||||
this.bindCodeFocus = false;
|
||||
},
|
||||
normalizeBindCode(value) {
|
||||
return String(value || '').replace(/\s+/g, '').toUpperCase();
|
||||
},
|
||||
validateBindCode(code) {
|
||||
// 6 位大写字母+数字
|
||||
return /^[A-Z0-9]{6}$/.test(code);
|
||||
},
|
||||
scanBindCode() {
|
||||
if (this.scanningCode) return;
|
||||
this.scanningCode = true;
|
||||
uni.scanCode({
|
||||
onlyFromCamera: true,
|
||||
scanType: ['qrCode', 'barCode', 'datamatrix', 'pdf417'],
|
||||
success: (res) => {
|
||||
const code = this.normalizeBindCode(res?.result || '');
|
||||
this.bindCode = code;
|
||||
if (this.validateBindCode(code)) {
|
||||
this.confirmBind();
|
||||
} else {
|
||||
uni.showToast({ title: '扫码内容不是有效绑定码', icon: 'none' });
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
const errMsg = String(error?.errMsg || '').toLowerCase();
|
||||
if (!errMsg.includes('cancel')) {
|
||||
uni.showToast({ title: '扫码失败,请重试', icon: 'none' });
|
||||
}
|
||||
},
|
||||
complete: () => {
|
||||
this.scanningCode = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
async confirmBind() {
|
||||
const code = this.normalizeBindCode(this.bindCode);
|
||||
const workbench = this.bindPopup?.workbench || {};
|
||||
const id = Number(workbench.id ?? workbench.workbench_id ?? 0);
|
||||
if (!this.validateBindCode(code)) {
|
||||
uni.showToast({ title: '请输入有效的6位绑定码', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (!id) {
|
||||
uni.showToast({ title: '缺少工作台信息', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (this.binding) return;
|
||||
this.binding = true;
|
||||
uni.hideKeyboard();
|
||||
// 请求期间暂停广播,避免重复扫码重复触发;结束后恢复
|
||||
this.safeDispatchBroadcast('stop');
|
||||
try {
|
||||
const res = await this.$http('workbench.bind', { code, id });
|
||||
const isSuccess = String(res?.flag || '').toLowerCase() === 'success' || Number(res?.code) === 200 || Number(res?.code) === 1;
|
||||
if (!isSuccess) {
|
||||
uni.showToast({ title: res?.message || '绑定失败', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
uni.showToast({ title: '绑定成功', icon: 'success' });
|
||||
this.closeBindPopup();
|
||||
this.loadWorkbenchList();
|
||||
} catch (error) {
|
||||
const msg = String(error?.message || error?.msg || '绑定失败');
|
||||
uni.showToast({ title: msg, icon: 'none' });
|
||||
} finally {
|
||||
this.binding = false;
|
||||
this.safeDispatchBroadcast('resume');
|
||||
}
|
||||
},
|
||||
handleSearch() {
|
||||
this.currentPage = 1;
|
||||
this.loadWorkbenchList();
|
||||
},
|
||||
handleClearSearch() {
|
||||
this.searchKeyword = '';
|
||||
this.currentPage = 1;
|
||||
this.loadWorkbenchList();
|
||||
},
|
||||
handleStatusFilter(value) {
|
||||
if (this.statusFilter === value) return;
|
||||
this.statusFilter = value;
|
||||
this.currentPage = 1;
|
||||
this.loadWorkbenchList();
|
||||
},
|
||||
handlePageChange(pageNum) {
|
||||
const nextPage = Number(pageNum?.pageNum || pageNum?.page || pageNum);
|
||||
this.currentPage = Number.isFinite(nextPage) && nextPage > 0 ? nextPage : 1;
|
||||
this.loadWorkbenchList();
|
||||
},
|
||||
getStatusText(status) {
|
||||
return Number(status) === 1 ? '启用' : '禁用';
|
||||
},
|
||||
getStatusType(status) {
|
||||
return Number(status) === 1 ? 'success' : 'warning';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.workbench-page {
|
||||
height: 100vh;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.normar_container {
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.search-filter {
|
||||
background: #ffffff;
|
||||
padding: 20rpx 24rpx 12rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.search-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.search-row ::v-deep .u-search {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.status-filter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
/* 真机 WebView 对 flex gap 兼容性差,改用 margin 拉开按钮间隔 */
|
||||
.status-filter__chip {
|
||||
padding: 8rpx 28rpx;
|
||||
font-size: 26rpx;
|
||||
color: #606266;
|
||||
background: #f5f5f5;
|
||||
border-radius: 999rpx;
|
||||
transition: all 0.2s;
|
||||
margin-right: 32rpx;
|
||||
}
|
||||
|
||||
.status-filter__chip:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.status-filter__chip--active {
|
||||
color: #ffffff;
|
||||
background: #2979ff;
|
||||
}
|
||||
|
||||
.list-content {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
min-height: 0;
|
||||
padding: 0 24rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
min-height: 50vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 14rpx;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 34rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.empty-hint {
|
||||
font-size: 26rpx;
|
||||
color: #909399;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.workbench-items {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 20rpx 0 24rpx;
|
||||
}
|
||||
|
||||
/* 工作台卡片上下间隔(用 margin 兼容真机 WebView) */
|
||||
.workbench-card {
|
||||
background: #ffffff;
|
||||
border-radius: 18rpx;
|
||||
padding: 22rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.workbench-card + .workbench-card {
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
|
||||
.workbench-card__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.workbench-card__name {
|
||||
font-size: 38rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.workbench-card__actions {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* 状态标签与绑定按钮间隔(用 margin 兼容真机 WebView) */
|
||||
.workbench-card__actions > :not(:first-child) {
|
||||
margin-left: 24rpx;
|
||||
}
|
||||
|
||||
.workbench-card__row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
font-size: 26rpx;
|
||||
padding: 6rpx 0;
|
||||
}
|
||||
|
||||
.workbench-card__label {
|
||||
flex-shrink: 0;
|
||||
color: #909399;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.workbench-card__value {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
color: #303133;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* 绑定面板 */
|
||||
.bind-popup {
|
||||
width: 580rpx;
|
||||
padding: 40rpx 36rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.bind-popup__header {
|
||||
position: relative;
|
||||
margin-bottom: 50rpx;
|
||||
}
|
||||
|
||||
.bind-popup__title {
|
||||
font-size: 34rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.bind-popup__close {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: -2rpx;
|
||||
transform: translateY(-50%);
|
||||
z-index: 2;
|
||||
padding: 6rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.bind-popup__workbench {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
padding: 16rpx 20rpx;
|
||||
margin-bottom: 24rpx;
|
||||
background: #f5f6f8;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.bind-popup__label {
|
||||
flex-shrink: 0;
|
||||
font-size: 26rpx;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.bind-popup__name {
|
||||
font-size: 38rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.bind-popup__hint {
|
||||
margin-top: 12rpx;
|
||||
font-size: 24rpx;
|
||||
color: #909399;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.bind-popup__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
|
||||
.bind-popup__actions ::v-deep .u-button {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.bind-popup__actions ::v-deep .u-button + .u-button {
|
||||
margin-left: 48rpx;
|
||||
}
|
||||
|
||||
/* 输入框行:输入框 + 行末扫码图标按钮 */
|
||||
.bind-popup__input-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.bind-popup__input-row ::v-deep .bind-popup__input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.bind-popup__input-row ::v-deep .bind-popup__scan-btn {
|
||||
flex: 0 0 auto;
|
||||
width: 88rpx;
|
||||
height: 88rpx;
|
||||
padding: 0;
|
||||
margin-left: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
||||
@ -183,6 +183,7 @@ export default {
|
||||
workbenchInputFocus: false, // 工作台登录码输入框自动聚焦(从打包模式退出回来时)
|
||||
showWorkbenchLogin: false, // 工作台登录码输入框显隐(隐藏入口:连续点击5次标题切换)
|
||||
workbenchTitleTapCount: 0, // 系统标题连点计数(满5次切换工作台登录码输入框显隐)
|
||||
autoEntering: false, // 自动进入打包模式防重入锁(检测到有效工作台 token 时直接进入 packMode)
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
@ -205,6 +206,8 @@ export default {
|
||||
},
|
||||
onShow() {
|
||||
this.scanning = true;
|
||||
// 检测到本地残留有效工作台 token 时自动进入打包模式(无需在登录页点击跳转)
|
||||
this.autoEnterPackMode();
|
||||
// 每次回到本页(reLaunch 重建 / 从其它页面返回)都重新绑定最新回调并确保广播监听
|
||||
this.$store.dispatch('broadcast/setCallbacks', {
|
||||
onResult: this.handleBroadcastResult
|
||||
@ -586,6 +589,38 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
// 自动进入打包模式:登录页检测到本地残留有效工作台 token(workbenchToken 非空)时,
|
||||
// 无需手动点击,自动进入打包模式页(packMode 内部会调用 getWorkbenchInfo 刷新工作台信息)
|
||||
autoEnterPackMode() {
|
||||
if (this.autoEntering) return;
|
||||
const token = String(uni.getStorageSync('workbenchToken') || '').trim();
|
||||
if (!token) return;
|
||||
|
||||
this.autoEntering = true;
|
||||
setTimeout(() => {
|
||||
// 延迟后再次校验(期间可能已被退出流程清除)
|
||||
const current = String(uni.getStorageSync('workbenchToken') || '').trim();
|
||||
if (!current) {
|
||||
this.autoEntering = false;
|
||||
return;
|
||||
}
|
||||
// 工作台会话判定依赖 主 token === workbenchToken;
|
||||
// 若主 token 被普通账号登录覆盖或被登出清空,用本地残留的有效工作台 token 恢复工作台会话,
|
||||
// 否则路由守卫会把 packMode 视为未登录并重定向回登录页。
|
||||
const mainToken = String(uni.getStorageSync('token') || '').trim();
|
||||
if (mainToken !== current) {
|
||||
console.log('[Login][auto] 主 token 与工作台 token 不一致,用本地工作台 token 恢复会话');
|
||||
setToken(current);
|
||||
}
|
||||
console.log('[Login][auto] 检测到有效工作台 token,自动进入打包模式');
|
||||
uni.reLaunch({
|
||||
url: '/pages/packing/packMode',
|
||||
fail: () => {
|
||||
this.autoEntering = false;
|
||||
}
|
||||
});
|
||||
}, 500);
|
||||
},
|
||||
handleWorkbenchInputConfirm() {
|
||||
// 工作台登录码输入框回车 / 枪扫内容(键盘模拟)落入该框后的统一入口:
|
||||
// 清空后交给 handleBroadcastResult 自动识别(wblc 工作台码 / 工牌 Base64)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user