From 43d16cd1960e6af64acd36f95f93eb8824153366 Mon Sep 17 00:00:00 2001 From: DXC Date: Mon, 9 Mar 2026 17:36:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=97=E8=A1=A8=E9=A1=B5=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=A1=86=E5=A2=9E=E5=8A=A0=E5=8D=B3=E6=97=B6=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E4=B8=8E=E9=98=B2=E6=8A=96=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inventory-web/src/views/stock/inbound/buy.vue | 23 ++++++++++++++++ .../src/views/stock/inbound/product.vue | 27 +++++++++++++++++-- .../src/views/stock/inbound/semi.vue | 27 +++++++++++++++++-- 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/inventory-web/src/views/stock/inbound/buy.vue b/inventory-web/src/views/stock/inbound/buy.vue index 08d14d8..0f7664c 100644 --- a/inventory-web/src/views/stock/inbound/buy.vue +++ b/inventory-web/src/views/stock/inbound/buy.vue @@ -20,6 +20,7 @@ placeholder="请输入名称、规格搜索..." class="filter-item-input" clearable + @input="handleInputSearch" @clear="fetchData" @keyup.enter="fetchData" style="width: 200px;" @@ -32,6 +33,7 @@ placeholder="请输入SKU搜索..." class="filter-item-input" clearable + @input="handleInputSearch" @clear="fetchData" @keyup.enter="fetchData" style="width: 160px;" @@ -664,6 +666,17 @@ import WebRtcCamera from '@/components/Camera/WebRtcCamera.vue' import WarehouseSelector from '@/components/WarehouseSelector.vue' import { useUserStore } from '@/stores/user' +// ------------------------------------ +// 防抖函数 +// ------------------------------------ +const debounce = (fn: Function, delay: number = 500) => { + let timer: ReturnType | null = null + return (...args: any[]) => { + if (timer) clearTimeout(timer) + timer = setTimeout(() => fn(...args), delay) + } +} + // ------------------------------------ // 自定义指令:v-loadmore (适配 Teleport 到 Body 的下拉框) // ------------------------------------ @@ -1226,6 +1239,16 @@ const fetchData = async () => { } finally { loading.value = false } } +// 防抖即时搜索 +const debouncedSearch = debounce(() => { + queryParams.page = 1 + fetchData() +}, 500) + +const handleInputSearch = () => { + debouncedSearch() +} + const fetchOptions = async () => { try { const res: any = await getFilterOptions() diff --git a/inventory-web/src/views/stock/inbound/product.vue b/inventory-web/src/views/stock/inbound/product.vue index da630c9..afb8f1a 100644 --- a/inventory-web/src/views/stock/inbound/product.vue +++ b/inventory-web/src/views/stock/inbound/product.vue @@ -19,6 +19,7 @@ placeholder="请输入名称、规格搜索..." class="filter-item-input" clearable + @input="handleInputSearch" @clear="fetchData" @keyup.enter="fetchData" style="width: 200px;" @@ -31,6 +32,7 @@ placeholder="请输入SKU搜索..." class="filter-item-input" clearable + @input="handleInputSearch" @clear="fetchData" @keyup.enter="fetchData" style="width: 160px;" @@ -534,6 +536,17 @@ import { getLabelPreview, executePrint } from '@/api/common/print' import { getWarehouseTree } from '@/api/common/warehouse' import { useUserStore } from '@/stores/user' +// ------------------------------------ +// 防抖函数 +// ------------------------------------ +const debounce = (fn: Function, delay: number = 500) => { + let timer: ReturnType | null = null + return (...args: any[]) => { + if (timer) clearTimeout(timer) + timer = setTimeout(() => fn(...args), delay) + } +} + // ------------------------------------ // v-loadmore // ------------------------------------ @@ -954,8 +967,8 @@ const handleManagerSelect = (item: any) => { const fetchData = async () => { loading.value = true try { - const params = { - ...queryParams, + const params = { + ...queryParams, statuses: queryParams.statuses.join(','), orderByColumn: queryParams.orderByColumn, isAsc: queryParams.isAsc, @@ -967,6 +980,16 @@ const fetchData = async () => { } finally { loading.value = false } } +// 防抖即时搜索 +const debouncedSearch = debounce(() => { + queryParams.page = 1 + fetchData() +}, 500) + +const handleInputSearch = () => { + debouncedSearch() +} + const fetchOptions = async () => { try { const res: any = await getFilterOptions() diff --git a/inventory-web/src/views/stock/inbound/semi.vue b/inventory-web/src/views/stock/inbound/semi.vue index 950bb48..3dd6726 100644 --- a/inventory-web/src/views/stock/inbound/semi.vue +++ b/inventory-web/src/views/stock/inbound/semi.vue @@ -20,6 +20,7 @@ placeholder="请输入名称、规格搜索..." class="filter-item-input" clearable + @input="handleInputSearch" @clear="fetchData" @keyup.enter="fetchData" style="width: 200px;" @@ -32,6 +33,7 @@ placeholder="请输入SKU搜索..." class="filter-item-input" clearable + @input="handleInputSearch" @clear="fetchData" @keyup.enter="fetchData" style="width: 160px;" @@ -598,6 +600,17 @@ import {getLabelPreview, executePrint} from '@/api/common/print' import { getWarehouseTree } from '@/api/common/warehouse' import { useUserStore } from '@/stores/user' +// ------------------------------------ +// 防抖函数 +// ------------------------------------ +const debounce = (fn: Function, delay: number = 500) => { + let timer: ReturnType | null = null + return (...args: any[]) => { + if (timer) clearTimeout(timer) + timer = setTimeout(() => fn(...args), delay) + } +} + // ------------------------------------ // 自定义指令:v-loadmore (适配 Teleport 到 Body 的下拉框) // ------------------------------------ @@ -1088,8 +1101,8 @@ const handleSortChange = ({ column, prop, order }: any) => { const fetchData = async () => { loading.value = true try { - const params = { - ...queryParams, + const params = { + ...queryParams, statuses: queryParams.statuses.join(','), orderByColumn: queryParams.orderByColumn, isAsc: queryParams.isAsc, @@ -1101,6 +1114,16 @@ const fetchData = async () => { } finally { loading.value = false } } +// 防抖即时搜索 +const debouncedSearch = debounce(() => { + queryParams.page = 1 + fetchData() +}, 500) + +const handleInputSearch = () => { + debouncedSearch() +} + const fetchOptions = async () => { try { const res: any = await getFilterOptions()