account.jsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. import React from 'react';
  2. import {Form,Button,Spin,message,Input,Select,Radio} from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. const FormItem =Form.Item;
  6. import {statuslist,lvl,currentMember} from '@/dataDic.js';
  7. import {getcustomerTyp,getCustomerSource} from '@/tools.js';
  8. const Account =React.createClass({
  9. httpAccount(record) {
  10. $.ajax({
  11. method: "get",
  12. dataType: "json",
  13. crossDomain: false,
  14. url: globalConfig.context + '/api/admin/customer/findUserAccountDetail',
  15. data: {
  16. uid: record
  17. },
  18. success: function(data) {
  19. let thisData = data.data;
  20. if(!thisData) {
  21. if(data.error && data.error.length) {
  22. message.warning(data.error[0].message);
  23. };
  24. thisData = {};
  25. };
  26. this.setState({
  27. Accountuid: thisData.id,
  28. mobile: thisData.mobile,
  29. nickname: thisData.nickname,
  30. email: thisData.email,
  31. type: getcustomerTyp(String(thisData.type)),
  32. isMember: thisData.isMember,
  33. currentMemberStatus: String(thisData.currentMemberStatus),
  34. lvl: String(thisData.lvl),
  35. status: String(thisData.status),
  36. createTimes: thisData.createTimes,
  37. });
  38. }.bind(this),
  39. }).always(function() {
  40. this.setState({
  41. loading: false
  42. });
  43. }.bind(this));
  44. },
  45. getInitialState(){
  46. return{
  47. loading:false
  48. }
  49. },
  50. //账户信息保存
  51. accountSave(e) {
  52. e.preventDefault();
  53. if(!this.state.mobile) {
  54. message.warning('手机号码不能为空!')
  55. return false;
  56. }
  57. this.setState({
  58. loading: true
  59. });
  60. $.ajax({
  61. method: "post",
  62. dataType: "json",
  63. url: globalConfig.context + '/api/admin/customer/updateUserAccount',
  64. data: {
  65. id: this.state.Accountuid,
  66. mobile: this.state.mobile,
  67. nickname: this.state.nickname,
  68. email: this.state.email,
  69. isMember: this.state.isMember,
  70. currentMemberStatus: this.state.currentMemberStatus,
  71. lvl: this.state.lvl,
  72. // status: this.state.status,
  73. }
  74. }).done(function(data) {
  75. this.setState({
  76. loading: false
  77. });
  78. if(!data.error.length) {
  79. message.success('保存成功!');
  80. this.props.closeDetail(false,true)
  81. } else {
  82. message.warning(data.error[0].message);
  83. }
  84. }.bind(this));
  85. },
  86. componentWillMount(){
  87. this.httpAccount(this.props.data.id);
  88. },
  89. detailsModal(){
  90. this.props.closeDetail(false, false)
  91. },
  92. componentWillReceiveProps(nextProps) {
  93. if(nextProps.data.id&&nextProps.accountState){
  94. this.httpAccount(nextProps.data.id)
  95. }
  96. },
  97. render(){
  98. const formItemLayout = {
  99. labelCol: { span: 8 },
  100. wrapperCol: { span: 14 },
  101. };
  102. //this.props.isGuidanceLv //也用于判断是否为跟进管理页面
  103. return(
  104. <div className="clearfix">
  105. <Form layout="horizontal" id="demand-form" onSubmit={this.accountSave} >
  106. <Spin spinning={this.state.loading} >
  107. <FormItem className="half-item"
  108. {...formItemLayout}
  109. label="注册手机号" >
  110. <span>{this.state.mobile}</span>
  111. </FormItem>
  112. <FormItem className="half-item"
  113. {...formItemLayout}
  114. label="注册用户名" >
  115. {
  116. this.props.isGuidanceLv ?
  117. <span>{this.state.nickname}</span>:
  118. <Input value={this.state.nickname} onChange={(e) => { this.setState({ nickname: e.target.value }); }} />
  119. }
  120. </FormItem>
  121. <FormItem className="half-item"
  122. {...formItemLayout}
  123. label="注册邮箱" >
  124. {
  125. this.props.isGuidanceLv ?
  126. <span>{this.state.email}</span>:
  127. <Input value={this.state.email} onChange={(e) => { this.setState({ email: e.target.value }); }} />
  128. }
  129. </FormItem>
  130. <div className="clearfix">
  131. <FormItem className="half-item"
  132. {...formItemLayout}
  133. label="客户类型" >
  134. <span>{this.state.type}</span>
  135. </FormItem>
  136. <FormItem className="half-item"
  137. {...formItemLayout}
  138. label="创建时间" >
  139. <span>{this.state.createTimes}</span>
  140. </FormItem>
  141. {/*<FormItem className="half-item" */}
  142. {/* {...formItemLayout}*/}
  143. {/* label="账户状态"*/}
  144. {/* > */}
  145. {/* <Select placeholder="账户状态" value={this.state.status} onChange={(e) => { this.setState({ status: e }); }} >*/}
  146. {/* {*/}
  147. {/* statuslist.map(function (item) {*/}
  148. {/* return <Select.Option key={item.value} >{item.key}</Select.Option>*/}
  149. {/* })*/}
  150. {/* }*/}
  151. {/* </Select>*/}
  152. {/*</FormItem>*/}
  153. </div>
  154. {!this.props.isGuidanceLv ? <div className="clearfix">
  155. <Button className='saveBtn' type="primary" htmlType="submit">保存</Button>
  156. <Button type="ghost" onClick={this.detailsModal}>取消</Button>
  157. </div> : <div/>}
  158. </Spin>
  159. </Form>
  160. </div>
  161. )
  162. }
  163. })
  164. export default Account;