import React from 'react'; import { Radio,Icon, Popconfirm,Button, AutoComplete ,Input,Select,Spin,Table, Switch, message, DatePicker, Modal,Form ,Row,Col,TimePicker} from 'antd'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; import moment from 'moment'; const Option = AutoComplete.Option; const OptGroup = AutoComplete.OptGroup; import './myClient.less'; const { Column, ColumnGroup } = Table; import {socialAttribute,newFollow,lvl, customerStatus,intentionalService} from '../../../dataDic.js'; import {getcustomerStatue,getprovince,getCompanyIntention,getfllowSituation,getContactType } from '../../../tools.js'; import AddContact from "../NEW/signCustomer/followDetail/addContact"; const MyBusiness = Form.create()(React.createClass({ loadData(pageNo, apiUrl) { this.state.data = []; this.setState({ loading: true, ispage:pageNo, }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url:globalConfig.context + '/api/admin/customer/listBusiness', data: { pageNo: pageNo || 1, pageSize: this.state.pagination.pageSize, businessGlossoryId: this.state.businessIdS, //业务意向 identifyName:this.state.identifyNameS, followSituation:this.state.followSituationS, customerStatus:this.state.customerStatusS, adminName: this.state.adminNameS, startDate: this.state.releaseDate[0], endDate: this.state.releaseDate[1], }, success: function (data) { let theArr = []; if (data.error.length || 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, businessId:thisdata.businessId, businessName:thisdata.businessName, identifyName:thisdata.identifyName, followSituation:thisdata.followSituation, customerStatus:thisdata.customerStatus, customerStatust:thisdata.customerStatus, adminName:thisdata.adminName, createTime:thisdata.createTime, updateTime:thisdata.updateTime, }); }; this.state.pagination.current = data.data.pageNo; this.state.pagination.total = data.data.totalCount; }; if(data.data&&data.data.list&&!data.data.list.length){ this.state.pagination.current=0; this.state.pagination.total=0; } this.setState({ dataSource: theArr, pagination: this.state.pagination, selectedRowKeys:[] }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, //点击出现函数 setModal2VisibleOk(e) { this.setState({ modal2Visible:true }); }, //点击消失函数 setModal2Visiblecancel(e) { this.setState({ modal2Visible:false }); }, getPictureUrl(e) { this.setState({pictureUrl: e }); }, handleOk(e){ this.setState({ visible: false, }); }, handleCancel(e){ this.setState({ visible: false, }); }, getInitialState() { return { dataSources:[], customerName:[], orgCodeUrl:[], companyLogoUrl:[], visible: false , searchMore: true, releaseDate: [], selectedRowKeys: [], selectedRowKey: [], selectedRows: [], loading: false, pagination: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize: 10, onChange: function (page) { this.loadData(page); }.bind(this), showTotal: function (total) { return '共' + total + '条数据'; } }, paginations: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize: 10, onChange: function (page) { this.loadVisit(page); }.bind(this), showTotal: function (total) { return '共' + total + '条数据'; } }, businessFollowList: [ { title: '跟进时间', dataIndex: 'followTime', key: 'followTime', }, { title: '营销员', dataIndex: 'adminName', key: 'adminName', }, { title: '意向进度', dataIndex: 'followSituation', key: 'followSituation', render:text=>{return getfllowSituation(text)} }, { title: '客户状态', dataIndex: 'customerStatus', key: 'customerStatus', render:text=>{return getcustomerStatue(text)} }, { title: '拜访方式', dataIndex: 'contactType', key:'contactType', render:text=>{return getContactType(text)} }, { title: '联系人', dataIndex: 'contacts', key: 'contacts', }, { title: '联系电话', dataIndex: 'contactMobile', key:'contactMobile', }, { title: '操作', dataIndex: 'ccc', key:'ccc', render: (text, record, index) => { return
{this.intentionDelet(record)}} okText="删除" cancelText="不删除">
} } ], columns: [ { title: '业务名称', dataIndex: 'businessName', key: 'businessName', }, { title: '意向时间', dataIndex: 'createTime', key: 'createTime', }, { title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', }, { title: '客户名称', dataIndex: 'identifyName', key: 'identifyName', }, { title: '营销员', dataIndex: 'adminName', key: 'adminName', }, { title: '意向进度', dataIndex: 'followSituation', key:'followSituation', render: text => { return getfllowSituation(text) } }, { title: '客户状态', dataIndex: 'customerStatus', key: 'customerStatus', render: text => { return getcustomerStatue(text) } }, { title: '操作', dataIndex: 'abc', key: 'abc', render: (text, record, index) => { return
{this.followStop(record)}} okText="停止" cancelText="不停止">
} } ], dataSource: [], searchTime: [,] }; }, //删除跟进记录 intentionDelet(uids){ this.setState({ loading:true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/deleteFollowOneBusiness", data: { ufbId: uids.ufbId,//删除的ID } }).done(function (data) { if (!data.error.length) { message.success('删除成功!'); this.setState({ loading: false, }); } else { message.warning(data.error[0].message); }; this.loadVisit(); this.loadData(this.state.ispage); }.bind(this)); }, //更多操作 ModalOperation(){ this.setState({ visible: true, }); }, //列表删除功能 delectRow() { let deletedIds; for (let idx = 0; idx < this.state.selectedRows.length; idx++) { let rowItem = this.state.selectedRows[idx]; if (rowItem.businessId) { deletedIds=rowItem.businessId; }; }; this.setState({ selectedRowKeys: [], }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/deleteBusiness", data: { businessId: deletedIds,//删除的ID } }).done(function (data) { if (!data.error.length) { message.success('删除成功!'); this.setState({ loading: false, }); } else { message.warning(data.error[0].message); }; this.loadData(this.state.ispage); }.bind(this)); }, //停止跟进 followStop(uids) { this.setState({ loading:true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/stopBusiness", data: { businessId: uids.businessId,//删除的ID } }).done(function (data) { if (!data.error.length) { message.success('成功停止跟进!'); this.setState({ loading: false, }); } else { message.warning(data.error[0].message); }; this.loadData(this.state.ispage); }.bind(this)); }, getOrgCodeUrl(e) { this.setState({ orgCodeUrl: e }); }, getCompanyLogoUrl(e) { this.setState({ companyLogoUrl: e }); }, componentWillMount() { //意向服务 let intentionalArr = []; newFollow.map(function (item) { intentionalArr.push( {item.key} ) }); this.state.intentionalOption = intentionalArr; this.loadData(); }, //新建 addClick() { this.state.businessGlossoryId=undefined; this.state.followSituation='0'; this.state.customerStatus='0'; this.state.contactType=undefined; this.state.superior=''; this.state.remarks=''; this.state.result=''; this.state.keys=false; this.state.lastName=undefined; this.addTime(); this.setState({ showDesc: true, }); }, addClickOk(){ this.setState({ businessId:'', showDesc: false, }); }, addClickCancel(){ this.setState({ businessId:'', showDesc: false, }); }, search() { this.loadData(); }, reset() { this.state.businessIdS=undefined; //名称1 this.state.identifyNameS=''; this.state.followSituationS=undefined; this.state.customerStatusS=undefined; this.state.adminNameS=''; this.state.releaseDate[0]=undefined; this.state.releaseDate[1]=undefined; this.loadData(); }, searchSwitch() { this.setState({ searchMore: !this.state.searchMore }); }, //详情保存函数 detailsSubmint(){ this.setState({ modal5Visible:false, }) }, //基本信息提交 newSubmit(e){ e.preventDefault(); this.setState({ selectedRowKeys: [], }); this.props.form.validateFields((err, values) => { if (!err) { this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", url:globalConfig.context + '/api/admin/customer/updateBusiness', data: { businessId:this.state.rowId, followSituation:this.state.followSituation, customerStatus:this.state.customerStatus, remarks:this.state.remarks, } }).done(function (data) { this.setState({ loading: false }); if (!data.error.length) { message.success('保存成功!'); this.detailsModal() ; this.loadData(this.state.ispage); } else { message.warning(data.error[0].message); } ; }.bind(this)); } }) }, //查看基本详情基本信息 loadInformation(record){ $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/customer/toUpdateBusiness', data: { businessId: record }, success: function (data) { let thisData = data.data; if (!thisData) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; thisData = {}; }; this.setState({ uids:thisData.uid, dataInformation:thisData, followSituation:thisData.followSituation, businessGlossoryId:thisData.businessGlossoryId, customerStatus:thisData.customerStatus, remarks:thisData.remarks, }); }.bind(this), }).always(function () { this.loadVisit(); this.setState({ loading: false }); }.bind(this)); }, detailsModalOk(e) { this.setState({ modal5Visible:true });//需要一个请求数据 this.loadInformation(e.businessId) }, //点击消失函数 detailsModal(e) { this.setState({ modal5Visible:false }); }, //拜访保存函数 visitSubmit(){ this.setState({ visitModul:false, }) }, businessFollowOk(){ this.setState({ businessFollowModul:false }); }, businessFollowCancel(){ this.setState({ businessFollowModul:false }); }, //点击新增详情 newContacts(){ if(this.state.uids||this.state.khId){ this.state.newsex =undefined; this.state.newname =''; this.state.newmobile=''; this.state.newwechat=''; this.state.newqq=''; this.state.newdepatrment=''; this.state.newposition=''; this.state.newemail=''; this.setState({ uids:this.state.uids?this.state.uids:this.state.khId, addcontactModul:true }); }else{ message.warning('请输入客户名称') } }, //跟进 addModify(e) { this.addTime(); this.HttpFollowUp(e.businessId); this.state.keys=true; this.setState({ showDesc: true, }); }, //当选择联系人的列表变化时,则执行 hundleName(e){ let changNub=this.state.telNum[e]; this.setState({ nub:this.state.telNum[e], lastName: e, }); }, //新建保存 addSubmit(e){ e.preventDefault(); if(this.state.businessGlossoryId==undefined){ message.warning('请选择业务意向') return false; } if(!this.state.businessId){ if(!this.state.theTypes){ message.warning('客户名为空或不存在') return false; } } if(this.state.contactType==undefined){ message.warning('请选择联系方式') return false; } if(this.state.lastName==undefined){ message.warning('请选择联系人') return false; } this.props.form.validateFields((err, values) => { if (!err) { this.setState({ loading: true }); let conts=this.state.lastName; let contactsId= this.state.contactsIdArr[conts].id; $.ajax({ method: "post", dataType: "json", crossDomain: false, url:!this.state.keys?globalConfig.context + '/api/admin/customer/addBusinessAndFollow':globalConfig.context + '/api/admin/customer/addFollowOneBusiness ', data:!this.state.businessId?{ uid:this.state.khId, businessGlossoryId: this.state.businessGlossoryId, followSituation:this.state.followSituation, customerStatus: this.state.customerStatus, contactType: this.state.contactType, ocbId: contactsId, createTime:this.state.createYear+''+this.state.creatMent, followTime:this.state.followTime, remarks: this.state.remarks, result: this.state.result, }:{ uid:this.state.uids, businessId:this.state.businessId, businessGlossoryId: this.state.businessGlossoryId, followSituation:this.state.followSituation, customerStatus: this.state.customerStatus, contactType: this.state.contactType, ocbId: contactsId, followTime:this.state.followTime, remarks: this.state.remarks, result: this.state.result, } }).done(function (data) { this.setState({ loading: false }); if (!data.error.length) { message.success('保存成功!'); this.addClickCancel(); this.loadData(this.state.ispage); this.state.businessId=''; } else { message.warning(data.error[0].message); } }.bind(this)); } }); }, //列表保存 addlistSubmit(e){ e.preventDefault(); this.props.form.validateFields((err, values) => { if (!err) { this.setState({ loading: true }); let conts=this.state.lastName; let contactsId= conts?this.state.contactsIdArr[conts].id:''; $.ajax({ method: "post", dataType: "json", crossDomain: false, url:globalConfig.context + '/api/admin/customer/updateFollowOneBusiness', data:{ ufbId:this.state.ufbIds, followId:this.state.followId, customerStatus: this.state.customerStatusV, followSituation:this.state.followSituationV, contactType: this.state.contactTypeV, ocbId:contactsId, remarks: this.state.remarksV, result: this.state.resultV, } }).done(function (data) { this.setState({ loading: false }); if (!data.error.length) { message.success('保存成功!'); this.businessFollowCancel(); this.loadVisit() } else { message.warning(data.error[0].message); } }.bind(this)); } }); }, //进入修改时 listFollowUp(e){ $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/toUpdateFollowOneBusiness", data:{ ufbId:e.ufbId }, success: function (data) { let thedata=data.data; if (!thedata) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; thedata = {}; }; this.setState({ businessGlossoryId:thedata.businessGlossoryId, followSituationV:thedata.followSituation, customerStatusV:thedata.customerStatus, followTime:thedata.followTime, createTime:thedata.createTime, identifyName:thedata.identifyName, contactTypeV:parseInt(thedata.contactType), resultV:thedata.result, remarksV:thedata.remarks, adminName:thedata.adminName, contacts:thedata.contacts, contactMobile:thedata.contactMobile, ufbId:thedata.ufbId, followId:thedata.followId, }); }.bind(this), }).always(function () { this.getNewWoman(this.state.uids) this.setState({ ufbIds:e.ufbId, loading: false }); }.bind(this)); }, //新建HTTP获取数据 addTime(){ $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/toAddBusinessAndFollow", data:{ }, success: function (data) { let theArr = []; let thedata=data.data; if (!thedata) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; thedata = {}; }; let creatMent=thedata.createTime.substr(10,9); let createYear=thedata.createTime.substr(0,10); this.setState({ createTime:thedata.createTime, creatMent:creatMent, createYear:createYear, followTime:thedata.followTime, adminName: thedata.adminName, }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, //客户名称初始加载 customerList(e){ $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/findCustomerByName", data:{ name: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({ uids:thedata.id, customerArr:thedata, }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, //值改变时请求客户名称 httpChange(e){ if(e.length>=2){ this.customerList(e); } this.setState({ superior:e }) }, //选择值时值匹配及联系人函数加载 autoChange(e){ let theType=''; let contactLists=this.state.customerArr||[]; if (e) { contactLists.map(function (item) { if (item.name == e.toString()) { theType = item.id; } }); } this.setState({ khId:theType }) this.getNewWoman(theType) }, //上级主管输入框失去焦点是判断客户是否存在 selectAuto(value,options){ let theType=''; let contactLists=this.state.customerArr||[]; if (value) { contactLists.map(function (item) { if (item.name == value.toString()) { theType = item.id; } }); } this.setState({ superior:value, khId:theType }) this.getNewWoman(theType) ; }, //客户输入框失去焦点是判断客户是否存在 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 }) }, //点击跟进时数据处理 HttpFollowUp(e){ $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/toAddFollowOneBusiness", data:{ businessId: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({ uids:thedata.uid, businessId:thedata.businessId, businessGlossoryId:thedata.businessGlossoryId, followSituation:thedata.followSituation, customerStatus:thedata.customerStatus, followTime:thedata.followTime, createTime:thedata.createTime, identifyName:thedata.identifyName, contactType:undefined, result:'', remarks:'', }); }.bind(this), }).always(function () { this.getNewWoman(this.state.uids) this.setState({ loading: false }); }.bind(this)); }, //获取联系人下拉框 getNewWoman(ids) { this.state.data = [] $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/findCustomerContacts", data:{ uid:ids, }, success: function (data) { let theArr = []; let thedata=data.data; if (!thedata) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; thedata = {}; }; var telNum=[]; var contactIds=[]; thedata.map(function (item,index) { telNum.push(thedata[index].mobile); }); for (let item in data.data) { let theData = data.data[item]; theArr.push( {theData.name} ); }; this.setState({ contactsIdArr:thedata, telNum:telNum, orderStatusOption: theArr, }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, //获取拜访详情ajax loadVisit(pageNo) { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url:globalConfig.context + '/api/admin/customer/listFollowHistory', data: { pageNo: pageNo || 1, pageSize: this.state.paginations.pageSize, uid: this.state.uids, //名称1 businessGlossoryId:this.state.businessGlossoryId, }, success: function (data) { let theArr = []; if (data.error.length || 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({ followId:thisdata.followId, followTime:thisdata.followTime, identifyName:thisdata.identifyName, contacts:thisdata.contacts, contactMobile:thisdata.contactMobile, result:thisdata.result, ufbId:thisdata.ufbId, adminName:thisdata.adminName, followSituation:thisdata.followSituation, customerStatus:thisdata.customerStatus, contactType:thisdata.contactType }); }; this.state.paginations.current = data.data.pageNo; this.state.paginations.total = data.data.totalCount; }; this.setState({ visitArrList: theArr, paginations: this.state.paginations }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, componentWillReceiveProps(nextProps) { if (!this.props.visible && nextProps.visible) { if (nextProps.data && nextProps.data.id) { this.loadData(nextProps.data.id, nextProps.detailApiUrl); }; this.state.data = {}; this.state.companyLogoUrl = []; this.state.orgCodeUrl = []; }; }, tableRowClick(record, index) { this.state.RowData = record; this.detailsModalOk(record); this.setState({ selectedRowKeys:[], rowId:record.businessId, }) }, followRowClick(record, index) { this.state.RowData = record; this.listFollowUp(record); this.setState({ businessFollowModul: true, selectedRowKeys:[], }); }, render() { const FormItem = Form.Item const rowSelection = { selectedRowKeys: this.state.selectedRowKeys, onChange: (selectedRowKeys, selectedRows) => { this.setState({ selectedRows: selectedRows.slice(-1), selectedRowKeys: selectedRowKeys.slice(-1) }); }, onSelect: (recordt, selected, selectedRows) => { this.setState({ recordt:recordt.id }) }, }; const rowSelections = { selectedRowKeys: this.state.selectedRowKey, onChange: (selectedRowKey, selectedRow) => { this.setState({ selectedRow: selectedRow.slice(-1), selectedRowKey: selectedRowKey.slice(-1) }); }, onSelect: (records, selected, selectedRow) => { this.setState({ selectedRow: selectedRow.slice(-1), records:records.id, }) }, }; const hasSelected = this.state.selectedRowKeys.length > 0; const { RangePicker } = DatePicker; const { getFieldDecorator } = this.props.form; const formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 14 }, }; const theInformation=this.state.dataInformation || {} const contactsOption=""; const formItemLayput = { labelCol: { span: 10 }, wrapperCol: { span: 14 }, }; const businessIds=this.state.businessId||''; const dataSources=this.state.customerArr || []; const options = dataSources.map((group) => ) return (
我的业务
{ this.setState({ identifyNameS: e.target.value }); }} /> 更多搜索
{ this.setState({ releaseDate: dataString }); }} /> { this.setState({ adminNameS: e.target.value }); }} />
{businessIds!=''?
{getCompanyIntention(this.state.businessGlossoryId)} {this.state.createTime} {this.state.identifyName}
:
*
{this.setState({createYear: time});}}/> { this.setState({creatMent: time}); }}/> *
} {this.state.adminName}
{ this.setState({ remarks: e.target.value }) }}/>
拜访情况
{ this.setState({ contactType: e.target.value }) }}> 外出 电话 QQ 微信 邮箱
{this.state.nub}
{this.state.adminName} {this.state.followTime}
{ this.setState({ result: e.target.value }); }}/>
{getCompanyIntention(theInformation.businessGlossoryId)} {theInformation.createTime} {theInformation.identifyName} {theInformation.adminName}
{ this.setState({ remarks: e.target.value }) }}/>
业务跟进
{ this.setState({ addcontactModul:false },()=>{ this.getNewWoman(this.state.uids) }) }} />
{getCompanyIntention(this.state.businessGlossoryId)} {this.state.createTime} {this.state.identifyName} {this.state.adminName}
{ this.setState({ remarksV: e.target.value }) }}/>
拜访情况
{ this.setState({ contactTypeV: e.target.value }) }}> 外出 电话 QQ 微信 邮箱
{this.state.contacts} {this.state.nub}
{this.state.adminName} {this.state.followTime}
{ this.setState({ resultV: e.target.value }); }}/>
); } })); export default MyBusiness;