feat: Add cache setting for table list
Realize the caching of the table list through loacalstorage function Change-Id: I87ae129d5adc8649787d6a3626abd3bf9b9e7c67
This commit is contained in:
parent
a5e03f36cb
commit
8eb796e9c7
@ -41,6 +41,8 @@ import {
|
|||||||
getValueRenderFunc,
|
getValueRenderFunc,
|
||||||
} from 'utils/table';
|
} from 'utils/table';
|
||||||
import { getNoValue } from 'utils/index';
|
import { getNoValue } from 'utils/index';
|
||||||
|
import { getLocalStorageItem, setLocalStorageItem } from 'utils/local-storage';
|
||||||
|
import { inject } from 'mobx-react';
|
||||||
import CustomColumns from './CustomColumns';
|
import CustomColumns from './CustomColumns';
|
||||||
import ItemActionButtons from './ItemActionButtons';
|
import ItemActionButtons from './ItemActionButtons';
|
||||||
import PrimaryActionButtons from './PrimaryActionButtons';
|
import PrimaryActionButtons from './PrimaryActionButtons';
|
||||||
@ -48,6 +50,7 @@ import BatchActionButtons from './BatchActionButtons';
|
|||||||
import Download from './Download';
|
import Download from './Download';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
|
@inject('rootStore')
|
||||||
export default class BaseTable extends React.Component {
|
export default class BaseTable extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
data: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).isRequired,
|
data: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).isRequired,
|
||||||
@ -117,7 +120,8 @@ export default class BaseTable extends React.Component {
|
|||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
hideRow: [],
|
hideRow:
|
||||||
|
getLocalStorageItem(`${this.useId}-${this.props.resourceName}`) || [],
|
||||||
// eslint-disable-next-line react/no-unused-state
|
// eslint-disable-next-line react/no-unused-state
|
||||||
filters: [],
|
filters: [],
|
||||||
timeFilter: {},
|
timeFilter: {},
|
||||||
@ -150,6 +154,12 @@ export default class BaseTable extends React.Component {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get useId() {
|
||||||
|
const { user = {} } = toJS(this.props.rootStore) || {};
|
||||||
|
const { user: { id } = {} } = user || {};
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
get itemActions() {
|
get itemActions() {
|
||||||
const { itemActions } = this.props;
|
const { itemActions } = this.props;
|
||||||
return itemActions;
|
return itemActions;
|
||||||
@ -222,11 +232,19 @@ export default class BaseTable extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
handleRowHide = (columns) => {
|
handleRowHide = (columns) => {
|
||||||
this.setState({
|
this.setState(
|
||||||
hideRow: this.hideableColValues.filter(
|
{
|
||||||
(value) => !columns.includes(value)
|
hideRow: this.hideableColValues.filter(
|
||||||
),
|
(value) => !columns.includes(value)
|
||||||
});
|
),
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
setLocalStorageItem(
|
||||||
|
`${this.useId}-${this.props.resourceName}`,
|
||||||
|
this.state.hideRow
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleCancelSelect = () => {
|
handleCancelSelect = () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user