import React,{Component} from "react";
import {
AutoComplete,
Button,
Cascader,
DatePicker,
Icon,
Input,
message, Modal,
Select,
Spin,
Table,
Tabs,
Upload
} from "antd";
import {ChooseList} from "../../../order/orderNew/chooseList";
import $ from "jquery/src/ajax";
import {
getSocialAttribute,
ShowModal
} from "@/tools.js";
import { citySelect, provinceList } from '@/NewDicProvinceList';
import moment from "moment";
import FollowDetail from "./followDetail";
import IntentionDetail from "./intentionDetail/intentionDetail";
import TransferRecords from './transferRecords';
import DuplicateData from './duplicateData';
const {TabPane} = Tabs;
const { RangePicker } = DatePicker;
class Channel extends Component{
constructor(props) {
super(props);
this.state={
columns: [
{
title: "客户名称",
dataIndex: "userName",
key: "userName",
},
{
title: "地区",
dataIndex: "locationProvince",
key: "locationProvince",
},
{
title: "社会性质",
dataIndex: "societyTag",
key: "societyTag",
render: (text) => {
return getSocialAttribute(text);
},
},
{
title: "渠道专员",
dataIndex: "aName",
key: "aName",
},
{
title: "客户联系人",
dataIndex: "contacts",
key: "contacts",
},
{
title: "联系电话",
dataIndex: "contactMobile",
key: "contactMobile",
},
{
title: "渠道初始时间",
dataIndex: "createTimes",
key: "createTimes",
},
{
title: "分配状态",
dataIndex: "status",
key: "status",
render: (text) => (
text === 0 ? '未分配' :
text === 1 ? '已存在' :
text === 2 ? '已分配' : ''
)
},
],
changeList:[],
dataSource:[],
pagination: {
defaultCurrent: 1,
defaultPageSize: 10,
showQuickJumper: true,
pageSize: 10,
onChange: function (page) {
this.loadData(page);
}.bind(this),
showTotal: function (total) {
return "共" + total + "条数据";
},
},
pageNo:1,
listLoading:false,
selectedRowKeys:[],
selectedRows:[],
modalVisible:false,
recordt:'',
nameSearch:'',
statusSearch:undefined,
provinceSearch:undefined,
addressSearch:[],
releaseDate:[],
upLoad: {
name: "file",
action: globalConfig.context + "/api/user/channel/import",
headers: {
authorization: "authorization-text"
},
onChange: info => {
if (info.file.status === "done") {
if (info.file.response && info.file.response.error.length === 0) {
if(info.file.response.data.list.length > 0){
this.setState({
duplicateData: [],
duplicateDataVisible: true
})
}else{
message.success("导入成功!");
this.loadData();
}
} else {
message.warning(info.file.response.error[0].message);
}
}
}
},
followData: '',
visitModul: false,
categoryArr:[],
tabsKey:'',
reasonsTransfer:''
}
this.loadData = this.loadData.bind(this);
this.search = this.search.bind(this);
this.reset = this.reset.bind(this);
this.changeList = this.changeList.bind(this);
this.download = this.download.bind(this);
this.category = this.category.bind(this);
this.closeDesc = this.closeDesc.bind(this);
this.guidanceRead = this.guidanceRead.bind(this);
this.tableRowClick = this.tableRowClick.bind(this);
this.detailCloseDesc = this.detailCloseDesc.bind(this);
this.supervisor = this.supervisor.bind(this);
this.httpChange = this.httpChange.bind(this);
this.blurChange = this.blurChange.bind(this);
this.selectAuto = this.selectAuto.bind(this);
this.changeAssigner = this.changeAssigner.bind(this);
}
componentDidMount() {
//城市
let provinces = [];
provinceList.map(function (item) {
var id = String(item.id);
provinces.push(
{item.name}
);
});
this.setState({
provinces
})
this.loadData();
this.category();
if(this.props.followUp){
this.state.columns.push({
title: "跟进操作",
dataIndex: "abc",
key: "abc",
render: (text, record, index) => {
return (
);
},
});
this.state.columns.push({
title: "指导意见",
dataIndex: "guidance",
key: "guidance",
render: (text, record, index) => {
return (
{/*指导 0无 1未读 2已读*/}
{text === 1 || text === 2 ?
:
暂无指导
}
);
},
});
this.setState({
columns:this.state.columns
})
}
}
visit(e) {
this.setState({
followData: e,
visitModul: true,
});
}
loadData(pageNo) {
this.setState({
listLoading: true,
});
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/customer/listChannelCustomer',
data: {
pageNo: pageNo || 1,
pageSize: this.state.pagination.pageSize,
name: this.state.nameSearch,
status:this.state.statusSearch,
province: !this.state.addressSearch.length
? this.state.provinceSearch
: this.state.addressSearch[0],
city: !this.state.addressSearch.length
? ""
: this.state.addressSearch[1],
startTime: this.state.releaseDate[0],
endTime: this.state.releaseDate[1],
},
success: function (data) {
ShowModal(this);
let theArr = [];
if (data.error.length > 0) {
message.warning(data.error[0].message);
} else {
for (let i = 0; i < data.data.list.length; i++) {
let thisdata = data.data.list[i];
let diqu =
(thisdata.province == null ? "" : thisdata.province) +
(thisdata.city == null ? "" : "-" + thisdata.city) +
(thisdata.area == null ? "" : "-" + thisdata.area);
thisdata.key = i;
thisdata.id = thisdata.uid;
thisdata.lastFollowTime = thisdata.lastFollowTime &&
thisdata.lastFollowTime.split(" ")[0];
thisdata.transferTime= thisdata.transferTime && thisdata.transferTime.split(" ")[0];
thisdata.surplusFollowTime = thisdata.surplusFollowTime && thisdata.surplusFollowTime.split(" ")[0];
thisdata.surplusSignTime = thisdata.surplusSignTime && thisdata.surplusSignTime.split(" ")[0];
thisdata.locationProvince = diqu;
theArr.push(thisdata);
}
this.state.pagination.current = data.data.pageNo;
this.state.pagination.total = data.data.totalCount;
this.setState({
pageNo: data.data.pageNo,
dataSource: theArr,
pagination: this.state.pagination,
})
}
}.bind(this),
}).always(
function () {
this.setState({
listLoading: false,
});
}.bind(this)
);
}
search(){
this.loadData();
}
reset(){
this.setState({
nameSearch:'',
provinceSearch:undefined,
addressSearch:[],
releaseDate:[],
statusSearch:undefined,
})
}
download() {
window.location.href =
globalConfig.context +
"/api/user/channel/downloadTemplate?" +
"sign=user_channel";
}
changeList(arr) {
const newArr = [];
this.state.columns.forEach(item => {
arr.forEach(val => {
if (val === item.title) {
newArr.push(item);
}
});
});
this.setState({
changeList: newArr
});
}
category() {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/Varieties/getSuperList",
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({
value: item.id,
key: item.cname,
});
});
}
this.setState({
categoryArr: theArr,
});
}.bind(this),
});
}
closeDesc(){
this.setState({
categoryArr:[],
followData:'',
visitModul:false
})
}
//已读指导记录
guidanceRead(id) {
return new Promise((resolve,reject)=>{
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/customer/pushGuidance",
data: {
uid: id,
}
}).done(function(data) {
if(!data.error.length) {
resolve();
} else {
message.warning(data.error[0].message);
reject();
};
}.bind(this));
})
}
tableRowClick(record) {
this.setState({
rowData:record,
modalVisible: true,
basicState: true,
contactState: true,
modalName: record.userName
})
}
detailCloseDesc(){
this.setState({
rowData:'',
modalVisible: false,
basicState: false,
contactState: false,
modalName: ''
})
}
supervisor(e) {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/customer/listAdminByName",
data: {
adminName: e,
},
success: function (data) {
let thedata = data.data;
if (!thedata) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
thedata = {};
}
this.setState({
customerArr: thedata,
});
}.bind(this),
}).always(
function () {
}.bind(this)
);
}
httpChange(e) {
if (e.length >= 1) {
this.supervisor(e);
}
this.setState({
auto: e,
});
}
blurChange(e) {
let theType = "";
let contactLists = this.state.customerArr || [];
if (e) {
contactLists.map(function (item) {
if (item.name == e.toString()) {
theType = item.id;
}
});
}
this.setState({
theTypes: theType,
});
}
selectAuto(value, options) {
this.setState({
auto: value,
});
}
showConfirm() {
this.setState({
visible:true
})
}
changeAssigner() {
if(!this.state.reasonsTransfer){
message.warning("请输入转交原因");
return;
}
if (this.state.theTypes) {
let changeIds = '';
let oldAid = '';
for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
let rowItem = this.state.selectedRows[idx];
if (rowItem.id) {
oldAid = rowItem.aid;
changeIds = this.state.selectedRows.length-1 === idx ? changeIds +rowItem.id : changeIds + rowItem.id + ',' ;
}
}
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/customer/channelCustomerDeliver",
data: {
userIds: changeIds, //这一行数据的ID
receiveId: this.state.theTypes, //指定转交人的ID
remarks: this.state.reasonsTransfer,
},
}).done(
function (data) {
if (!data.error.length) {
message.success("转交成功!");
this.setState({
auto: "",
loading: false,
selectedRowKeys: [],
reasonsTransfer:'',
visible:false
},()=>{
this.loadData(
Math.min(
this.state.ispage == undefined ? 1 : this.state.ispage,
Math.ceil((this.state.pagination.total - 1) / 10)
)
);
});
} else {
message.warning(data.error[0].message);
}
}.bind(this)
);
} else {
message.warning("请输入转交人姓名");
}
}
render() {
const rowSelection = {
hideDefaultSelections: true,
selectedRowKeys: this.state.selectedRowKeys,
onChange: (selectedRowKeys, selectedRows) => {
this.setState({
modalVisible: false,
selectedRows: selectedRows,
selectedRowKeys: selectedRowKeys,
});
},
onSelect: (recordt, selected, selectedRows) => {
this.setState({
modalVisible: false,
recordt: recordt.id,
});
},
};
const dataSources = this.state.customerArr || [];
const options = dataSources.map((group) => (
{group.name}
));
const hasSelected = this.state.selectedRowKeys.length > 0;
return (
渠道客户
{
this.setState({ nameSearch: e.target.value });
}}
/>
{/*0未分配 1已存在 2已分配*/}
{
this.setState({ addressSearch: e });
}}
/>
{
this.setState({ releaseDate: dataString });
}}
/>
{this.props.deliver ?
: ''}
{this.props.deliver ?
: ''}
{this.props.deliver === 2 ?
: ''}
{this.props.recovery ?
: ''}
{this.props.channel ?
: null}
{this.props.channel ?
: ''}
{this.props.channel ?
: ''}
{this.state.duplicateDataVisible ?
{
this.setState({
duplicateData:[],
duplicateDataVisible: false
})
}}
/> : null}
{this.state.transferVisible ? {
this.setState({
transferVisible:false,
transferId:''
})
}}
/> : '' }
{
this.changeAssigner()
}}
onCancel={()=>{
this.setState({
reasonsTransfer:'',
visible:false
})
}}
>
确定要转交以下客户吗?
{
this.state.selectedRows.map((value,index)=>(
{value.userName}
))
}
转交原因:
{
this.setState({reasonsTransfer : e.target.value });
}}
/>
)
}
}
export default Channel;