Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(table): radio filter controller improvement #2850

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/table/_example/filter-controlled.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export default {
{ label: '已过期', value: 2 },
{ label: '审批失败', value: 3 },
],
// confirm to search and hide filter popup
confirmEvents: ['onChange'],
// 支持透传全部 Popup 组件属性
// popupProps: {
// attach: () => document.body,
Expand Down
6 changes: 5 additions & 1 deletion src/table/filter-controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,19 @@ export default defineComponent({
if (column.colKey && this.innerFilterValue && column.colKey in this.innerFilterValue) {
filterComponentProps.value = this.innerFilterValue[column.colKey];
}
// 这个代码必须放在这里,没事儿别改
// 这个代码必须放在这里,否则会造成顺序错误
const on = {
change: (val: any) => {
this.$emit('inner-filter-change', val, column);
if (column.filter?.confirmEvents?.includes('onChange')) {
this.filterPopupVisible = false;
}
},
};
// 允许自定义触发确认搜索的事件
if (column.filter.confirmEvents) {
column.filter.confirmEvents.forEach((event) => {
if (event === 'onChange') return;
const pureEvent = lowerFirst(event.replace('on', ''));
on[pureEvent] = () => {
this.$emit('confirm', column);
Expand Down
Loading