diff --git a/web-react/src/components/business/house-log.jsx b/web-react/src/components/business/house-log.jsx index 66a2395..c711110 100644 --- a/web-react/src/components/business/house-log.jsx +++ b/web-react/src/components/business/house-log.jsx @@ -1,12 +1,12 @@ import React, { Component } from 'react' -import { Descriptions, Spin, Steps, Timeline } from 'antd' +import { Descriptions, Spin, Steps, Timeline, Button } from 'antd' import { AntIcon } from 'components' import { api } from 'common/api' import getDictData from 'util/dic' import { toCamelCase } from 'util/format' const ellipsisType = [3, 4, 6] - +const loadFlag = [] export default class houseLog extends Component { state = { loading: true, @@ -14,6 +14,7 @@ export default class houseLog extends Component { houseLogType: [], }, data: [], + showCount: 3, } async componentDidMount() { @@ -46,51 +47,98 @@ export default class houseLog extends Component { } return null } - + //点击加载更多按钮 展示全部 + showMore = () => { + loadFlag.length = 0 + this.setState({ + showCount: 10000, + }) + } + //只显示一次 ellipsisType 如果要全部显示 将false改为 true + loadOnce(itemType) { + if (loadFlag.includes(itemType)) return false + if (ellipsisType.includes(itemType)) { + loadFlag.unshift(itemType) + } + return true + } + //组件卸载清空 数组 否则再次点开数组中有值存在 + componentWillUnmount() { + loadFlag.length = 0 + } render() { - const { loading, codes, data } = this.state - + const { loading, codes, data, showCount } = this.state return ( }> {data.map((item, i) => ( - - ) : ( - [ - , - , - , - ][item.status] - ) - } - > -
- - {['等待', '正在', ''][item.status] + - this.bindCodeValue(item.type, 'house_log_type')} - -
-

{item.finishedTime}

- - {item.remark && ( - {item.remark} - )} - - {item.targetUserNames.split(',').join(' / ')} - - {item.finishedUserName && ( - - {item.finishedUserName} - - )} - -
+ + {i < showCount && ( + + {this.loadOnce(item.type) && ( + + ) : ( + [ + , + , + , + ][item.status] + ) + } + > +
+ + {['等待', '正在', ''][item.status] + + this.bindCodeValue( + item.type, + 'house_log_type' + )} + +
+

{item.finishedTime}

+ + {item.remark && ( + + {item.remark} + + )} + + {item.targetUserNames.split(',').join(' / ')} + + {item.finishedUserName && ( + + {item.finishedUserName} + + )} + +
+ )} +
+ )} +
))}
+ + {showCount < data.length && ( + + )} +
) }