From 423ca1c5d4e4cc7eba9e12125e74f47f5756f967 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 24 六月 2021 17:29:59 +0800 Subject: [PATCH] 2021-06-24 --- src/tabviews/custom/components/card/data-card/index.jsx | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx index 90e0085..5f29f7b 100644 --- a/src/tabviews/custom/components/card/data-card/index.jsx +++ b/src/tabviews/custom/components/card/data-card/index.jsx @@ -40,14 +40,20 @@ sync: false, // 鏄惁缁熶竴璇锋眰鏁版嵁 card: null, // 鍗$墖璁剧疆 data: null, // 鏁版嵁 - total: null + total: null, + precards: [], + nextcards: [], } UNSAFE_componentWillMount () { const { data, initdata, BID } = this.props let _config = fromJS(this.props.config).toJS() - _config.subcards = _config.subcards.map(item => { + let _card = null + let precards = [] + let nextcards = [] + + _config.subcards.forEach(item => { item.setting.$click = '' if (item.setting.click === 'button') { if (item.elements.filter(ele => ele.eleType === 'button').length < 2) { @@ -55,10 +61,18 @@ } item.setting.click = '' } - return item + + if (item.$cardType !== 'extendCard') { + _card = item + } else if (!_card) { + precards.push(item) + } else { + nextcards.push(item) + } }) - let _card = _config.subcards.shift() + _config.subcards = null + let _cols = new Map() let _data = null @@ -74,11 +88,16 @@ if (_config.wrap.cardFloat && _config.wrap.cardFloat !== 'left') { let _width = 0 - _config.subcards.forEach(card => { + precards.forEach(card => { + _width += card.setting.width + }) + nextcards.forEach(card => { _width += card.setting.width }) _config.$offset = _width + } else { + _config.wrap.cardFloat = null } if (_data) { @@ -109,6 +128,8 @@ }) this.setState({ + precards, + nextcards, sync: _sync, data: _data, BID: BID || '', @@ -574,7 +595,7 @@ } render() { - const { config, loading, data, pageIndex, total, card, activeKey, BID, BData, selectedData, selectKeys } = this.state + const { config, precards, nextcards, loading, data, pageIndex, total, card, activeKey, BID, BData, selectedData, selectKeys } = this.state let _total = 0 let switchable = false @@ -584,7 +605,7 @@ } let offset = 0 - if (config.wrap.cardFloat && config.wrap.cardFloat !== 'left') { + if (config.wrap.cardFloat) { let length = data ? data.length : 0 if (card.setting.width * length + config.$offset < 24) { offset = 24 - card.setting.width * length - config.$offset @@ -616,19 +637,25 @@ <div className={`data-zoom ${config.wrap.cardType || ''} ${config.wrap.scale || ''}`}> {switchable ? <div className={'prev-page ' + (pageIndex === 1 ? 'disabled' : '')} onClick={this.prevPage}><div><div><img src={preImg} alt=""/></div></div></div> : null} <Row className="card-row-list"> + {offset ? <Col span={offset} style={{height: '10px'}}> </Col> : null} + {precards.map((item, index) => ( + <Col key={'pre' + index} className={item.setting.$click} span={item.setting.width || 6}> + <CardItem card={item} cards={config} data={{$$BID: BID, $$type: 'extendCard'}}/> + </Col> + ))} {data && data.map((item, index) => ( - <Col className={(activeKey === index ? ' active' : (selectKeys.indexOf(index) > -1 ? ' selected' : '')) + (card.setting.$click ? ' pointer' : '') + card.setting.$click} key={index} span={card.setting.width} offset={!index ? offset : 0} onClick={() => {this.changeCard(index, item)}}> + <Col className={(activeKey === index ? ' active' : (selectKeys.indexOf(index) > -1 ? ' selected' : '')) + (card.setting.$click ? ' pointer' : '') + card.setting.$click} key={index} span={card.setting.width} onClick={() => {this.changeCard(index, item)}}> <CardItem card={card} cards={config} data={item}/> </Col> ))} - {config.subcards.map((item, index) => ( - <Col key={'mk' + index} className={item.setting.$click} span={item.setting.width || 6} offset={(!data || data.length === 0) ? offset : 0}> + {nextcards.map((item, index) => ( + <Col key={'next' + index} className={item.setting.$click} span={item.setting.width || 6}> <CardItem card={item} cards={config} data={{$$BID: BID, $$type: 'extendCard'}}/> </Col> ))} </Row> {switchable ? <div className={'prev-page ' + (total <= _total ? 'disabled' : '')} onClick={this.nextPage}><div><div><img src={nextImg} alt=""/></div></div></div> : null} - {config.subcards.length === 0 && (!data || data.length === 0) ? <Empty description={false}/> : null} + {precards.length === 0 && nextcards.length === 0 && (!data || data.length === 0) ? <Empty description={false}/> : null} </div> {config.wrap.pagestyle !== 'switch' && config.setting.laypage && data ? <Pagination size="small" total={total} showTotal={t => `鍏� ${t} 鏉} pageSize={config.setting.pageSize} onChange={this.changePageIndex} current={pageIndex}/> : null} </div> -- Gitblit v1.8.0