import React from 'react'; import { Button, Cascader, Modal, Input, Select, Tag, Spin, Table, Tabs, Form, Col, message, Tooltip, AutoComplete } from 'antd'; import $ from 'jquery/src/ajax'; import { ShowModal } from '../../../../tools.js' import { areaSelect, citySelect, provinceList } from '@/NewDicProvinceList'; import ShowModalDiv from "@/showModal.jsx"; import ZhuanjiaoDetail from "@/zhuanjiaoDetail.jsx"; import Detaile from './detail.jsx'; import { ChooseList } from "../../../order/orderNew/chooseList"; import EnterpriseNameChange from "../../../../common/enterpriseNameChange"; import TextArea from "antd/es/input/TextArea"; const confirm = Modal.confirm; const { TabPane } = Tabs const QueryCustomer = React.createClass({ // loadData(pageNo, apiUrl) { if (!this.state.nameSearch) { return } // 新需求 除湖南和内蒙古外 不让其他省操作 if (adminData.province != "21" && adminData.province != "11") { return } this.setState({ visitModul: false, loading: true, modalVisible: false, }); let api = apiUrl ? apiUrl : this.props.ApiUrl; $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + api, data: { pageNo: pageNo || 1, pageSize: this.state.pagination.pageSize, name: this.state.nameSearch, departmentId: this.state.departmenttSearch, aid: this.state.theTypes, }, success: function (data) { ShowModal(this); 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]; 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.signBills = thisdata.signBills; thisdata.createTime = thisdata.createTime && thisdata.createTime.split(" ")[0]; thisdata.locationProvince = diqu; theArr.push(thisdata); } 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: [], ispage: data.data.pageNo, }); }.bind(this), }).always( function () { this.setState({ loading: false, }); }.bind(this) ); }, //部门 departmentList() { this.setState({ loading: true, }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/organization/selectSuperId", 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({ key: index, name: item.name, id: item.id, }); }); } this.setState({ departmentArr: theArr, }); }.bind(this), }).always( function () { this.setState({ loading: false, }); }.bind(this) ); }, // getInitialState() { return { verification: false, businessScope: [], cooperationProjects: [], selectCooperationProjects: [], addressSearch: [], dataSource: [], zhuanjiaoVisible: false, zhuanjiaoData: [], loading: false, departmentArr: [], selectedRowKeys: [], selectedRowKey: [], selectedRows: [], pagination: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize: 10, onChange: function (page) { this.loadData(page); }.bind(this), showTotal: function (total) { return "共" + total + "条数据"; }, }, columns: [ { title: "客户名称", dataIndex: "name", key: "name", render: (text, record) => { return ( {record.channel === 1 ?
外联
: null}
{text}
) } }, { title: "统一社会信用代码", dataIndex: "orgCode", key: "orgCode", }, { title: "共享类型", dataIndex: "shareType", key: "shareType", //0-私有 1-公共 2 签单 render: (text, record) => { return ( { text === '0' ? '私有' : text === '1' ? '公共' : text === '2' ? '签单' : text === '3' ? '外联' : text === '4' ? '渠道' : text === '5' ? '线索' : '' } {/* { record.newChannel == "1" ? "渠道" : "" } */} ) } }, { title: "地区", dataIndex: "locationProvince", key: "locationProvince", }, { title: "创建时间", dataIndex: "createTime", key: "createTime", width: 80, }, { title: "客户所属人", dataIndex: "adminName", key: "adminName", }, { title: "资料所属人", dataIndex: "informationMaintainer", key: "informationMaintainer", }, { title: "操作", dataIndex: "abc", key: "abc", render: (text, record) => { return (
{record.shareType === '1' && }
); }, }, ], }; }, handleClose(removedTag) { let businessScope = this.state.businessScope.filter(tag => { return tag !== removedTag }); this.setState({ businessScope }); }, handleCloseCooperation(removedTag) { let selectCooperationProjects = this.state.selectCooperationProjects.filter(tag => { return tag.value !== removedTag.value }); this.setState({ selectCooperationProjects }); }, showInput() { let str = this.state.businessScope.join('/') this.setState({ inputVisible: true, inputValue: str }); }, handleInputConfirm() { let inputValue = this.state.inputValue; let arr = inputValue.split('/'); let lv = true; for (let i of arr) { if (!i.replace(/\s+/g, '')) { message.warning("请填写关键词且不为空"); return; } if (i.length > 16) { message.warning('单个标签字数不能超过16个字符') lv = false; return; } } if (lv) { arr = Array.from(new Set(arr)); arr = arr.filter(v => v); this.setState({ businessScope: arr, inputVisible: false, inputValue: '', }); } }, //加载(自动补全) 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.selectCooperationProjects.filter(v => v.value === value); if (arr.length > 0) { if (arr1.length > 0) { message.warning('选项已存在'); } else { this.state.selectCooperationProjects.push({ label: arr[0].bname, value: arr[0].id, }) this.setState({ selectCooperationProjects: this.state.selectCooperationProjects }) } } }, // 查询客户补充完整 receive(e) { this.setState({ loading: true, selectedRowKeys: [], }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/checkUser", data: { id: e.id || e.uid, } }).done(function (data) { if (!data.error.length) { let obj = data.data let selectCooperationProjects = !!obj.intendedProject ? obj.intendedProject.split(',') : [] if (selectCooperationProjects.length > 0) { selectCooperationProjects = selectCooperationProjects.map((item) => { return { label: item } }) } this.setState({ loading: false, verification: true, id: obj.id, name: obj.name, orgCode: obj.orgCode, ProvinceCity: [obj.province, obj.city, obj.area], // content: obj.contacts, position: obj.position, // telnum: obj.contactMobile, businessScope: !!obj.businessScope ? obj.businessScope.split(',') : [], selectCooperationProjects: selectCooperationProjects, level: obj.level, nature: obj.nature, natureOther: obj.natureOther, }); } else { message.warning(data.error[0].message); }; }.bind(this)); }, // 补充客户并领取 handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { let re = new RegExp("^[\u4e00-\u9fa5]"); if (!re.test(values.name)) { message.warning('公司名称必须以汉字开头!') return } if (!re.test(values.name.charAt(values.name.length - 1))) { message.warning('公司名称必须以汉字结尾!') return } if (values.name.length > 64) { message.warning('公司名称字数不超过64个!') return false; }; let regu = /[`~!#$%^&*'_[\]+=<>?:"{}|~!#¥%……&*=-@-!{}|/《》?:“”【】、;;‘’,,.。、\s+]/g; if (regu.test(values.name)) { message.warning('公司名称不能存在特殊符号或空格!') return false; } if (!/^[A-Z0-9]{15}$|^[A-Z0-9]{17}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$/.test(values.orgCode)) { message.warning('请输入正确的统一社会信用代码!') return } if (/.*[\u4e00-\u9fa5]+.*$/.test(values.content)) { } else { message.error("请填写正确的联系人,且至少包含一个汉字"); return false; }; if (/.*[\u4e00-\u9fa5]+.*$/.test(values.position)) { } else { message.error("请填写正确的职位,且至少包含一个汉字"); return false; }; if (!values.ProvinceCity[1]) { message.warning('请选择地区'); return false; }; if (values.content.length > 32) { message.warning('联系人字数不超过32个') return false; }; if (values.length > 13) { message.warning('电话号码字数不超过13个') return false; }; if (this.state.businessScope.length === 0) { message.warning('请选择主营产品') return false; } if (this.state.selectCooperationProjects.length === 0) { message.warning('请选择意向合作项目') return false; } if (!this.state.level && this.state.level != 0) { message.warning('请选择客户类型') return false; } if (!this.state.nature && this.state.nature != 0) { message.warning('请选择客户性质') return false; } if (this.state.nature == 0 && !this.state.natureOther) { message.warning('其他说明不能为空') return false; } let arr = []; for (let i of this.state.selectCooperationProjects) { arr.push(i.label) } if (!err) { this.setState({ loading: true }); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/customer/updateAndReceiveCustomer', data: { id: this.state.id, orgCode: values.orgCode, contacts: values.content, contactMobile: values.telnum, societyTag: '0', //社会属性默认为 社会企业 //source:values.customerSource, province: (values.ProvinceCity)[0],//省 city: (values.ProvinceCity)[1],//市 area: (values.ProvinceCity)[2],//区 type: '1', intendedProject: arr.join(','), businessScope: this.state.businessScope.join(','), position: values.position, level: this.state.level, nature: this.state.nature, natureOther: this.state.natureOther, } }).done(function (data) { this.setState({ loading: false }); if (!data.error.length) { message.success('领取成功!'); this.setState({ verification: false }) this.loadData(this.state.ispage); } else { message.warning(data.error[0].message); } }.bind(this)); } }); }, receives(e) { this.setState({ loading: true, }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/receiveCustomer", data: { uid: e.id, } }).done(function (data) { this.setState({ loading: false, }); if (data.error.length === 0) { message.success(e.signBills == 1 ? '领取成功!客户为签单客户,请在【签单单位客户】列表中查询' : '领取成功!客户为私有客户,请在【私有单位客户】列表中查询'); this.loadData(this.state.ispage); } else { message.warning(data.error[0].message); }; }.bind(this)); }, // zhuanjiaoDetailCancel() { this.setState({ zhuanjiaoVisible: false, }); }, // zhuanjiaoLog(record) { this.setState({ zhuanjiaoVisible: true, zhuanjiaoId: record.id, }); }, // seeDetail(record) { this.setState({ data: record, visitModul: true, }); }, // closeDesc(e) { this.state.visitModul = e; }, // search() { this.loadData(); }, // reset() { this.setState({ nameSearch: undefined, departmenttSearch: undefined, theTypes: undefined, auto: undefined, provinceSearch: undefined, addressSearch: [], dataSource: [] }) // this.loadData(); }, componentWillReceiveProps(nextProps) { if (nextProps.ApiUrl != this.props.ApiUrl) { this.state.nameSearch = ""; this.state.provinceSearch = undefined; this.state.addressSearch = []; this.loadData(null, nextProps.ApiUrl); } }, componentWillMount() { // this.departmentList(); //城市 let Province = []; provinceList.map(function (item) { var id = String(item.id); Province.push( {item.name} ); }); this.state.Provinces = Province; this.loadData(); }, //指定转交人自动补全 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 () { this.setState({ loading: false, }); }.bind(this) ); }, //输入转交人输入框失去焦点是判断客户是否存在 selectAuto(value, options) { this.setState({ auto: value, }); }, 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, }); }, //值改变时请求客户名称 httpChange(e) { if (e.length >= 1) { this.supervisor(e); } this.setState({ auto: e, }); }, changeList(arr) { const newArr = []; this.state.columns.forEach(item => { arr.forEach(val => { if (val === item.title) { newArr.push(item); } }); }); this.setState({ changeList: newArr }); }, render() { let departmentArr = this.state.departmentArr || []; const intentionState = this.props.intentionState; const { getFieldDecorator } = this.props.form; const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 }, }; const FormItem = Form.Item; const rowSelection = { selectedRowKeys: this.state.selectedRowKeys, onChange: (selectedRowKeys, selectedRows) => { this.setState({ modalVisible: false, selectedRows: selectedRows.slice(-1), selectedRowKeys: selectedRowKeys.slice(-1), }); }, 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({ showModal: false }) }} />
{!intentionState ? "单位客户查询" : "个人客户查询"}
{ this.setState({ nameSearch: e.target.value }); }} /> {/* */} {/* */}
{this.state.zhuanjiaoVisible ? ( ) : ( "" )} { this.setState({ verification: false, id: undefined, name: undefined, orgCode: undefined, ProvinceCity: [], content: undefined, position: undefined, telnum: undefined, businessScope: [], selectCooperationProjects: [], level: undefined, nature: undefined, natureOther: undefined, }) this.props.form.resetFields(); }} width='600px' title='客户信息' footer={null} className="admin-desc-content">
注意:请录入真实有效的客户信息
{getFieldDecorator('name', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.name })( // // // {this.state.verification && } // // )}
{getFieldDecorator('orgCode', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.orgCode })( )}
如,科德集团则填写91430105670766451M
{getFieldDecorator('ProvinceCity', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.ProvinceCity })( )}
{getFieldDecorator('content', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.content })( )}
{getFieldDecorator('position', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.position })( )}
{getFieldDecorator('telnum', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.telnum })( )}
{this.state.businessScope.map((tag, index) => { const isLongTag = tag.length > 20; const tagElem = ( this.handleClose(tag)}> {isLongTag ? `${tag.slice(0, 20)}...` : tag} ); return isLongTag ? {tagElem} : tagElem; })} { !this.state.inputVisible && }
{this.state.inputVisible && (