import React,{Component} from "react"; import {Button, Input, message, Modal, Popconfirm, Spin, Table, Tooltip} from "antd"; import InforChange from './inforChange'; import './index.less'; import $ from "jquery/src/ajax"; class EnterpriseNameChange extends Component{ constructor(props) { super(props); this.state={ visible:false, enterpriseName:'', loading:false, colunmn: [ { title: "操作人名称", dataIndex: "adminName", key: "adminName", }, { title: "客户名称", dataIndex: "name", key: "name", render:(text)=>{ return (
{text}
) } }, { title: "操作时间", dataIndex: "createTimes", key: "createTimes", }, ], dataSource:[] } this.onCancel = this.onCancel.bind(this); this.onOk = this.onOk.bind(this); } onCancel(){ this.setState({ visible:false, loading:false, }) } onOk(){ if(!this.state.enterpriseName){ message.warning('请输入企业名称'); return; } this.setState({ loading: true }); $.ajax({ url: globalConfig.context + "/api/admin/customer/updateUserName", method: "post", data: { uid:this.props.enterpriseId, userName:this.state.enterpriseName } }).done( function(data) { this.setState({ loading: false }); if (data.error.length === 0) { message.success("恭喜您,更名成功!"); this.setState({ visible:false }) this.props.onChangeSuccess(this.state.enterpriseName); }else{ message.warning(data.error[0].message); } }.bind(this) ) } 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) ); } render() { return ( { this.props.changeOtherInfor ? : null }
{this.props.type === 'modify' ?
更名前:
{this.props.enterpriseName}
更名后:
{ this.setState({ enterpriseName: e.target.value }) }} />
: this.props.type === 'journal' ?
{this.state.initialName ?
初始客户名称:{this.state.initialName}
: null} : null } { this.props.type === 'modify' ? { e.stopPropagation(); this.onOk(); }} okText="确定" cancelText="取消"> : null } ) } } export default EnterpriseNameChange;