feat(order-picking): 完善拣货页任务流程与菜单交互

This commit is contained in:
zm2000 2026-05-11 17:57:30 +08:00
parent c8a3344b7a
commit 32759f820c
2 changed files with 251 additions and 52 deletions

View File

@ -224,6 +224,12 @@ export default {
method: "POST",
isSystemApi: true
},
wavePickTaskCurrent: {
path: "pick.wavePickTaskCurrent",
auth: true,
method: "POST",
isSystemApi: true
},
wavePickTaskDetail: {
path: "pick.wavePickTaskDetail",
auth: true,
@ -256,6 +262,12 @@ export default {
auth: true,
method: "POST",
isSystemApi: true
},
wavePickTaskCancelSelf: {
path: "order.wave.wavePickTaskCancelSelf",
auth: true,
method: "POST",
isSystemApi: true
}
}
},

View File

@ -3,7 +3,9 @@
<view class="normar_container">
<page-nav :title="title">
<template #right>
<view class="nav-complete-btn nav-complete-btn--disabled">完成收货</view>
<view class="nav-right" :class="{ 'nav-right--disabled': !hasActiveTask }">
<u-icon name="more-dot-fill" size="22" @click="openActionSheet"></u-icon>
</view>
</template>
</page-nav>
@ -16,24 +18,26 @@
</view>
<view v-else class="content-wrap">
<view class="search-card">
<view class="search-input-wrap">
<u-search
v-model="keyword"
placeholder="请输入商品编码/名称/库位/条码"
:bg-color="'#f5f5f5'"
shape="round"
:show-action="false"
@search="handleSearch"
@clear="clearSearch"
></u-search>
<view class="search-actions">
<view class="scan-btn" @click="handleCameraScan">
<u-icon name="scan" size="38rpx" color="#2979ff"></u-icon>
</view>
<view class="search-divider"></view>
<view class="search-btn" @click="handleSearch">
<text class="search-btn__text">搜索</text>
<view class="search-filter">
<view class="search-box">
<view class="search-box-inner">
<u-search
v-model="keyword"
placeholder="请输入商品编码/名称/库位/条码"
:bg-color="'#f5f5f5'"
shape="round"
:show-action="false"
@search="handleSearch"
@clear="clearSearch"
></u-search>
<view class="search-actions">
<view class="scan-btn" @click="handleCameraScan">
<u-icon name="scan" size="38rpx" color="#2979ff"></u-icon>
</view>
<view class="search-divider"></view>
<view class="search-btn" @click="handleSearch">
<text class="search-btn__text">搜索</text>
</view>
</view>
</view>
</view>
@ -101,6 +105,7 @@
</template>
</view>
</view>
<u-action-sheet :actions="pickActionList" :show="showActionSheet" @select="handleAction" @close="showActionSheet = false"></u-action-sheet>
</view>
</template>
@ -121,11 +126,14 @@
selectedItemBarcodeLoading: false,
selectedItemBarcode: '',
itemBarcodeCache: {},
showActionSheet: false,
taskInfo: {
taskId: '',
taskNo: '',
batchNo: '',
status: 0
status: 0,
creatorId: '',
creatorName: ''
},
boxList: [],
pickingSummary: {
@ -142,6 +150,42 @@
};
},
computed: {
hasActiveTask() {
const currentTaskId = Number(this.taskInfo?.taskId || this.taskId || 0);
return Number.isFinite(currentTaskId) && currentTaskId > 0;
},
currentLoginUserId() {
return String(
this.$store?.getters?.user?.id ||
this.$store?.getters?.user?.user_id ||
this.$store?.getters?.user?.employees_id ||
this.$store?.getters?.roleId ||
''
).trim();
},
canCancelPickTask() {
const creatorId = String(this.taskInfo?.creatorId || '').trim();
const currentUserId = String(this.currentLoginUserId || '').trim();
if (!creatorId || !currentUserId) {
return true;
}
return creatorId === currentUserId;
},
pickActionList() {
const actions = [
{
name: '完成拣货',
action: 'completePick'
}
];
if (this.canCancelPickTask) {
actions.push({
name: '取消拣货',
action: 'cancelPick'
});
}
return actions;
},
modeName() {
return this.pickingView.modeName || '--';
},
@ -196,9 +240,105 @@
if (incomingTaskId !== '') {
this.taskId = String(incomingTaskId || '').trim();
this.requestWavePickTaskDetail();
return;
}
this.requestCurrentWavePickTask();
},
methods: {
openActionSheet() {
if (!this.hasActiveTask) {
return;
}
this.showActionSheet = true;
},
handleAction(action) {
switch (action?.action) {
case 'completePick':
this.handleCompletePick();
break;
case 'cancelPick':
this.handleCancelPick();
break;
default:
this.showActionSheet = false;
}
},
handleCompletePick() {
this.showActionSheet = false;
uni.showToast({
title: '完成拣货',
icon: 'none'
});
},
handleCancelPick() {
this.showActionSheet = false;
if (!this.canCancelPickTask) {
uni.showToast({
title: '仅任务创建人可取消',
icon: 'none'
});
return;
}
const taskIdNumber = Number(this.taskInfo?.taskId || this.taskId || 0);
if (!taskIdNumber) {
uni.showToast({
title: '缺少任务ID',
icon: 'none'
});
return;
}
uni.showModal({
title: '取消拣货',
content: '确认取消当前拣货任务吗?',
success: async res => {
if (!res?.confirm) {
return;
}
uni.showLoading({
title: '正在取消...'
});
try {
const response = await this.$http('order.wave.wavePickTaskCancelSelf', {
task_id: taskIdNumber
});
const payload = response?.data?.data || response?.data || response || {};
const cancelledCount = Number(payload?.cancelled_count ?? 0);
const taskNo = String(payload?.task_no || this.taskInfo?.taskNo || '').trim();
const successTitle = cancelledCount > 0
? (taskNo ? `已取消:${taskNo}` : '取消成功')
: '取消完成';
uni.showToast({
title: successTitle,
icon: 'none'
});
if (cancelledCount > 0) {
this.taskId = '';
this.taskInfo = {
taskId: '',
taskNo: '',
batchNo: '',
status: 0,
creatorId: '',
creatorName: ''
};
this.pickingView = {
modeCode: '',
modeName: '--',
items: []
};
this.selectedIndex = 0;
}
} catch (error) {
uni.showToast({
title: this.getApiErrorMessage(error, '取消拣货失败'),
icon: 'none'
});
} finally {
uni.hideLoading();
}
}
});
},
getApiErrorMessage(error, fallback = '请求失败') {
const message = error?.message || error?.msg || error?.errMsg || error?.data?.message;
return String(message || fallback);
@ -206,17 +346,50 @@
extractTaskDetailPayload(response) {
return response?.data?.data || response?.data || response?.result || response || {};
},
extractCurrentTaskIdFromResponse(response) {
const payload = response?.data?.data || response?.data || response?.result || response || {};
const candidate = payload?.task_id ?? payload?.taskId ?? payload?.task?.task_id ?? payload?.task?.taskId ?? null;
if (candidate === null || candidate === undefined || candidate === '') {
return null;
}
const taskId = Number(candidate);
return Number.isFinite(taskId) && taskId > 0 ? taskId : null;
},
async requestCurrentWavePickTask() {
try {
const response = await this.$http('pick.wavePickTaskCurrent', {});
const currentTaskId = this.extractCurrentTaskIdFromResponse(response);
if (currentTaskId) {
this.taskId = String(currentTaskId);
this.requestWavePickTaskDetail();
return;
}
uni.showToast({
title: '请扫描面单或拣货单进入拣货流程',
icon: 'none'
});
} catch (error) {
uni.showToast({
title: this.getApiErrorMessage(error, '请扫描面单或拣货单进入拣货流程'),
icon: 'none'
});
}
},
normalizeTaskDetailPayload(payload = {}) {
const task = payload?.task || {};
const summary = payload?.picking_summary || {};
const view = payload?.picking_view || {};
const viewItems = Array.isArray(view?.items) ? view.items : [];
const creatorId = task?.creator_id ?? task?.created_by ?? task?.create_user_id ?? task?.creator_user_id ?? task?.operator_id ?? task?.picker_id ?? task?.creator?.id ?? task?.creator?.user_id ?? '';
const creatorName = task?.creator_name || task?.created_by_name || task?.operator_name || task?.picker_name || task?.creator?.real_name || task?.creator?.name || '';
this.taskInfo = {
taskId: task?.task_id ?? this.taskId,
taskNo: task?.task_no || '',
batchNo: task?.batch_no || '',
status: Number(task?.status || 0)
status: Number(task?.status || 0),
creatorId: String(creatorId || '').trim(),
creatorName: String(creatorName || '').trim()
};
this.boxList = Array.isArray(payload?.boxes) ? payload.boxes : [];
this.pickingSummary = {
@ -571,70 +744,84 @@
min-height: 0;
}
.search-card {
.search-filter {
background: #ffffff;
padding: 20rpx 24rpx;
border-radius: 12rpx;
padding: 20rpx;
border: 1rpx solid #ebeef5;
border: 1rpx solid #f0f0f0;
}
.search-input-wrap {
display: flex;
align-items: center;
background: #fff;
border-radius: 26rpx;
padding: 8rpx 12rpx;
border: 1rpx solid #dbe7ff;
.search-box-inner {
position: relative;
}
::v-deep .search-box-inner .u-search {
width: 100%;
}
::v-deep .search-box-inner .u-search__content {
padding-right: 200rpx;
}
::v-deep .search-box-inner .u-search__content__close {
margin-right: 12rpx;
}
.search-actions {
position: absolute;
right: 24rpx;
top: 50%;
transform: translateY(-50%);
height: 68rpx;
display: flex;
align-items: center;
margin-left: 12rpx;
}
.scan-btn {
width: 64rpx;
height: 64rpx;
height: 68rpx;
padding: 0 8rpx 0 4rpx;
display: flex;
align-items: center;
justify-content: center;
&:active {
opacity: 0.88;
}
}
.search-divider {
width: 1rpx;
height: 34rpx;
background: #e6eaf2;
height: 28rpx;
background: #dcdfe6;
margin: 0 16rpx 0 10rpx;
}
.search-btn {
padding: 0 20rpx;
height: 64rpx;
height: 68rpx;
padding: 0 8rpx;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
&:active {
opacity: 0.88;
}
}
.search-btn__text {
font-size: 32rpx;
font-size: 30rpx;
color: #2979ff;
font-weight: 600;
font-weight: 500;
line-height: 1;
}
.nav-complete-btn {
height: 52rpx;
line-height: 52rpx;
padding: 0 12rpx;
border-radius: 10rpx;
font-size: 22rpx;
text-align: center;
white-space: nowrap;
.nav-right {
padding-right: 20rpx;
}
.nav-complete-btn--disabled {
background: #f2f3f5;
color: #c0c4cc;
border: 1rpx solid #e4e7ed;
.nav-right--disabled {
opacity: 0.45;
pointer-events: none;
}