index.jsx 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. import React,{Component} from "react";
  2. import {Button, Input, message, Modal, Popconfirm, Spin, Table, Tooltip} from "antd";
  3. import InforChange from './inforChange';
  4. import './index.less';
  5. import $ from "jquery/src/ajax";
  6. class EnterpriseNameChange extends Component{
  7. constructor(props) {
  8. super(props);
  9. this.state={
  10. visible:false,
  11. enterpriseName:'',
  12. loading:false,
  13. colunmn: [
  14. {
  15. title: "操作人名称",
  16. dataIndex: "adminName",
  17. key: "adminName",
  18. },
  19. {
  20. title: "客户名称",
  21. dataIndex: "name",
  22. key: "name",
  23. render:(text)=>{
  24. return (
  25. <Tooltip title={text}>
  26. <div style={{
  27. maxWidth:'150px',
  28. overflow:'hidden',
  29. textOverflow: "ellipsis",
  30. whiteSpace:'nowrap',
  31. }}>{text}</div>
  32. </Tooltip>
  33. )
  34. }
  35. },
  36. {
  37. title: "操作时间",
  38. dataIndex: "createTimes",
  39. key: "createTimes",
  40. },
  41. ],
  42. dataSource:[]
  43. }
  44. this.onCancel = this.onCancel.bind(this);
  45. this.onOk = this.onOk.bind(this);
  46. }
  47. onCancel(){
  48. this.setState({
  49. visible:false,
  50. loading:false,
  51. })
  52. }
  53. onOk(){
  54. if(!this.state.enterpriseName){
  55. message.warning('请输入企业名称');
  56. return;
  57. }
  58. this.setState({
  59. loading: true
  60. });
  61. $.ajax({
  62. url: globalConfig.context + "/api/admin/customer/updateUserName",
  63. method: "post",
  64. data: {
  65. uid:this.props.enterpriseId,
  66. userName:this.state.enterpriseName
  67. }
  68. }).done(
  69. function(data) {
  70. this.setState({
  71. loading: false
  72. });
  73. if (data.error.length === 0) {
  74. message.success("恭喜您,更名成功!");
  75. this.setState({
  76. visible:false
  77. })
  78. this.props.onChangeSuccess(this.state.enterpriseName);
  79. }else{
  80. message.warning(data.error[0].message);
  81. }
  82. }.bind(this)
  83. )
  84. }
  85. loadData() {
  86. this.setState({
  87. loading: true
  88. });
  89. $.ajax({
  90. method: "get",
  91. dataType: "json",
  92. crossDomain: false,
  93. url: globalConfig.context + "/api/admin/customer/listUserName",
  94. data: {
  95. uid: this.props.enterpriseId,
  96. },
  97. success: function (data) {
  98. if (data.error.length || data.data.list == "") {
  99. if (data.error && data.error.length) {
  100. message.warning(data.error[0].message);
  101. }
  102. } else {
  103. this.setState({
  104. initialName:data.data[0] ? data.data[0].name : ''
  105. })
  106. data.data.splice(0,1);
  107. this.setState({
  108. dataSource: data.data,
  109. });
  110. }
  111. }.bind(this),
  112. }).always(
  113. function () {
  114. this.setState({
  115. loading: false,
  116. });
  117. }.bind(this)
  118. );
  119. }
  120. render() {
  121. return (
  122. <span className='enterpriseNameChange'>
  123. <Button
  124. type="primary"
  125. disabled={this.props.disabled}
  126. loading={this.state.loading}
  127. style={this.props.style}
  128. onClick={()=>{
  129. if(this.props.type === 'journal'){
  130. this.loadData();
  131. }
  132. this.setState({
  133. visible:true
  134. })
  135. }}>
  136. {this.props.type === 'journal' ? '更改日志': this.props.type === 'modify' ? '企业更名': ''}
  137. </Button>
  138. {
  139. this.props.changeOtherInfor ?
  140. <InforChange
  141. enterpriseId={this.props.enterpriseId}
  142. type={this.props.type}
  143. data={this.props.data}
  144. /> : null
  145. }
  146. <Modal
  147. footer={null}
  148. maskClosable={false}
  149. width={this.props.type === 'journal' ? '1000px': this.props.type === 'modify' ? '300px': ''}
  150. title={this.props.type === 'journal' ? '更名日志': this.props.type === 'modify' ? '企业更名': ''}
  151. visible={this.state.visible}
  152. onCancel={this.onCancel}>
  153. <div>
  154. {this.props.type === 'modify' ?
  155. <div className='enterpriseNameContent'>
  156. <div className='enterpriseNameItem'>
  157. <div className='enterpriseNameTitle'>更名前:</div>
  158. <div className='enterpriseNameValue'>{this.props.enterpriseName}</div>
  159. </div>
  160. <div className='enterpriseNameItem'>
  161. <div className='enterpriseNameTitle'>更名后:</div>
  162. <div className='enterpriseNameValue'>
  163. <Input
  164. value={this.state.enterpriseName}
  165. onChange={(e) => {
  166. this.setState({
  167. enterpriseName: e.target.value
  168. })
  169. }} />
  170. </div>
  171. </div>
  172. </div> : this.props.type === 'journal' ?
  173. <div>
  174. {this.state.initialName ? <div style={{paddingBottom:'20px'}}>
  175. 初始客户名称:{this.state.initialName}
  176. </div> : null}
  177. <Spin spinning={this.state.loading} >
  178. <Table
  179. columns={this.state.colunmn}
  180. dataSource={this.state.dataSource}
  181. pagination={false}
  182. scroll={{ x: "max-content", y: 0 }}
  183. bordered
  184. size="small"
  185. />
  186. </Spin>
  187. </div> : null
  188. }
  189. {
  190. this.props.type === 'modify' ?
  191. <Popconfirm placement="top" title="确定要修改吗?" onConfirm={(e)=>{
  192. e.stopPropagation();
  193. this.onOk();
  194. }} okText="确定" cancelText="取消">
  195. <Button type='primary' onClick={this.handleCancel}>
  196. 确定修改
  197. </Button>
  198. </Popconfirm> : null
  199. }
  200. </div>
  201. </Modal>
  202. </span>
  203. )
  204. }
  205. }
  206. export default EnterpriseNameChange;