import React, { Component } from "react"; import { AutoComplete, Button, Cascader, Input, message, Modal, Popconfirm, Select, Spin, Table, Tag, Tooltip } from "antd"; import { areaSelect, getProvince } from '@/NewDicProvinceList'; import { industry } from '@/dataDic.js' import { getIndustry } from '@/tools.js' import $ from "jquery/src/ajax"; import TextArea from "antd/es/input/TextArea"; const Option = Select.Option; class InforChange extends Component { constructor(props) { super(props); this.state = { visible: false, changeType: 0, colunmn: [ { title: "操作人名称", dataIndex: "adminName", key: "adminName", }, { title: "客户名称", dataIndex: "name", key: "name", render: (text) => { return (
{text}
) } }, { title: "操作时间", dataIndex: "createTimes", key: "createTimes", }, ], dataSource: [], inputVisible: false, inputValue: '', dataArrar: [], cooperationProjects: [], orgCode: props.data.orgCode, locationProvince: props.data.locationProvince, businessScope: props.data.businessScope, intendedProject: props.data.intendedProject, industryName: props.data.industry, } this.onChange = this.onChange.bind(this); this.onCancel = this.onCancel.bind(this); this.loadData = this.loadData.bind(this); this.onOk = this.onOk.bind(this); this.showInput = this.showInput.bind(this); this.handleInputConfirm = this.handleInputConfirm.bind(this); this.handleClose = this.handleClose.bind(this); this.handleCloseCooperation = this.handleCloseCooperation.bind(this); this.supervisor = this.supervisor.bind(this); this.onSelect = this.onSelect.bind(this); } onChange(type) { if (!this.props.data.level && this.props.data.level != 0) { Modal.warning({ title: '系统提示', content: (

请先设置客户类型。操作位置:

1.勾选客户名称

2.点击切换至“操作”项

3.选择相应的客户类型即可。

), }); return } this.setState({ visible: true, changeType: type, }) } onCancel() { this.setState({ visible: false, loading: false, changeType: 0, dataArrar: [] }) } loadData() { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/listUserName", data: { uid: this.props.enterpriseId, }, 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({ initialName: data.data[0] ? data.data[0].name : '' }) data.data.splice(0, 1); this.setState({ dataSource: data.data, }); } }.bind(this), }).always( function () { this.setState({ loading: false, }); }.bind(this) ); } onOk() { const { dataArrar } = this.state; if (this.state.changeType === 3 && !/^[A-Z0-9]{15}$|^[A-Z0-9]{17}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$/.test(dataArrar)) { message.warning('请输入正确的统一社会信用代码') return } if (this.state.changeType === 0 && dataArrar.length === 0) { message.warning('请输入省-市-区'); return; } if (this.state.changeType === 1 && dataArrar.length === 0) { message.warning('请输入企业主管产品/服务'); return; } if (this.state.changeType === 2 && dataArrar.length === 0) { message.warning('请输入意向合作项目'); return; } if (this.state.changeType === 4 && dataArrar.length === 0) { message.warning('请选择企业行业'); return } this.setState({ loading: true }); let data = { uid: this.props.enterpriseId, } if (this.state.changeType === 0) { data.province = dataArrar[0] || undefined; data.city = dataArrar[1] || undefined; data.area = dataArrar[2] || undefined; } if (this.state.changeType === 1) { data.businessScope = dataArrar.join(',') } if (this.state.changeType === 2) { let arr = []; for (let i of dataArrar) { arr.push(i.label) } data.intendedProject = arr.join(',') } if (this.state.changeType === 3) { data.orgCode = dataArrar // this.props.onCancel(); } if (this.state.changeType === 4) { data.industry = dataArrar } $.ajax({ url: globalConfig.context + "/api/admin/customer/updateUserDate", method: "post", data: data }).done( function (data) { this.setState({ loading: false }); if (data.error.length === 0) { message.success("恭喜您,更改成功!"); if (this.state.changeType === 0) { this.setState({ locationProvince: getProvince(dataArrar[0], dataArrar[1], dataArrar[2]) }) } if (this.state.changeType === 1) { this.setState({ businessScope: dataArrar.join(',') }) } if (this.state.changeType === 2) { let arr = []; for (let i of dataArrar) { arr.push(i.label) } this.setState({ intendedProject: arr.join(',') }) } if (this.state.changeType === 3) { this.setState({ orgCode: dataArrar }) this.props.onCancel(); } if (this.state.changeType === 4) { this.setState({ industryName: getIndustry(dataArrar) }) } this.onCancel(); } else { message.warning(data.error[0].message); } }.bind(this) ) } showInput() { let str = this.state.dataArrar.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.length > 16) { message.warning('单个标签字数不能超过16个字符') lv = false; return; } } if (lv) { arr = Array.from(new Set(arr)); arr = arr.filter(v => v); this.setState({ dataArrar: arr, inputVisible: false, inputValue: '', }); } } handleClose(removedTag) { let dataArrar = this.state.dataArrar.filter(tag => { return tag !== removedTag }); this.setState({ dataArrar }); } handleCloseCooperation(removedTag) { let dataArrar = this.state.dataArrar.filter(tag => { return tag.value !== removedTag.value }); this.setState({ dataArrar }); } 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 }) } } } render() { return (
统一社会信用代码:
{ !this.state.orgCode ? "待补充" : this.state.orgCode }
{this.props.type === 'modify' && } {this.props.type === 'modify' && 如,科德集团则填写91430105670766451M}
省-市-区:
{ this.state.locationProvince }
{this.props.type === 'modify' && }
企业主营产品/服务:
{ this.state.businessScope }
{this.props.type === 'modify' && }
意向合作项目:
{ this.state.intendedProject }
{this.props.type === 'modify' && }
企业行业:
{ this.state.industryName }
{this.props.type === 'modify' && }
{this.props.type === 'modify' ?
{ this.state.changeType === 0 ? '省-市-区' : this.state.changeType === 1 ? '企业主管产品/服务' : this.state.changeType === 2 ? '意向合作项目' : this.state.changeType === 3 ? '统一社会信用代码' : this.state.changeType === 4 ? '企业行业' : '' } :
{ this.state.changeType === 0 ? this.state.locationProvince : this.state.changeType === 1 ? this.state.businessScope : this.state.changeType === 2 ? this.state.intendedProject : this.state.changeType === 3 ? this.state.orgCode : this.state.changeType === 4 ? this.state.industryName : '' }
更改:
{ this.state.changeType === 0 ? { this.setState({ dataArrar: e }) }} /> : this.state.changeType === 1 ?
{this.state.dataArrar.map((tag) => { 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 && (