修复 Table 固定页面报错问题

This commit is contained in:
2betop 2020-08-04 16:50:36 +08:00
parent 1bf1f6b78d
commit 25361e09f8

View File

@ -1110,16 +1110,10 @@ export default class Table extends React.Component<TableProps, object> {
if (column.name === store.orderBy) { if (column.name === store.orderBy) {
if (store.orderDir === 'desc') { if (store.orderDir === 'desc') {
// 降序之后取消排序 // 降序之后取消排序
store.setOrderByInfo( store.setOrderByInfo('', 'asc');
'',
'asc'
);
} else { } else {
// 升序之后降序 // 升序之后降序
store.setOrderByInfo( store.setOrderByInfo(column.name, 'desc');
column.name,
'desc'
);
} }
} else { } else {
store.setOrderByInfo(column.name as string, 'asc'); store.setOrderByInfo(column.name as string, 'asc');
@ -2364,12 +2358,12 @@ export class HeadCellSearchDropDown extends React.Component<
isActive() { isActive() {
const {data, name} = this.props; const {data, name} = this.props;
if (data.orderBy === name) { if (data?.orderBy === name) {
return true; return true;
} }
for (let item of this.formItems) { for (let item of this.formItems) {
if (item !== 'orderBy' && item !== 'orderDir') { if (item !== 'orderBy' && item !== 'orderDir') {
if (data[`${item}`]) { if (data?.[`${item}`]) {
return true; return true;
} }
} }
@ -2393,7 +2387,9 @@ export class HeadCellSearchDropDown extends React.Component<
const isActive = this.isActive(); const isActive = this.isActive();
return ( return (
<span className={cx(`${ns}TableCell-searchBtn`, isActive ? 'is-active' : '')}> <span
className={cx(`${ns}TableCell-searchBtn`, isActive ? 'is-active' : '')}
>
<span onClick={this.open}> <span onClick={this.open}>
<Icon icon="search" className="icon" /> <Icon icon="search" className="icon" />
</span> </span>
@ -2588,7 +2584,7 @@ export class HeadCellFilterDropDown extends React.Component<
const {name, onQuery} = this.props; const {name, onQuery} = this.props;
onQuery({ onQuery({
[name]: undefined [name]: undefined
}) });
this.close(); this.close();
} }
@ -2605,7 +2601,12 @@ export class HeadCellFilterDropDown extends React.Component<
} = this.props; } = this.props;
return ( return (
<span className={cx(`${ns}TableCell-filterBtn`, data[name] ? 'is-active' : '')}> <span
className={cx(
`${ns}TableCell-filterBtn`,
data[name] ? 'is-active' : ''
)}
>
<span onClick={this.open}> <span onClick={this.open}>
<Icon icon="column-filter" className="icon" /> <Icon icon="column-filter" className="icon" />
</span> </span>
@ -2652,7 +2653,13 @@ export class HeadCellFilterDropDown extends React.Component<
</Checkbox> </Checkbox>
</li> </li>
))} ))}
<li key="DropDown-menu-reset" className={cx('DropDown-divider')} onClick={this.handleReset.bind(this)}>{__('重置')}</li> <li
key="DropDown-menu-reset"
className={cx('DropDown-divider')}
onClick={this.handleReset.bind(this)}
>
{__('重置')}
</li>
</ul> </ul>
) : null} ) : null}
</PopOver> </PopOver>