import React from 'react'; import { Select, Spin, Input, Table, Button ,DatePicker, Form , Tabs , Switch,message} from 'antd'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; import './report.less'; import DiurnalStatisticsOne from './timeStatisticsOne.jsx'; import { post } from '../../../dataDic.js'; import moment from 'moment'; import {ChooseList} from "../../order/orderNew/chooseList"; const TabPane = Tabs.TabPane; const DiurnalStatistics = React.createClass({ loadData(timeTypes,totalArr) { let total=totalArr; this.setState({ loading: true, timeTypes:timeTypes }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/report/sales/sometimeMarketingStatistics", data: { type:'1', timeType:this.state.releaseDate[0]?4:timeTypes, startTime: this.state.releaseDate[0], endTime: this.state.releaseDate[1], depId:this.state.superId,//部门机构 }, 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) { let nub=index+1; theArr.push({ key: index, theNumber:false, nub:nub, id: item.id, departmentId:item.departmentId,//部门ID departmentName:item.departmentName,//部门名称 departmentManagerName:item.departmentManagerName,//部门负责人名称 roleName:item.roleName, //角色职位 countVisitNo:item.countVisitNo,//拜访量 countTelNo:item.countTelNo,//电话量 countFollowNo:item.countFollowNo,//总量 dayAVG:parseFloat(item.dayAVG).toFixed(2),//营销日均量 }) }) } if(theArr.length){ theArr.push( { key:9999999, theNumber:true, departmentName:'合计', countVisitNo:total.countVisitNo,//拜访量 countTelNo:total.countTelNo,//电话量 countFollowNo:total.countFollowNo,//总量 dayAVG:parseFloat(total.dayAVG).toFixed(2),//营销日均量 } ) } this.setState({ dataSource: theArr, }) }.bind(this), }).always(function() { this.setState({ loading: false }); }.bind(this)); }, totalData(timeTypes) { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/report/sales/countsometimeMarketingStatistics", data: { type:'1', timeType:this.state.releaseDate[0]?4:timeTypes, startTime: this.state.releaseDate[0], endTime: this.state.releaseDate[1], depId:this.state.superId,//部门机构 }, success: function(data) { let thedata = data.data; let theArr = []; if(!thedata) { if(data.error && data.error.length) { message.warning(data.error[0].message); }; thedata = {}; } this.loadData(timeTypes,thedata) this.selectSuperId(); }.bind(this), }).always(function() { this.setState({ loading: false }); }.bind(this)); }, //时间选择 selTime(value,index){ this.setState({ Dtime:value, selTime:index }) }, //获取上级组织 selectSuperId() { this.state.data = [] $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/organization/selectSuperId", data:{ }, success: function (data) { let theArr = []; let theId=[];//用于保存上级组织的ID和名称 let thedata=data.data; if (!thedata) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; thedata = {}; }; var contactIds=[]; for(var i=0;i{theData.name} ); theId.push( [theData.id,theData.name] ); }; this.setState({ SuperArr:thedata, contactsOption: theArr, theId: theId, orderStatusOptions:data.data, }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, //判断浏览器类型 getExplorer() { var explorer = window.navigator.userAgent; //ie if(explorer.indexOf("MSIE") >= 0) { return 'ie'; } //firefox else if(explorer.indexOf("Firefox") >= 0) { return 'Firefox'; } //Chrome else if(explorer.indexOf("Chrome") >= 0) { return 'Chrome'; } //Opera else if(explorer.indexOf("Opera") >= 0) { return 'Opera'; } //Safari else if(explorer.indexOf("Safari") >= 0) { return 'Safari'; } }, //导出为exel表格 tabExel() { var table = document.querySelector('#daochu'); var idTmr; //debugger; //整个表格拷贝到EXCEL中 if(this.getExplorer() == 'ie') { var curTbl = document.getElementById(tableid); var oXL = new ActiveXObject("Excel.Application"); //创建AX对象excel var oWB = oXL.Workbooks.Add(); //获取workbook对象 var xlsheet = oWB.Worksheets(1); //激活当前sheet var sel = document.body.createTextRange(); sel.moveToElementText(curTbl); //把表格中的内容移到TextRange中 sel.select(); //全选TextRange中内容 sel.execCommand("Copy"); //复制TextRange中内容 xlsheet.Paste(); //粘贴到活动的EXCEL中 oXL.Visible = true; //设置excel可见属性 try { var fname = oXL.Application.GetSaveAsFilename("Excel.xls", "Excel Spreadsheets (*.xls), *.xls"); } catch(e) { print("Nested catch caught " + e); } finally { oWB.SaveAs(fname); oWB.Close(savechanges = false); //xls.visible = false; oXL.Quit(); oXL = null; //结束excel进程,退出完成 //window.setInterval("Cleanup();",1); idTmr = window.setInterval("Cleanup();", 1); } } else { this.tableToExcel(table,this.getExplorer()); } function Cleanup() { window.clearInterval(idTmr); CollectGarbage(); } }, tableToExcel(table,name) { var uri = 'data:application/vnd.ms-excel;base64,', template = '{table}
', base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) } if(!table.nodeType) table = document.getElementById(table); var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML }; window.location.href = uri + base64(format(template, ctx)) }, getInitialState() { return { releaseDate: [], selectedRowKeys: [], selectedRows: [], loading: false, visible: false, showDesc: false, timeState:false, weekColor:true, monthColor:false, quarterColor:false, yearColor:false, Dtime:undefined, timeTypes:0, selTime:'', columns: [ { title: '序号', dataIndex: 'nub', width:50, key: 'nub', fixed:false, render:(text,record)=>{ if(!record.theNumber){ return text }else{ return { children: text, props: { colSpan:0 }, } } } }, { title: '部门', dataIndex: 'departmentName', key: 'departmentName', width:230, fixed:false, render:(text,record)=>{ if(!record.theNumber){ return text//&&text.length>6?{text.substr(0,6)+'…'}:text }else{ return { children: text, props: { colSpan:3 }, } } } }, { title: '总经理', fixed:false, dataIndex: 'departmentManagerName', key: 'departmentManagerName', render:(text,record)=>{ if(!record.theNumber){ return text }else{ return { children: text, props: { colSpan:0 }, } } } }, { title: '营销总量', fixed:false, dataIndex: 'countFollowNo', key: 'countFollowNo', sorter: (a, b) => a.countFollowNo - b.countFollowNo, render:(text,record)=>{ if(!record.theNumber){ return text }else{ return { children: text, props: { colSpan:1 }, } } } }, { title: '电话量', fixed:false, dataIndex: 'countTelNo', key: 'countTelNo', sorter: (a, b) => a.countTelNo - b.countTelNo, render:(text,record)=>{ if(!record.theNumber){ return text }else{ return { children: text, props: { colSpan:1 }, } } } }, { title: '外拜量', fixed:false, dataIndex: 'countVisitNo', key: 'countVisitNo', sorter: (a, b) => a.countVisitNo - b.countVisitNo, render:(text,record)=>{ if(!record.theNumber){ return text }else{ return { children: text, props: { colSpan:1 }, } } } }, { title: '营销日均量', fixed:false, dataIndex: 'dayAVG', key: 'dayAVG', sorter: (a, b) => a.dayAVG - b.dayAVG, render:(text,record)=>{ if(!record.theNumber){ return text }else{ return { children: text, props: { colSpan:1 }, } } } } ], dataSource: [], }; }, search() { this.totalData(this.state.timeTypes); }, reset() { this.state.superId = undefined;//部门机构清零 this.totalData(0) this.setState({ order:"false" }) }, week(){ this.state.releaseDate[0] = undefined;//开始时间清零 this.state.releaseDate[1] = undefined;//结束时间清零 this.totalData(0); this.setState({ weekColor:true, monthColor:false, quarterColor:false, yearColor:false }) }, month(){ this.state.releaseDate[0] = undefined;//开始时间清零 this.state.releaseDate[1] = undefined;//结束时间清零 this.totalData(1); this.setState({ weekColor:false, monthColor:true, quarterColor:false, yearColor:false }) }, quarter(){ this.state.releaseDate[0] = undefined;//开始时间清零 this.state.releaseDate[1] = undefined;//结束时间清零 this.totalData(2); this.setState({ weekColor:false, monthColor:false, quarterColor:true, yearColor:false }) }, year(){ this.state.releaseDate[0] = undefined;//开始时间清零 this.state.releaseDate[1] = undefined;//结束时间清零 this.totalData(3); this.setState({ weekColor:false, monthColor:false, quarterColor:false, yearColor:true }) }, //重构排序 tabChange(pagination,filter,sorter){ // console.log(pagination) // console.log(sorter) }, componentWillMount() { //this.loadData(); this.totalData(0); let times=new Date(); let nowTime=times.getFullYear()+'年'+(times.getMonth()+1)+'月'+times.getDate()+'日'; this.setState({ Nowtime:nowTime }) }, 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(

客户营销统计表(部门)

部门机构 : 起止时间: { this.setState({ releaseDate: dataString }); }} />
) } }); const Tablees=Form.create()(React.createClass({ //详情tab切换数据处理 callbacks(e) { this.setState({ callnubs: e, }) if(e == '1') { } if(e == '2') { } }, getInitialState() { return { callnubs: "1", } }, render() { return(
); } })); export default Tablees;