king
2021-11-12 0c84df247914f893ef5e41d57a422e10a2dc814c
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
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Progress } from 'antd'
 
// import './index.scss'
 
class MkProgress extends Component {
  static propTpyes = {
    config: PropTypes.object,
    value: PropTypes.any
  }
 
  render() {
    const { value, config } = this.props
 
    let type = config.showType || 'line'
 
    if (type === 'line') {
      return <Progress percent={value} type="line" className={config.strokeLinecap || ''} strokeWidth={config.strokeWidth || 8} strokeColor={config.color} showInfo={config.showInfo === 'true'}/>
    }
 
    let width = config.outlineWidth || 0
 
    if (this.progress && (!width || width > this.progress.clientWidth)) {
      width = this.progress.clientWidth
    }
 
    return (
      <div ref={(ref) => this.progress = ref } style={{textAlign: config.textAlign || 'left'}}>
        <Progress percent={value} width={width} type={type} strokeLinecap={config.strokeLinecap || 'round'} strokeWidth={config.strokeWidth || 8} strokeColor={config.color} showInfo={config.showInfo === 'true'}/>
      </div>
    )
  }
}
 
export default MkProgress