WMS_PDA/pages/work/order/picking.vue

1287 lines
33 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="order-picking-page">
<view class="normar_container">
<page-nav :title="title">
<template #right>
<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>
<view v-if="!taskId" class="empty-wrap">
<view class="empty-card">
<u-icon name="scan" size="72rpx" color="#2979ff"></u-icon>
<text class="empty-title">开始拣货</text>
<text class="empty-desc">扫描快递单号或波次号开始拣货</text>
</view>
</view>
<view v-else class="content-wrap">
<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>
</view>
<view v-if="loadingTaskDetail" class="loading-wrap">
<text class="loading-text">任务详情加载中...</text>
</view>
<template v-else>
<view class="top-detail-panel">
<view v-if="!selectedPickItem" class="list-empty">暂无拣货数据</view>
<view v-else class="pick-card">
<view class="detail-main">
<view class="detail-main-left">
<view
v-if="getSelectedImageList().length > 1"
class="goods-image-grid"
@click="previewSelectedItemImage"
>
<view
v-for="(img, imgIndex) in getSelectedImageThumbList()"
:key="img + '-' + imgIndex"
class="pick-grid-cell"
>
<u-image
class="pick-grid-image"
:src="img"
mode="aspectFill"
width="58rpx"
height="58rpx"
></u-image>
<view v-if="imgIndex === 3 && getSelectedImageExtraCount() > 0" class="pick-more-mask">
<text class="pick-more-text">+{{ getSelectedImageExtraCount() }}</text>
</view>
</view>
</view>
<u-image
v-else-if="selectedItemImageUrl"
class="goods-image"
:src="selectedItemImageUrl"
width="120rpx"
height="120rpx"
mode="aspectFill"
@click="previewSelectedItemImage"
></u-image>
<view v-else class="pick-image-empty">{{ selectedItemImageLoading ? '图片加载中...' : '暂无商品图片' }}</view>
</view>
<view class="detail-main-right" @click="goProductQueryByCurrentBarcode">
<view class="pick-card__head">
<text class="pick-name">{{ selectedPickItem.itemName || '--' }}</text>
</view>
<view class="pick-row"><text class="pick-label">商品条码:</text><text class="pick-value">{{ selectedItemBarcodeLoading ? '条码加载中...' : (selectedItemBarcode || '--') }}</text></view>
<view class="pick-row"><text class="pick-label">库位:</text><text class="pick-value pick-value--highlight">{{ selectedPickItem.spaceName || '--' }}</text></view>
<view class="pick-row"><text class="pick-label">应拣总数:</text><text class="pick-value">{{ selectedPickItem.totalQty }}</text></view>
</view>
</view>
<view class="alloc-panel">
<view class="pick-row pick-row--top"><text class="pick-label">分配篮号:</text></view>
<scroll-view class="alloc-scroll" scroll-y>
<view class="alloc-wrap" v-if="selectedPickItem.boxAllocations && selectedPickItem.boxAllocations.length">
<view class="alloc-item" v-for="alloc in selectedPickItem.boxAllocations" :key="`${selectedPickItem.itemCode}-${alloc.boxId}`">
<text class="alloc-text">{{ alloc.boxNo }}号篮: {{ alloc.allocatedQty }}</text>
</view>
</view>
<view v-else class="alloc-empty">暂无分配</view>
<view class="alloc-safe-bottom"></view>
</scroll-view>
</view>
</view>
</view>
<scroll-view class="bottom-grid-panel" scroll-y>
<view v-if="filteredPickItems.length === 0" class="list-empty">暂无拣货数据</view>
<view v-else class="index-grid">
<view
v-for="(item, index) in filteredPickItems"
:key="`${item.spaceId}-${item.itemCode}-${index}`"
class="index-cell"
:class="{ 'index-cell--active': selectedIndex === index }"
@click="selectPickItem(index)"
>
<text class="index-text">{{ index + 1 }}</text>
</view>
</view>
<view class="safe-bottom"></view>
</scroll-view>
</template>
</view>
</view>
<u-action-sheet :actions="pickActionList" :show="showActionSheet" @select="handleAction" @close="showActionSheet = false"></u-action-sheet>
</view>
</template>
<script>
export default {
data() {
return {
title: '订单拣货',
taskId: '',
keyword: '',
selectedIndex: 0,
loadingTaskDetail: false,
selectedItemImageLoading: false,
selectedItemImageUrl: '',
selectedItemImageUrls: [],
itemImageCache: {},
itemImageListCache: {},
selectedItemBarcodeLoading: false,
selectedItemBarcode: '',
itemBarcodeCache: {},
showActionSheet: false,
taskInfo: {
taskId: '',
taskNo: '',
batchNo: '',
status: 0,
creatorId: '',
creatorName: ''
},
boxList: [],
pickingSummary: {
totalLines: 0,
totalQty: 0,
distinctSpaces: 0,
distinctItems: 0
},
pickingView: {
modeCode: '',
modeName: '--',
items: []
}
};
},
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 || '--';
},
filteredPickItems() {
const list = Array.isArray(this.pickingView.items) ? this.pickingView.items : [];
const key = String(this.keyword || '').trim().toLowerCase();
if (!key) {
return list;
}
return list.filter(item => {
const fields = [
item.itemCode,
item.itemName,
item.spaceName,
item.spaceBarcode
]
.map(value => String(value || '').toLowerCase());
const allocText = (Array.isArray(item.boxAllocations) ? item.boxAllocations : [])
.map(alloc => `${alloc.boxNo}`)
.join(',')
.toLowerCase();
return fields.some(text => text.includes(key)) || allocText.includes(key);
});
},
selectedPickItem() {
if (!this.filteredPickItems.length) {
return null;
}
return this.filteredPickItems[this.selectedIndex] || this.filteredPickItems[0];
}
},
watch: {
filteredPickItems(newList) {
if (!Array.isArray(newList) || newList.length === 0) {
this.selectedIndex = 0;
return;
}
if (this.selectedIndex > newList.length - 1) {
this.selectedIndex = 0;
}
},
selectedPickItem: {
handler(item) {
this.loadSelectedItemImage(item);
this.loadSelectedItemBarcode(item);
},
immediate: true
}
},
onLoad(options) {
this.$store.dispatch('broadcast/setCallbacks', {
onResult: this.handleBroadcastScan
});
this.$store.dispatch('broadcast/start');
const incomingTaskId = options?.taskId || options?.task_id || '';
if (incomingTaskId !== '') {
this.taskId = String(incomingTaskId || '').trim();
this.requestWavePickTaskDetail();
return;
}
this.requestCurrentWavePickTask();
},
onShow() {
this.$store.dispatch('broadcast/resume');
},
onHide() {
this.$store.dispatch('broadcast/stop');
},
onUnload() {
this.$store.dispatch('broadcast/stop');
},
methods: {
getSelectedImageList() {
if (Array.isArray(this.selectedItemImageUrls) && this.selectedItemImageUrls.length) {
return this.selectedItemImageUrls;
}
if (this.selectedItemImageUrl) {
return [this.selectedItemImageUrl];
}
return [];
},
getSelectedImageThumbList() {
return this.getSelectedImageList().slice(0, 4);
},
getSelectedImageExtraCount() {
const total = this.getSelectedImageList().length;
return total > 4 ? total - 4 : 0;
},
normalizeScanResult(scanResult) {
if (!scanResult) {
return '';
}
if (typeof scanResult === 'string') {
return scanResult.trim();
}
if (typeof scanResult?.result === 'string') {
return scanResult.result.trim();
}
if (typeof scanResult?.data === 'string') {
return scanResult.data.trim();
}
return '';
},
handleScanKeywordEntry(rawKeyword) {
const scanText = this.normalizeScanResult(rawKeyword);
if (!scanText) {
uni.showToast({
title: '未识别到有效条码',
icon: 'none'
});
return;
}
this.keyword = scanText;
if (!this.hasActiveTask) {
this.requestPickTaskByKeyword(scanText);
return;
}
this.handleSearch();
},
handleBroadcastScan(payload) {
const scanText = this.normalizeScanResult(payload);
if (!this.hasActiveTask) {
this.handleScanKeywordEntry(scanText);
}
},
extractTaskIdCandidate(rawValue) {
if (rawValue === null || rawValue === undefined || rawValue === '') {
return null;
}
const taskId = Number(rawValue);
if (!Number.isFinite(taskId) || taskId <= 0) {
return null;
}
return taskId;
},
extractTaskIdFromPickQueryResponse(response) {
const payload = response?.data?.data || response?.data || response?.result || response || {};
const candidates = [
payload?.task_id,
payload?.taskId,
payload?.existing_task_id,
payload?.created_task_id,
payload?.existing?.task_id,
payload?.existing?.taskId,
payload?.created?.task_id,
payload?.created?.taskId,
payload?.task?.task_id,
payload?.task?.taskId
];
for (let i = 0; i < candidates.length; i += 1) {
const resolvedTaskId = this.extractTaskIdCandidate(candidates[i]);
if (resolvedTaskId) {
return resolvedTaskId;
}
}
return null;
},
extractPickTaskConflictInfo(error) {
const responseData = error?.data || error?.response?.data || {};
const payload = responseData?.data || responseData || {};
const message = String(
payload?.message ||
payload?.msg ||
responseData?.message ||
responseData?.msg ||
error?.message ||
''
).trim();
const code = String(payload?.code || responseData?.code || error?.code || '').toLowerCase();
const creatorName = String(
payload?.creator_name ||
payload?.owner_name ||
payload?.task_creator_name ||
payload?.creator?.real_name ||
payload?.creator?.name ||
''
).trim();
const taskId = this.extractTaskIdCandidate(
payload?.task_id ?? payload?.existing_task_id ?? payload?.task?.task_id ?? null
);
const identifyText = `${code} ${message}`.toLowerCase();
const isConflict = identifyText.includes('conflict') || identifyText.includes('owner') || identifyText.includes('创建人') || identifyText.includes('归属') || identifyText.includes('非当前用户') || identifyText.includes('非本人');
return {
isConflict,
creatorName,
taskId,
message
};
},
buildPickTaskConflictMessage(conflictInfo) {
const lines = ['该拣货任务已被其他人员占用'];
if (conflictInfo?.creatorName) {
lines.push(`创建人:${conflictInfo.creatorName}`);
}
if (conflictInfo?.taskId) {
lines.push(`任务ID:${conflictInfo.taskId}`);
}
if (conflictInfo?.message) {
lines.push(conflictInfo.message);
}
return lines.join('\n');
},
async requestPickTaskByKeyword(keyword) {
const normalizedKeyword = String(keyword || '').trim();
if (!normalizedKeyword) {
uni.showToast({
title: '请输入运单号或波次号',
icon: 'none'
});
return;
}
uni.showLoading({
title: '正在查询任务...'
});
try {
const response = await this.$http('pick.query', {
keyword: normalizedKeyword
});
const taskId = this.extractTaskIdFromPickQueryResponse(response);
if (!taskId) {
uni.showToast({
title: '未查询到可拣货任务',
icon: 'none'
});
return;
}
this.taskId = String(taskId);
this.keyword = '';
await this.requestWavePickTaskDetail();
} catch (error) {
const conflictInfo = this.extractPickTaskConflictInfo(error);
if (conflictInfo.isConflict) {
uni.showModal({
title: '任务归属冲突',
content: this.buildPickTaskConflictMessage(conflictInfo),
showCancel: false
});
return;
}
uni.showToast({
title: this.getApiErrorMessage(error, '任务查询失败'),
icon: 'none'
});
} finally {
uni.hideLoading();
}
},
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);
},
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;
}
return;
} 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),
creatorId: String(creatorId || '').trim(),
creatorName: String(creatorName || '').trim()
};
this.boxList = Array.isArray(payload?.boxes) ? payload.boxes : [];
this.pickingSummary = {
totalLines: Number(summary?.total_lines || 0),
totalQty: Number(summary?.total_qty || 0),
distinctSpaces: Number(summary?.distinct_spaces || 0),
distinctItems: Number(summary?.distinct_items || 0)
};
this.pickingView = {
modeCode: view?.mode_code ?? '',
modeName: view?.mode_name || '--',
items: viewItems.map(item => ({
spaceId: item?.space_id ?? '',
spaceName: item?.space_name || item?.location_space?.custom_name || '--',
spaceBarcode: item?.location_space?.custom_barcode || '--',
itemCode: item?.item_code || '--',
itemName: item?.item_name || '--',
stockId: Number(item?.stock_id || item?.item_snapshot?.stock_id || 0),
totalQty: Number(item?.total_qty || 0),
boxAllocations: (Array.isArray(item?.box_allocations) ? item.box_allocations : []).map(alloc => ({
boxId: alloc?.box_id ?? '',
boxNo: alloc?.box_no ?? '--',
allocatedQty: Number(alloc?.allocated_qty || 0)
}))
}))
};
this.selectedIndex = 0;
},
async requestWavePickTaskDetail() {
const taskIdNumber = Number(this.taskId || 0);
if (!taskIdNumber) {
return;
}
this.loadingTaskDetail = true;
try {
const response = await this.$http('pick.wavePickTaskDetail', {
task_id: taskIdNumber
});
const payload = this.extractTaskDetailPayload(response);
this.normalizeTaskDetailPayload(payload);
} catch (error) {
this.pickingView.items = [];
uni.showToast({
title: this.getApiErrorMessage(error, '任务详情获取失败'),
icon: 'none'
});
} finally {
this.loadingTaskDetail = false;
}
},
clearSearch() {
this.keyword = '';
},
getSelectedItemImageKey(item) {
if (!item || typeof item !== 'object') {
return '';
}
return String(item.stockId || item.itemCode || '').trim();
},
extractImageListFromGetImagesResponse(response) {
if (!response || typeof response !== 'object') {
return [];
}
const candidates = [
response.data,
response.data && response.data.data,
response.data && response.data.images,
response.data && response.data.list,
response.data && response.data.rows,
response.data && response.data.records,
response.data && response.data.result,
response.data && response.data.result && response.data.result.images,
response.data && response.data.result && response.data.result.list,
response.images,
response.list,
response.rows,
response.records
];
for (let i = 0; i < candidates.length; i += 1) {
const current = candidates[i];
if (!current) {
continue;
}
if (Array.isArray(current)) {
return current;
}
if (typeof current === 'object') {
const objectCandidates = [current.images, current.list, current.rows, current.records, current.data];
for (let j = 0; j < objectCandidates.length; j += 1) {
if (Array.isArray(objectCandidates[j])) {
return objectCandidates[j];
}
}
}
}
return [];
},
resolveImageUrlFromEntry(entry) {
if (!entry) {
return '';
}
if (typeof entry === 'string') {
return entry;
}
if (typeof entry !== 'object') {
return '';
}
return String(
entry.url ||
entry.path ||
entry.fileUrl ||
entry.file_url ||
(entry.file && (entry.file.file_url || entry.file.fileUrl)) ||
entry.image_url ||
entry.img_url ||
entry.src ||
''
).trim();
},
async loadSelectedItemImage(item) {
if (!item) {
this.selectedItemImageUrl = '';
this.selectedItemImageUrls = [];
this.selectedItemImageLoading = false;
return;
}
const imageKey = this.getSelectedItemImageKey(item);
if (!imageKey) {
this.selectedItemImageUrl = '';
this.selectedItemImageUrls = [];
this.selectedItemImageLoading = false;
return;
}
if (Object.prototype.hasOwnProperty.call(this.itemImageCache, imageKey)) {
this.selectedItemImageUrl = this.itemImageCache[imageKey] || '';
this.selectedItemImageUrls = Array.isArray(this.itemImageListCache[imageKey]) ? this.itemImageListCache[imageKey] : [];
this.selectedItemImageLoading = false;
return;
}
this.selectedItemImageLoading = true;
this.selectedItemImageUrl = '';
this.selectedItemImageUrls = [];
try {
const stockId = Number(item.stockId || 0);
const response = await this.$http('common.getImages', {
id: stockId,
business_id: stockId,
stock_id: stockId,
type: 'stock',
business_type: 'stock'
});
const list = this.extractImageListFromGetImagesResponse(response);
const urls = list.map(entry => this.resolveImageUrlFromEntry(entry)).filter(Boolean);
const firstUrl = urls[0] || '';
this.$set(this.itemImageCache, imageKey, firstUrl || '');
this.$set(this.itemImageListCache, imageKey, urls);
if (this.getSelectedItemImageKey(this.selectedPickItem) === imageKey) {
this.selectedItemImageUrl = firstUrl || '';
this.selectedItemImageUrls = urls;
}
} catch (error) {
this.$set(this.itemImageCache, imageKey, '');
this.$set(this.itemImageListCache, imageKey, []);
if (this.getSelectedItemImageKey(this.selectedPickItem) === imageKey) {
this.selectedItemImageUrl = '';
this.selectedItemImageUrls = [];
}
} finally {
if (this.getSelectedItemImageKey(this.selectedPickItem) === imageKey) {
this.selectedItemImageLoading = false;
}
}
},
getSelectedItemBarcodeKey(item) {
if (!item || typeof item !== 'object') {
return '';
}
return String(item.stockId || '').trim();
},
extractBarcodeListFromResponse(response) {
const candidates = [
response?.data,
response?.data?.data,
response?.list,
response
];
for (let i = 0; i < candidates.length; i += 1) {
if (Array.isArray(candidates[i])) {
return candidates[i];
}
}
return [];
},
resolveBarcodeFromEntry(entry) {
if (!entry) {
return '';
}
if (typeof entry === 'string') {
return entry.trim();
}
if (typeof entry !== 'object') {
return '';
}
return String(entry.barcode || entry.code || '').trim();
},
async loadSelectedItemBarcode(item) {
if (!item) {
this.selectedItemBarcode = '';
this.selectedItemBarcodeLoading = false;
return;
}
const barcodeKey = this.getSelectedItemBarcodeKey(item);
if (!barcodeKey) {
this.selectedItemBarcode = '';
this.selectedItemBarcodeLoading = false;
return;
}
if (Object.prototype.hasOwnProperty.call(this.itemBarcodeCache, barcodeKey)) {
this.selectedItemBarcode = this.itemBarcodeCache[barcodeKey] || '';
this.selectedItemBarcodeLoading = false;
return;
}
this.selectedItemBarcodeLoading = true;
this.selectedItemBarcode = '';
try {
const stockId = Number(item.stockId || 0);
const response = await this.$http('stock.warehouse.getBarcodes', {
id: stockId
});
const list = this.extractBarcodeListFromResponse(response);
const firstBarcode = this.resolveBarcodeFromEntry(list[0]);
this.$set(this.itemBarcodeCache, barcodeKey, firstBarcode || '');
if (this.getSelectedItemBarcodeKey(this.selectedPickItem) === barcodeKey) {
this.selectedItemBarcode = firstBarcode || '';
}
} catch (error) {
this.$set(this.itemBarcodeCache, barcodeKey, '');
if (this.getSelectedItemBarcodeKey(this.selectedPickItem) === barcodeKey) {
this.selectedItemBarcode = '';
}
} finally {
if (this.getSelectedItemBarcodeKey(this.selectedPickItem) === barcodeKey) {
this.selectedItemBarcodeLoading = false;
}
}
},
handleSearch() {
const normalizedKeyword = String(this.keyword || '').trim();
this.keyword = normalizedKeyword;
if (!this.hasActiveTask) {
this.requestPickTaskByKeyword(normalizedKeyword);
}
},
selectPickItem(index) {
this.selectedIndex = Number(index || 0);
},
previewSelectedItemImage() {
const urls = Array.isArray(this.selectedItemImageUrls) && this.selectedItemImageUrls.length
? this.selectedItemImageUrls
: (this.selectedItemImageUrl ? [this.selectedItemImageUrl] : []);
if (!urls.length) {
return;
}
const currentIndex = this.selectedItemImageUrl ? Math.max(urls.indexOf(this.selectedItemImageUrl), 0) : 0;
this.$tools.previewImage(urls, currentIndex);
},
goProductQueryByCurrentBarcode() {
if (this.selectedItemBarcodeLoading) {
uni.showToast({
title: '条码加载中,请稍后',
icon: 'none'
});
return;
}
const barcode = String(this.selectedItemBarcode || '').trim();
if (!barcode) {
uni.showToast({
title: '当前商品暂无条码',
icon: 'none'
});
return;
}
uni.navigateTo({
url: `/pages/work/product/query?keyword=${encodeURIComponent(barcode)}`
});
},
handleCameraScan() {
uni.scanCode({
onlyFromCamera: true,
scanType: ['barCode', 'qrCode'],
success: res => {
this.handleScanKeywordEntry(res);
},
fail: () => {
uni.showToast({
title: '扫码失败,请重试',
icon: 'none'
});
}
});
}
}
};
</script>
<style lang="scss" scoped>
.order-picking-page {
min-height: 100vh;
background: #f8f9fa;
}
::v-deep .normar_container {
min-height: 100vh;
display: flex;
flex-direction: column;
}
.empty-wrap {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
padding: 24rpx;
box-sizing: border-box;
}
.empty-card {
width: 100%;
max-width: 620rpx;
background: #ffffff;
border-radius: 16rpx;
border: 1rpx solid #e8eefc;
padding: 48rpx 24rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 14rpx;
}
.empty-title {
font-size: 36rpx;
line-height: 1.2;
color: #303133;
font-weight: 600;
}
.empty-desc {
font-size: 30rpx;
line-height: 1.4;
color: #606266;
text-align: center;
}
.content-wrap {
flex: 1;
padding: 24rpx;
box-sizing: border-box;
display: flex;
flex-direction: column;
gap: 16rpx;
min-height: 0;
}
.top-detail-panel {
flex: 1;
min-height: 0;
}
.search-filter {
background: #ffffff;
padding: 20rpx 24rpx;
border-radius: 12rpx;
border: 1rpx solid #f0f0f0;
}
.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;
}
.scan-btn {
height: 68rpx;
padding: 0 8rpx 0 4rpx;
display: flex;
align-items: center;
justify-content: center;
&:active {
opacity: 0.88;
}
}
.search-divider {
width: 1rpx;
height: 28rpx;
background: #dcdfe6;
margin: 0 16rpx 0 10rpx;
}
.search-btn {
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: 30rpx;
color: #2979ff;
font-weight: 500;
line-height: 1;
}
.nav-right {
padding-right: 20rpx;
}
.nav-right--disabled {
opacity: 0.45;
pointer-events: none;
}
.loading-wrap {
background: #ffffff;
border-radius: 12rpx;
padding: 24rpx;
border: 1rpx solid #ebeef5;
}
.loading-text {
font-size: 30rpx;
color: #606266;
}
.bottom-grid-panel {
flex: 0 0 300rpx;
height: 300rpx;
background: #ffffff;
border-radius: 12rpx;
padding: 12rpx;
border: 1rpx solid #ebeef5;
}
.list-empty {
background: #ffffff;
border-radius: 12rpx;
padding: 28rpx;
border: 1rpx solid #ebeef5;
font-size: 30rpx;
color: #909399;
}
.pick-card {
background: #ffffff;
border-radius: 12rpx;
padding: 20rpx;
border: 1rpx solid #ebeef5;
height: 100%;
display: flex;
flex-direction: column;
box-sizing: border-box;
}
.pick-card__head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12rpx;
}
.pick-name {
font-size: 32rpx;
color: #303133;
font-weight: 600;
flex: 1;
}
.pick-row {
display: flex;
align-items: center;
font-size: 28rpx;
line-height: 44rpx;
margin-top: 6rpx;
}
.detail-main {
display: flex;
align-items: flex-start;
gap: 16rpx;
}
.detail-main-left {
width: 120rpx;
min-width: 120rpx;
}
.goods-image {
border-radius: 10rpx;
overflow: hidden;
background: #f5f7fa;
}
.goods-image-grid {
width: 120rpx;
height: 120rpx;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-content: space-between;
}
.pick-grid-cell {
position: relative;
width: 58rpx;
height: 58rpx;
border-radius: 8rpx;
overflow: hidden;
background: #f5f7fa;
}
.pick-grid-image {
border-radius: 8rpx;
overflow: hidden;
}
.pick-more-mask {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.45);
display: flex;
align-items: center;
justify-content: center;
}
.pick-more-text {
font-size: 22rpx;
color: #fff;
font-weight: 600;
}
.detail-main-right {
flex: 1;
min-width: 0;
cursor: pointer;
}
.pick-image-empty {
width: 120rpx;
height: 120rpx;
border-radius: 10rpx;
border: 1rpx dashed #dcdfe6;
color: #909399;
font-size: 22rpx;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
padding: 6rpx;
box-sizing: border-box;
}
.pick-row--top {
margin-top: 10rpx;
}
.alloc-panel {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
}
.alloc-scroll {
flex: 1;
min-height: 0;
}
.pick-label {
width: 150rpx;
min-width: 150rpx;
color: #909399;
}
.pick-value {
color: #303133;
}
.pick-value--highlight {
color: #2979ff;
font-weight: 700;
}
.index-grid {
display: flex;
flex-wrap: wrap;
gap: 8rpx;
}
.alloc-wrap {
display: flex;
flex-wrap: wrap;
gap: 8rpx;
margin-top: 8rpx;
}
.alloc-item {
padding: 6rpx 12rpx;
border-radius: 999rpx;
background: #f2f7ff;
}
.alloc-text {
font-size: 24rpx;
color: #2979ff;
}
.alloc-empty {
font-size: 26rpx;
color: #909399;
margin-top: 8rpx;
}
.alloc-safe-bottom {
height: 8rpx;
}
.index-cell {
flex: 0 0 calc((100% - 32rpx) / 5);
width: calc((100% - 32rpx) / 5);
aspect-ratio: 1 / 1;
box-sizing: border-box;
border-radius: 12rpx;
background: #f5f7fa;
border: 1rpx solid #e4e7ed;
display: flex;
align-items: center;
justify-content: center;
}
.index-cell--active {
background: #eaf2ff;
border-color: #2979ff;
}
.index-text {
font-size: 34rpx;
font-weight: 600;
color: #2979ff;
}
.safe-bottom {
height: calc(20rpx + env(safe-area-inset-bottom));
}
</style>