mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 12:08:13 +08:00
fix: 修复开启 autoGenerateFilter 后同时有没有可搜索项时, 接口不初始化的问题 (#3500)
This commit is contained in:
parent
c79b40c426
commit
27671920ab
@ -465,12 +465,16 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const {store, autoGenerateFilter} = this.props;
|
const {store, autoGenerateFilter, columns} = this.props;
|
||||||
|
|
||||||
if (this.props.perPage) {
|
if (this.props.perPage) {
|
||||||
store.changePage(store.page, this.props.perPage);
|
store.changePage(store.page, this.props.perPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 没有 filter 或者 没有展示 filter 时应该默认初始化一次,
|
||||||
|
// 否则就应该等待 filter 里面的表单初始化的时候才初始化
|
||||||
|
// 另外autoGenerateFilter时,table 里面会单独处理这块逻辑
|
||||||
|
// 所以这里应该忽略 autoGenerateFilter 情况
|
||||||
if (
|
if (
|
||||||
(!this.props.filter || (store.filterTogggable && !store.filterVisible)) &&
|
(!this.props.filter || (store.filterTogggable && !store.filterVisible)) &&
|
||||||
!autoGenerateFilter
|
!autoGenerateFilter
|
||||||
|
@ -500,7 +500,7 @@ export default class Table extends React.Component<TableProps, object> {
|
|||||||
this.handleMouseLeave = this.handleMouseLeave.bind(this);
|
this.handleMouseLeave = this.handleMouseLeave.bind(this);
|
||||||
this.subFormRef = this.subFormRef.bind(this);
|
this.subFormRef = this.subFormRef.bind(this);
|
||||||
this.handleColumnToggle = this.handleColumnToggle.bind(this);
|
this.handleColumnToggle = this.handleColumnToggle.bind(this);
|
||||||
this.renderAutoFilterForm = this.renderAutoFilterForm.bind(this);
|
|
||||||
this.updateAutoFillHeight = this.updateAutoFillHeight.bind(this);
|
this.updateAutoFillHeight = this.updateAutoFillHeight.bind(this);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -614,6 +614,19 @@ export default class Table extends React.Component<TableProps, object> {
|
|||||||
window.addEventListener('resize', this.affixDetect);
|
window.addEventListener('resize', this.affixDetect);
|
||||||
this.updateAutoFillHeight();
|
this.updateAutoFillHeight();
|
||||||
window.addEventListener('resize', this.updateAutoFillHeight);
|
window.addEventListener('resize', this.updateAutoFillHeight);
|
||||||
|
|
||||||
|
const {store, autoGenerateFilter, onSearchableFromInit} = this.props;
|
||||||
|
|
||||||
|
// autoGenerateFilter 开启后
|
||||||
|
// 如果没有一个 searchable 的 column crud 就不会初始化加载
|
||||||
|
// 所以这里加个判断默认初始加载一次
|
||||||
|
if (
|
||||||
|
autoGenerateFilter &&
|
||||||
|
!store.searchableColumns.length &&
|
||||||
|
onSearchableFromInit
|
||||||
|
) {
|
||||||
|
onSearchableFromInit({});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1470,7 +1483,13 @@ export default class Table extends React.Component<TableProps, object> {
|
|||||||
|
|
||||||
activedSearchableColumns.forEach((column, index) => {
|
activedSearchableColumns.forEach((column, index) => {
|
||||||
groupedSearchableColumns[index % 3].body.push({
|
groupedSearchableColumns[index % 3].body.push({
|
||||||
...column.searchable,
|
...(column.searchable === true
|
||||||
|
? {
|
||||||
|
type: 'input-text',
|
||||||
|
name: column.name,
|
||||||
|
label: column.label
|
||||||
|
}
|
||||||
|
: column.searchable),
|
||||||
name: column.searchable?.name ?? column.name,
|
name: column.searchable?.name ?? column.name,
|
||||||
label: column.searchable?.label ?? column.label,
|
label: column.searchable?.label ?? column.label,
|
||||||
mode: 'horizontal'
|
mode: 'horizontal'
|
||||||
|
@ -518,9 +518,7 @@ export const TableStore = iRendererStore
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getSearchableColumns() {
|
function getSearchableColumns() {
|
||||||
return self.columns.filter(
|
return self.columns.filter(column => column.searchable);
|
||||||
column => column.searchable && isObject(column.searchable)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user