king
2020-05-14 eb31b84962c192de57abbb473cb4733a09bf4363
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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