myClientDesc.jsx 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. import React from 'react';
  2. import { Icon, Modal, message, Spin, Input, Select, Button, Form } from 'antd';
  3. import './myClient.less';
  4. import ajax from 'jquery/src/ajax/xhr.js';
  5. import $ from 'jquery/src/ajax';
  6. import {socialAttribute} from '../../../dataDic.js';
  7. const AchievementDetailForm = Form.create()(React.createClass({
  8. getInitialState() {
  9. return {
  10. loading: false,
  11. data: {},
  12. };
  13. },
  14. handleSubmit(e) {
  15. e.preventDefault();
  16. this.props.form.validateFields((err, values) => {
  17. if(values.companyNamet.length>64){
  18. message.warning('联系人字数不超过64个')
  19. return false;
  20. };
  21. if(values.telnums.length>13){
  22. message.warning('电话号码字数不超过13个')
  23. return false;
  24. };
  25. if (!err) {
  26. this.setState({
  27. loading: true
  28. });
  29. $.ajax({
  30. method: "POST",
  31. dataType: "json",
  32. crossDomain: false,
  33. url: globalConfig.context + '/api/admin/customer/addCustomer',
  34. data: {
  35. contacts:values.companyNamet,
  36. societyTag:values.societyTagt,
  37. name: values.companyNamet,
  38. contactMobile: values.telnums,
  39. type:'0'
  40. }
  41. }).done(function (data) {
  42. this.setState({
  43. loading: false
  44. });
  45. if (!data.error.length) {
  46. message.success('保存成功!');
  47. this.props.handleOk();
  48. } else {
  49. message.warning(data.error[0].message);
  50. }
  51. }.bind(this));
  52. }
  53. });
  54. },
  55. //去完善
  56. addContent(){
  57. let telnum=this.state.telnum;
  58. let companyName=this.state.companyNamet;
  59. let content=this.state.content;
  60. if(!telnum||!companyName||!content){
  61. message.warning('此3项都要填');
  62. }else{
  63. this.props.newmodal(true);
  64. this.props.closeDesc(false);
  65. }
  66. },
  67. componentWillMount() {
  68. this.state.companyNamet='';
  69. this.state.telnum='';
  70. this.state.depatrments='';
  71. this.state.positions='';
  72. this.state.wechats='';
  73. this.state.qqs='';
  74. this.state.emails='';
  75. },
  76. componentWillReceiveProps(nextProps) {
  77. if (!this.props.visible && nextProps.visible) {
  78. this.state.companyNamet='';
  79. this.state.telnum='';
  80. this.props.form.resetFields();
  81. };
  82. },
  83. render() {
  84. const theData = this.state.data || {};
  85. const { getFieldDecorator } = this.props.form;
  86. const FormItem = Form.Item
  87. const formItemLayout = {
  88. labelCol: { span: 8 },
  89. wrapperCol: { span: 14 },
  90. };
  91. return (
  92. <div>
  93. <Form horizontal onSubmit={this.handleSubmit} id="demand-form">
  94. <Spin spinning={this.state.loading}>
  95. <div className="clearfix">
  96. <FormItem className="half-item"
  97. >
  98. <span className="mandatory" style={{color:'red',marginLeft:'57px'}}>*请录入真实有效的客户信息</span>
  99. </FormItem>
  100. </div>
  101. <div className="clearfix">
  102. <FormItem className="half-item"
  103. {...formItemLayout}
  104. label="客户姓名" >
  105. {getFieldDecorator('companyNamet', {
  106. rules: [{ required: true, message: '此项为必填项!' }],
  107. initialValue: this.state.companyNamet
  108. })(
  109. <Input placeholder="客户姓名" />
  110. )}
  111. </FormItem>
  112. </div>
  113. <div className="clearfix">
  114. <FormItem className="half-item"
  115. {...formItemLayout}
  116. label="联系电话" >
  117. {getFieldDecorator('telnums', {
  118. rules: [{ required: true, message: '此项为必填项!' }],
  119. initialValue: this.state.telnums
  120. })(
  121. <Input placeholder="联系电话" />
  122. )}
  123. </FormItem>
  124. </div>
  125. <div className="clearfix">
  126. <FormItem className="half-item"
  127. {...formItemLayout}
  128. label="社会属性"
  129. >
  130. {getFieldDecorator('societyTagt', {
  131. rules: [{ required: true, message: '此项为必填项!' }],
  132. initialValue: this.state.societyTagt
  133. })(
  134. <Select placeholder="客户社会属性">
  135. {
  136. socialAttribute.map(function (item) {
  137. return <Select.Option key={item.value} >{item.key}</Select.Option>
  138. })
  139. }
  140. </Select>
  141. )}
  142. </FormItem>
  143. </div>
  144. <FormItem wrapperCol={{ span: 12, offset: 4 }}>
  145. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  146. {/*<Button className="set-submit" type="primary" onClick={(e)=>{this.addContent();this.props.closeDesc}}>去完善</Button>*/}
  147. <Button className="set-submit" type="ghost" onClick={this.props.closeDesc}>取消</Button>
  148. </FormItem>
  149. </Spin>
  150. </Form >
  151. </div>
  152. )
  153. }
  154. }));
  155. const CustomerDetail = React.createClass({
  156. getInitialState() {
  157. return {
  158. visible: false,
  159. tabsKey: 1,
  160. loading: false,
  161. dataSource: [],
  162. };
  163. },
  164. handleCancel(e) {
  165. this.setState({
  166. visible: false,
  167. });
  168. this.props.closeDesc(false);
  169. },
  170. handleOk(e) {
  171. this.setState({
  172. visible: false,
  173. });
  174. this.props.closeDesc(false, true);
  175. },
  176. componentWillReceiveProps(nextProps) {
  177. if (!this.state.visible && nextProps.showDesc) {
  178. this.state.tabsKey = "1";
  179. };
  180. this.state.visible = nextProps.showDesc;
  181. },
  182. render() {
  183. return (
  184. <div className="patent-desc">
  185. <Modal maskClosable={false} visible={this.state.visible}
  186. onOk={this.checkPatentProcess} onCancel={this.handleCancel}
  187. width='800px'
  188. title='新建客户'
  189. footer=''
  190. className="admin-desc-content">
  191. <Spin spinning={this.state.loading}>
  192. <AchievementDetailForm
  193. data={this.props.data}
  194. newmodal={this.props.newmodal}
  195. closeDesc={this.handleCancel}
  196. visible={this.state.visible}
  197. handleOk={this.handleOk} />
  198. </Spin>
  199. </Modal>
  200. </div>
  201. );
  202. },
  203. });
  204. export default CustomerDetail;