forked from nsjcy/frontEnd/nsjcy

LAPTOP-RI7D261L\Mr Ke
2020-02-04 d25d5769416fbb2e861e8f434c5a6770ff69c482
SunshineIns/src/view/BulidMakingView/index.jsx
@@ -1,18 +1,296 @@
/**
 * 徐祥健<xuxj@hugeinfo.com.cn>
 * 2018年7月22日 16:40
 * 刘文浩<xuxj@hugeinfo.com.cn>
 * 2019年9月27日 16:42
 *
 */
import React from 'react';
import './style.scss';
import { Table, Card, Button, Upload, Icon, message } from 'antd';
import Fetch from '../../fetch';
import { domain } from '../../fetch/_fetch';
import moment from 'moment';
export default function BulidMakingView({ loading }) {
  return (
    <div className="bulid-making-view-main">
      功能开发中......
    </div>
  );
export default class BulidMakingView extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      data: null,
      loading: false,
    };
  }
  componentDidMount() {
    // const { id } = this.props.match.params;
    console.log(1111)
    this.loadstate();
  }
  loadstate = () => {
    Fetch.finds().then(res => {
      if (res.code === 0) {
        console.log(res.data)
        this.setState({
          data: res.data
        })
      } else {
        message.error(res.msg, 2)
      }
    })
  }
  render() {
    // 业务报表
    const columns = [
      {
        title: '日期',
        dataIndex: 'date',
        render: (value, row, index) => {
          const obj = {
            children: moment(new Date()).format("YYYY") + '年',
            props: {},
          };
          if (index === 0) {
            obj.props.rowSpan = 4;
          } if (index === 1) {
            obj.props.rowSpan = 0;
          } if (index === 2) {
            obj.props.rowSpan = 0;
          } if (index === 3) {
            obj.props.rowSpan = 0;
          }
          return obj;
        },
      },
      {
        title: '类型',
        className: 'column-type',
        dataIndex: 'type',
      },
      {
        title: '在线申诉',
        className: 'column-appeal',
        dataIndex: 'appeal',
      },
      {
        title: '国家赔偿',
        className: 'column-compensate',
        dataIndex: 'compensate',
      },
      {
        title: '信访预约',
        className: 'column-appointment',
        dataIndex: 'appointment',
      },
      {
        title: '司法救助',
        className: 'column-judicial',
        dataIndex: 'judicial',
      },
    ];
    //事项申请报表
    const columns1 = [
      {
        title: '日期',
        dataIndex: 'date',
        render: (value, row, index) => {
          const obj = {
            children: moment(new Date()).format("YYYY") + '年',
            props: {},
          };
          if (index === 0) {
            obj.props.rowSpan = 4;
          } if (index === 1) {
            obj.props.rowSpan = 0;
          } if (index === 2) {
            obj.props.rowSpan = 0;
          } if (index === 3) {
            obj.props.rowSpan = 0;
          }
          return obj;
        },
      },
      {
        title: '类型',
        className: 'column-type',
        dataIndex: 'type',
      },
      {
        title: '申请司法救助',
        className: 'column-judicial ',
        dataIndex: 'judicial',
      },
      {
        title: '申请国家赔偿',
        className: 'column-compensate',
        dataIndex: 'compensate',
      },
      {
        title: '申请活动报名',
        className: 'column-registration',
        dataIndex: 'registration',
      },
      {
        title: '其他申请',
        className: 'column-otherApply',
        dataIndex: 'otherApply',
      },
    ];
    //账号报表
    const columns2 = [
      {
        title: '类型',
        className: 'column-type',
        dataIndex: 'type',
      },
      {
        title: '启动中',
        className: 'column-appeal',
        dataIndex: 'using',
      },
      {
        title: '停用',
        className: 'column-damage',
        dataIndex: 'stop',
      },
      {
        title: '总览',
        className: 'column-petition',
        dataIndex: 'petition',
        render: (text, record) => {
          return record.using ? (Number(record.using) + Number(record.stop)) : ''
        }
      }
    ];
    //投诉建议报表
    const columns3 = [
      {
        title: '日期',
        dataIndex: 'date',
        render: (value, row, index) => {
          const obj = {
            children: moment(new Date()).format("YYYY") + '年',
            props: {},
          };
          if (index === 0) {
            obj.props.rowSpan = 4;
          } if (index === 1) {
            obj.props.rowSpan = 0;
          } if (index === 2) {
            obj.props.rowSpan = 0;
          } if (index === 3) {
            obj.props.rowSpan = 0;
          }
          return obj;
        },
      },
      {
        title: '类型',
        className: 'column-type',
        dataIndex: 'type',
      },
      {
        title: '扫黑除恶',
        className: 'column-purify',
        dataIndex: 'purify',
      },
      {
        title: '公益诉讼',
        className: 'column-welfare',
        dataIndex: 'welfare',
      },
      {
        title: '信访投诉',
        className: 'column-petition',
        dataIndex: 'petition',
      },
      {
        title: '其他投诉',
        className: 'column-otherComplaint',
        dataIndex: 'otherComplaint',
      },
    ];
    const { data } = this.state;
    const props = {
      multiple: false,
      showUploadList: false,
      name: 'excel',
      action: domain + `api/statistics/importExcel`,
      headers: {
        authorization: 'authorization-text',
      },
      onChange: (info) => {
        if (info.file.status !== 'uploading') {
          console.log(info.file, info.fileList);
        }
        if (info.file.response.code === 0) {
          message.success(`${info.file.name}导入成功!`);
          console.log('刷新页面')
          this.loadstate()
        } else if (info.file.response.code === -1) {
          message.error(`${info.file.name} 导入失败!`);
        }else {
          message.error(`${info.file.name} 导入异常!`);
        }
      },
    };
    return (
      <div className="bulid-making-view-main">
        <div className='bulid-making-view-button'>
          <Upload {...props}>
            <Button type="primary" size="large" className="bulid-making-view-margin">一键导入</Button>
          </Upload>
          <Button size="large" className="bulid-making-view-margin"><a href={domain + `api/statistics/export`}>一键导出</a></Button>
        </div>
        <div className="bulid-making-view-row">
          <Card title="业务报表" hoverable className="bulid-making-view-row-table bulid-making-view-marginTop">
            <Table
              className="bulid-making-view-row-table1"
              columns={columns}
              dataSource={data ? data.businessReportList : []}
              pagination={false}
              bordered
            />
          </Card>
          <Card title="事项申请报表" hoverable className="bulid-making-view-row-table bulid-making-view-marginTop">
            <Table
              className="bulid-making-view-row-table1"
              columns={columns1}
              dataSource={data ? data.applyReportList : []}
              pagination={false}
              bordered
            />
          </Card>
        </div>
        <div className="bulid-making-view-row">
          <Card title="账号报表" hoverable className="bulid-making-view-row-table">
            <Table
              className="bulid-making-view-row-table1"
              columns={columns2}
              dataSource={data ? data.accountReportList : []}
              pagination={false}
              bordered
            />
          </Card>
          <Card title="投诉建议报表" hoverable className="bulid-making-view-row-table">
            <Table
              className="bulid-making-view-row-table1"
              columns={columns3}
              dataSource={data ? data.complaintReportList : []}
              pagination={false}
              bordered
            />
          </Card>
        </div>
      </div>
    );
  }
}