zollero / el-search-table-pagination

🐶 Combine Form, Table and Pagination components of Element UI together.
MIT License
305 stars 79 forks source link

Possibility argument issue for function searchHandler #53

Open pzgz opened 4 years ago

pzgz commented 4 years ago

https://github.com/zollero/el-search-table-pagination/blob/9640d71ef69a2d7401c6e371213f66eebd22fb22/packages/search-table-pagination/src/main.vue#L185

Please check the line above, I think we might have issue with this function. Since dataChangeHandler method is expecting query parameters. But if seachHandler was called by parameter resetPageIndex, arguments[0]' will be the value forresetPageIndex. Therefore,dataChangeHandler` method call never can get the query parameters.

Simply said, that's no way to call searchHandler with both resetPageIndex set to false and query parameter object pass in

pzgz commented 4 years ago

实际上,我是在尝试修改这个插件来支持一个返回到列表页面时能够恢复之前做的搜索结果,包括查询条件,分页情况和排序情况时发现这个问题的。

这个问题目前我已经能够绕过去,在给自定义的查询表单设置初始值的时候,同时要把初始条件设置到组件的params上,上面的这个问题就无所谓了。使用组件内带的搜索表单应该没有问题。可能需要在说明里面写一下,如果使用form 插槽来实现自定义的搜索表单,还需要考虑到初始值的时候,除了自己需要考虑搜索表单初始化的同时,也切记要设置组件的params参数。

另外我修改了这个组件并增加了初始pageSize和和初始pageIndex的设置,来允许组件加载数据的时候直接按照设定的分页数量来分页并前往指定的页面,如果可以的话,我提一个PR。