修改随机入库页面

This commit is contained in:
zm2000 2026-09-03 16:25:52 +08:00
parent 2be017d58f
commit 1c0f6a9451

View File

@ -272,6 +272,10 @@ export default {
this.totalItems = Number(pagination.total || summary.total || list.length || 0);
this.totalPages = Number(pagination.totalPages || Math.ceil(this.totalItems / this.pageSize) || 0);
this.currentPage = Number(pagination.page || this.currentPage || 1);
// 待入库列表为空且带关键词时,去掉 order_status 条件再查一次,仅用于判断是否已入库,不参与列表展示
if (list.length === 0 && this.normalizeKeyword(this.searchKeyword)) {
this.checkAlreadyInbound(this.searchKeyword);
}
} catch (error) {
const msg = String(error?.message || error?.msg || '查询入库单失败');
uni.showToast({ title: msg, icon: 'none' });
@ -279,6 +283,39 @@ export default {
this.loading = false;
}
},
async checkAlreadyInbound(keyword) {
const normalizedKeyword = this.normalizeKeyword(keyword);
if (!normalizedKeyword) return;
try {
// 不带 order_status 条件,仅按关键词查询,用于判断该单是否已不在待入库列表(如已入库)
const res = await this.$http('storage.entry.list', {
pagination: {
page: 1,
pageSize: this.pageSize
},
where: {
quickWhere: {
value: normalizedKeyword
}
}
});
const isSuccess = String(res?.code || '') === '200' || String(res?.flag || '').toLowerCase() === 'success';
if (!isSuccess) return;
const data = res?.data?.data || res?.data || {};
const list = Array.isArray(data.list) ? data.list : [];
// 关键词与返回列表的入库单号对比,命中则提示已入库(二次查询结果不用于展示)
const matched = list.some(item =>
this.normalizeKeyword(item?.entry_order_code) === normalizedKeyword
);
if (matched) {
uni.showToast({ title: '已入库', icon: 'none' });
this.speakVoice('已入库');
}
} catch (error) {
// 二次查询仅用于提示,异常时静默忽略,不影响主流程
console.warn('[RandomStorageList] checkAlreadyInbound 查询异常:', error);
}
},
handlePageChange(pageNum) {
const nextPage = Number(pageNum?.pageNum || pageNum?.page || pageNum);
this.currentPage = Number.isFinite(nextPage) && nextPage > 0 ? nextPage : 1;