import React from 'react' import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; import { Modal, Form, layout, Radio, Button, Input, Spin, Table, Select, Popconfirm, message } from 'antd'; import { intentionalService, newFollow, customerStatus } from '@/dataDic.js'; import { getCompanyIntention, getfllowSituation, getcustomerStatue } from '@/tools.js'; const FormItem = Form.Item; import AddContact from './followDetail/addContact.jsx'; import BusName from '../intentionCustomer/followDetail/businessName'; const FollowDetail = React.createClass({ getInitialState() { return { visitModul: false, loading: false, data: [], busModul: false, intentionList: [ { title: '业务名称', dataIndex: 'businessVarietiesName', width: 120, key: 'businessVarietiesName', render: (text, record, index) => { return (
{!record.id ? ( ) : ( {record.businessVarietiesName} )}
); }, }, { title: '项目名称', dataIndex: 'businessProjectName', key: 'businessProjectName', width: 120, render: (text, record, index) => { return (
{!record.id ? (
) : ( {record.businessProjectName} )}
); }, }, { title: '最新进度', width: 120, dataIndex: 'followSituation', key: 'followSituation', render: (text, record, index) => { if (text == 5 && !record.isEdit) { return newFollow.map(function (item) { if (item.value == text) { return item.key; } }); } else { return ( ); } }, }, { title: '最新状态', width: 120, dataIndex: 'customerStatus', key: 'customerStatus', render: (text, record, index) => { if (record.followSituation == 5 && !record.isEdit) { return customerStatus.map(function (item) { if (item.value == text) { return item.key; } }); } else { return ( ); } }, }, { title: '跟进说明', width: 120, dataIndex: 'remarks', key: 'remarks', render: (text, record, index) => { if (record.followSituation == 5 && !record.isEdit) { return text; } else { return ( { record.remarks = e.target.value; this.setState({ data: this.state.data }); }} /> ); } }, }, { title: '操作', width: 120, dataIndex: 'rrr', key: 'rrr', render: (text, record, index) => { return
{!record.id ? ( { this.intentionDelet(record, index); }} okText="删除" cancelText="不删除" > ) : { this.againProjectTask(record, index) }} okText="再次签单" cancelText="取消"> }
} } ], } }, //选择子项目 businessFn(record, index) { if (!record.businessGlossoryId) { message.warn("请先选择业务名称!"); return; } this.setState({ businessId: record.businessGlossoryId, busModul: true, index: index, addcontactModul: false, }); }, closeBus(datas, e, s) { this.state.addcontactModul = e; this.state.busModul = false; if (s) { this.state.data[this.state.index].businessName = datas.id; this.state.data[this.state.index].projectName = datas.name; this.setState({ busModul: false, data: this.state.data, }); } }, //拜访意向服务列表单个删除 intentionDelet(e, index) { let deteluserBusinessList = this.state.data.splice(index, 1); this.setState({ selectedRowKeys: [], }); }, //签单 againProjectTask(e, index) { this.setState({ loading: true, selectedRowKeys: [], }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/againProjectTask", data: { uid: e.uids, projectId: e.businessName, } }).done(function (data) { if (!data.error.length) { message.success('签单成功'); if (this.props.isFlag) { this.deletelist(this.props.followData.id) } else { this.props.loadData(); } this.setState({ loading: false, }); } else { message.warning(data.error[0].message); }; //this.deletelist(this.props.followData.id) }.bind(this)); }, //拜访modul函数 visitOk(e) { this.setState({ addcontactModul: false, visitModul: false }); }, visitCancel(e) { this.setState({ addcontactModul: false, visitModul: false }); this.props.closeDesc(false, false) }, //获取联系人下拉框 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) { contactIds.push(thedata[index].id); 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({ deletId: ids, loading: false }); }.bind(this)); }, //刷新新增拜访记录刷新 deletelist(e) { this.setState({ loading: true }) $.ajax({ method: "get", dataType: "json", url: globalConfig.context + '/api/admin/customer/toAddFollowOnLock', data: { uid: e, }, success: function (data) { let listArr = []; let thedata = data.data; if (!thedata) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; thedata = {}; }; if (data.data.userBusinessList[0] != null) { for (let i = 0; i < data.data.userBusinessList.length; i++) { let thisdata = data.data.userBusinessList[i]; if (thisdata != null) { listArr.push({ key: i, id: thisdata.businessId, businessName: thisdata.businessProjectId, businessVarietiesName: thisdata.businessVarietiesName, businessProjectName: thisdata.businessProjectName, followSituation: thisdata.followSituation == null ? undefined : String(thisdata.followSituation), customerStatus: thisdata.customerStatus == null ? undefined : String(thisdata.customerStatus), remarks: thisdata.remarks, uid: thisdata.uid, uids: data.data.uid }); } }; } this.setState({ contacts: thedata.contacts, uids: data.data.uid, uid: thedata.uid, data: listArr, followTime: thedata.followTime, remarks: thedata.remarks, }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, //当选择联系人的列表变化时,则执行 hundleName(e) { let changNub = this.state.telNum[e]; this.setState({ nub: this.state.telNum[e], lastName: e, }); }, //点击添加联系人 newContacts() { this.setState({ busModul: false, uids: this.state.uid, addcontactModul: true }); }, //页面刷新 closeFollow(e, s) { this.state.addcontactModul = false; this.state.visitModul = true; if (s) { this.getNewWoman(this.props.followData.id); this.deletelist(this.props.followData.id) }; }, //详情保存 visitSubmit(e) { e.preventDefault(); let GlossoryId = false; this.state.data.map(function (item) { if (!item.followSituation || !item.customerStatus || !item.businessName) { GlossoryId = true } }) if (this.state.contactType == undefined) { message.warning('请选择拜访方式') return false; }; if (this.state.lastName == undefined) { message.warning('请选择联系人') return false; } if (this.state.result.length < 10) { message.warning("备注不少于10个字符!"); return false; } if (this.state.data.length && GlossoryId) { message.warning("项目名称/最新进度/最新状态不能为空!") return false; }; this.setState({ loading: true }); let dataList = this.state.data, idsList = []; dataList.map((item, index) => { idsList.push({ businessId: item.id || '', businessProjectId: item.businessName, customerStatus: item.customerStatus, followSituation: item.followSituation, remarks: item.remarks || '' }) }); let contactsId = ''; let conts = this.state.lastName; contactsId = this.state.contactsIdArr[conts].id; //新增 $.ajax({ method: "post", dataType: "json", url: globalConfig.context + '/api/admin/customer/addFollow', data: { userBusinessList: JSON.stringify(idsList), uid: this.state.uid, ocbId: contactsId, contactType: this.state.contactType, result: this.state.result, followTime: this.state.followTime, } }).done(function (data) { this.setState({ loading: false }); if (!data.error.length) { message.success('保存成功!'); this.props.closeDesc(false, true); this.visitCancel(); this.props.loadData(); } else { message.warning(data.error[0].message); } }.bind(this)); }, //添加新业务 addNew() { this.state.data.push({ isEdit: true, projectName: "选择", businessName: "", customerStatus: undefined, businessGlossoryId: undefined, followSituation: undefined, remarks: "", }); this.setState({ addcontactModul: false, data: this.state.data, }); }, componentWillReceiveProps(nextProps) { if (nextProps.visitModul && nextProps.followData.id) { this.setState({ result: '', contactType: undefined, visitModul: true, loading: true, lastName: undefined, nub: '', busModul: false, addcontactModul: false }) this.getNewWoman(nextProps.followData.id); this.deletelist(nextProps.followData.id) }; }, render() { const formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 14 }, }; return (
{ this.setState({ contactType: e.target.value }); }} > {/*外出*/} 电话 QQ 微信 邮箱 来访面谈 *
{this.state.contacts ? ( ) : ( * )} {this.state.nub} {this.state.followTime}
* { this.setState({ result: e.target.value }); }} />
业务意向
); } }) export default FollowDetail;