import React from "react"; import { Table, Button, Spin, message, Popconfirm, Alert, Modal, Input, Cascader, Select, InputNumber, AutoComplete, Tag } from "antd"; import $ from "jquery/src/ajax"; import AddContact from "../../../customer/NEW/signCustomer/followDetail/addContact"; import "./index.less"; import { areaSelect, getProvince } from "@/NewDicProvinceList"; const TextArea = Input.TextArea; const Option = Select.Option; const ContactPerson = React.createClass({ getInitialState() { return { major: 0, loading: false, addcontactModul: false, enterpriseName: "", ContactsLists: [ { title: "姓名", dataIndex: "name", key: "name", render: (text, record, index) => { if (record.id) return
{text}
; }, }, { title: "联系人部门", dataIndex: "department", key: "department", render: (text, record, index) => { if (record.id) return
{text}
; }, }, { title: "联系人职务", dataIndex: "position", key: "position", render: (text, record, index) => { if (record.id) return
{text}
; }, }, { title: "主要联系人", dataIndex: "major", width: 100, key: "major", render: (text) => { return text == 1 ? "是" : "否"; }, }, { title: "地区", dataIndex: "cityName", key: "cityName", render: (text, record, index) => { if (record.id) return
{text}
; }, }, { title: "手机号码", dataIndex: "mobile", key: "mobile", render: (text, record, index) => { if (record.id) return
{text}
; }, }, { title: "座机", dataIndex: "fixedTel", key: "fixedTel", render: (text, record, index) => { if (record.id) return
{text}
; }, }, { title: "微信", dataIndex: "wechat", key: "wechat", render: (text, record, index) => { if (record.id) return
{text}
; }, }, { title: "联系人QQ", dataIndex: "qq", key: "qq", render: (text, record, index) => { if (record.id) return
{text}
; }, }, { title: "电子邮箱", dataIndex: "email", key: "email", render: (text, record, index) => { if (record.id) return
{text}
; }, }, { title: "更新时间", dataIndex: "createTimes", key: "createTimes", render: (text, record, index) => { if (record.id) return
{text}
; }, }, { title: "跟进人", dataIndex: "aname", key: "aname", render: (text, record, index) => { if (record.id) return
{text}
; }, }, { title: "操作", dataIndex: "dels", key: "dels", render: (text, record, index) => { return ( !this.props.isCustomerAdmin && (
{/* 禁止管理员删除联系人 */} {/* {adminData.isSuperAdmin || !record.id ? ( { this.confirmDelet(record); }} okText="删除" cancelText="不删除" > ) : ( "" )} */} {record.major != 1 ? ( ) : ( "" )}
) ); }, }, ], channeOb: [ { name: "民主党派", val: 2 }, { name: "园区", val: 3 }, { name: "民间组织", val: 4 }, { name: "战略合作单位", val: 5 }, { name: "其他", val: 1 }, ], visible: "", //修改弹窗状态 name: "", locationProvince: "", introduction: "", newname: "", dataArrar: [], newintroduction: "", newtype: 0, enterpriseCount: 0, channelIndicators: "", cooperationProjects: [], }; }, //tab2删除 confirmDelet(e) { this.setState({ loading: true, }); if (e.id) { $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/deleteOneContact", data: { ocbId: e.id, //删除的ID }, }).done( function (data) { if (!data.error.length) { message.success("删除成功!"); this.setState({ loading: false, }); } else { message.warning(data.error[0].message); } this.contactLists(); }.bind(this) ); } else { this.contactLists(); } }, //选择主要联系人 mainContact(record) { this.setState({ loading: true, }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/updateMainContact", data: { uid: this.props.data.id, ocbId: record.id, }, }).done( function (data) { if (!data.error.length) { message.success("设为主要联系人成功!"); this.setState({ loading: false, }); } else { message.warning(data.error[0].message); } this.contactLists(); }.bind(this) ); this.state.contactList.forEach((item) => { item.major = 0; }); record.major = 1; // console.log(record); this.setState({ contactList: this.state.contactList, }); }, //tab2获取联系人详情 contactLists(ids) { this.setState({ loading: true, }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/findCustomerContacts", data: { uid: ids || this.props.data.id, //名称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.length; i++) { let thisdata = data.data[i]; theArr.push({ key: i, id: thisdata.id, name: thisdata.name, mobile: thisdata.mobile, email: thisdata.email, qq: thisdata.qq, wechat: thisdata.wechat, department: thisdata.department, position: thisdata.position, major: thisdata.major, createTimes: thisdata.createTimes, fixedTel: thisdata.fixedTel, aname: thisdata.aname, cityName: (thisdata.provinceName || "") + (thisdata.cityName || "") + (thisdata.areaName || ""), }); } } this.setState({ contactList: theArr, }); }.bind(this), }).always( function () { this.setState({ loading: false, }); }.bind(this) ); }, //新增 //tab2新增联系人 addcontact() { this.setState({ addcontactModul: true, }); }, // componentWillMount() { const { data } = this.props this.contactLists(this.props.data.id); this.setState({ name: this.props.name, locationProvince: (data.province || "") + (!data.city ? "" : "-") + (data.city || "") + (!data.area ? "" : "-") + (data.area || ""), introduction: this.props.data.introduction, type: this.props.data.type, enterpriseCount: this.props.data.enterpriseCount, channelIndicators: this.props.data.channelIndicators, intendedProject: this.props.data.intendedProject, }); this.queryByUid(this.props.data.id) }, componentWillReceiveProps(nextProps) { // if (nextProps.data.id && nextProps.contactState) { if (nextProps.data.id) { this.contactLists(nextProps.data.id); } }, // 查询企业信息 queryByUid() { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/userArchives/queryByUid", data: { id: this.props.data.id, }, success: function (data) { if (data.error.length || data.data.list == "") { if (data.error && data.error.length) { message.warning(data.error[0].message); } } else { this.setState({ interviewDistribution: data.data.interviewDistribution, interviewIdeas: data.data.interviewIdeas, // detail: data.data }) } }.bind(this) }).always( function () { this.setState({ loading: false }); }.bind(this) ); }, supervisor(value) { $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/order/getBusinessProjectByName', data: { businessName: value }, success: function (data) { let thedata = data.data; if (data.error.length === 0) { this.setState({ cooperationProjects: thedata, }); } else { message.warning(data.error[0].message); } }.bind(this), }).always( function () { }.bind(this) ); }, onSelect(value) { let arr = this.state.cooperationProjects.filter(v => v.id === value); let arr1 = this.state.dataArrar.filter(v => v.value === value); if (arr.length > 0) { if (arr1.length > 0) { message.warning('选项已存在'); } else { this.state.dataArrar.push({ label: arr[0].bname, value: arr[0].id, }) this.setState({ dataArrar: this.state.dataArrar }) } } }, // 修改渠道名称 onOk() { if (!this.state.newname) { message.warning("请输入渠道名称"); return; } this.setState({ loading: true, }); $.ajax({ url: globalConfig.context + "/api/admin/customer/updateUserName", method: "post", data: { uid: this.props.data.id, userName: this.state.newname, }, }).done( function (data) { this.setState({ loading: false, }); if (data.error.length === 0) { message.success("恭喜您,更名成功!"); this.setState({ visible: "", name: this.state.newname, }); } else { message.warning(data.error[0].message); } }.bind(this) ); }, // 修改信息 updateDate() { const { dataArrar, visible, newintroduction, newtype, newenterpriseCount, newchannelIndicators, newinterviewIdeas, newinterviewDistribution } = this.state; if (dataArrar.length === 0 && visible == "city") { message.warning("请选择省-市-区"); return; } if (!newintroduction && visible == "introduction") { message.warning("请输入简介"); return; } if (newtype == 0 && visible == "type") { message.warning("请选择渠道类别"); return; } if (!newenterpriseCount && newenterpriseCount != 0 && visible == "enterpriseCount") { message.warning("请输入渠道覆盖企业数"); return; } if (!newchannelIndicators && visible == "channelIndicators") { message.warning("请输入渠道考核标准"); return; } if (dataArrar.length == 0 && visible == "intendedProject") { message.warning("请输入面谈项目"); return; } if (!newinterviewIdeas && visible == "interviewIdeas") { message.warning("请输入面谈思路及目的"); return; } if (!newinterviewDistribution && visible == "interviewDistribution") { message.warning("请输入我方主要面谈及分工"); return; } this.setState({ loading: true, }); let data = { uid: this.props.data.id, }; if (visible == "city") { data.province = dataArrar[0] || undefined; data.city = dataArrar[1] || undefined; data.area = dataArrar[2] || undefined; } if (visible == "introduction") { data.introduction = newintroduction; } if (visible == "type") { data.channelType = newtype; } if (visible == "enterpriseCount") { data.enterpriseCount = newenterpriseCount; } if (visible == "channelIndicators") { data.channelIndicators = newchannelIndicators } if (visible == "intendedProject") { let arr = []; for (let i of dataArrar) { arr.push(i.label) } data.intendedProject = arr.join(',') } if (visible == "interviewIdeas") { data.interviewIdeas = newinterviewIdeas } if (visible == "interviewDistribution") { data.interviewDistribution = newinterviewDistribution } $.ajax({ url: globalConfig.context + visible == "channelIndicators" ? "/api/admin/userArchives/update" : visible == "enterpriseCount" ? "/api/admin/userArchives/update" : visible == "interviewIdeas" ? "/api/admin/userArchives/update" : visible == "interviewDistribution" ? "/api/admin/userArchives/update" : "/api/admin/customer/updateUserDate", method: "post", data: data, }).done( function (data) { this.setState({ loading: false, }); if (data.error.length === 0) { message.success("恭喜您,更改成功!"); this.setState({ visible: "", }); if (visible == "city") { this.setState({ locationProvince: getProvince( dataArrar[0], dataArrar[1], dataArrar[2] ), }); } if (visible == "introduction") { this.setState({ introduction: newintroduction, }); } if (visible == "type") { this.setState({ type: newtype, }); } if (visible == "enterpriseCount") { this.setState({ enterpriseCount: newenterpriseCount, }); } if (visible == "channelIndicators") { this.setState({ channelIndicators: newchannelIndicators, }); } if (visible == "intendedProject") { let arr = []; for (let i of dataArrar) { arr.push(i.label) } this.setState({ intendedProject: arr.join(',') }) } if (visible == "interviewIdeas") { this.setState({ interviewIdeas: newinterviewIdeas, }); } if (visible == "interviewDistribution") { this.setState({ interviewDistribution: newinterviewDistribution, }); } } else { message.warning(data.error[0].message); } }.bind(this) ); }, handleCloseCooperation(removedTag) { let dataArrar = this.state.dataArrar.filter(tag => { return tag.value !== removedTag.value }); this.setState({ dataArrar }); }, render() { const { visible } = this.state; return (
渠道名称:{this.state.name}
渠道类别:{[ "", "其他", "民主党派", "园区", "民间组织", "战略合作单位", ][this.state.type]}
省-市-区: {this.state.locationProvince}
渠道简介:{this.state.introduction}
渠道覆盖企业数:{this.state.enterpriseCount}
渠道考核指标:{this.state.channelIndicators}
面谈的渠道情况
面谈项目     { !this.props.isCustomerAdmin && }
{this.state.intendedProject || "无"}
面谈思路及目的     { !this.props.isCustomerAdmin && }
{this.state.interviewIdeas || "无"}
我方主要面谈人及分工     { !this.props.isCustomerAdmin && }
{this.state.interviewDistribution || "无"}
{/* 新增联系人 */} { this.setState( { addcontactModul: false, }, () => { this.contactLists(); } ); }} /> {/* 信息修改 */} { this.setState({ visible: "", }); }} >
{visible == "name" && (
更改前:
{this.state.name}
更改后:
{ this.setState({ newname: e.target.value, }); }} />
)} {visible == "city" && (
更改前:
{this.state.locationProvince}
更改后:
{ this.setState({ dataArrar: e, }); }} />
)} {visible == "introduction" && (
更改前:
{this.state.introduction}
更改后: