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", method: "POST",
isSystemApi: true isSystemApi: true
}, },
wavePickTaskCurrent: {
path: "pick.wavePickTaskCurrent",
auth: true,
method: "POST",
isSystemApi: true
},
wavePickTaskDetail: { wavePickTaskDetail: {
path: "pick.wavePickTaskDetail", path: "pick.wavePickTaskDetail",
auth: true, auth: true,
@ -256,6 +262,12 @@ export default {
auth: true, auth: true,
method: "POST", method: "POST",
isSystemApi: true isSystemApi: true
},
wavePickTaskCancelSelf: {
path: "order.wave.wavePickTaskCancelSelf",
auth: true,
method: "POST",
isSystemApi: true
} }
} }
}, },

View File

@ -3,7 +3,9 @@
<view class="normar_container"> <view class="normar_container">
<page-nav :title="title"> <page-nav :title="title">
<template #right> <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> </template>
</page-nav> </page-nav>
@ -16,8 +18,9 @@
</view> </view>
<view v-else class="content-wrap"> <view v-else class="content-wrap">
<view class="search-card"> <view class="search-filter">
<view class="search-input-wrap"> <view class="search-box">
<view class="search-box-inner">
<u-search <u-search
v-model="keyword" v-model="keyword"
placeholder="请输入商品编码/名称/库位/条码" placeholder="请输入商品编码/名称/库位/条码"
@ -38,6 +41,7 @@
</view> </view>
</view> </view>
</view> </view>
</view>
<view v-if="loadingTaskDetail" class="loading-wrap"> <view v-if="loadingTaskDetail" class="loading-wrap">
<text class="loading-text">任务详情加载中...</text> <text class="loading-text">任务详情加载中...</text>
@ -101,6 +105,7 @@
</template> </template>
</view> </view>
</view> </view>
<u-action-sheet :actions="pickActionList" :show="showActionSheet" @select="handleAction" @close="showActionSheet = false"></u-action-sheet>
</view> </view>
</template> </template>
@ -121,11 +126,14 @@
selectedItemBarcodeLoading: false, selectedItemBarcodeLoading: false,
selectedItemBarcode: '', selectedItemBarcode: '',
itemBarcodeCache: {}, itemBarcodeCache: {},
showActionSheet: false,
taskInfo: { taskInfo: {
taskId: '', taskId: '',
taskNo: '', taskNo: '',
batchNo: '', batchNo: '',
status: 0 status: 0,
creatorId: '',
creatorName: ''
}, },
boxList: [], boxList: [],
pickingSummary: { pickingSummary: {
@ -142,6 +150,42 @@
}; };
}, },
computed: { 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() { modeName() {
return this.pickingView.modeName || '--'; return this.pickingView.modeName || '--';
}, },
@ -196,9 +240,105 @@
if (incomingTaskId !== '') { if (incomingTaskId !== '') {
this.taskId = String(incomingTaskId || '').trim(); this.taskId = String(incomingTaskId || '').trim();
this.requestWavePickTaskDetail(); this.requestWavePickTaskDetail();
return;
} }
this.requestCurrentWavePickTask();
}, },
methods: { 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 = '请求失败') { getApiErrorMessage(error, fallback = '请求失败') {
const message = error?.message || error?.msg || error?.errMsg || error?.data?.message; const message = error?.message || error?.msg || error?.errMsg || error?.data?.message;
return String(message || fallback); return String(message || fallback);
@ -206,17 +346,50 @@
extractTaskDetailPayload(response) { extractTaskDetailPayload(response) {
return response?.data?.data || response?.data || response?.result || 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 = {}) { normalizeTaskDetailPayload(payload = {}) {
const task = payload?.task || {}; const task = payload?.task || {};
const summary = payload?.picking_summary || {}; const summary = payload?.picking_summary || {};
const view = payload?.picking_view || {}; const view = payload?.picking_view || {};
const viewItems = Array.isArray(view?.items) ? view.items : []; 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 = { this.taskInfo = {
taskId: task?.task_id ?? this.taskId, taskId: task?.task_id ?? this.taskId,
taskNo: task?.task_no || '', taskNo: task?.task_no || '',
batchNo: task?.batch_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.boxList = Array.isArray(payload?.boxes) ? payload.boxes : [];
this.pickingSummary = { this.pickingSummary = {
@ -571,70 +744,84 @@
min-height: 0; min-height: 0;
} }
.search-card { .search-filter {
background: #ffffff; background: #ffffff;
padding: 20rpx 24rpx;
border-radius: 12rpx; border-radius: 12rpx;
padding: 20rpx; border: 1rpx solid #f0f0f0;
border: 1rpx solid #ebeef5;
} }
.search-input-wrap { .search-box-inner {
display: flex; position: relative;
align-items: center; }
background: #fff;
border-radius: 26rpx; ::v-deep .search-box-inner .u-search {
padding: 8rpx 12rpx; width: 100%;
border: 1rpx solid #dbe7ff; }
::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 { .search-actions {
position: absolute;
right: 24rpx;
top: 50%;
transform: translateY(-50%);
height: 68rpx;
display: flex; display: flex;
align-items: center; align-items: center;
margin-left: 12rpx;
} }
.scan-btn { .scan-btn {
width: 64rpx; height: 68rpx;
height: 64rpx; padding: 0 8rpx 0 4rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
&:active {
opacity: 0.88;
}
} }
.search-divider { .search-divider {
width: 1rpx; width: 1rpx;
height: 34rpx; height: 28rpx;
background: #e6eaf2; background: #dcdfe6;
margin: 0 16rpx 0 10rpx;
} }
.search-btn { .search-btn {
padding: 0 20rpx; height: 68rpx;
height: 64rpx; padding: 0 8rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
flex-shrink: 0;
&:active {
opacity: 0.88;
}
} }
.search-btn__text { .search-btn__text {
font-size: 32rpx; font-size: 30rpx;
color: #2979ff; color: #2979ff;
font-weight: 600; font-weight: 500;
line-height: 1;
} }
.nav-complete-btn { .nav-right {
height: 52rpx; padding-right: 20rpx;
line-height: 52rpx;
padding: 0 12rpx;
border-radius: 10rpx;
font-size: 22rpx;
text-align: center;
white-space: nowrap;
} }
.nav-complete-btn--disabled { .nav-right--disabled {
background: #f2f3f5; opacity: 0.45;
color: #c0c4cc;
border: 1rpx solid #e4e7ed;
pointer-events: none; pointer-events: none;
} }