import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { is, fromJS } from 'immutable'
|
import { Col } from 'antd'
|
|
import asyncComponent from '@/utils/asyncComponent'
|
import zhCN from '@/locales/zh-CN/model.js'
|
import enUS from '@/locales/en-US/model.js'
|
|
import './index.scss'
|
|
const CardCellComponent = asyncComponent(() => import('../cardcellList'))
|
|
class CardBoxComponent extends Component {
|
static propTpyes = {
|
cards: PropTypes.object, // 卡片行配置信息
|
card: PropTypes.object, // 卡片配置信息
|
data: PropTypes.object
|
}
|
|
state = {
|
dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
|
card: null, // 卡片信息,包括正反面
|
}
|
|
/**
|
* @description 搜索条件初始化
|
*/
|
UNSAFE_componentWillMount () {
|
|
}
|
|
shouldComponentUpdate (nextProps, nextState) {
|
return !is(fromJS(this.state), fromJS(nextState))
|
}
|
|
/**
|
* @description 组件销毁,清除state更新,清除快捷键设置
|
*/
|
componentWillUnmount () {
|
this.setState = () => {
|
return
|
}
|
}
|
|
render() {
|
const { card, data } = this.props
|
|
return (
|
<Col span={card.setting.width || 6}>
|
<div className="card-item-box" style={card.style}>
|
<CardCellComponent data={data} elements={card.elements}/>
|
</div>
|
</Col>
|
)
|
}
|
}
|
|
export default CardBoxComponent
|