feat: 优化商品查询与收货任务流程
This commit is contained in:
parent
dcd8ae4f68
commit
154b2d7b2a
@ -40,6 +40,12 @@ export default {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
isSystemApi: true
|
isSystemApi: true
|
||||||
},
|
},
|
||||||
|
recognizeLicensePlate: {
|
||||||
|
path: "index.recognizeLicensePlate",
|
||||||
|
auth: true,
|
||||||
|
method: "POST",
|
||||||
|
isSystemApi: true
|
||||||
|
},
|
||||||
listTemplatesByType: {
|
listTemplatesByType: {
|
||||||
path: "setting.printTemplate.listTemplatesByType",
|
path: "setting.printTemplate.listTemplatesByType",
|
||||||
auth: true,
|
auth: true,
|
||||||
@ -94,6 +100,12 @@ export default {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
isSystemApi: true
|
isSystemApi: true
|
||||||
},
|
},
|
||||||
|
bindStore: {
|
||||||
|
path: "storage.receiving.bindStore",
|
||||||
|
auth: true,
|
||||||
|
method: "POST",
|
||||||
|
isSystemApi: true
|
||||||
|
},
|
||||||
addDetail: {
|
addDetail: {
|
||||||
path: "storage.receiving.addDetail",
|
path: "storage.receiving.addDetail",
|
||||||
auth: true,
|
auth: true,
|
||||||
|
|||||||
@ -2,9 +2,8 @@
|
|||||||
<view class="goods-detail-page">
|
<view class="goods-detail-page">
|
||||||
<view class="normar_container">
|
<view class="normar_container">
|
||||||
<page-nav :title="title"></page-nav>
|
<page-nav :title="title"></page-nav>
|
||||||
|
<view v-if="item" class="detail-fixed-header">
|
||||||
<scroll-view class="detail-content" scroll-y>
|
<view class="detail-card detail-card--header">
|
||||||
<view class="detail-card" v-if="item">
|
|
||||||
<view class="detail-header">
|
<view class="detail-header">
|
||||||
<view class="item-title-row">
|
<view class="item-title-row">
|
||||||
<text class="goods-name">{{ item.item_name || item.product_name || item.name || '未命名商品' }}</text>
|
<text class="goods-name">{{ item.item_name || item.product_name || item.name || '未命名商品' }}</text>
|
||||||
@ -16,8 +15,8 @@
|
|||||||
class="goods-image"
|
class="goods-image"
|
||||||
:src="getImageUrl(item)"
|
:src="getImageUrl(item)"
|
||||||
mode="aspectFill"
|
mode="aspectFill"
|
||||||
width="90rpx"
|
width="140rpx"
|
||||||
height="90rpx"
|
height="140rpx"
|
||||||
>
|
>
|
||||||
<template #error>
|
<template #error>
|
||||||
<view class="image-placeholder">
|
<view class="image-placeholder">
|
||||||
@ -35,8 +34,8 @@
|
|||||||
class="grid-image"
|
class="grid-image"
|
||||||
:src="img"
|
:src="img"
|
||||||
mode="aspectFill"
|
mode="aspectFill"
|
||||||
width="44rpx"
|
width="68rpx"
|
||||||
height="44rpx"
|
height="68rpx"
|
||||||
>
|
>
|
||||||
<template #error>
|
<template #error>
|
||||||
<view class="image-placeholder image-placeholder-small">
|
<view class="image-placeholder image-placeholder-small">
|
||||||
@ -62,7 +61,12 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view v-if="item" class="detail-fixed-placeholder"></view>
|
||||||
|
|
||||||
|
<scroll-view class="detail-content" scroll-y>
|
||||||
|
<view class="detail-card detail-card--body" v-if="item">
|
||||||
<view class="info-section">
|
<view class="info-section">
|
||||||
<view class="info-row">
|
<view class="info-row">
|
||||||
<text class="label">名称:</text>
|
<text class="label">名称:</text>
|
||||||
@ -292,9 +296,28 @@ export default {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.detail-fixed-header {
|
||||||
|
flex-shrink: 0;
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: calc(var(--status-bar-height) + 110rpx);
|
||||||
|
z-index: 30;
|
||||||
|
background: #f7f8fa;
|
||||||
|
padding: 0 20rpx 0;
|
||||||
|
box-shadow: 0 2rpx 10rpx rgba(15, 23, 42, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-fixed-placeholder {
|
||||||
|
flex-shrink: 0;
|
||||||
|
height: 290rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.detail-content {
|
.detail-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
|
position: relative;
|
||||||
|
z-index: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail-card {
|
.detail-card {
|
||||||
@ -304,6 +327,16 @@ export default {
|
|||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.detail-card--header {
|
||||||
|
margin: 0;
|
||||||
|
padding: 20rpx;
|
||||||
|
border-radius: 0 0 12rpx 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-card--body {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.detail-header {
|
.detail-header {
|
||||||
padding-bottom: 18rpx;
|
padding-bottom: 18rpx;
|
||||||
border-bottom: 2rpx solid #e5e7eb;
|
border-bottom: 2rpx solid #e5e7eb;
|
||||||
@ -318,7 +351,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.goods-name {
|
.goods-name {
|
||||||
font-size: 30rpx;
|
font-size: 42rpx;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #303133;
|
color: #303133;
|
||||||
}
|
}
|
||||||
@ -329,7 +362,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.item-thumb {
|
.item-thumb {
|
||||||
width: 90rpx;
|
width: 140rpx;
|
||||||
margin-right: 20rpx;
|
margin-right: 20rpx;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
@ -341,8 +374,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.goods-image-grid {
|
.goods-image-grid {
|
||||||
width: 90rpx;
|
width: 140rpx;
|
||||||
height: 90rpx;
|
height: 140rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@ -351,8 +384,8 @@ export default {
|
|||||||
|
|
||||||
.grid-cell {
|
.grid-cell {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 44rpx;
|
width: 68rpx;
|
||||||
height: 44rpx;
|
height: 68rpx;
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: #f5f7fa;
|
background: #f5f7fa;
|
||||||
@ -364,8 +397,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.image-placeholder {
|
.image-placeholder {
|
||||||
width: 90rpx;
|
width: 140rpx;
|
||||||
height: 90rpx;
|
height: 140rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@ -373,8 +406,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.image-placeholder-small {
|
.image-placeholder-small {
|
||||||
width: 44rpx;
|
width: 68rpx;
|
||||||
height: 44rpx;
|
height: 68rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.more-mask {
|
.more-mask {
|
||||||
@ -390,7 +423,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.more-text {
|
.more-text {
|
||||||
font-size: 18rpx;
|
font-size: 22rpx;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
@ -414,7 +447,7 @@ export default {
|
|||||||
.compact-label {
|
.compact-label {
|
||||||
width: auto;
|
width: auto;
|
||||||
margin-right: 6rpx;
|
margin-right: 6rpx;
|
||||||
font-size: 24rpx;
|
font-size: 35rpx;
|
||||||
color: #909399;
|
color: #909399;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
@ -422,7 +455,7 @@ export default {
|
|||||||
|
|
||||||
.compact-value {
|
.compact-value {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
font-size: 24rpx;
|
font-size: 35rpx;
|
||||||
color: #000;
|
color: #000;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@ -443,14 +476,14 @@ export default {
|
|||||||
.label {
|
.label {
|
||||||
width: auto;
|
width: auto;
|
||||||
margin-right: 6rpx;
|
margin-right: 6rpx;
|
||||||
font-size: 24rpx;
|
font-size: 35rpx;
|
||||||
color: #909399;
|
color: #909399;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.value {
|
.value {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
font-size: 24rpx;
|
font-size: 35rpx;
|
||||||
color: #000;
|
color: #000;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
@ -1,26 +1,47 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="goods-query-page">
|
<view class="goods-query-page">
|
||||||
<view class="normar_container">
|
<view class="normar_container">
|
||||||
<page-nav :title="title"></page-nav>
|
<view class="page-header">
|
||||||
|
<page-nav :title="title">
|
||||||
<view class="search-panel">
|
<template #right>
|
||||||
<view class="search-input-wrap">
|
<view class="nav-mode-switch-group">
|
||||||
<u-search
|
<view
|
||||||
v-model="keyword"
|
class="nav-mode-switch-btn"
|
||||||
placeholder="请输入商品条码或名称"
|
:class="{ 'nav-mode-switch-btn--active': queryMode === 'batch' }"
|
||||||
:bg-color="'#f5f5f5'"
|
@click="setQueryMode('batch')"
|
||||||
shape="round"
|
>
|
||||||
:show-action="false"
|
<text class="nav-mode-switch-btn__text">批次</text>
|
||||||
@search="handleSearch"
|
</view>
|
||||||
@clear="handleSearch"
|
<view
|
||||||
></u-search>
|
class="nav-mode-switch-btn"
|
||||||
<view class="search-actions">
|
:class="{ 'nav-mode-switch-btn--active': queryMode === 'nonBatch' }"
|
||||||
<view class="scan-btn" @click="handleCameraScan">
|
@click="setQueryMode('nonBatch')"
|
||||||
<u-icon name="scan" size="38rpx" color="#2979ff"></u-icon>
|
>
|
||||||
|
<text class="nav-mode-switch-btn__text">非批次</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="search-divider"></view>
|
</template>
|
||||||
<view class="search-btn" @click="handleSearch">
|
</page-nav>
|
||||||
<text class="search-btn__text">搜索</text>
|
|
||||||
|
<view class="search-panel">
|
||||||
|
<view class="search-input-wrap">
|
||||||
|
<u-search
|
||||||
|
v-model="keyword"
|
||||||
|
placeholder="请输入商品条码或名称"
|
||||||
|
:bg-color="'#f5f5f5'"
|
||||||
|
shape="round"
|
||||||
|
:show-action="false"
|
||||||
|
@search="handleSearch"
|
||||||
|
@clear="handleSearch"
|
||||||
|
></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>
|
</view>
|
||||||
@ -45,8 +66,8 @@
|
|||||||
class="goods-image"
|
class="goods-image"
|
||||||
:src="getImageUrl(item)"
|
:src="getImageUrl(item)"
|
||||||
mode="aspectFill"
|
mode="aspectFill"
|
||||||
width="90rpx"
|
width="140rpx"
|
||||||
height="90rpx"
|
height="140rpx"
|
||||||
>
|
>
|
||||||
<template #error>
|
<template #error>
|
||||||
<view class="image-placeholder">
|
<view class="image-placeholder">
|
||||||
@ -67,8 +88,8 @@
|
|||||||
class="grid-image"
|
class="grid-image"
|
||||||
:src="img"
|
:src="img"
|
||||||
mode="aspectFill"
|
mode="aspectFill"
|
||||||
width="44rpx"
|
width="68rpx"
|
||||||
height="44rpx"
|
height="68rpx"
|
||||||
>
|
>
|
||||||
<template #error>
|
<template #error>
|
||||||
<view class="image-placeholder image-placeholder-small">
|
<view class="image-placeholder image-placeholder-small">
|
||||||
@ -99,11 +120,57 @@
|
|||||||
<text class="label">SKU规格:</text>
|
<text class="label">SKU规格:</text>
|
||||||
<text class="value">{{ item.sku_property || '--' }}</text>
|
<text class="value">{{ item.sku_property || '--' }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view v-if="hasBatchNumber(item)" class="item-row">
|
||||||
|
<text class="label">批次号:</text>
|
||||||
|
<text class="value">{{ getBatchNumberText(item) }}</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="item-arrow" @click.stop="goProductDetail(item)">
|
<view class="item-arrow" @click.stop="goProductDetail(item)">
|
||||||
<u-icon name="arrow-right" size="18" color="#c0c4cc" :custom-style="{ pointerEvents: 'none' }"></u-icon>
|
<u-icon name="arrow-right" size="18" color="#c0c4cc" :custom-style="{ pointerEvents: 'none' }"></u-icon>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view v-if="queryMode === 'nonBatch' && getStorageList(item).length" class="storage-section">
|
||||||
|
<scroll-view class="storage-scroll" scroll-x>
|
||||||
|
<view class="storage-table storage-table--non-batch">
|
||||||
|
<view class="storage-table__head storage-table__row">
|
||||||
|
<text class="storage-col storage-col--space">库位</text>
|
||||||
|
<text class="storage-col storage-col--qty">库存</text>
|
||||||
|
<text class="storage-col storage-col--qty">可移库存</text>
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
v-for="(storageItem, storageIndex) in getStorageList(item)"
|
||||||
|
:key="getStorageItemKey(storageItem, storageIndex)"
|
||||||
|
class="storage-table__row"
|
||||||
|
>
|
||||||
|
<text class="storage-col storage-col--space">{{ getStorageSpaceText(storageItem) }}</text>
|
||||||
|
<text class="storage-col storage-col--qty">{{ getStorageQuantityText(storageItem) }}</text>
|
||||||
|
<text class="storage-col storage-col--qty storage-col--highlight">{{ getStorageAvailableText(storageItem) }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
<view v-if="queryMode === 'batch' && getBatchStorageList(item).length" class="storage-section">
|
||||||
|
<scroll-view class="storage-scroll" scroll-x>
|
||||||
|
<view class="storage-table storage-table--batch">
|
||||||
|
<view class="storage-table__head storage-table__row">
|
||||||
|
<text class="storage-col storage-col--batch">批次号</text>
|
||||||
|
<text class="storage-col storage-col--space">库位</text>
|
||||||
|
<text class="storage-col storage-col--qty">库存</text>
|
||||||
|
<text class="storage-col storage-col--qty">可移库存</text>
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
v-for="(storageItem, storageIndex) in getBatchStorageList(item)"
|
||||||
|
:key="getBatchStorageItemKey(item, storageItem, storageIndex)"
|
||||||
|
class="storage-table__row"
|
||||||
|
>
|
||||||
|
<text class="storage-col storage-col--batch">{{ getBatchNumberBySource(storageItem, item) }}</text>
|
||||||
|
<text class="storage-col storage-col--space">{{ getStorageSpaceText(storageItem) }}</text>
|
||||||
|
<text class="storage-col storage-col--qty">{{ getStorageQuantityText(storageItem) }}</text>
|
||||||
|
<text class="storage-col storage-col--qty storage-col--highlight">{{ getStorageAvailableText(storageItem) }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@ -123,8 +190,10 @@
|
|||||||
return {
|
return {
|
||||||
title: '商品查询',
|
title: '商品查询',
|
||||||
keyword: '',
|
keyword: '',
|
||||||
|
queryMode: 'nonBatch',
|
||||||
loading: false,
|
loading: false,
|
||||||
list: [],
|
list: [],
|
||||||
|
rawList: [],
|
||||||
restoreScrollTop: 0,
|
restoreScrollTop: 0,
|
||||||
listScrollTopCache: 0
|
listScrollTopCache: 0
|
||||||
}
|
}
|
||||||
@ -363,6 +432,55 @@
|
|||||||
|
|
||||||
return String(item.item_name || item.product_name || item.name || '').trim();
|
return String(item.item_name || item.product_name || item.name || '').trim();
|
||||||
},
|
},
|
||||||
|
getBatchNumberText(item) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return '--';
|
||||||
|
}
|
||||||
|
|
||||||
|
return item.batch_number || item.batch_no || item.lot_number || item.lot_no || '--';
|
||||||
|
},
|
||||||
|
hasBatchNumber(item) {
|
||||||
|
return this.getBatchNumberText(item) !== '--';
|
||||||
|
},
|
||||||
|
applyQueryModeFilter(list) {
|
||||||
|
if (!Array.isArray(list) || !list.length) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.queryMode === 'batch') {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
return list.filter(item => !this.hasBatchNumber(item));
|
||||||
|
},
|
||||||
|
updateDisplayListByMode(sourceList, keyword, isBarcodeKeyword) {
|
||||||
|
const filteredByKeyword = isBarcodeKeyword
|
||||||
|
? this.filterByBarcodeExact(sourceList, keyword)
|
||||||
|
: this.filterByNameContains(sourceList, keyword);
|
||||||
|
|
||||||
|
this.list = this.applyQueryModeFilter(filteredByKeyword);
|
||||||
|
},
|
||||||
|
buildQueryParams(keyword) {
|
||||||
|
return {
|
||||||
|
keyword,
|
||||||
|
with_stock: true,
|
||||||
|
is_batch: this.queryMode === 'batch'
|
||||||
|
};
|
||||||
|
},
|
||||||
|
setQueryMode(nextMode) {
|
||||||
|
if (!nextMode || nextMode === this.queryMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.queryMode = nextMode;
|
||||||
|
const keyword = this.normalizeKeyword(this.keyword);
|
||||||
|
if (!keyword) {
|
||||||
|
this.list = this.applyQueryModeFilter(this.rawList);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.handleSearch();
|
||||||
|
},
|
||||||
filterByNameContains(list, keyword) {
|
filterByNameContains(list, keyword) {
|
||||||
const target = String(keyword || '').trim().toLowerCase();
|
const target = String(keyword || '').trim().toLowerCase();
|
||||||
if (!target) {
|
if (!target) {
|
||||||
@ -413,6 +531,101 @@
|
|||||||
getImageThumbList(item) {
|
getImageThumbList(item) {
|
||||||
return this.getImageList(item).slice(0, 4);
|
return this.getImageList(item).slice(0, 4);
|
||||||
},
|
},
|
||||||
|
getStorageList(item) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(item.storage)) {
|
||||||
|
return item.storage.filter(entry => entry && typeof entry === 'object');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(item.wms_storage)) {
|
||||||
|
return item.wms_storage.filter(entry => entry && typeof entry === 'object');
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
getBatchStorageList(item) {
|
||||||
|
const storageList = this.getStorageList(item);
|
||||||
|
if (storageList.length) {
|
||||||
|
return storageList;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item && typeof item === 'object') {
|
||||||
|
return [item];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
getStorageItemKey(item, index) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
return item.id || item.space_id || item.storage_id || item.space_barcode || item.space_name || index;
|
||||||
|
},
|
||||||
|
getBatchStorageItemKey(sourceItem, storageItem, index) {
|
||||||
|
if (!storageItem || typeof storageItem !== 'object') {
|
||||||
|
return this.getStorageItemKey(sourceItem, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return storageItem.id
|
||||||
|
|| storageItem.batch_id
|
||||||
|
|| storageItem.space_id
|
||||||
|
|| `${this.getBatchNumberBySource(storageItem, sourceItem)}_${this.getStorageSpaceText(storageItem)}_${index}`;
|
||||||
|
},
|
||||||
|
getBatchNumberBySource(item, fallbackItem) {
|
||||||
|
const currentBatch = this.getBatchNumberText(item);
|
||||||
|
if (currentBatch !== '--') {
|
||||||
|
return currentBatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getBatchNumberText(fallbackItem);
|
||||||
|
},
|
||||||
|
getStorageSpaceText(item) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return '--';
|
||||||
|
}
|
||||||
|
|
||||||
|
return item.space_code
|
||||||
|
|| item.space?.code
|
||||||
|
|| item.space?.space_code
|
||||||
|
|| item.space?.name
|
||||||
|
|| item.space_name
|
||||||
|
|| item.space_barcode
|
||||||
|
|| item.location_name
|
||||||
|
|| item.position_name
|
||||||
|
|| item.name
|
||||||
|
|| '--';
|
||||||
|
},
|
||||||
|
getStorageQuantityText(item) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return '--';
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getValueOrDash(
|
||||||
|
item.quantity
|
||||||
|
?? item.actual_quantity
|
||||||
|
?? item.stock
|
||||||
|
?? item.total_quantity
|
||||||
|
?? item.qty
|
||||||
|
);
|
||||||
|
},
|
||||||
|
getStorageAvailableText(item) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return '--';
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getValueOrDash(
|
||||||
|
item.available_quantity
|
||||||
|
?? item.movable_quantity
|
||||||
|
?? item.moveable_quantity
|
||||||
|
?? item.can_move_quantity
|
||||||
|
?? item.free_quantity
|
||||||
|
?? item.usable_quantity
|
||||||
|
);
|
||||||
|
},
|
||||||
getExtraImageCount(item) {
|
getExtraImageCount(item) {
|
||||||
const total = this.getImageList(item).length;
|
const total = this.getImageList(item).length;
|
||||||
return total > 4 ? total - 4 : 0;
|
return total > 4 ? total - 4 : 0;
|
||||||
@ -446,28 +659,21 @@
|
|||||||
async handleSearch() {
|
async handleSearch() {
|
||||||
const keyword = this.normalizeKeyword(this.keyword);
|
const keyword = this.normalizeKeyword(this.keyword);
|
||||||
this.keyword = keyword;
|
this.keyword = keyword;
|
||||||
|
console.log('[ProductQuery] 搜索内容:', keyword, '模式:', this.queryMode);
|
||||||
if (!keyword) {
|
if (!keyword) {
|
||||||
|
this.rawList = [];
|
||||||
this.list = [];
|
this.list = [];
|
||||||
|
console.log('[ProductQuery] 搜索内容为空,结果已清空');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isBarcodeKeyword = this.isBarcodeLike(keyword);
|
const isBarcodeKeyword = this.isBarcodeLike(keyword);
|
||||||
const queryParams = {
|
const queryParams = this.buildQueryParams(keyword);
|
||||||
pagination: {
|
console.log('[ProductQuery] 搜索参数:', queryParams);
|
||||||
page: 1,
|
|
||||||
pageSize: 100
|
|
||||||
},
|
|
||||||
keyword
|
|
||||||
};
|
|
||||||
|
|
||||||
if (isBarcodeKeyword) {
|
|
||||||
queryParams.barcode = keyword;
|
|
||||||
queryParams.barcodes = [keyword];
|
|
||||||
}
|
|
||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
try {
|
try {
|
||||||
const res = await this.$http('stock.warehouse.list', queryParams);
|
const res = await this.$http('stock.warehouse.search', queryParams);
|
||||||
|
|
||||||
if (res && res.code === 200) {
|
if (res && res.code === 200) {
|
||||||
const responseData = res.data;
|
const responseData = res.data;
|
||||||
@ -478,20 +684,27 @@
|
|||||||
nextList = responseData.list;
|
nextList = responseData.list;
|
||||||
} else if (responseData && Array.isArray(responseData.rows)) {
|
} else if (responseData && Array.isArray(responseData.rows)) {
|
||||||
nextList = responseData.rows;
|
nextList = responseData.rows;
|
||||||
|
} else if (responseData && Array.isArray(responseData.data)) {
|
||||||
|
nextList = responseData.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.list = isBarcodeKeyword
|
this.rawList = nextList;
|
||||||
? this.filterByBarcodeExact(nextList, keyword)
|
this.updateDisplayListByMode(nextList, keyword, isBarcodeKeyword);
|
||||||
: this.filterByNameContains(nextList, keyword);
|
console.log('[ProductQuery] 搜索结果数量:', this.list.length);
|
||||||
|
console.log('[ProductQuery] 搜索结果列表:', this.list);
|
||||||
} else {
|
} else {
|
||||||
|
this.rawList = [];
|
||||||
this.list = [];
|
this.list = [];
|
||||||
|
console.log('[ProductQuery] 搜索失败响应:', res);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: (res && res.message) || '查询失败',
|
title: (res && res.message) || '查询失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
this.rawList = [];
|
||||||
this.list = [];
|
this.list = [];
|
||||||
|
console.error('[ProductQuery] 搜索异常:', error);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: (error && error.message) || '查询失败',
|
title: (error && error.message) || '查询失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
@ -521,13 +734,72 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.page-header {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 20;
|
||||||
|
background: #fff;
|
||||||
|
flex-shrink: 0;
|
||||||
|
box-shadow: 0 2rpx 10rpx rgba(15, 23, 42, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
.search-panel {
|
.search-panel {
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-bottom: 1rpx solid #f2f2f2;
|
border-bottom: 1rpx solid #f2f2f2;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 2;
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .nav-title .right {
|
||||||
|
width: auto;
|
||||||
|
min-width: 182rpx;
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-mode-switch-group {
|
||||||
|
height: 50rpx;
|
||||||
|
padding: 3rpx;
|
||||||
|
border-radius: 26rpx;
|
||||||
|
background: #edf2ff;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 1rpx solid #dbe7ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-mode-switch-btn {
|
||||||
|
min-width: 76rpx;
|
||||||
|
height: 42rpx;
|
||||||
|
padding: 0 14rpx;
|
||||||
|
border-radius: 21rpx;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
&__text {
|
||||||
|
font-size: 20rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #5f6b7a;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
opacity: 0.88;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-mode-switch-btn--active {
|
||||||
|
background: #2979ff;
|
||||||
|
box-shadow: 0 3rpx 8rpx rgba(41, 121, 255, 0.18);
|
||||||
|
|
||||||
|
.nav-mode-switch-btn__text {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-input-wrap {
|
.search-input-wrap {
|
||||||
@ -599,6 +871,8 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
height: auto;
|
height: auto;
|
||||||
|
position: relative;
|
||||||
|
z-index: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-wrap {
|
.list-wrap {
|
||||||
@ -619,11 +893,11 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
position: relative;
|
position: relative;
|
||||||
padding-right: 20rpx;
|
padding-right: 92rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-thumb {
|
.item-thumb {
|
||||||
width: 90rpx;
|
width: 140rpx;
|
||||||
margin-right: 20rpx;
|
margin-right: 20rpx;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
@ -636,8 +910,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.goods-image-grid {
|
.goods-image-grid {
|
||||||
width: 90rpx;
|
width: 140rpx;
|
||||||
height: 90rpx;
|
height: 140rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@ -646,8 +920,8 @@
|
|||||||
|
|
||||||
.grid-cell {
|
.grid-cell {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 44rpx;
|
width: 68rpx;
|
||||||
height: 44rpx;
|
height: 68rpx;
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: #f5f7fa;
|
background: #f5f7fa;
|
||||||
@ -660,7 +934,7 @@
|
|||||||
|
|
||||||
.image-placeholder {
|
.image-placeholder {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 90rpx;
|
height: 140rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@ -668,7 +942,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.image-placeholder-small {
|
.image-placeholder-small {
|
||||||
height: 44rpx;
|
height: 68rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.more-mask {
|
.more-mask {
|
||||||
@ -696,14 +970,14 @@
|
|||||||
|
|
||||||
.item-arrow {
|
.item-arrow {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: -16rpx;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
transform: translateY(-50%);
|
transform: translateY(-50%);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 44rpx;
|
width: 112rpx;
|
||||||
height: 44rpx;
|
height: 112rpx;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -715,7 +989,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.goods-name {
|
.goods-name {
|
||||||
font-size: 30rpx;
|
font-size: 42rpx;
|
||||||
color: #303133;
|
color: #303133;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@ -734,10 +1008,101 @@
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.storage-section {
|
||||||
|
margin-top: 10rpx;
|
||||||
|
padding-top: 10rpx;
|
||||||
|
border-top: 1rpx solid #eef1f6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storage-scroll {
|
||||||
|
width: 100%;
|
||||||
|
white-space: nowrap;
|
||||||
|
border-radius: 10rpx;
|
||||||
|
border: 1rpx solid #dfe7f5;
|
||||||
|
background: #f8faff;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storage-table {
|
||||||
|
background: #f8faff;
|
||||||
|
overflow: visible;
|
||||||
|
border: 0;
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storage-table--non-batch {
|
||||||
|
min-width: 680rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storage-table--batch {
|
||||||
|
min-width: 860rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storage-table__row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 48rpx;
|
||||||
|
padding: 0 8rpx;
|
||||||
|
border-bottom: 1rpx solid #e8eef7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storage-table__row:last-child {
|
||||||
|
border-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storage-table__head {
|
||||||
|
background: #edf4ff;
|
||||||
|
border-bottom: 1rpx solid #dbe6f7;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 8;
|
||||||
|
box-shadow: 0 2rpx 6rpx rgba(219, 230, 247, 0.65);
|
||||||
|
}
|
||||||
|
|
||||||
|
.storage-col {
|
||||||
|
font-size: 33rpx;
|
||||||
|
color: #606266;
|
||||||
|
line-height: 1.4;
|
||||||
|
padding: 10rpx 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
text-align: center;
|
||||||
|
border-right: 1rpx solid #e8eef7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storage-table__row .storage-col:last-child {
|
||||||
|
border-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storage-col--space {
|
||||||
|
flex: 1.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storage-col--batch {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storage-col--qty {
|
||||||
|
flex: 0.72;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storage-table--batch .storage-col--qty {
|
||||||
|
flex: 0.62;
|
||||||
|
padding-left: 2rpx;
|
||||||
|
padding-right: 2rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storage-col--highlight {
|
||||||
|
color: #2979ff;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
width: auto;
|
width: auto;
|
||||||
margin-right: 6rpx;
|
margin-right: 6rpx;
|
||||||
font-size: 24rpx;
|
font-size: 35rpx;
|
||||||
color: #909399;
|
color: #909399;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
@ -745,7 +1110,7 @@
|
|||||||
|
|
||||||
.value {
|
.value {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
font-size: 24rpx;
|
font-size: 35rpx;
|
||||||
color: #000;
|
color: #000;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
@ -10,7 +10,18 @@
|
|||||||
</u-form-item>
|
</u-form-item>
|
||||||
|
|
||||||
<u-form-item label="货主" prop="store_id">
|
<u-form-item label="货主" prop="store_id">
|
||||||
<view>{{receivingInfo.store?receivingInfo.store.store_remask:'未设置'}}</view>
|
<view
|
||||||
|
v-if="canBindStore"
|
||||||
|
class="store-bind-trigger"
|
||||||
|
@click="showStorePicker = true"
|
||||||
|
>
|
||||||
|
<text class="store-bind-text">{{ pendingStoreName || '请选择货主绑定' }}</text>
|
||||||
|
<view class="store-bind-action">
|
||||||
|
<text class="store-bind-action-text">选择绑定</text>
|
||||||
|
<u-icon name="arrow-right" size="24rpx" color="#2979ff"></u-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view v-else>{{ receivingInfo.store ? receivingInfo.store.store_remask : '未设置' }}</view>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
|
|
||||||
<u-form-item label="来货方式" prop="delivery_method">
|
<u-form-item label="来货方式" prop="delivery_method">
|
||||||
@ -90,6 +101,14 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</u-form>
|
</u-form>
|
||||||
|
<inputAndSelect
|
||||||
|
title="选择货主"
|
||||||
|
:list="storeList"
|
||||||
|
:show="showStorePicker"
|
||||||
|
:value="pendingStoreId"
|
||||||
|
@change="handleStoreChange"
|
||||||
|
@close="showStorePicker = false"
|
||||||
|
></inputAndSelect>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -135,12 +154,23 @@
|
|||||||
label: '不带托盘'
|
label: '不带托盘'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
rules: {}
|
rules: {},
|
||||||
|
showStorePicker: false,
|
||||||
|
storeList: [],
|
||||||
|
pendingStoreId: null,
|
||||||
|
pendingStoreName: '',
|
||||||
|
bindingStore: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
canBindStore() {
|
||||||
|
return !!this.receivingInfo && !!this.receivingInfo.id && !this.receivingInfo.store_id;
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
console.log("onShow");
|
console.log("onShow");
|
||||||
this.qrcode(this.receivingInfo.receiving_number);
|
this.qrcode(this.receivingInfo.receiving_number);
|
||||||
|
this.loadStoreList();
|
||||||
},
|
},
|
||||||
filters: {
|
filters: {
|
||||||
statusFilter(status) {
|
statusFilter(status) {
|
||||||
@ -158,9 +188,90 @@
|
|||||||
console.log(newval);
|
console.log(newval);
|
||||||
this.qrcode(newval)
|
this.qrcode(newval)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'receivingInfo.store_id': {
|
||||||
|
immediate: true,
|
||||||
|
handler(newValue) {
|
||||||
|
if (newValue) {
|
||||||
|
this.pendingStoreId = newValue;
|
||||||
|
this.pendingStoreName = this.receivingInfo.store && this.receivingInfo.store.store_remask ? this.receivingInfo.store.store_remask : '';
|
||||||
|
} else {
|
||||||
|
this.pendingStoreId = null;
|
||||||
|
this.pendingStoreName = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async loadStoreList() {
|
||||||
|
try {
|
||||||
|
const res = await this.$http('common.store', {});
|
||||||
|
this.storeList = Array.isArray(res && res.stores) ? res.stores : [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载货主列表失败:', error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleStoreChange(option) {
|
||||||
|
this.showStorePicker = false;
|
||||||
|
|
||||||
|
if (!option || !option.value) {
|
||||||
|
this.pendingStoreId = null;
|
||||||
|
this.pendingStoreName = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.showModal({
|
||||||
|
title: '货主绑定',
|
||||||
|
content: `是否将当前收货单绑定到货主【${option.label}】?绑定后不可更改。`,
|
||||||
|
success: async ({ confirm }) => {
|
||||||
|
if (!confirm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.bindStore(option);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async bindStore(option) {
|
||||||
|
if (!this.receivingInfo || !this.receivingInfo.id || !option || !option.value || this.bindingStore) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.bindingStore = true;
|
||||||
|
uni.showLoading({
|
||||||
|
title: '绑定中...'
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await this.$http('storage.receiving.bindStore', {
|
||||||
|
id: this.receivingInfo.id,
|
||||||
|
receiving_id: this.receivingInfo.id,
|
||||||
|
store_id: option.value
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res && res.code === 200) {
|
||||||
|
this.pendingStoreId = option.value;
|
||||||
|
this.pendingStoreName = option.label;
|
||||||
|
uni.showToast({
|
||||||
|
title: '绑定成功',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
this.$emit('change');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error((res && res.message) || '绑定失败');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('绑定货主失败:', error);
|
||||||
|
uni.showToast({
|
||||||
|
title: (error && error.message) || '绑定失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
this.bindingStore = false;
|
||||||
|
uni.hideLoading();
|
||||||
|
}
|
||||||
|
},
|
||||||
normalizeUniScanResult(scanResult) {
|
normalizeUniScanResult(scanResult) {
|
||||||
if (!scanResult) {
|
if (!scanResult) {
|
||||||
return '';
|
return '';
|
||||||
@ -303,6 +414,33 @@
|
|||||||
opacity: 0.85;
|
opacity: 0.85;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.store-bind-trigger {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 72rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-bind-text {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-bind-action {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8rpx;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-bind-action-text {
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #2979ff;
|
||||||
|
}
|
||||||
|
|
||||||
.section {
|
.section {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
|
|||||||
@ -10,7 +10,10 @@
|
|||||||
|
|
||||||
<!-- 店铺信息 -->
|
<!-- 店铺信息 -->
|
||||||
<u-form-item label="货主" @click="showStorePicker = true">
|
<u-form-item label="货主" @click="showStorePicker = true">
|
||||||
<u-input v-model="storeName" placeholder="请选择货主" />
|
<view class="store-select-display">
|
||||||
|
<text :class="['store-select-text', !formData.store_id ? 'store-select-placeholder' : '']">{{ storeName || '请选择货主' }}</text>
|
||||||
|
<u-icon name="arrow-right" size="24rpx" color="#c0c4cc"></u-icon>
|
||||||
|
</view>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
|
|
||||||
<!-- 来货方式 -->
|
<!-- 来货方式 -->
|
||||||
@ -23,7 +26,12 @@
|
|||||||
|
|
||||||
<!-- 车牌号(货车时显示) -->
|
<!-- 车牌号(货车时显示) -->
|
||||||
<u-form-item v-if="formData.delivery_method === 'truck'" label="车牌号" prop="license_plate">
|
<u-form-item v-if="formData.delivery_method === 'truck'" label="车牌号" prop="license_plate">
|
||||||
<u-input v-model="formData.license_plate" placeholder="请输入车牌号" maxlength="20" />
|
<view class="tracking-input-wrap">
|
||||||
|
<u-input v-model="formData.license_plate" placeholder="请输入车牌号" maxlength="20" />
|
||||||
|
<view class="scan-camera-btn" @click="handleLicensePlateCapture">
|
||||||
|
<u-icon name="camera" size="34rpx" color="#2979ff"></u-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
|
|
||||||
<!-- 物流单号(非货车时显示) -->
|
<!-- 物流单号(非货车时显示) -->
|
||||||
@ -181,10 +189,221 @@
|
|||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
submitting: false,
|
submitting: false,
|
||||||
|
recognizingPlate: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
getPlatformInfo() {
|
||||||
|
const systemInfo = typeof uni.getSystemInfoSync === 'function' ? uni.getSystemInfoSync() : {};
|
||||||
|
return {
|
||||||
|
platform: systemInfo.platform || 'unknown',
|
||||||
|
uniPlatform: systemInfo.uniPlatform || 'unknown',
|
||||||
|
system: systemInfo.system || '',
|
||||||
|
model: systemInfo.model || '',
|
||||||
|
appVersion: systemInfo.appVersion || ''
|
||||||
|
};
|
||||||
|
},
|
||||||
|
arrayBufferToBase64(buffer) {
|
||||||
|
if (uni.arrayBufferToBase64) {
|
||||||
|
return uni.arrayBufferToBase64(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
let binary = '';
|
||||||
|
const bytes = new Uint8Array(buffer);
|
||||||
|
const length = bytes.byteLength;
|
||||||
|
for (let i = 0; i < length; i += 1) {
|
||||||
|
binary += String.fromCharCode(bytes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof btoa === 'function') {
|
||||||
|
return btoa(binary);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error('当前环境不支持 ArrayBuffer 转 Base64');
|
||||||
|
},
|
||||||
|
readFileBase64ByPlus(filePath) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (typeof plus === 'undefined' || !plus.io || !plus.io.resolveLocalFileSystemURL) {
|
||||||
|
reject(new Error('PLUS 文件系统不可用'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
plus.io.resolveLocalFileSystemURL(filePath, (entry) => {
|
||||||
|
entry.file((file) => {
|
||||||
|
const reader = new plus.io.FileReader();
|
||||||
|
reader.onloadend = (event) => {
|
||||||
|
const result = String(event?.target?.result || event?.result || '');
|
||||||
|
resolve(result.replace(/^data:.*?;base64,/, ''));
|
||||||
|
};
|
||||||
|
reader.onerror = (error) => reject(error);
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
}, reject);
|
||||||
|
}, reject);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
readFileBase64ByRequest(filePath) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.request({
|
||||||
|
url: filePath,
|
||||||
|
method: 'GET',
|
||||||
|
responseType: 'arraybuffer',
|
||||||
|
success: (res) => {
|
||||||
|
try {
|
||||||
|
resolve(this.arrayBufferToBase64(res.data));
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (error) => reject(error)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async getImageBase64(filePath) {
|
||||||
|
const platformInfo = this.getPlatformInfo();
|
||||||
|
console.log('[ReceivingCreate] 图片转Base64平台信息:', platformInfo);
|
||||||
|
console.log('[ReceivingCreate] 图片转Base64文件路径:', filePath);
|
||||||
|
|
||||||
|
const tryByFileSystemManager = () => new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
const fileSystemManager = uni.getFileSystemManager && uni.getFileSystemManager();
|
||||||
|
if (!fileSystemManager || typeof fileSystemManager.readFile !== 'function') {
|
||||||
|
reject(new Error('getFileSystemManager.readFile 不可用'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('[ReceivingCreate] 图片转Base64读取分支: getFileSystemManager.readFile');
|
||||||
|
fileSystemManager.readFile({
|
||||||
|
filePath,
|
||||||
|
encoding: 'base64',
|
||||||
|
success: ({ data }) => resolve(String(data || '')),
|
||||||
|
fail: (error) => reject(error)
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!filePath) {
|
||||||
|
reject(new Error('图片路径无效'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tryByFileSystemManager()
|
||||||
|
.then(resolve)
|
||||||
|
.catch((fileSystemError) => {
|
||||||
|
console.warn('[ReceivingCreate] getFileSystemManager 分支失败:', fileSystemError);
|
||||||
|
console.log('[ReceivingCreate] 图片转Base64读取分支: plus.io.FileReader');
|
||||||
|
this.readFileBase64ByPlus(filePath)
|
||||||
|
.then(resolve)
|
||||||
|
.catch((plusError) => {
|
||||||
|
console.warn('[ReceivingCreate] plus.io.FileReader 分支失败:', plusError);
|
||||||
|
console.log('[ReceivingCreate] 图片转Base64读取分支: uni.request(arraybuffer)');
|
||||||
|
this.readFileBase64ByRequest(filePath)
|
||||||
|
.then(resolve)
|
||||||
|
.catch((requestError) => {
|
||||||
|
console.error('[ReceivingCreate] uni.request(arraybuffer) 分支失败:', requestError);
|
||||||
|
reject(requestError);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
extractLicensePlate(response) {
|
||||||
|
if (!response) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const directFields = [
|
||||||
|
response.license_plate,
|
||||||
|
response.licensePlate,
|
||||||
|
response.plate_number,
|
||||||
|
response.plateNo,
|
||||||
|
response.plate_number_text,
|
||||||
|
response.number
|
||||||
|
];
|
||||||
|
const directMatch = directFields.find(value => typeof value === 'string' && value.trim());
|
||||||
|
if (directMatch) {
|
||||||
|
return directMatch.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = response.data;
|
||||||
|
if (data && typeof data === 'object') {
|
||||||
|
return this.extractLicensePlate(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(data) && data.length) {
|
||||||
|
return this.extractLicensePlate(data[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
async handleLicensePlateCapture() {
|
||||||
|
if (this.recognizingPlate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const chooseResult = await new Promise((resolve, reject) => {
|
||||||
|
uni.chooseImage({
|
||||||
|
count: 1,
|
||||||
|
sourceType: ['camera'],
|
||||||
|
sizeType: ['compressed'],
|
||||||
|
success: resolve,
|
||||||
|
fail: reject
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const filePath = chooseResult?.tempFilePaths?.[0] || chooseResult?.tempFiles?.[0]?.path;
|
||||||
|
if (!filePath) {
|
||||||
|
throw new Error('未获取到拍照文件');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.recognizingPlate = true;
|
||||||
|
uni.showLoading({ title: '识别车牌中', mask: true });
|
||||||
|
|
||||||
|
const imageBase64 = await this.getImageBase64(filePath);
|
||||||
|
if (!imageBase64) {
|
||||||
|
throw new Error('图片转换失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
const recognizeParams = {
|
||||||
|
image_base64: imageBase64
|
||||||
|
};
|
||||||
|
console.log('[ReceivingCreate] 车牌识别请求参数:', {
|
||||||
|
...recognizeParams,
|
||||||
|
image_base64: `${imageBase64.slice(0, 80)}...`,
|
||||||
|
image_base64_length: imageBase64.length
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await this.$http('common.recognizeLicensePlate', recognizeParams, '', false);
|
||||||
|
console.log('[ReceivingCreate] 车牌识别接口返回:', result);
|
||||||
|
const licensePlate = this.extractLicensePlate(result);
|
||||||
|
if (!licensePlate) {
|
||||||
|
throw new Error((result && result.message) || '未识别到车牌号');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.formData.license_plate = licensePlate;
|
||||||
|
uni.showToast({
|
||||||
|
title: '识别成功',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
const errMsg = String(error?.errMsg || error?.message || error || '').toLowerCase();
|
||||||
|
if (errMsg.includes('cancel')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.showToast({
|
||||||
|
title: (error && error.message) || '车牌识别失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
this.recognizingPlate = false;
|
||||||
|
uni.hideLoading();
|
||||||
|
}
|
||||||
|
},
|
||||||
normalizeUniScanResult(scanResult) {
|
normalizeUniScanResult(scanResult) {
|
||||||
if (!scanResult) {
|
if (!scanResult) {
|
||||||
return '';
|
return '';
|
||||||
@ -437,4 +656,24 @@
|
|||||||
border-top: 1px solid rgba(0, 0, 0, .3);
|
border-top: 1px solid rgba(0, 0, 0, .3);
|
||||||
background-color: #FFF;
|
background-color: #FFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.store-select-display {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 72rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-select-text {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #303133;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-select-placeholder {
|
||||||
|
color: #c0c4cc;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
Loading…
x
Reference in New Issue
Block a user