feat:page增加onBulkChange

This commit is contained in:
dqc 2022-07-19 12:40:46 +08:00
parent 3890a174d4
commit 91edbf429a
3 changed files with 9 additions and 5 deletions

View File

@ -51,7 +51,7 @@ const result = async (req, res) => {
? data
: data.filter(function (item) {
return browser ? ~item.browser.indexOf(browser) : false;
})[0] || data[0]
})[0]
});
};

View File

@ -558,14 +558,12 @@ export class FormItemWrap extends React.Component<FormItemProps> {
ctx,
!!(autoFill.api as BaseApiObject)?.silent
);
if (!result) return;
this.lastSearchTerm = getVariable(result, itemName) ?? term;
this.lastSearchTerm =
(result && getVariable(result, itemName)) ?? term;
if (autoFill?.fillMapping) {
result = dataMapping(autoFill.fillMapping, result);
}
result && onBulkChange?.(result);
}
}

View File

@ -284,6 +284,7 @@ export default class Page extends React.Component<PageProps> {
bulkBindFunctions<Page /*为毛 this 的类型自动识别不出来*/>(this, [
'handleAction',
'handleChange',
'handleBulkChange',
'handleQuery',
'handleDialogConfirm',
'handleDialogClose',
@ -690,6 +691,10 @@ export default class Page extends React.Component<PageProps> {
onChange?.apply(null, arguments);
}
handleBulkChange(values: Object) {
this.props.store?.updateData?.(values);
}
renderHeader() {
const {
title,
@ -789,6 +794,7 @@ export default class Page extends React.Component<PageProps> {
onAction: this.handleAction,
onQuery: initApi ? this.handleQuery : undefined,
onChange: this.handleChange,
onBulkChange: this.handleBulkChange,
pageLoading: store.loading
};