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

Revert "feat: table搜索表单值发生改变可以触发reload (#3378)" #3407

Merged
merged 1 commit into from
Dec 13, 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
26 changes: 1 addition & 25 deletions src/components/Form/src/components/FormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import { cloneDeep, upperFirst } from 'lodash-es';
import { useItemLabelWidth } from '../hooks/useLabelWidth';
import { useI18n } from '@/hooks/web/useI18n';
import { useDebounceFn } from '@vueuse/core';

export default defineComponent({
name: 'BasicFormItem',
Expand Down Expand Up @@ -271,36 +270,13 @@
component,
field,
changeEvent = 'change',
watchEventNames = ['search', 'change'],
enableWatchEvent = true,
valueField,
} = props.schema;

const isCheck = component && ['Switch', 'Checkbox'].includes(component);

const eventKey = `on${upperFirst(changeEvent)}`;

const { autoSetPlaceHolder, size, watchEvent } = props.formProps;
let eventNames = {};
if (watchEvent && enableWatchEvent) {
// table search 开启才触发事件
let immediateEvents = ['search']; // 立即执行的事件
watchEventNames.forEach((item) => {
let timer: number = 500;
if (immediateEvents.includes(item)) {
timer = 0;
}
eventNames[`on${upperFirst(item)}`] = useDebounceFn(
(...args: Nullable<Recordable<any>>[]) => {
// todo 后续需要优化input中文输入的问题
console.log(args);
const { reload = () => {} } = props.tableAction || {};
reload();
},
timer,
);
});
}
const on = {
[eventKey]: (...args: Nullable<Recordable<any>>[]) => {
const [e] = args;
Expand All @@ -314,6 +290,7 @@
};
const Comp = componentMap.get(component) as ReturnType<typeof defineComponent>;

const { autoSetPlaceHolder, size } = props.formProps;
const propsData: Recordable<any> = {
allowClear: true,
size,
Expand All @@ -338,7 +315,6 @@
const compAttr: Recordable<any> = {
...propsData,
...on,
...eventNames,
...bindValue,
};

Expand Down
3 changes: 0 additions & 3 deletions src/components/Form/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,4 @@ export const basicProps = {
labelAlign: propTypes.string,

rowProps: Object as PropType<RowProps>,

// table 开启监听表单监听事件,触发table reload
watchEvent: propTypes.bool.def(false),
};
6 changes: 0 additions & 6 deletions src/components/Form/src/types/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export interface FormProps {
submitFunc?: () => Promise<void>;
transformDateFunc?: (date: any) => string;
colon?: boolean;
watchEvent?: boolean;
}
export type RenderOpts = {
disabled: boolean;
Expand Down Expand Up @@ -224,11 +223,6 @@ interface BaseFormSchema {
dynamicReadonly?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);

dynamicRules?: (renderCallbackParams: RenderCallbackParams) => Rule[];

watchEventNames?: string[];

// 禁用事件监听触发reload
enableWatchEvent?: boolean;
}
export interface ComponentFormSchema extends BaseFormSchema {
// render component
Expand Down
39 changes: 0 additions & 39 deletions src/views/demo/table/tableData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,45 +259,6 @@ export function getFormConfig(): Partial<FormProps> {
xxl: 8,
},
},
{
field: `field12`,
label: `input值改变`,
component: 'InputSearch',
enableWatchEvent: true,
componentProps: {
placeholder: '需要开启watchEvent',
},
colProps: {
xl: 12,
xxl: 8,
},
},
{
field: 'field13',
component: 'Select',
label: 'select值改变',
componentProps: {
placeholder: '需要开启watchEvent',
options: [
{
label: '公开',
value: '1',
},
{
label: '部分公开',
value: '2',
},
{
label: '不公开',
value: '3',
},
],
},
colProps: {
xl: 12,
xxl: 8,
},
},
],
};
}
Expand Down