From eaec8547aa16e944718a4a1c9218c2a42d83de3f Mon Sep 17 00:00:00 2001 From: "Mr.j" <2221464500@qq.com> Date: Fri, 1 Aug 2025 16:24:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=86=E9=A1=B5=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=97=A0=E6=B3=95=E7=BB=91=E5=AE=9A=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/EquipmentSearch.vue | 161 ++++++++++++++++-- .../device-management/index.vue | 35 +++- 2 files changed, 175 insertions(+), 21 deletions(-) diff --git a/src/views/system-resource/device-management/components/EquipmentSearch.vue b/src/views/system-resource/device-management/components/EquipmentSearch.vue index be26ad4..98b5eb9 100644 --- a/src/views/system-resource/device-management/components/EquipmentSearch.vue +++ b/src/views/system-resource/device-management/components/EquipmentSearch.vue @@ -8,44 +8,48 @@ - +
@@ -53,44 +57,133 @@
+ +
+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + +
- + @@ -113,7 +206,6 @@ import { reactive } from 'vue' import { IconRefresh, IconSearch } from '@arco-design/web-vue/es/icon' import type { EquipmentPageQuery } from '@/types/equipment.d' -// 定义组件属性 interface Props { loading?: boolean } @@ -123,13 +215,22 @@ const props = withDefaults(defineProps(), { loading: false, }) -// 定义事件 const emit = defineEmits<{ search: [params: EquipmentPageQuery] reset: [] }>() -// 搜索表单数据 +// 防抖函数 +// eslint-disable-next-line ts/no-unsafe-function-type +const debounce = (func: Function, delay: number) => { + let timeoutId: NodeJS.Timeout + return (...args: any[]) => { + clearTimeout(timeoutId) + // eslint-disable-next-line prefer-spread + timeoutId = setTimeout(() => func.apply(null, args), delay) + } +} + const searchForm = reactive({ equipmentName: '', equipmentType: '', @@ -140,9 +241,20 @@ const searchForm = reactive({ invoice: '', barcode: '', importer: '', + equipmentSn: '', + assetCode: '', + brand: '', + responsiblePerson: '', + useStatus: '', + equipmentModel: '', + specification: '', + physicalLocation: '', + supplierName: '', + maintenancePerson: '', + inventoryBarcode: '', + assetRemark: '', }) -// 选项数据 const equipmentTypeOptions = [ { label: '计算机设备', value: 'computer' }, { label: '网络设备', value: 'network' }, @@ -174,20 +286,35 @@ const healthStatusOptions = [ { label: '故障', value: 'fault' }, ] -// 搜索处理 +const useStatusOptions = [ + { label: '空闲中', value: '0' }, + { label: '使用中', value: '1' }, +] + +// 防抖搜索函数 +const debouncedSearch = debounce(() => { + console.log('🔍 EquipmentSearch - 防抖搜索触发') + console.log('🔍 EquipmentSearch - 搜索表单数据:', searchForm) + emit('search', { ...searchForm }) +}, 300) + const handleSearch = () => { + console.log('🔍 EquipmentSearch - 搜索按钮被点击') + console.log('🔍 EquipmentSearch - 搜索表单数据:', searchForm) + console.log('🔍 EquipmentSearch - 发送的搜索参数:', { ...searchForm }) emit('search', { ...searchForm }) } -// 重置处理 const handleReset = () => { + console.log('🔄 EquipmentSearch - 重置按钮被点击') + console.log('🔄 EquipmentSearch - 重置前的表单数据:', { ...searchForm }) Object.keys(searchForm).forEach((key) => { searchForm[key as keyof EquipmentPageQuery] = '' as any }) + console.log('🔄 EquipmentSearch - 重置后的表单数据:', { ...searchForm }) emit('reset') } -// 暴露方法给父组件 defineExpose({ reset: handleReset, getSearchForm: () => ({ ...searchForm }), diff --git a/src/views/system-resource/device-management/index.vue b/src/views/system-resource/device-management/index.vue index c2f96cf..3c84f8e 100644 --- a/src/views/system-resource/device-management/index.vue +++ b/src/views/system-resource/device-management/index.vue @@ -144,7 +144,8 @@ import type { EquipmentPageQuery, EquipmentResp } from '@/types/equipment.d' defineOptions({ name: 'EquipmentCenter' }) -// 搜索表单引用 +// 当前搜索参数 +const currentSearchParams = ref({}) // 表格数据 const tableData = ref([]) @@ -473,6 +474,11 @@ const transformBackendData = (data: any[]) => { // 加载数据 const loadData = async (searchParams?: EquipmentPageQuery) => { + console.log('📊 loadData - 开始加载数据') + console.log('📊 loadData - 接收到的搜索参数:', searchParams) + console.log('📊 loadData - 搜索参数类型:', typeof searchParams) + console.log('📊 loadData - 当前分页配置:', pagination) + loading.value = true try { const params = { @@ -481,8 +487,17 @@ const loadData = async (searchParams?: EquipmentPageQuery) => { ...(searchParams || {}), // 添加搜索条件 } - console.log('发送的请求参数:', params) - console.log('当前分页配置:', pagination) + console.log('📊 loadData - 构建的完整请求参数:', params) + console.log('📊 loadData - 请求参数类型:', typeof params) + console.log('📊 loadData - 请求参数是否为对象:', params && typeof params === 'object') + + // 详细打印每个搜索字段 + if (searchParams) { + console.log('📊 loadData - 搜索字段详情:') + Object.entries(searchParams).forEach(([key, value]) => { + console.log(` ${key}: ${value} (类型: ${typeof value})`) + }) + } const res = await pageEquipment(params) @@ -530,13 +545,25 @@ const loadData = async (searchParams?: EquipmentPageQuery) => { // 搜索 const handleSearch = (searchParams: EquipmentPageQuery) => { + console.log('🔍 主组件 - 接收到的搜索参数:', searchParams) + console.log('🔍 主组件 - 搜索参数类型:', typeof searchParams) + console.log('🔍 主组件 - 搜索参数是否为对象:', searchParams && typeof searchParams === 'object') + pagination.current = 1 + currentSearchParams.value = { ...searchParams } + + console.log('🔍 主组件 - 保存的当前搜索参数:', currentSearchParams.value) + console.log('🔍 主组件 - 准备调用 loadData,传递参数:', searchParams) + loadData(searchParams) } // 重置 const handleReset = () => { + console.log('🔄 主组件 - 重置操作') pagination.current = 1 + currentSearchParams.value = {} + console.log('🔄 主组件 - 清空后的当前搜索参数:', currentSearchParams.value) loadData() } @@ -544,7 +571,7 @@ const handleReset = () => { const handleTableChange = (pag: any) => { pagination.current = pag.current || 1 pagination.pageSize = pag.pageSize || 10 - loadData() + loadData(currentSearchParams.value) } // 新增