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()