account.jsx 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. return(
  103. <div className="clearfix">
  104. <Form layout="horizontal" id="demand-form" onSubmit={this.accountSave} >
  105. <Spin spinning={this.state.loading} >
  106. <FormItem className="half-item"
  107. {...formItemLayout}
  108. label="注册手机号" >
  109. <span>{this.state.mobile}</span>
  110. </FormItem>
  111. <FormItem className="half-item"
  112. {...formItemLayout}
  113. label="注册用户名" >
  114. <Input value={this.state.nickname} onChange={(e) => { this.setState({ nickname: e.target.value }); }} />
  115. </FormItem>
  116. <FormItem className="half-item"
  117. {...formItemLayout}
  118. label="注册邮箱" >
  119. <Input value={this.state.email} onChange={(e) => { this.setState({ email: e.target.value }); }} />
  120. </FormItem>
  121. <div className="clearfix">
  122. <FormItem className="half-item"
  123. {...formItemLayout}
  124. label="客户类型" >
  125. <span>{this.state.type}</span>
  126. </FormItem>
  127. <FormItem className="half-item"
  128. {...formItemLayout}
  129. label="创建时间" >
  130. <span>{this.state.createTimes}</span>
  131. </FormItem>
  132. <FormItem className="half-item"
  133. {...formItemLayout}
  134. label="账户状态"
  135. >
  136. <Select placeholder="账户状态" value={this.state.status} onChange={(e) => { this.setState({ status: e }); }} >
  137. {
  138. statuslist.map(function (item) {
  139. return <Select.Option key={item.value} >{item.key}</Select.Option>
  140. })
  141. }
  142. </Select>
  143. </FormItem>
  144. </div>
  145. <div className="clearfix">
  146. <Button className='saveBtn' type="primary" htmlType="submit">保存</Button>
  147. <Button type="ghost" onClick={this.detailsModal}>取消</Button>
  148. </div>
  149. </Spin>
  150. </Form>
  151. </div>
  152. )
  153. }
  154. })
  155. export default Account;