import React,{Component} from 'react';
import {
Button, DatePicker,
Input,
message,
Select,
Spin,
Table, Tabs,
} from "antd";
import './index.less';
import $ from "jquery/src/ajax";
import CustomerDetails from './customerDetails';
import moment from "moment";
import {ChooseList} from "../../../order/orderNew/chooseList";
const { RangePicker } = DatePicker;
const { TabPane } = Tabs;
class DepartmentStatistics extends Component{
constructor(props) {
super(props);
this.state={
superId:undefined,
nameSearch: '',
releaseDate: [],
columns: [
{
title: "部门",
dataIndex: "name",
key: "name",
width: '25%',
},
{
title: "私有数",
dataIndex: "userCount",
key: "userCount",
className: 'tableRowStyle',
width: 120,
render: (text, record) => {
return (
{
if(record.aid){
e.stopPropagation();
this.setState({
customerVisible: true,
aid: record.aid,
aName: record.aName,
type: 0,
})
}
}}>
{text}
);
},
},
{
title: "渠道数",
dataIndex: "channelCount",
key: "channelCount",
className: 'tableRowStyle',
width: 120,
render: (text, record) => {
return (
{
if(record.aid){
e.stopPropagation();
this.setState({
customerVisible: true,
aid: record.aid,
aName: record.aName,
type: 1,
})
}
}}>
{text}
);
},
},
{
title: "签单数",
dataIndex: "signCount",
key: "signCount",
className: 'tableRowStyle',
width: 120,
render: (text, record) => {
return (
{
if(record.aid){
e.stopPropagation();
this.setState({
customerVisible: true,
aName: record.aName,
aid: record.aid,
type: 2,
})
}
}}>
{text}
);
},
},
{
title: "私有新增数",
dataIndex: "newCount",
key: "newCount",
className: 'tableRowStyle',
width: 120,
render: (text, record) => {
return (
{
if(record.aid){
e.stopPropagation();
this.setState({
customerVisible: true,
aName: record.aName,
aid: record.aid,
type: 3,
})
}
}}>
{text}
);
},
},
{
title: "渠道新增数",
dataIndex: "channelNewCount",
key: "channelNewCount",
className: 'tableRowStyle',
width: 120,
render: (text, record) => {
return (
{
if(record.aid){
e.stopPropagation();
this.setState({
customerVisible: true,
aName: record.aName,
aid: record.aid,
type: 4,
})
}
}}>
{text}
);
},
},
{
title: "私有面谈数",
dataIndex: "completeCount",
key: "completeCount",
className: 'tableRowStyle',
width: 120,
render: (text, record) => {
return (
{
if(record.aid){
e.stopPropagation();
this.setState({
customerVisible: true,
aName: record.aName,
aid: record.aid,
type: 5,
})
}
}}>
{text}
);
},
},
{
title: "渠道面谈数",
dataIndex: "channelCompleteCount",
key: "channelCompleteCount",
className: 'tableRowStyle',
width: 120,
render: (text, record) => {
return (
{
if(record.aid){
e.stopPropagation();
this.setState({
customerVisible: true,
aName: record.aName,
aid: record.aid,
type: 6,
})
}
}}>
{text}
);
},
},
{
title: "私有领取数",
dataIndex: "receiveCount",
key: "receiveCount",
className: 'tableRowStyle',
width: 120,
render: (text, record) => {
return (
{
if(record.aid){
e.stopPropagation();
this.setState({
customerVisible: true,
aName: record.aName,
aid: record.aid,
type: 7,
})
}
}}>
{text}
);
},
},
],
contactsOption:null,
loading: false,
ispage: 1,
aid:'',
type:'',
visible:false,
};
this.loadData = this.loadData.bind(this);
this.reset = this.reset.bind(this);
this.selectSuperId = this.selectSuperId.bind(this);
this.changeList = this.changeList.bind(this);
}
componentDidMount() {
this.selectSuperId();
}
loadData() {
if(!this.state.superId){
message.warning('请选择部门后再搜索')
return;
}
this.setState({
loading: true,
});
let api = '/api/admin/customer/selectAllUser';
let data = {};
if(this.state.superId){
data.depId = this.state.superId;
}
if(this.state.nameSearch){
data.aName = this.state.nameSearch;
}
if(this.state.releaseDate[0]){
data.startTime = this.state.releaseDate[0]
}
if(this.state.releaseDate[1]){
data.endTime = this.state.releaseDate[1]
}
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + api,
data: data,
success: function (data) {
let theArr = [];
if (data.error.length !== 0) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
} else {
data.data.children = data.data.list;
data.data.children = data.data.children.concat(data.data.aList);
theArr.push(data.data);
theArr = this.handleTabsInfor(theArr);
this.setState({
ispage: data.data.pageNo,
dataSource: theArr,
});
}
}.bind(this),
}).always(
function () {
this.setState({
loading: false,
});
}.bind(this)
);
};
//表格数据处理
handleTabsInfor(infor){
for(let i=0;i{
this.loadData();
});
};
//获取上级组织
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 = {};
};
for(var i=0;i{theData.name}
);
theId.push(
[theData.id,theData.name]
);
};
this.setState({
SuperArr:thedata,
contactsOption: theArr,
theId: theId,
orderStatusOptions:data.data,
});
if(!this.state.superId){
this.setState({
superId:data.data[0].id
},()=>{
this.loadData();
})
}
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
}
changeList(arr) {
const newArr = [];
this.state.columns.forEach(item => {
arr.forEach(val => {
if (val === item.title) {
newArr.push(item);
}
});
});
this.setState({
changeList: newArr
});
}
render() {
return(
部门统计
{
this.setState({ nameSearch: e.target.value });
}}
/>
{
this.setState({ releaseDate: dataString });
}}
/>
{this.state.customerVisible ?
{
this.setState({
customerVisible: false,
aid: '',
type: '',
})
}}
/> : }
)
}
}
export default DepartmentStatistics;