| | |
| | | |
| | | class CardCell extends Component { |
| | | static propTpyes = { |
| | | type: PropTypes.any, // 卡片类型,添加按钮为 insert |
| | | BID: PropTypes.any, // 主表ID |
| | | BData: PropTypes.any, // 主表数据 |
| | | Tab: PropTypes.any, // 如果当前元素为标签时,tab为标签信息 |
| | |
| | | |
| | | state = { |
| | | extra: null, // 顶部按钮信息 |
| | | actions: null // 底部按钮行 |
| | | actions: null, // 底部按钮行 |
| | | cardwidth: 0, |
| | | cardheight: 0, |
| | | plusSize: 0 |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | componentDidMount() { |
| | | if (this.insertRef) { |
| | | let _width = this.insertRef.offsetWidth |
| | | let _height = this.insertRef.offsetHeight |
| | | |
| | | if (this.props.card.header) { |
| | | _height += 46 |
| | | } |
| | | if (this.props.card.bottom) { |
| | | _height += 49 |
| | | } |
| | | this.setState({ |
| | | cardwidth: _width, |
| | | cardheight: _height, |
| | | plusSize: _width > _height ? _height / 2 : _width / 2 |
| | | }) |
| | | } |
| | | } |
| | | |
| | | componentDidUpdate() { |
| | | if (this.insertRef) { |
| | | let _width = this.insertRef.offsetWidth |
| | | let _height = this.insertRef.offsetHeight |
| | | |
| | | if (this.props.card.header) { |
| | | _height += 46 |
| | | } |
| | | if (this.props.card.bottom) { |
| | | _height += 49 |
| | | } |
| | | |
| | | if (_height !== this.state.cardheight || _width !== this.state.cardwidth) { |
| | | this.setState({ |
| | | cardwidth: _width, |
| | | cardheight: _height, |
| | | plusSize: _width > _height ? _height / 2 : _width / 2 |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | return ( |
| | | <div className={className}> |
| | | <span className={className}> |
| | | {content} |
| | | </div> |
| | | </span> |
| | | ) |
| | | } else if (col.type === 'number') { |
| | | let content = '' |
| | |
| | | } |
| | | |
| | | return ( |
| | | <div className={className}> |
| | | <span className={className}> |
| | | {content} |
| | | </div> |
| | | </span> |
| | | ) |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { card, selectKey, data } = this.props |
| | | const { extra, actions } = this.state |
| | | const { card, selectKey, data, type } = this.props |
| | | const { extra, actions, plusSize } = this.state |
| | | |
| | | let title = null |
| | | if (card.header) { |
| | |
| | | |
| | | return ( |
| | | <div className={'chart-card-box ' + card.outclass} style={card.outstyle || null} > |
| | | <Card |
| | | {type !== 'insert' ? <Card |
| | | size="small" |
| | | className={'chart-card ' + (selectKey === data.key ? 'chart-card-selected' : '')} |
| | | title={title} |
| | |
| | | })} |
| | | </div> |
| | | </div> |
| | | </Card> |
| | | </Card> : null} |
| | | {type === 'insert' ? <Card |
| | | size="small" |
| | | className="chart-card insert" |
| | | title={card.header ? ' ' : null} |
| | | bordered={card.bordered} |
| | | actions={card.bottom.actions ? [''] : null} |
| | | > |
| | | <div className="ant-card-meta" ref={(ref) => this.insertRef = ref} style={card.flex ? {display: 'flex'} : null}> |
| | | {card.avatar ? <div className="ant-card-meta-avatar" style={card.avatar.class}> </div> : null } |
| | | <div className="ant-card-meta-detail" style={card.flex ? {flex: 1} : null}> |
| | | {card.details.map((detail, i) => (<div className={detail.class} style={detail.style} key={i}></div>))} |
| | | </div> |
| | | </div> |
| | | <div className="mk-card-insert"> |
| | | <NormalButton |
| | | BID={this.props.BID} |
| | | Tab={this.props.Tab} |
| | | btn={card.insertAction} |
| | | show={'plus' + plusSize} |
| | | BData={this.props.BData} |
| | | setting={this.props.setting} |
| | | columns={this.props.logcolumns} |
| | | selectedData={[]} |
| | | ContainerId={this.props.ContainerId} |
| | | updateStatus={this.updateStatus} |
| | | /> |
| | | </div> |
| | | </Card> : null} |
| | | </div> |
| | | ) |
| | | } |
| | |
| | | let actionMap = new Map() // 按钮组 |
| | | let columns = fromJS(config.columns).toJS() |
| | | let actions = fromJS(config.action).toJS() |
| | | let insertAction = null |
| | | |
| | | columns.forEach(col => { |
| | | if (col.field) { |
| | |
| | | actions.forEach(item => { |
| | | if ((item.Ot && item.Ot !== 'notRequired' && !['excelIn', 'excelOut'].includes(item.OpenType)) || item.funcType === 'changeuser') { |
| | | actionMap.set(item.uuid, item) |
| | | } else if (plot.insert === 'true' && !insertAction && item.OpenType === 'pop' && item.sqlType === 'insert' && item.Ot === 'notRequired') { |
| | | insertAction = item |
| | | } |
| | | }) |
| | | |
| | |
| | | |
| | | card.switch = plot.switch !== 'false' |
| | | |
| | | card.insertAction = insertAction // 添加卡片 |
| | | |
| | | this.setState({card: card, colMap: colMap}) |
| | | } |
| | | |
| | |
| | | const { plot } = this.props |
| | | const { card } = this.state |
| | | |
| | | let _flex = false |
| | | if (card.avatar) { |
| | | let _flex = false |
| | | let _cardWidth = 300 |
| | | |
| | | if (plot.widthType === 'absolute') { |
| | | _cardWidth = plot.cardWidth |
| | | } else { |
| | |
| | | /> |
| | | )) |
| | | } |
| | | {!loading && card.insertAction && plot.over !== 'roll' ? |
| | | <CardCell |
| | | key="insert" |
| | | type="insert" |
| | | BID={BID} |
| | | Tab={Tab} |
| | | card={card} |
| | | data={{key: 'insert'}} |
| | | BData={BData} |
| | | MenuID={MenuID} |
| | | setting={config.setting} |
| | | ContainerId={ContainerId} |
| | | switchCard={() => {}} |
| | | refreshdata={this.props.refreshdata} |
| | | /> : null |
| | | } |
| | | {plot.over === 'roll' && data && data.length > 0 ? |
| | | <Tabs activeKey=""> |
| | | {data.map((item, i) => ( |
| | |
| | | switchCard={this.switchCard} |
| | | refreshdata={this.props.refreshdata} |
| | | />} key={i}></TabPane> |
| | | |
| | | ))} |
| | | {!loading && card.insertAction ? |
| | | <TabPane tab={<CardCell |
| | | type="insert" |
| | | BID={BID} |
| | | Tab={Tab} |
| | | card={card} |
| | | data={{key: 'insert'}} |
| | | BData={BData} |
| | | MenuID={MenuID} |
| | | setting={config.setting} |
| | | ContainerId={ContainerId} |
| | | switchCard={() => {}} |
| | | refreshdata={this.props.refreshdata} |
| | | />} key="insert"></TabPane> : null |
| | | } |
| | | </Tabs> : null |
| | | } |
| | | {!data || data.length === 0 ? <Empty description={false}/> : null} |
| | | {(loading || !card.insertAction) && (!data || data.length === 0) ? <Empty description={false}/> : null} |
| | | <div className="clear"></div> |
| | | </div> |
| | | ) |