| | |
| | | params = opts.getBeginListFunc!(params) |
| | | } |
| | | pageF.loading = true; |
| | | const queryParams = filterEmptyParams(opts.queryParams.value); |
| | | opts.getListApi!({ |
| | | pageNum: page.currentPage, |
| | | pageSize: page.pageSize, |
| | |
| | | * 2. 新增:手动触发搜索逻辑 (用于回车搜索) |
| | | */ |
| | | const manualSearch = () => { |
| | | if (!opts.queryParams || !opts.queryParams.value) return; // 容错处理 |
| | | opts.page.currentPage = 1; // 回车搜索默认切回第一页 |
| | | if (opts.handleQueryFunc) { |
| | | opts.handleQueryFunc(); |
| | |
| | | |
| | | /** 清空搜索回调方法 */ |
| | | const searchReset = () => { |
| | | opts.queryParams = {}; // 修改为操作 .value |
| | | // opts.queryParams = {}; // 修改为操作 .value |
| | | // ✅ 正确写法:清空 ref 内部的值 |
| | | if (opts.queryParams && opts.queryParams.value) { |
| | | // 方案 A:直接清空对象内部属性 |
| | | Object.keys(opts.queryParams.value).forEach(key => { |
| | | delete opts.queryParams.value[key]; |
| | | }); |
| | | |
| | | } |
| | | if (opts.handleQueryFunc) { |
| | | opts.handleQueryFunc(); |
| | | } |
| | |
| | | * 导出 |
| | | */ |
| | | const handleExport =()=>{ |
| | | console.log(opts.queryParams.value) |
| | | opts.exportApi!(opts.queryParams.value); |
| | | const queryParams = filterEmptyParams(opts.queryParams.value); |
| | | opts.exportApi!( opts.queryParams.value); |
| | | } |
| | | const handleDelete = () =>{ |
| | | if ( !(pageF?.ids)|| pageF?.ids?.length === 0) { |
| | |
| | | } |
| | | |
| | | } |
| | | /** |
| | | * 过滤空字符串参数 |
| | | */ |
| | | const filterEmptyParams = (params: any) => { |
| | | const result: any = {}; |
| | | for (const key in params) { |
| | | const val = params[key]; |
| | | // 过滤空字符串、null、undefined |
| | | if (val !== '' && val !== null && val !== undefined) { |
| | | result[key] = val; |
| | | } |
| | | } |
| | | return result; |
| | | }; |
| | | return { |
| | | pageF, |
| | | tableData, |