index.tsx 5.2 KB
Newer Older
ada committed
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
import * as React from 'react'
import * as echarts from 'echarts'
import Card from '@components/Card'
import Table from '@components/Table'
import { addInterFn, removeInterFn } from '@utils/index'
import ZhsModal from '@components/ZhsModal';
import * as style from './style.scss'

export interface Left1Props {
}

export default class Left1 extends React.Component<Left1Props, {}> {
  state = {
    sumline1: {
      theme: '#1adbfe',
      icon: 'icon1',
      title: '刑事案件',
      anjianSum: 21,
      anjianIng: 24,
      anjianLeft: 24,
      catchNum: 5
    },
    sumline2: {
      theme: '#18cf90',
      icon: 'icon2',
      title: '行政案件',
      anjianSum: 24,
      anjianIng: 2,
      anjianLeft: 3,
      catchNum: 1
    },

    daily: {
      ZDJQ: 0,
      GZJQ: 1
    },
    month: {
      ZDJQ: 0,
      GZJQ: 1
    },
    showToast: false
  }

  pieContent: any = null;
  componentWillMount() {
    
  }
  componentDidMount() {
    this.renderPie()
    this.fetchJingQing = this.fetchJingQing.bind(this)
    this.fetchJingQing()
    // addInterFn(this.fetchJingQing, 10)
  }

  componentWillUnmount () {
    removeInterFn(this.fetchJingQing)
  }

  fetchJingQing() {
    let self = this
    fetch('http://50.88.20.34:8081/jksj/dpsj/jqquery.action').then((response: any) => {
      return response.json()
    }).then((data) => {
        if(data.code === '0') {
          self.setState({
            daily: data.result.DAY,
            month: data.result.MONTH
          })
        }
        self.renderPie()
    })
  }

  renderPie() {
    const resizePercent: number = (window as any)['resizePercent']

    var option: echarts.EChartOption = {
      color: ['#fc8e31', '#35dbdf'],
      title: {
        show: false,
      },
      tooltip: {
        trigger: 'item',
        formatter: "{a} <br/>{b} : {c} ({d}%)",
      },
      legend: {
        x: 'left',
        y: 'top',
        orient: 'vertical',
        data: ['重点警情', '关注警情'],
        itemWidth: 9,
        itemHeight: 9,
        textStyle: {
          color: '#b6deff',
          fontSize: 16 * resizePercent
        }
      },
      toolbox: {
        show: false
      },
      series: [
        {
          name: '警情',
          type: 'pie',
          radius: ['20%', '50%'],
          // roseType: 'radius',
          data: [
            { value: this.state.daily.ZDJQ, name: '重点警情' },
            { value: this.state.daily.GZJQ, name: '关注警情' }
          ],
          label: {
            formatter: [
              '{a|{c}}',
              '{b|{b}}'
            ].join('\n'),
            rich: {
              a: {
                fontSize: 32 * resizePercent,
                lineHeight: 10,
                align: 'center'
              },
              b: {
                height: 25,
              }
            }
          }
        }
      ]
    }

    var myChart = echarts.init(this.pieContent)


    myChart.setOption(option)
    myChart.on('click', (params: any) => {
      if(params.name === '关注警情') {
        
        this.setState({
          showToast: true
      })
      }
    })
    
  }

  closeModal() {
    this.setState({
        showToast: false
    })
}

  render() {
    return <div className={style.content}>
      <Card>
        <div className={style.all}>
          <div className={style.jingqingTable}>
            <Table img={require('./icon.png')} title={'警情态势'}>
              <div className={style.pieContent}>
                <div className={style.pie} ref={dom => this.pieContent = dom}></div>
                <div className={style.pieTable}>
                  <div className={style.line}>
                    <div className={style.item}>警情</div>
                    <div className={style.item}>今日</div>
                    <div className={style.item}>本月</div>
                  </div>
                  <div className={style.line}>
                    <div className={style.item}>关注</div>
                    <div className={style.item}>{this.state.daily.GZJQ}</div>
                    <div className={style.item}>{this.state.month.GZJQ}</div>
                  </div>
                  <div className={style.line}>
                    <div className={style.item}>重点</div>
                    <div className={style.item}>{this.state.daily.ZDJQ}</div>
                    <div className={style.item}>{this.state.month.ZDJQ}</div>
                  </div>
                </div>
              </div>
            </Table>
          </div>
        </div>
      </Card>
      <ZhsModal title="关注警情" showModal={this.state.showToast} onClose={this.closeModal.bind(this)}>
        <p>2019年04月06日14时01分22秒,江苏省南通市崇川区观音山镇通富路与通甲路老双毛毯厂着火,民警速至现场,此处为冯建春(32062419760322715X 电话13739144730)的织布厂操作车间发生火灾,具体原因不详,现场过火面积100平方左右,操作车间内的损失待进一步核实,民警现场维持秩序,协助消防救援,民警通知报警人陈夕梅(320624197011207163 电话15996585898),车间工人葛云芳(320624197506057187 电话13912298094)及冯建春到所进一步调查。</p>
      </ZhsModal>
    </div>
  }
}