修改绑定工作台、散单,团购波次策略、打包模式页面

This commit is contained in:
zm2000 2026-09-08 17:45:41 +08:00
parent 86b93002f7
commit 163fbc86a7
5 changed files with 300 additions and 134 deletions

4
env.js
View File

@ -1,4 +1,4 @@
// export const BASE_URL = 'http://qimen.wms.gztbyc.com' //生产环境接口地址
export const BASE_URL = 'http://192.168.11.56:6060' //开发环境接口地址
export const BASE_URL = 'http://qimen.wms.gztbyc.com' //生产环境接口地址
// export const BASE_URL = 'http://192.168.11.56:6060' //开发环境接口地址
export const API_URL = `${BASE_URL}/system` //后台接口域名
export const IMG_URL = 'https://ye4s.file.gzxunren.com' //全局网络图片地址变量,css背景图片地址变量在uni.scss

View File

@ -120,10 +120,10 @@
<u-icon name="scan" size="38" color="#2979ff"></u-icon>
</u-button>
</view>
<view class="bind-popup__hint">支持扫码枪广播 / 摄像头扫描工作台屏幕二维码</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>
<u-button size="small" type="primary" :loading="binding" @click="confirmBind">确定</u-button>
</view>
</view>
</u-popup>
@ -184,6 +184,19 @@
this.safeDispatchBroadcast('stop');
},
methods: {
// 语音播报($tools.speakText 封装,自动 catch)
speakText(text = '') {
try {
const tools = this.$tools;
if (!tools || typeof tools.speakText !== 'function') return;
const task = tools.speakText(String(text).trim(), {});
if (task && typeof task.catch === 'function') {
task.catch(error => console.warn('[WorkbenchBind] 语音播报失败:', error));
}
} catch (error) {
console.warn('[WorkbenchBind] 语音播报异常:', error);
}
},
safeDispatchBroadcast(action, payload) {
try {
const task = this.$store.dispatch(`broadcast/${action}`, payload);
@ -216,6 +229,7 @@
const code = this.normalizeBindCode(scanText);
if (!this.validateBindCode(code)) {
uni.showToast({ title: '扫码内容不是有效绑定码', icon: 'none' });
this.speakText('无记录');
return;
}
this.bindCode = code;
@ -338,6 +352,7 @@
this.confirmBind();
} else {
uni.showToast({ title: '扫码内容不是有效绑定码', icon: 'none' });
this.speakText('无记录');
}
},
fail: (error) => {
@ -357,6 +372,7 @@
const id = Number(workbench.id ?? workbench.workbench_id ?? 0);
if (!this.validateBindCode(code)) {
uni.showToast({ title: '请输入有效的6位绑定码', icon: 'none' });
this.speakText('无记录');
return;
}
if (!id) {
@ -373,14 +389,17 @@
const isSuccess = String(res?.flag || '').toLowerCase() === 'success' || Number(res?.code) === 200 || Number(res?.code) === 1;
if (!isSuccess) {
uni.showToast({ title: res?.message || '绑定失败', icon: 'none' });
this.speakText('绑定失败');
return;
}
uni.showToast({ title: '绑定成功', icon: 'success' });
this.speakText('绑定成功');
this.closeBindPopup();
this.loadWorkbenchList();
} catch (error) {
const msg = String(error?.message || error?.msg || '绑定失败');
uni.showToast({ title: msg, icon: 'none' });
this.speakText('绑定失败');
} finally {
this.binding = false;
this.safeDispatchBroadcast('resume');

View File

@ -168,55 +168,39 @@
</view>
<view class="user-drawer__body">
<!-- 已绑定操作员:姓名 + 绑定状态 + 移除 -->
<template v-if="boundOperator.memberId">
<view class="operator-line">
<text class="operator-line__name">{{ boundOperator.userName || '--' }}</text>
<view class="operator-line__status operator-line__status--bound">
<text class="operator-line__status-text">已绑定</text>
</view>
<view class="operator-line__remove" @click="handleRemoveOperator">
<u-icon name="trash" size="30rpx" color="#f56c6c"></u-icon>
<text class="operator-line__remove-text">移除</text>
</view>
</view>
</template>
<!-- 未绑定:扫码识别工牌 → 绑定 -->
<template v-else>
<view class="scan-section">
<view class="scan-row">
<input
class="scan-input"
v-model="opScanCode"
:focus="opInputFocus"
placeholder="输入/扫描工牌绑定工作台"
placeholder-style="color:#c0c4cc;font-size:34rpx"
@confirm="handleOpInputConfirm"
/>
<view class="camera-btn" @click="handleOpCameraScan">
<u-icon name="scan" size="36rpx" color="#2979ff"></u-icon>
</view>
<view class="scan-section">
<view class="scan-row">
<input
class="scan-input"
v-model="opScanCode"
:focus="opInputFocus"
placeholder="输入/扫描工牌绑定工作台"
placeholder-style="color:#c0c4cc;font-size:34rpx"
@confirm="handleOpInputConfirm"
/>
<view class="camera-btn" @click="handleOpCameraScan">
<u-icon name="scan" size="36rpx" color="#2979ff"></u-icon>
</view>
</view>
</view>
<view v-if="opQueryState === 'loading'" class="query-state query-state--loading">
<u-loading-icon text="识别中..." color="#2979ff"></u-loading-icon>
</view>
<view v-if="opQueryState === 'loading'" class="query-state query-state--loading">
<u-loading-icon text="识别中..." color="#2979ff"></u-loading-icon>
</view>
<view v-else-if="opQueryState === 'identified' && opQueryResult" class="operator-ident-card">
<u-button
text="绑定"
type="primary"
:loading="opBinding"
@click="handleBindOperator"
></u-button>
</view>
<view v-else-if="opQueryState === 'identified' && opQueryResult" class="operator-ident-card">
<u-button
text="绑定"
type="primary"
:loading="opBinding"
@click="handleBindOperator"
></u-button>
</view>
<view v-else-if="opQueryState === 'error'" class="query-state query-state--error">
<text class="query-state__error-text">{{ opQueryError || '识别失败,请重试' }}</text>
</view>
</template>
<view v-else-if="opQueryState === 'error'" class="query-state query-state--error">
<text class="query-state__error-text">{{ opQueryError || '识别失败,请重试' }}</text>
</view>
</view>
</view>
</u-popup>
@ -288,6 +272,28 @@
</view>
</view>
</u-popup>
<!-- 移除操作员二次确认弹窗 -->
<u-popup
:show="removeOperatorPopupOpen"
mode="center"
:closeable="true"
:closeOnClickOverlay="false"
border-radius="20"
:z-index="10095"
@close="handleCloseRemoveOperatorPopup"
>
<view class="remove-operator-popup">
<view class="remove-operator-popup__title">移除操作员</view>
<view class="remove-operator-popup__body">
<text class="remove-operator-popup__text">确认移除操作员「{{ boundOperator.userName || '--' }}」?移除后需重新扫码绑定。</text>
</view>
<view class="remove-operator-popup__actions">
<view class="remove-operator-popup__btn remove-operator-popup__btn--cancel" @click="handleCloseRemoveOperatorPopup">取消</view>
<view class="remove-operator-popup__btn remove-operator-popup__btn--confirm" @click="confirmRemoveOperator">确定</view>
</view>
</view>
</u-popup>
</view>
</template>
@ -341,7 +347,9 @@ export default {
// 取消核实弹窗(团单)
cancelVerifyPopupOpen: false,
// 退出工作台弹窗
exitPopupOpen: false
exitPopupOpen: false,
// 移除操作员二次确认弹窗
removeOperatorPopupOpen: false
}
},
// 团购:全部商品核实完成后自动提交开始打包(每次查询仅自动提交一次)
@ -737,28 +745,30 @@ export default {
this.groupSubmitting = false;
}
},
// 打开操作员弹窗:已绑定态展示操作员信息;未绑定态准备枪扫/输入工牌绑定
// 顶部操作员姓名按钮:已绑定态直接弹移除二次确认;未绑定态打开操作员弹窗准备枪扫/输入工牌绑定
handleUserInfo() {
// 已绑定:简化操作,直接弹移除操作员二次确认弹窗
if (this.boundOperator.memberId) {
this.handleRemoveOperator();
return;
}
// 未绑定:打开操作员弹窗
this.userDrawerOpen = true;
// 确保广播监听(从其它页面返回时可能已 pause),未绑定时扫码即识别绑定
this.safeDispatchBroadcast('setCallbacks', {
onResult: this.handleBroadcastResult
});
this.safeDispatchBroadcast('resume');
if (!this.boundOperator.memberId) {
// 重置识别待绑定态并聚焦输入框,便于扫码枪/键盘输入
this.opScanCode = '';
this.opQueryState = '';
this.opQueryResult = null;
this.opQueryError = '';
this.$nextTick(() => {
setTimeout(() => {
this.opInputFocus = true;
}, 300);
});
} else {
this.opInputFocus = false;
}
// 重置识别待绑定态并聚焦输入框,便于扫码枪/键盘输入
this.opScanCode = '';
this.opQueryState = '';
this.opQueryResult = null;
this.opQueryError = '';
this.$nextTick(() => {
setTimeout(() => {
this.opInputFocus = true;
}, 300);
});
},
// 关闭操作员弹窗
handleCloseUserDrawer() {
@ -1173,11 +1183,12 @@ export default {
name,
wmsAccountId: (rawWmsId === null || rawWmsId === undefined || rawWmsId === '') ? null : Number(rawWmsId)
};
this.opQueryState = 'identified';
// 识别成功直接进入绑定流程(binding 态不展示绑定按钮,避免按钮一闪而过)
this.opQueryState = 'binding';
// 扫描/输入成功且识别到姓名:输入框直接回显姓名
this.opScanCode = name;
this.opInputFocus = false;
// 有效扫描值直接完成绑定,无需手动点击绑定按钮(延迟到识别 loading 关闭后)
// 有效扫描值直接完成绑定(延迟到识别 loading 关闭后,避免与绑定 loading 冲突)
setTimeout(() => {
this.handleBindOperator();
}, 0);
@ -1253,18 +1264,31 @@ export default {
this.speakText('绑定成功');
} catch (error) {
console.error('[packMode] 绑定操作员失败:', error);
uni.showToast({ title: error?.message || '绑定操作员失败', icon: 'none' });
this.speakText('绑定失败');
// 绑定失败:进入待绑定态,保留识别结果,展示「绑定」按钮供手动重试
this.opQueryState = 'identified';
uni.showToast({ title: error?.message || '绑定操作员失败,请点击绑定重试', icon: 'none' });
this.speakText('绑定失败,请点击绑定重试');
} finally {
uni.hideLoading();
this.opBinding = false;
}
},
// 移除操作员(workbench.removeMember):按本地保存的成员行 id 直接移除
// 移除操作员(workbench.removeMember):先弹二次确认,确认后按本地保存的成员行 id 移除
handleRemoveOperator() {
const memberId = String(this.boundOperator?.memberId || '').trim();
if (!memberId) return;
this.doRemoveOperator(memberId);
this.removeOperatorPopupOpen = true;
},
// 关闭移除操作员二次确认弹窗
handleCloseRemoveOperatorPopup() {
this.removeOperatorPopupOpen = false;
},
// 确认移除操作员
async confirmRemoveOperator() {
const memberId = String(this.boundOperator?.memberId || '').trim();
this.removeOperatorPopupOpen = false;
if (!memberId) return;
await this.doRemoveOperator(memberId);
},
// 执行移除成员请求(silent=true 时为退出工作台前的静默解绑:不弹 loading/toast/语音)
async doRemoveOperator(memberId, opts = {}) {
@ -1971,51 +1995,6 @@ export default {
gap: 20rpx;
}
.operator-line {
display: flex;
align-items: center;
}
.operator-line__name {
font-size: 36rpx;
font-weight: 600;
color: #303133;
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.operator-line__status {
flex-shrink: 0;
padding: 6rpx 16rpx;
border-radius: 999rpx;
font-size: 36rpx;
margin-left: 14rpx;
margin-right: 30rpx;
}
.operator-line__status--bound {
background: #e8f8ef;
color: #18b566;
}
.operator-line__remove {
display: flex;
align-items: center;
gap: 6rpx;
flex-shrink: 0;
padding: 10rpx 20rpx;
border-radius: 8rpx;
background: #fef0f0;
}
.operator-line__remove-text {
font-size: 36rpx;
color: #f56c6c;
}
.operator-ident-card {
margin-top: 24rpx;
background: #f0f7ff;
@ -2043,9 +2022,11 @@ export default {
.user-drawer__header {
padding: 48rpx 28rpx 16rpx;
flex-shrink: 0;
text-align: center;
}
.user-drawer__title {
display: block;
font-size: 42rpx;
font-weight: 600;
color: #303133;
@ -2349,4 +2330,64 @@ export default {
background: #f56c6c;
color: #ffffff;
}
.remove-operator-popup {
width: 640rpx;
padding: 40rpx 32rpx 32rpx;
background: #ffffff;
border-radius: 20rpx;
box-sizing: border-box;
}
.remove-operator-popup__title {
font-size: 42rpx;
font-weight: 600;
color: #303133;
text-align: center;
margin-bottom: 32rpx;
}
.remove-operator-popup__body {
margin-bottom: 36rpx;
padding: 24rpx;
background: #f8f9fa;
border-radius: 12rpx;
}
.remove-operator-popup__text {
font-size: 36rpx;
color: #303133;
line-height: 1.6;
}
.remove-operator-popup__actions {
display: flex;
align-items: center;
}
.remove-operator-popup__btn {
flex: 1;
height: 88rpx;
border-radius: 12rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 36rpx;
font-weight: 500;
}
.remove-operator-popup__btn:not(:last-child) {
margin-right: 20rpx;
}
.remove-operator-popup__btn--cancel {
background: #f5f7fa;
color: #606266;
border: 1rpx solid #dcdfe6;
}
.remove-operator-popup__btn--confirm {
background: #f56c6c;
color: #ffffff;
}
</style>

View File

@ -15,6 +15,7 @@
<view class="top-module">
<view class="content-card content-card--detail">
<view class="card-title">{{ currentStrategy.strategyName }}</view>
<view v-if="currentStrategy.disabled" class="strategy-status-row">状态:已停用</view>
<view class="card-row"><text class="label">创建人:</text><text class="value">{{ currentStrategy.creatorName }}</text></view>
<view class="card-row"><text class="label">匹配订单:</text><text class="value">{{ currentStrategy.matchedOrderCountFiltered }}</text></view>
<view class="card-row"><text class="label">SKU区间:</text><text class="value">{{ currentStrategy.orderMinSku }} - {{ currentStrategy.orderMaxSku }}</text></view>
@ -68,7 +69,7 @@
<view v-for="item in strategyList" :key="`strategy-${item.id}`" class="pick-slot">
<view
class="pick-card"
:class="{ 'pick-card--active': currentStrategyId === item.id }"
:class="{ 'pick-card--active': currentStrategyId === item.id, 'pick-card--disabled': item.disabled }"
@click="selectStrategy(item)"
>
<view class="pick-card__top">
@ -76,7 +77,7 @@
<u-notice-bar
:text="item.strategyName || '--'"
mode="horizontal"
bg-color="#19be6b"
:bg-color="item.disabled ? '#c0c4cc' : '#19be6b'"
color="#ffffff"
:volume-icon="false"
:more-icon="false"
@ -87,6 +88,7 @@
></u-notice-bar>
</view>
</view>
<view v-if="item.disabled" class="pick-card__disabled-badge">已停用</view>
<view class="pick-card__main">
<text class="pick-card__num">{{ item.matchedOrderCountFiltered }}</text>
</view>
@ -334,8 +336,12 @@
const expressLimitList = this.normalizeLimitList(source.allowed_expresses);
const provinceLimitList = this.normalizeLimitList(source.allowed_provinces);
const platformLimitList = this.normalizeLimitList(source.allowed_platforms);
const status = Number(source.status);
return {
id: source.id ?? '',
status,
disabled: status === 0,
statusText: status === 0 ? '已停用' : '启用',
strategyName: source.strategy_name || '',
strategyType: source.strategy_type ?? '--',
strategyTypeText: this.normalizeStrategyTypeText(source.strategy_type),
@ -371,6 +377,13 @@
if (!item || typeof item !== 'object') {
return;
}
if (item.disabled) {
uni.showToast({
title: '该策略已停用',
icon: 'none'
});
return;
}
this.currentStrategyId = item.id;
},
handleRefresh() {
@ -384,6 +397,13 @@
});
return;
}
if (this.currentStrategy.disabled) {
uni.showToast({
title: '该策略已停用',
icon: 'none'
});
return;
}
if (this.creatingTask) {
return;
}
@ -432,7 +452,8 @@
const parsedList = this.parseWaveStrategyResponse(response);
parsedList.sort((a, b) => Number(b.matchedOrderCountFiltered) - Number(a.matchedOrderCountFiltered));
this.strategyList = parsedList;
this.currentStrategyId = this.strategyList[0]?.id || '';
const firstEnabled = this.strategyList.find(item => !item.disabled);
this.currentStrategyId = firstEnabled?.id || '';
} catch (error) {
this.currentStrategyId = '';
this.strategyList = [];
@ -582,6 +603,13 @@
margin-bottom: 14rpx;
}
.strategy-status-row {
font-size: 24rpx;
color: #f56c6c;
margin-top: -10rpx;
margin-bottom: 14rpx;
}
.card-row {
display: flex;
align-items: flex-start;
@ -701,6 +729,31 @@
box-shadow: 0 10rpx 24rpx rgba(255, 153, 0, 0.2);
}
.pick-card--disabled {
border-color: #dcdfe6;
background: #f5f7fa;
opacity: 0.72;
}
.pick-card--disabled .pick-card__title-marquee {
background: #c0c4cc;
}
.pick-card--disabled .pick-card__bottom {
background: #c0c4cc;
}
.pick-card__disabled-badge {
align-self: flex-end;
margin: 8rpx 8rpx 0 0;
padding: 0 10rpx;
border-radius: 8rpx;
background: #909399;
color: #ffffff;
font-size: 18rpx;
line-height: 28rpx;
}
.pick-card__top {
display: flex;
justify-content: space-between;

View File

@ -15,6 +15,7 @@
<view class="top-module">
<view class="content-card content-card--detail">
<view class="card-title">{{ currentStrategy.strategyName }}</view>
<view v-if="currentStrategy.disabled" class="strategy-status-row">状态:已停用</view>
<view class="card-row"><text class="label">创建人:</text><text class="value">{{ currentStrategy.creatorName }}</text></view>
<view class="card-row"><text class="label">匹配订单:</text><text class="value">{{ currentStrategy.matchedOrderCountFiltered }}</text></view>
<view class="card-row"><text class="label">SKU区间:</text><text class="value">{{ currentStrategy.orderMinSku }} - {{ currentStrategy.orderMaxSku }}</text></view>
@ -68,25 +69,26 @@
<view v-for="item in strategyList" :key="`strategy-${item.id}`" class="pick-slot">
<view
class="pick-card"
:class="{ 'pick-card--active': currentStrategyId === item.id }"
:class="{ 'pick-card--active': currentStrategyId === item.id, 'pick-card--disabled': item.disabled }"
@click="selectStrategy(item)"
>
<view class="pick-card__top">
<view class="pick-card__title-marquee">
<u-notice-bar
:text="item.strategyName || '--'"
mode="horizontal"
bg-color="#19be6b"
color="#ffffff"
:volume-icon="false"
:more-icon="false"
:speed="60"
:padding="0"
:radius="0"
:autoplay="true"
></u-notice-bar>
</view>
<view class="pick-card__top">
<view class="pick-card__title-marquee">
<u-notice-bar
:text="item.strategyName || '--'"
mode="horizontal"
:bg-color="item.disabled ? '#c0c4cc' : '#19be6b'"
color="#ffffff"
:volume-icon="false"
:more-icon="false"
:speed="60"
:padding="0"
:radius="0"
:autoplay="true"
></u-notice-bar>
</view>
</view>
<view v-if="item.disabled" class="pick-card__disabled-badge">已停用</view>
<view class="pick-card__main">
<text class="pick-card__num">{{ item.matchedOrderCountFiltered }}</text>
</view>
@ -334,8 +336,12 @@
const expressLimitList = this.normalizeLimitList(source.allowed_expresses);
const provinceLimitList = this.normalizeLimitList(source.allowed_provinces);
const platformLimitList = this.normalizeLimitList(source.allowed_platforms);
const status = Number(source.status);
return {
id: source.id ?? '',
status,
disabled: status === 0,
statusText: status === 0 ? '已停用' : '启用',
strategyName: source.strategy_name || '',
strategyType: source.strategy_type ?? '--',
strategyTypeText: this.normalizeStrategyTypeText(source.strategy_type),
@ -371,6 +377,13 @@
if (!item || typeof item !== 'object') {
return;
}
if (item.disabled) {
uni.showToast({
title: '该策略已停用',
icon: 'none'
});
return;
}
this.currentStrategyId = item.id;
},
handleRefresh() {
@ -384,6 +397,13 @@
});
return;
}
if (this.currentStrategy.disabled) {
uni.showToast({
title: '该策略已停用',
icon: 'none'
});
return;
}
if (this.creatingTask) {
return;
}
@ -432,7 +452,8 @@
const parsedList = this.parseWaveStrategyResponse(response);
parsedList.sort((a, b) => Number(b.matchedOrderCountFiltered) - Number(a.matchedOrderCountFiltered));
this.strategyList = parsedList;
this.currentStrategyId = this.strategyList[0]?.id || '';
const firstEnabled = this.strategyList.find(item => !item.disabled);
this.currentStrategyId = firstEnabled?.id || '';
} catch (error) {
this.currentStrategyId = '';
this.strategyList = [];
@ -582,6 +603,13 @@
margin-bottom: 14rpx;
}
.strategy-status-row {
font-size: 24rpx;
color: #f56c6c;
margin-top: -10rpx;
margin-bottom: 14rpx;
}
.card-row {
display: flex;
align-items: flex-start;
@ -701,6 +729,31 @@
box-shadow: 0 10rpx 24rpx rgba(255, 153, 0, 0.2);
}
.pick-card--disabled {
border-color: #dcdfe6;
background: #f5f7fa;
opacity: 0.72;
}
.pick-card--disabled .pick-card__title-marquee {
background: #c0c4cc;
}
.pick-card--disabled .pick-card__bottom {
background: #c0c4cc;
}
.pick-card__disabled-badge {
align-self: flex-end;
margin: 8rpx 8rpx 0 0;
padding: 0 10rpx;
border-radius: 8rpx;
background: #909399;
color: #ffffff;
font-size: 18rpx;
line-height: 28rpx;
}
.pick-card__top {
display: flex;
justify-content: space-between;