import React from 'react'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; import "./statistics.less"; import { Button, Table, Spin, message, Tabs, DatePicker, Select } from 'antd'; var intentionalService = []; const TabPane = Tabs.TabPane; import moment from 'moment'; import {ChooseList} from "../../order/orderNew/chooseList"; const VisitStatistics = React.createClass({ loadData(pageNo, nub) { this.state.data = []; this.setState({ loading: true }); let urls = ''; switch(nub) { case "1": urls = ""; break; //日 case "2": urls = "daySpan"; break; //日 case "3": urls = "weekSpan"; break; //周 case "4": urls = "monthSpan"; break; //月 case "5": urls = "quarterSpan"; break; //季 case "6": urls = "yearSpan"; break; //年 default: urls = ''; } $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/followStatistic", data: { pageNo: pageNo || 1, pageSize: this.state.pagination.pageSize, startDate: this.state.releaseDate[0], endDate: this.state.releaseDate[1], timeSpan: this.state.releaseDate[0] ? '' : urls, depId: this.state.depId, depNo:this.state.departmentt }, success: function(data) { let theArr = []; if(!data.data || !data.data.list) { if(data.error && data.error.length) { message.warning(data.error[0].message); }; } else { for(let i = 0; i < data.data.list.length; i++) { let thisdata = data.data.list[i]; theArr.push({ key: i, id: thisdata.id, adminName: thisdata.adminName, departmentName: thisdata.departmentName, followNo: thisdata.followNo, customerNo: thisdata.customerNo, telNo: thisdata.telNo, qqNo: thisdata.qqNo, visitNo: thisdata.visitNo, emailNo: thisdata.emailNo, letterNo: thisdata.letterNo, wxNo: thisdata.wxNo, }); }; this.state.pagination.current = data.data.pageNo; this.state.pagination.total = data.data.totalCount; }; if(!data.data.list.length){ this.state.pagination.current=0; this.state.pagination.total=0; } this.setState({ dataSource: theArr, pagination: this.state.pagination }); }.bind(this), }).always(function() { this.setState({ loading: false }); }.bind(this)); }, getInitialState() { return { releaseDate: [], loading: false, callnub: '1', pagination: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize: 10, onChange: function(page) { this.call(page) }.bind(this), showTotal: function(total) { return '共' + total + '条数据'; } }, columns: [{ title: '营销员', dataIndex: 'adminName', key: 'adminName', }, { title: '部门', dataIndex: 'departmentName', key: 'departmentName', }, { title: '拜访次数', dataIndex: 'followNo', key: 'followNo', }, { title: '拜访客户数', dataIndex: 'customerNo', key: 'customerNo', }, { title: '电话量', dataIndex: 'telNo', key: 'telNo', }, { title: '外拜量', dataIndex: 'visitNo', key: 'visitNo', }, { title: 'QQ量', dataIndex: 'qqNo', key: 'qqNo', }, { title: '邮件量', dataIndex: 'emailNo', key: 'emailNo', }, { title: '书信量', dataIndex: 'letterNo', key: 'letterNo', }, { title: '微信量', dataIndex: 'wxNo', key: 'wxNo', }, ] } }, callback(e) { this.setState({ callnub: e, releaseDate: [] }) this.loadData(1, e) }, call(a) { this.loadData(a, this.state.callnub) }, search() { if(this.state.releaseDate[0]) { this.setState({ callnub: '1' }) } else { this.state.releaseDate = [] } this.loadData(1, this.state.callnub) }, //部门 departmentList() { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/organization/selectSuperId", data: { }, success: function(data) { let thedata = data.data; let theArr=[]; if(!thedata) { if(data.error && data.error.length) { message.warning(data.error[0].message); }; thedata = {}; }else{ thedata.map(function(item,index){ theArr.push({ key:index, name:item.name, id:item.id, depNo:item.depNo }) }) } this.setState({ departmentArr:theArr, }) }.bind(this), }).always(function() { this.setState({ loading: false }); }.bind(this)); }, reset() { this.state.departmentt=undefined; this.state.releaseDate = []; this.loadData(1, this.state.callnub); }, componentWillMount() { this.loadData(); this.departmentList() }, changeList(arr) { const newArr = []; this.state.columns.forEach(item => { arr.forEach(val => { if (val === item.title) { newArr.push(item); } }); }); this.setState({ changeList: newArr }); }, render() { const { RangePicker } = DatePicker; let departmentArr = this.state.departmentArr || []; return