import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { is, fromJS } from 'immutable'
|
import { Card, Icon } from 'antd'
|
|
import Utils from '@/utils/utils.js'
|
import zhCN from '@/locales/zh-CN/model.js'
|
import enUS from '@/locales/en-US/model.js'
|
// import ChartCompileForm from './chartcompile'
|
|
import DragDetail from './dragdetail'
|
import './index.scss'
|
|
// const { Meta } = Card
|
|
class LineChart extends Component {
|
static propTpyes = {
|
card: PropTypes.object,
|
config: PropTypes.object,
|
plotchange: PropTypes.func
|
}
|
|
state = {
|
dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS,
|
visible: true,
|
cardcell: null // 卡片元素
|
}
|
|
componentDidMount () {
|
|
}
|
|
UNSAFE_componentWillReceiveProps (nextProps) {
|
if (!is(fromJS(this.props.card), fromJS(nextProps.card))) {
|
|
}
|
}
|
|
|
plotChange = (values) => {
|
const { card, config } = this.props
|
let _card = {...card, ...values}
|
let _charts = fromJS(config.charts).toJS()
|
|
_charts = _charts.map(item => {
|
if (item.uuid === _card.uuid) {
|
return _card
|
}
|
return item
|
})
|
|
this.props.plotchange({...config, charts: _charts})
|
}
|
|
handleList = (list) => {
|
this.plotChange({details: list})
|
}
|
|
editdetail = (_cell) => {
|
if (!_cell) {
|
_cell = {uuid: Utils.getuuid()}
|
}
|
|
this.setState({
|
cardcell: _cell
|
})
|
|
}
|
|
deletedetail = () => {
|
|
}
|
|
render() {
|
const { card } = this.props
|
|
return (
|
<div className="line-card-edit-box">
|
{card.title ? <p className="chart-title">{card.title}</p> : null}
|
{card.cardType === 'card1' ? <Card
|
className={card.widthType === 'ratio' ? 'ant-col ant-col-' + card.cardWidth : ''}
|
style={card.widthType === 'absolute' ? { width: card.cardWidth } : null}
|
>
|
<div className="ant-card-meta">
|
<Icon type="plus" onClick={this.editdetail} />
|
<DragDetail
|
list={card.details}
|
handleList={this.handleList}
|
handleMenu={this.editdetail}
|
deleteMenu={this.deletedetail}
|
/>
|
</div>
|
</Card> : null}
|
{/* <Card
|
className={card.widthType === 'ratio' ? 'ant-col ant-col-' + card.cardWidth : ''}
|
style={card.widthType === 'absolute' ? { width: card.cardWidth } : null}
|
>
|
<Meta
|
avatar={
|
<Avatar size={64} src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" />
|
}
|
title="Card title"
|
description="This is the description"
|
/>
|
</Card> */}
|
{/* <ChartCompileForm
|
plot={plot}
|
type={plot.chartType}
|
config={this.props.config}
|
dict={this.state.dict}
|
plotchange={this.plotChange}
|
/> */}
|
</div>
|
)
|
}
|
}
|
|
export default LineChart
|