Merge pull request #407 from RickCole21/master

add loadDataOnceFetchOnFilter
This commit is contained in:
liaoxuezhi 2019-12-29 10:34:06 +08:00 committed by GitHub
commit 8b6a3c3450
3 changed files with 11 additions and 2 deletions

View File

@ -12,6 +12,7 @@ CRUD 支持三种模式:`table`、`cards`、`list`,默认为 `table`。
| className | `string` | | 表格外层 Dom 的类名 |
| [api](#api) | [Api](./Types.md#Api) | | CRUD 用来获取列表数据的 api。 |
| loadDataOnce | `boolean` | | 是否一次性加载所有数据(前端分页) |
| loadDataOnceFetchOnFilter | `boolean` | `true` | 在开启loadDataOnce时filter时是否去重新请求api |
| source | `string` | | 数据映射接口返回某字段的值,不设置会默认把接口返回的`items`或者`rows`填充进`mode`区域 |
| filter | [Form](./Form/Form.md) | | 设置过滤器,当该表单提交后,会把数据带给当前 `mode` 刷新列表。 |
| filterTogglable | `boolean` | `false` | 是否可显隐过滤器 |

View File

@ -69,6 +69,7 @@ interface CRUDProps extends RendererProps {
syncResponse2Query?: boolean;
keepItemSelectionOnPageChange?: boolean;
loadDataOnce?: boolean;
loadDataOnceFetchOnFilter?: boolean; // 在开启loadDataOnce时filter时是否去重新请求api
source?: string;
}
@ -114,6 +115,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
'labelTpl',
'labelField',
'loadDataOnce',
'loadDataOnceFetchOnFilter',
'source'
];
static defaultProps = {
@ -129,7 +131,8 @@ export default class CRUD extends React.Component<CRUDProps, any> {
silentPolling: false,
filterTogglable: false,
filterDefaultVisible: true,
loadDataOnce: false
loadDataOnce: false,
loadDataOnceFetchOnFilter: true
};
control: any;
@ -685,6 +688,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
pickerMode,
env,
loadDataOnce,
loadDataOnceFetchOnFilter,
source
} = this.props;
@ -720,6 +724,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
autoAppend: true,
forceReload,
loadDataOnce,
loadDataOnceFetchOnFilter,
source,
silent,
pageField,

View File

@ -110,6 +110,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
options?: fetchOptions & {
forceReload?: boolean;
loadDataOnce?: boolean; // 配置数据是否一次性加载,如果是这样,由前端来完成分页,排序等功能。
loadDataOnceFetchOnFilter?: boolean; // 在开启loadDataOnce时filter时是否去重新请求api
source?: string; // 支持自定义属于映射,默认不配置,读取 rows 或者 items
loadDataMode?: boolean;
syncResponse2Query?: boolean;
@ -120,6 +121,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
options: fetchOptions & {
forceReload?: boolean;
loadDataOnce?: boolean; // 配置数据是否一次性加载,如果是这样,由前端来完成分页,排序等功能。
loadDataOnceFetchOnFilter?: boolean; // 在开启loadDataOnce时filter时是否去重新请求api
source?: string; // 支持自定义属于映射,默认不配置,读取 rows 或者 items
loadDataMode?: boolean;
syncResponse2Query?: boolean;
@ -127,7 +129,8 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
) {
try {
if (
options.forceReload === false &&
(options.forceReload === false ||
options.loadDataOnceFetchOnFilter === false) &&
options.loadDataOnce &&
self.total
) {