| | |
| | | |
| | | _config.subcards = null |
| | | |
| | | let _cols = new Map() |
| | | |
| | | let _data = null |
| | | let _sync = _config.setting.sync === 'true' |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | _config.columns.forEach(item => { |
| | | if (item.type !== 'number') return |
| | | _cols.set(item.field, item) |
| | | }) |
| | | |
| | | _card.elements = _card.elements.map(item => { |
| | | if (item.eleType === 'number' && item.field && _cols.has(item.field) && typeof(item.decimal) !== 'number') { |
| | | item.decimal = _cols.get(item.field).decimal || 0 |
| | | } |
| | | return item |
| | | }) |
| | | _card.backElements = _card.backElements.map(item => { |
| | | if (item.eleType === 'number' && item.field && _cols.has(item.field) && typeof(item.decimal) !== 'number') { |
| | | item.decimal = _cols.get(item.field).decimal || 0 |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | let supComs = null |
| | | if (_config.wrap.supType === 'multi') { |
| | |
| | | if (config.uuid !== menuId) return |
| | | |
| | | if (checked) { |
| | | let index = '' |
| | | let keys = [] |
| | | let items = [] |
| | | let last = '' |
| | | |
| | | data.forEach((item, i) => { |
| | | if (item.$disabled) return |
| | | |
| | | items.push(item) |
| | | keys.push(i) |
| | | index = i |
| | | last = item |
| | | }) |
| | | |
| | | this.setState({ |
| | | activeKey: '', |
| | | selectKeys: data.map((item, index) => index), |
| | | selectedData: data |
| | | activeKey: index, |
| | | selectKeys: keys, |
| | | selectedData: items |
| | | }) |
| | | |
| | | MKEmitter.emit('resetSelectLine', config.uuid, '', '') |
| | | MKEmitter.emit('syncBalconyData', config.uuid, data, data.length > 0) |
| | | if (data.length === 0) { |
| | | MKEmitter.emit('resetSelectLine', config.uuid, last ? last.$$uuid : '', last) |
| | | MKEmitter.emit('syncBalconyData', config.uuid, items, data.length > 0 && data.length === keys.length) |
| | | if (items.length === 0) { |
| | | message.warning('未获取到数据!') |
| | | } |
| | | } else { |
| | |
| | | |
| | | MKEmitter.emit('resetSelectLine', config.uuid, '', '') |
| | | MKEmitter.emit('syncBalconyData', config.uuid, [], false) |
| | | } |
| | | } |
| | | |
| | | checkAll = () => { |
| | | const { config, data, selectedData } = this.state |
| | | |
| | | if (!data || data.length === 0) return |
| | | |
| | | if (selectedData.length === 0 || selectedData.length < data.length) { |
| | | let index = '' |
| | | let keys = [] |
| | | let items = [] |
| | | let last = '' |
| | | |
| | | data.forEach((item, i) => { |
| | | if (item.$disabled) return |
| | | |
| | | items.push(item) |
| | | keys.push(i) |
| | | index = i |
| | | last = item |
| | | }) |
| | | |
| | | this.setState({ |
| | | activeKey: index, |
| | | selectKeys: keys, |
| | | selectedData: items |
| | | }) |
| | | |
| | | MKEmitter.emit('resetSelectLine', config.uuid, last ? last.$$uuid : '', last) |
| | | if (config.setting.$hasSyncModule) { |
| | | MKEmitter.emit('syncBalconyData', config.uuid, items, data.length === keys.length) |
| | | } |
| | | } else { |
| | | this.setState({ |
| | | activeKey: '', |
| | | selectKeys: [], |
| | | selectedData: [] |
| | | }) |
| | | |
| | | MKEmitter.emit('resetSelectLine', config.uuid, '', '') |
| | | if (config.setting.$hasSyncModule) { |
| | | MKEmitter.emit('syncBalconyData', config.uuid, [], false) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | this.loaded = true |
| | | if (config.$cache && pageIndex === 1) { |
| | | if (config.$cache && pageIndex === 1 && config.setting.onload !== 'false') { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | } |
| | | |
| | |
| | | extendData = {...extendData, ...data[0]} |
| | | } |
| | | |
| | | let checkAll = '' |
| | | if (config.wrap.selStyle && config.wrap.selStyle.indexOf('check') > -1) { |
| | | if (selectedData.length > 0) { |
| | | checkAll = selectedData.length < data.length ? ' half' : ' whole' |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | <div className="custom-data-card-box" id={'anchor' + config.uuid} style={config.style}> |
| | | {loading ? |
| | |
| | | <Row className={'card-row-list ' + config.wrap.layout}> |
| | | {precards.map((item, index) => ( |
| | | <Col key={'pre' + index} className="extend-card" span={item.setting.width || 6}> |
| | | <CardItem card={item} cards={config} data={extendData}/> |
| | | <CardItem card={item} cards={config} data={extendData}> |
| | | {item.setting.checkAll === 'show' ? <span onClick={this.checkAll} className={'circle-select' + checkAll}></span> : null} |
| | | </CardItem> |
| | | </Col> |
| | | ))} |
| | | {data && data.map((item, index) => { |
| | | let className = card.setting.click ? 'mk-card pointer ' : 'mk-card ' |
| | | let className = 'mk-card ' |
| | | if (config.wrap.parity === 'true') { |
| | | if (index % 2 === 1) { |
| | | className += 'mk-parity-bg ' |
| | | } |
| | | } |
| | | if (item.$disabled) { |
| | | className = 'mk-disabled' |
| | | } else if (activeKey === index) { |
| | |
| | | } |
| | | |
| | | return ( |
| | | <Col className={className} key={index} span={card.setting.width} onClick={() => {this.changeCard(index, item)}}> |
| | | <CardItem card={card} cards={config} data={item}/> |
| | | <Col className={className} key={index} span={card.setting.width}> |
| | | <CardItem card={card} cards={config} data={item} onClick={() => {this.changeCard(index, item)}}> |
| | | <span className="circle-select"></span> |
| | | </CardItem> |
| | | </Col> |
| | | ) |
| | | })} |
| | | {nextcards.map((item, index) => ( |
| | | <Col key={'next' + index} className="extend-card" span={item.setting.width || 6}> |
| | | <CardItem card={item} cards={config} data={extendData}/> |
| | | <CardItem card={item} cards={config} data={extendData}> |
| | | {item.setting.checkAll === 'show' ? <span onClick={this.checkAll} className={'circle-select' + checkAll}></span> : null} |
| | | </CardItem> |
| | | </Col> |
| | | ))} |
| | | </Row> |
| | |
| | | ) |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | export default DataCard |