新增库位查询页面
This commit is contained in:
parent
55b96d25be
commit
6913373362
@ -269,6 +269,12 @@ export default {
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
listBySpaceId: {
|
||||
path: "storage.inventory.listBySpaceId",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
transferByProduct: {
|
||||
path: "storage.inventory.transferByProduct",
|
||||
auth: true,
|
||||
|
||||
4
env.js
4
env.js
@ -1,4 +1,4 @@
|
||||
// export const BASE_URL = 'http://qimen.wms.gztbyc.com' //生产环境接口地址
|
||||
export const BASE_URL = 'http://192.168.11.56:6060' //开发环境接口地址
|
||||
export const BASE_URL = 'http://qimen.wms.gztbyc.com' //生产环境接口地址
|
||||
// export const BASE_URL = 'http://192.168.11.56:6060' //开发环境接口地址
|
||||
export const API_URL = `${BASE_URL}/system` //后台接口域名
|
||||
export const IMG_URL = 'https://ye4s.file.gzxunren.com' //全局网络图片地址变量,css背景图片地址变量在uni.scss
|
||||
|
||||
@ -110,6 +110,13 @@
|
||||
"titleNView": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/warehouse/locationInquiry",
|
||||
"style" :
|
||||
{
|
||||
"titleNView": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/403",
|
||||
"style" :
|
||||
|
||||
@ -1182,6 +1182,7 @@
|
||||
toPath(item) {
|
||||
const menuName = String(item?.name || '').trim();
|
||||
const isGoodsQuery = menuName === '商品查询' || (menuName.includes('商品') && menuName.includes('查询'));
|
||||
const isSpaceQuery = menuName === '库位查询' || (menuName.includes('库位') && menuName.includes('查询'));
|
||||
const isOrderPicking = menuName === '订单拣货' || (menuName.includes('订单') && menuName.includes('拣货'));
|
||||
const isScatterWaveStrategy = menuName === '散单波次策略' || (menuName.includes('散单') && menuName.includes('波次'));
|
||||
const isGrouponWaveStrategy = menuName === '团购波次策略' || (menuName.includes('团购') && menuName.includes('波次'));
|
||||
@ -1207,6 +1208,10 @@
|
||||
this.$tools.routerTo('/pages/work/storage/random-storage');
|
||||
return;
|
||||
}
|
||||
if (isSpaceQuery) {
|
||||
this.$tools.routerTo('/pages/warehouse/locationInquiry');
|
||||
return;
|
||||
}
|
||||
const targetPath = isGoodsQuery
|
||||
? '/pages/work/product/query'
|
||||
: (isOrderPicking
|
||||
|
||||
891
pages/warehouse/locationInquiry.vue
Normal file
891
pages/warehouse/locationInquiry.vue
Normal file
@ -0,0 +1,891 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<!-- 状态栏占位 -->
|
||||
<view class="status_bar"></view>
|
||||
|
||||
<!-- 头部栏 -->
|
||||
<view class="header">
|
||||
<view class="logout" @click="handleBack">
|
||||
<u-icon name="arrow-left" size="36rpx" color="#303133"></u-icon>
|
||||
</view>
|
||||
<text class="header__title">库位查询</text>
|
||||
<view class="header__placeholder"></view>
|
||||
</view>
|
||||
|
||||
<!-- 内容区 -->
|
||||
<view class="content_box">
|
||||
<!-- 库位编码/条码搜索区 -->
|
||||
<view class="search-panel">
|
||||
<view class="search-input-wrap">
|
||||
<u-search
|
||||
v-model="keyword"
|
||||
placeholder="请输入或者扫描库位编码/条码"
|
||||
:bg-color="'#f5f5f5'"
|
||||
shape="round"
|
||||
:show-action="false"
|
||||
@search="handleQuery"
|
||||
@clear="handleClear"
|
||||
></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="handleQuery">
|
||||
<text class="search-btn__text">搜索</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 库位名称显示 -->
|
||||
<view v-if="spaceInfo" class="line line--space">
|
||||
<text class="line__label">库位名称</text>
|
||||
<text class="line__value line__value--space">{{ spaceName }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 商品列表滚动区 -->
|
||||
<scroll-view class="scroll_box" scroll-y>
|
||||
<view
|
||||
v-for="(goods, index) in goodsList"
|
||||
:key="goodsItemKey(goods, index)"
|
||||
class="listBox"
|
||||
>
|
||||
<view class="goods-card__head" @click="goProductQuery(goods)">
|
||||
<view class="goods-card__thumb" @click.stop="previewGoodsImage(goods)">
|
||||
<u-image
|
||||
class="goods-card__image"
|
||||
:src="goodsImage(goods)"
|
||||
mode="aspectFill"
|
||||
width="120rpx"
|
||||
height="120rpx"
|
||||
>
|
||||
<template #error>
|
||||
<view class="goods-card__placeholder">
|
||||
<u-icon name="photo" size="32" color="#c0c4cc"></u-icon>
|
||||
</view>
|
||||
</template>
|
||||
</u-image>
|
||||
</view>
|
||||
<view class="goods-card__info">
|
||||
<view class="line line--compact">
|
||||
<text class="line__label">货主</text>
|
||||
<text class="line__value">{{ goodsStoreName(goods) }}</text>
|
||||
</view>
|
||||
<view class="line line--compact">
|
||||
<text class="line__label">商品</text>
|
||||
<text class="line__value">{{ goodsName(goods) }}、{{ goodsBarcode(goods) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="line line--count" @click="goRelocation(goods)">
|
||||
<view class="line--count__half line--count__half--left">
|
||||
<text class="line__label">总数量</text>
|
||||
<text class="line__value">{{ goodsCount(goods) }}</text>
|
||||
</view>
|
||||
<view class="line--count__half line--count__half--right">
|
||||
<text class="line__label">可移数量</text>
|
||||
<text class="line__value">{{ goodsCopyCount(goods) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="!querying && goodsList.length === 0" class="empty-state">
|
||||
<u-icon name="search" size="88" color="#c0c4cc"></u-icon>
|
||||
<text class="empty-text">{{ queried ? '该库位无有量库存' : '暂无库位数据' }}</text>
|
||||
<text class="empty-hint">请输入关键字进行查询</text>
|
||||
</view>
|
||||
|
||||
<!-- 底部安全区 -->
|
||||
<view class="safe-area-bottom"></view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<!-- 库位选择弹窗 -->
|
||||
<u-popup :show="selectorVisible" mode="bottom" :closeable="true" border-radius="20" :z-index="10090" @close="selectorVisible = false">
|
||||
<view class="space-selector">
|
||||
<view class="space-selector__header">
|
||||
<text class="space-selector__title">请选择库位</text>
|
||||
</view>
|
||||
<scroll-view class="space-selector__list" scroll-y>
|
||||
<view
|
||||
v-for="(item, index) in spaceOptions"
|
||||
:key="item.id || index"
|
||||
class="space-selector__item"
|
||||
@click="selectSpace(item)"
|
||||
>
|
||||
<text class="space-selector__name">{{ item.custom_name || item.space_code || '--' }}</text>
|
||||
<text class="space-selector__code">编码:{{ item.space_code || '--' }}</text>
|
||||
<text v-if="item.custom_barcode" class="space-selector__code">条码:{{ item.custom_barcode }}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</u-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
// 库位关键字输入(space_code / custom_barcode)
|
||||
keyword: '',
|
||||
// 库位选择弹窗
|
||||
selectorVisible: false,
|
||||
spaceOptions: [],
|
||||
searching: false,
|
||||
// 查询状态
|
||||
querying: false,
|
||||
queried: false,
|
||||
spaceInfo: null,
|
||||
goodsList: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 库位号:custom_name 优先,否则 space_code
|
||||
spaceName() {
|
||||
const s = this.spaceInfo;
|
||||
if (!s) return '--';
|
||||
return String(s.custom_name ?? s.customName ?? s.space_code ?? s.spaceCode ?? s.name ?? '--').trim() || '--';
|
||||
}
|
||||
},
|
||||
onLoad(options = {}) {
|
||||
// 支持通过 ?keyword=xxx 预填库位编码/条码并自动查询
|
||||
const preset = String(options.keyword || '').trim();
|
||||
if (preset) {
|
||||
this.keyword = preset;
|
||||
this.$nextTick(() => this.handleQuery());
|
||||
}
|
||||
this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult });
|
||||
this.safeDispatchBroadcast('start');
|
||||
},
|
||||
onShow() {
|
||||
this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult });
|
||||
this.safeDispatchBroadcast('resume');
|
||||
},
|
||||
onHide() {
|
||||
this.safeDispatchBroadcast('pause');
|
||||
},
|
||||
onUnload() {
|
||||
this.safeDispatchBroadcast('stop');
|
||||
},
|
||||
methods: {
|
||||
// ===== 基础工具 =====
|
||||
safeDispatchBroadcast(action, payload) {
|
||||
try {
|
||||
const task = this.$store.dispatch(`broadcast/${action}`, payload);
|
||||
if (task && typeof task.catch === 'function') {
|
||||
task.catch(error => console.warn(`[locationInquiry] broadcast/${action} 调用失败:`, error));
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`[locationInquiry] broadcast/${action} 调用异常:`, error);
|
||||
}
|
||||
},
|
||||
normalizeScanResult(scanResult) {
|
||||
if (!scanResult) return '';
|
||||
if (typeof scanResult === 'string') return scanResult.trim();
|
||||
if (typeof scanResult.result === 'string') return scanResult.result.trim();
|
||||
if (Array.isArray(scanResult.result)) {
|
||||
const first = scanResult.result.find(item => item);
|
||||
if (typeof first === 'string') return first.trim();
|
||||
if (first && typeof first.data === 'string') return first.data.trim();
|
||||
}
|
||||
if (typeof scanResult.data === 'string') return scanResult.data.trim();
|
||||
return '';
|
||||
},
|
||||
speak(text = '') {
|
||||
try {
|
||||
const tools = this.$tools;
|
||||
if (!tools || typeof tools.speakText !== 'function') return;
|
||||
const task = tools.speakText(String(text).trim(), {});
|
||||
if (task && typeof task.catch === 'function') {
|
||||
task.catch(error => console.warn('[locationInquiry] 语音播报失败:', error));
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('[locationInquiry] 语音播报异常:', error);
|
||||
}
|
||||
},
|
||||
toast(title, icon = 'none') {
|
||||
uni.showToast({ title, icon });
|
||||
},
|
||||
handleBack() {
|
||||
const pages = getCurrentPages();
|
||||
if (pages.length > 1) {
|
||||
uni.navigateBack({ delta: 1 });
|
||||
return;
|
||||
}
|
||||
uni.reLaunch({ url: '/pages/index/index' });
|
||||
},
|
||||
// ===== 商品字段解析(data.list 项:数量字段在项上,商品信息在 item.stock) =====
|
||||
goodsItemKey(goods, index) {
|
||||
if (!goods) return index;
|
||||
const id = goods.stock_id ?? goods.stock?.id;
|
||||
return id !== undefined && id !== null && id !== '' ? id : index;
|
||||
},
|
||||
goodsName(goods) {
|
||||
const stock = goods?.stock;
|
||||
const name = stock?.item_name ?? stock?.name ?? stock?.product_name;
|
||||
const text = String(name ?? '').trim();
|
||||
return text || (goods?.stock_id ? `商品#${goods.stock_id}` : '--');
|
||||
},
|
||||
goodsBarcode(goods) {
|
||||
const stock = goods?.stock;
|
||||
const codes = stock?.barcodes;
|
||||
if (Array.isArray(codes) && codes.length) {
|
||||
const list = codes.map(c => {
|
||||
if (typeof c === 'string') return c.trim();
|
||||
if (c && typeof c === 'object') return String(c.barcode ?? c.code ?? '').trim();
|
||||
return '';
|
||||
}).filter(Boolean);
|
||||
if (list.length) return list.join('、');
|
||||
}
|
||||
return String(stock?.item_code ?? '').trim() || '--';
|
||||
},
|
||||
goodsStoreName(goods) {
|
||||
return String(goods?.store_name ?? '').trim() || '--';
|
||||
},
|
||||
goodsCount(goods) {
|
||||
const v = goods?.quantity;
|
||||
return v === null || v === undefined || v === '' ? '--' : String(v);
|
||||
},
|
||||
goodsCopyCount(goods) {
|
||||
const v = goods?.available_quantity;
|
||||
return v === null || v === undefined || v === '' ? '--' : String(v);
|
||||
},
|
||||
// 商品图片:优先取已拉取的 images 列表,其次商品/库存对象上的单图字段
|
||||
goodsImage(goods) {
|
||||
const list = this.goodsImages(goods);
|
||||
return list.length ? list[0] : '';
|
||||
},
|
||||
goodsImages(goods) {
|
||||
if (!goods || typeof goods !== 'object') return [];
|
||||
const stock = goods.stock && typeof goods.stock === 'object' ? goods.stock : {};
|
||||
const singles = [
|
||||
goods.image, goods.image_url, goods.img, goods.pic, goods.photo, goods.cover, goods.cover_url,
|
||||
stock.image, stock.image_url, stock.img, stock.pic, stock.photo, stock.cover, stock.cover_url
|
||||
];
|
||||
for (const s of singles) {
|
||||
if (Array.isArray(s)) {
|
||||
const first = s.find(u => u);
|
||||
if (first) return [String(first)];
|
||||
} else if (s) {
|
||||
return [String(s)];
|
||||
}
|
||||
}
|
||||
const arrays = [goods.images, goods.pics, goods.image_urls, stock.images, stock.pics, stock.image_urls];
|
||||
for (const arr of arrays) {
|
||||
if (!Array.isArray(arr) || !arr.length) continue;
|
||||
const urls = arr.map(u => {
|
||||
if (!u) return '';
|
||||
if (typeof u === 'string') return u.trim();
|
||||
if (typeof u === 'object') return String(u.url || u.path || u.image_url || u.fileUrl || u.successUrl || '').trim();
|
||||
return '';
|
||||
}).filter(Boolean);
|
||||
if (urls.length) return urls;
|
||||
}
|
||||
return [];
|
||||
},
|
||||
previewGoodsImage(goods) {
|
||||
const images = this.goodsImages(goods);
|
||||
if (!images.length) return;
|
||||
uni.previewImage({ current: images[0], urls: images });
|
||||
},
|
||||
// 列表项未携带图片时,按商品 id 拉取图片(并发上限 4,避免 PDA 卡顿)
|
||||
async fetchGoodsImages(list) {
|
||||
if (!Array.isArray(list) || !list.length) return;
|
||||
const itemsToFetch = [];
|
||||
list.forEach(goods => {
|
||||
if (!goods || typeof goods !== 'object') return;
|
||||
if (this.goodsImages(goods).length) return;
|
||||
const id = this.normalizePositiveId(goods.stock_id ?? goods.stock?.id);
|
||||
if (id) itemsToFetch.push({ goods, id });
|
||||
});
|
||||
if (!itemsToFetch.length) return;
|
||||
const limit = 4;
|
||||
let cursor = 0;
|
||||
while (cursor < itemsToFetch.length) {
|
||||
const batch = itemsToFetch.slice(cursor, cursor + limit);
|
||||
cursor += limit;
|
||||
const settled = await Promise.all(batch.map(async ({ id }) => {
|
||||
try {
|
||||
const res = await this.$http('common.getImages', { type: 'stock', id }, '', false);
|
||||
return { ok: true, res };
|
||||
} catch (error) {
|
||||
return { ok: false };
|
||||
}
|
||||
}));
|
||||
settled.forEach((result, i) => {
|
||||
if (!result.ok) return;
|
||||
const response = result.res;
|
||||
if (Number(response?.code) !== 200) return;
|
||||
const imageData = Array.isArray(response?.data)
|
||||
? response.data
|
||||
: (response?.data?.list || []);
|
||||
if (!Array.isArray(imageData) || !imageData.length) return;
|
||||
const urls = imageData.map(img => {
|
||||
if (!img) return '';
|
||||
if (typeof img === 'string') return img.trim();
|
||||
if (img.file && typeof img.file === 'object') return String(img.file.file_url || img.file.url || img.file.path || '').trim();
|
||||
return String(img.url || img.path || img.image_url || img.fileUrl || img.successUrl || '').trim();
|
||||
}).filter(Boolean);
|
||||
if (urls.length) this.$set(batch[i].goods, 'images', urls);
|
||||
});
|
||||
}
|
||||
},
|
||||
normalizePositiveId(value) {
|
||||
const n = Number(value);
|
||||
if (!Number.isFinite(n)) return null;
|
||||
const normalized = Math.trunc(n);
|
||||
return normalized > 0 ? normalized : null;
|
||||
},
|
||||
// 点击货主/商品:跳转商品查询页(预填关键字与商品 id)
|
||||
goProductQuery(goods) {
|
||||
if (!goods || typeof goods !== 'object') return;
|
||||
const stock = goods.stock && typeof goods.stock === 'object' ? goods.stock : {};
|
||||
const stockId = this.normalizePositiveId(goods.stock_id ?? stock.id);
|
||||
// 关键字:优先第一个条码,其次商品编码,最后商品名称
|
||||
let keyword = '';
|
||||
if (Array.isArray(stock.barcodes) && stock.barcodes.length) {
|
||||
keyword = stock.barcodes.map(c => {
|
||||
if (typeof c === 'string') return c.trim();
|
||||
if (c && typeof c === 'object') return String(c.barcode ?? c.code ?? '').trim();
|
||||
return '';
|
||||
}).find(Boolean) || '';
|
||||
}
|
||||
if (!keyword) keyword = String(stock.item_code ?? '').trim();
|
||||
if (!keyword) keyword = this.goodsName(goods);
|
||||
uni.setStorageSync('replenish_query_keyword', keyword);
|
||||
const query = stockId ? `?stock_id=${encodeURIComponent(stockId)}` : '';
|
||||
uni.navigateTo({ url: `/pages/work/product/query${query}` });
|
||||
},
|
||||
// 点击商品卡片:跳转移库作业页(预填源库位、商品与可移数量)
|
||||
goRelocation(goods) {
|
||||
if (!goods || typeof goods !== 'object') return;
|
||||
const stockId = this.normalizePositiveId(goods.stock_id ?? goods.stock?.id);
|
||||
const sourceSpaceId = this.normalizePositiveId(this.spaceInfo?.id ?? goods.space_id);
|
||||
if (!sourceSpaceId) {
|
||||
this.toast('未获取到源库位ID');
|
||||
return;
|
||||
}
|
||||
if (!stockId) {
|
||||
this.toast('未获取到商品ID');
|
||||
return;
|
||||
}
|
||||
const copyCount = this.goodsCopyCount(goods);
|
||||
const stockObj = goods.stock && typeof goods.stock === 'object' ? goods.stock : {};
|
||||
// barcodes 是 [{id, barcode}] 结构,转成字符串数组,避免移库页显示 [object Object]
|
||||
const barcodes = Array.isArray(stockObj.barcodes)
|
||||
? stockObj.barcodes.map(c => {
|
||||
if (typeof c === 'string') return c.trim();
|
||||
if (c && typeof c === 'object') return String(c.barcode ?? c.code ?? '').trim();
|
||||
return '';
|
||||
}).filter(Boolean)
|
||||
: [];
|
||||
const cacheKey = `relocation_prefill_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
||||
uni.setStorageSync(cacheKey, {
|
||||
stock: {
|
||||
...goods,
|
||||
...stockObj,
|
||||
barcodes,
|
||||
relocation_storage_id: null,
|
||||
relocation_product_stock_id: stockId,
|
||||
relocation_query_mode: 'nonBatch'
|
||||
},
|
||||
sourceSpace: {
|
||||
id: sourceSpaceId,
|
||||
name: this.spaceName,
|
||||
code: String(this.spaceInfo?.space_code ?? goods.space_code ?? '')
|
||||
},
|
||||
moveQuantity: (copyCount !== '--' && copyCount !== '') ? copyCount : ''
|
||||
});
|
||||
uni.navigateTo({ url: `/pages/work/storage/relocation?cacheKey=${cacheKey}` });
|
||||
},
|
||||
// ===== 查询 =====
|
||||
handleQuery() {
|
||||
this.resolveSpace(this.keyword);
|
||||
},
|
||||
handleClear() {
|
||||
this.keyword = '';
|
||||
this.spaceInfo = null;
|
||||
this.goodsList = [];
|
||||
this.queried = false;
|
||||
},
|
||||
handleCameraScan() {
|
||||
uni.scanCode({
|
||||
onlyFromCamera: true,
|
||||
scanType: ['qrCode', 'barCode', 'datamatrix', 'pdf417'],
|
||||
success: (res) => {
|
||||
const code = this.normalizeScanResult(res);
|
||||
if (!code) return;
|
||||
this.keyword = code;
|
||||
this.resolveSpace(code);
|
||||
},
|
||||
fail: () => {}
|
||||
});
|
||||
},
|
||||
handleBroadcastResult(result) {
|
||||
const code = this.normalizeScanResult(result);
|
||||
if (!code) return;
|
||||
this.keyword = code;
|
||||
this.resolveSpace(code);
|
||||
},
|
||||
// 解析库位:按 space_code / custom_barcode 搜索,唯一命中直接查询,多个则弹出选择
|
||||
async resolveSpace(keyword) {
|
||||
if (this.searching || this.querying) return;
|
||||
const code = String(keyword ?? '').trim();
|
||||
if (!code) {
|
||||
this.toast('请输入或者扫描库位编码/条码');
|
||||
return;
|
||||
}
|
||||
this.searching = true;
|
||||
let resolvedId = null;
|
||||
uni.showLoading({ title: '查询中...', mask: true });
|
||||
try {
|
||||
const res = await this.$http('common.searchSpace', { keyword: code }, '', false);
|
||||
if (res?.flag === 'failure' || Number(res?.code) !== 200) {
|
||||
this.toast(String(res?.message || '库位搜索失败'));
|
||||
this.speak('无记录');
|
||||
return;
|
||||
}
|
||||
const list = Array.isArray(res?.data)
|
||||
? res.data.filter(item => item && typeof item === 'object')
|
||||
: [];
|
||||
if (list.length === 0) {
|
||||
this.speak('无记录');
|
||||
this.toast('未找到匹配库位');
|
||||
return;
|
||||
}
|
||||
if (list.length === 1) {
|
||||
resolvedId = list[0].id ?? list[0].space_id;
|
||||
} else {
|
||||
this.spaceOptions = list;
|
||||
this.selectorVisible = true;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[locationInquiry] 库位搜索失败:', error);
|
||||
this.toast(error?.message || '库位搜索失败');
|
||||
} finally {
|
||||
uni.hideLoading();
|
||||
this.searching = false;
|
||||
}
|
||||
if (resolvedId) {
|
||||
this.querySpace(resolvedId);
|
||||
}
|
||||
},
|
||||
// 选择库位后查询
|
||||
selectSpace(item) {
|
||||
this.selectorVisible = false;
|
||||
this.querySpace(item?.id ?? item?.space_id);
|
||||
},
|
||||
async querySpace(id) {
|
||||
if (this.querying) return;
|
||||
const raw = String(id ?? '').trim();
|
||||
if (!raw) {
|
||||
this.toast('库位ID无效');
|
||||
return;
|
||||
}
|
||||
const spaceId = Number(raw);
|
||||
if (!Number.isInteger(spaceId) || spaceId <= 0) {
|
||||
this.toast('库位ID无效');
|
||||
return;
|
||||
}
|
||||
this.querying = true;
|
||||
this.queried = true;
|
||||
uni.showLoading({ title: '查询中...', mask: true });
|
||||
try {
|
||||
// toastAfter=false:失败提示由本方法自行控制
|
||||
const res = await this.$http('storage.inventory.listBySpaceId', { space_id: spaceId }, '', false);
|
||||
if (res?.flag === 'failure' || Number(res?.code) !== 200) {
|
||||
this.toast(String(res?.message || '库位查询失败'));
|
||||
this.speak('无记录');
|
||||
this.spaceInfo = null;
|
||||
this.goodsList = [];
|
||||
return;
|
||||
}
|
||||
const data = (res?.data && typeof res.data === 'object') ? res.data : {};
|
||||
this.spaceInfo = data.space ?? null;
|
||||
this.goodsList = Array.isArray(data.list)
|
||||
? data.list.filter(item => item && typeof item === 'object')
|
||||
: [];
|
||||
const goodsImageTask = this.fetchGoodsImages(this.goodsList);
|
||||
if (goodsImageTask && typeof goodsImageTask.catch === 'function') {
|
||||
goodsImageTask.catch(error => console.warn('[locationInquiry] 拉取商品图片失败:', error));
|
||||
}
|
||||
if (this.goodsList.length) {
|
||||
this.toast(`查询到 ${this.goodsList.length} 种商品`, 'none');
|
||||
} else {
|
||||
this.speak('无记录');
|
||||
this.toast('该库位无有量库存');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[locationInquiry] 库位查询失败:', error);
|
||||
this.toast(error?.message || '库位查询失败');
|
||||
this.spaceInfo = null;
|
||||
this.goodsList = [];
|
||||
} finally {
|
||||
uni.hideLoading();
|
||||
this.querying = false;
|
||||
// 查询后清空输入框,便于连续扫描
|
||||
this.keyword = '';
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.content {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: #f5f6f7;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* u-popup 根节点自带 flex:1(uView 组件内置),放在纵向 flex 容器里会与 content_box 平分高度,这里中和掉 */
|
||||
.content > .u-popup {
|
||||
flex: none;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.status_bar {
|
||||
height: var(--status-bar-height, 0px);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 100rpx;
|
||||
padding: 0 24rpx;
|
||||
box-sizing: border-box;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.logout {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.header__title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.header__placeholder {
|
||||
width: 80rpx;
|
||||
}
|
||||
|
||||
.content_box {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 搜索区(参考商品查询) */
|
||||
.search-panel {
|
||||
background: #ffffff;
|
||||
border-bottom: 1rpx solid #f2f2f2;
|
||||
padding: 16rpx;
|
||||
box-sizing: border-box;
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.search-input-wrap {
|
||||
position: relative;
|
||||
|
||||
::v-deep .u-search {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
::v-deep .u-search__content {
|
||||
padding-right: 200rpx;
|
||||
}
|
||||
|
||||
::v-deep .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;
|
||||
|
||||
&__text {
|
||||
font-size: 30rpx;
|
||||
font-weight: 500;
|
||||
color: #2979ff;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
&:active {
|
||||
opacity: 0.88;
|
||||
}
|
||||
}
|
||||
|
||||
/* 通用行 */
|
||||
.line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 16rpx 20rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.line__label {
|
||||
font-size: 30rpx;
|
||||
color: #909399;
|
||||
flex-shrink: 0;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.line__value {
|
||||
flex: 1;
|
||||
font-size: 45rpx;
|
||||
color: #303133;
|
||||
word-break: break-all;
|
||||
overflow-wrap: break-word;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.line__value--space {
|
||||
font-size: 50rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
/* 库位名称显示 */
|
||||
.line--space {
|
||||
margin: 12rpx 12rpx 0;
|
||||
background: #07c160;
|
||||
border-radius: 16rpx;
|
||||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.line--space .line__label {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
/* 商品列表 */
|
||||
.scroll_box {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
min-height: 0;
|
||||
margin: 12rpx 0 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.listBox {
|
||||
box-sizing: border-box;
|
||||
background: #ffffff;
|
||||
border: 2rpx solid #dcdfe6;
|
||||
border-radius: 16rpx;
|
||||
box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.08);
|
||||
margin: 0 12rpx 16rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.listBox:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* 商品卡片头部:图片在前,货主/商品信息在后 */
|
||||
.goods-card__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 20rpx 20rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.goods-card__thumb {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
flex-shrink: 0;
|
||||
border-radius: 12rpx;
|
||||
overflow: hidden;
|
||||
background: #f5f6f7;
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
|
||||
.goods-card__image {
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.goods-card__placeholder {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #f5f6f7;
|
||||
}
|
||||
|
||||
.goods-card__info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.line--compact {
|
||||
padding: 16rpx 0;
|
||||
}
|
||||
|
||||
.line--compact .line__value {
|
||||
font-size: 40rpx;
|
||||
}
|
||||
|
||||
.line--count {
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.line--count__half {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10rpx 20rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.line--count__half--left {
|
||||
background: #f56c6c;
|
||||
}
|
||||
|
||||
.line--count__half--right {
|
||||
background: #2979ff;
|
||||
}
|
||||
|
||||
.line--count__half .line__label,
|
||||
.line--count__half .line__value {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.line--count__half .line__value {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 160rpx 0 100rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 30rpx;
|
||||
color: #909399;
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.empty-hint {
|
||||
font-size: 24rpx;
|
||||
color: #c0c4cc;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
/* 底部安全区 */
|
||||
.safe-area-bottom {
|
||||
height: constant(safe-area-inset-bottom);
|
||||
height: env(safe-area-inset-bottom);
|
||||
}
|
||||
|
||||
/* 库位选择弹窗 */
|
||||
.space-selector {
|
||||
background: #ffffff;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
padding: 32rpx 24rpx 40rpx;
|
||||
box-sizing: border-box;
|
||||
max-height: 70vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.space-selector__header {
|
||||
text-align: center;
|
||||
padding-bottom: 20rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.space-selector__title {
|
||||
font-size: 34rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.space-selector__list {
|
||||
max-height: 56vh;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.space-selector__item {
|
||||
padding: 24rpx 20rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.space-selector__item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.space-selector__name {
|
||||
font-size: 34rpx;
|
||||
font-weight: 500;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.space-selector__code {
|
||||
font-size: 28rpx;
|
||||
color: #909399;
|
||||
}
|
||||
</style>
|
||||
Loading…
x
Reference in New Issue
Block a user