mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:48:13 +08:00
feat: crud列过滤支持展开刷新 (#6479)
Co-authored-by: wanglinfang <wanglinfang@baidu.com>
This commit is contained in:
parent
6a51ca3c5a
commit
e3f6821155
@ -2895,12 +2895,13 @@ itemAction 里的 onClick 还能通过 `data` 参数拿到当前行的数据,
|
||||
|
||||
#### QuickFilterConfig
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ---------- | ----------------------------- | ------- | -------------------------------------------------------- | ------- |
|
||||
| options | `Array<any>` | - | 静态选项 | |
|
||||
| multiple | `boolean` | `false` | 是否支持多选 | |
|
||||
| source | [`Api`](../../docs/types/api) | - | 选项 API 接口 | |
|
||||
| strictMode | `string` | `false` | 严格模式,开启严格模式后,会采用 JavaScript 严格想等比较 | `2.3.0` |
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ------------- | ----------------------------- | ------- | -------------------------------------------------------- | ------- |
|
||||
| options | `Array<any>` | - | 静态选项 | |
|
||||
| multiple | `boolean` | `false` | 是否支持多选 | |
|
||||
| source | [`Api`](../../docs/types/api) | - | 选项 API 接口 | |
|
||||
| refreshOnOpen | `boolean` | `false` | 配置 source 前提下,每次展开筛选浮层是否重新加载选项数据 | `2.9.0` |
|
||||
| strictMode | `boolean` | `false` | 严格模式,开启严格模式后,会采用 JavaScript 严格想等比较 | `2.3.0` |
|
||||
|
||||
#### QuickEditConfig
|
||||
|
||||
|
@ -22,6 +22,7 @@ export interface QuickFilterConfig {
|
||||
/* 是否开启严格对比模式 */
|
||||
strictMode?: boolean;
|
||||
[propName: string]: any;
|
||||
refreshOnOpen?: boolean; // 展开是否重新加载数据 当source配置api时才起作用
|
||||
}
|
||||
|
||||
export interface HeadCellFilterProps extends RendererProps {
|
||||
@ -51,7 +52,7 @@ export class HeadCellFilterDropDown extends React.Component<
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const {filterable, name, store} = this.props;
|
||||
const {filterable} = this.props;
|
||||
|
||||
if (filterable.source) {
|
||||
this.fetchOptions();
|
||||
@ -121,7 +122,7 @@ export class HeadCellFilterDropDown extends React.Component<
|
||||
this.sourceInvalid && this.fetchOptions();
|
||||
}
|
||||
|
||||
fetchOptions() {
|
||||
async fetchOptions() {
|
||||
const {env, filterable, data} = this.props;
|
||||
if (!isEffectiveApi(filterable.source, data)) {
|
||||
return;
|
||||
@ -130,11 +131,10 @@ export class HeadCellFilterDropDown extends React.Component<
|
||||
const api = normalizeApi(filterable.source);
|
||||
api.cache = 3000; // 开启 3s 缓存,因为固顶位置渲染1次会额外多次请求。
|
||||
|
||||
env.fetcher(api, data).then(ret => {
|
||||
let options = (ret.data && ret.data.options) || [];
|
||||
this.setState({
|
||||
filterOptions: ret && ret.data && this.alterOptions(options)
|
||||
});
|
||||
const ret = await env.fetcher(api, data);
|
||||
let options = (ret.data && ret.data.options) || [];
|
||||
this.setState({
|
||||
filterOptions: ret && ret.data && this.alterOptions(options)
|
||||
});
|
||||
}
|
||||
|
||||
@ -178,7 +178,11 @@ export class HeadCellFilterDropDown extends React.Component<
|
||||
this.close();
|
||||
}
|
||||
|
||||
open() {
|
||||
async open() {
|
||||
const {filterable} = this.props;
|
||||
if (filterable.refreshOnOpen && filterable.source) {
|
||||
await this.fetchOptions();
|
||||
}
|
||||
this.setState({
|
||||
isOpened: true
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user