myClientDesc.jsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. import React from 'react';
  2. import { Tabs, Table, Icon, Tooltip, Modal, message, AutoComplete, Spin, DatePicker,Upload, Input, InputNumber, Select,TimePicker, Button, Radio, Form, Cascader, Tag, Switch } from 'antd';
  3. import './myClient.less';
  4. import ajax from 'jquery/src/ajax/xhr.js';
  5. import moment from 'moment';
  6. import $ from 'jquery/src/ajax';
  7. import { areaSelect } from '../../NewDicProvinceList';
  8. import { maturityList, innovationList, transferModeList,cityArr ,newFollow,customerStatus,intentionalService,tag} from '../../dataDic';
  9. import { IndustryObject, getIndustryCategory } from '../../DicIndustryList.js';
  10. import { beforeUploadFile, splitUrl, companySearch, getTransferMode, getAchievementCategory, getTechAuditStatus, getDemandType, getMaturity, getInnovation,beforeUpload, getBase64,getsex,getCompanyIntention,getcityArr,getfllowSituation,getcustomerStatue} from '../../tools.js';
  11. import throttle from '../../throttle.js';
  12. const AchievementDetailForm = Form.create()(React.createClass({
  13. getInitialState() {
  14. return {
  15. loading: false,
  16. data: {},
  17. tags: [],
  18. };
  19. },
  20. handleSubmit(e) {
  21. e.preventDefault();
  22. this.props.form.validateFields((err, values) => {
  23. //意向服务多选
  24. // let companyMore = [];
  25. // if (values.companyIntention.length) {
  26. // let companyList = [];
  27. // values.companyIntention.map(function (item) {
  28. // companyList.push(item);
  29. // });
  30. // companyMore = companyList.join(",");
  31. // };
  32. // let yearMonth = new Date().toLocaleDateString();
  33. // let yearString = yearMonth.split('/').join('-');
  34. let days = new Date();
  35. let years =days.getFullYear();
  36. let months=parseInt(days.getMonth()+1)<10? "0"+days.getMonth()+1:days.getMonth()+1;
  37. let dayt = parseInt(days.getDate())<10 ? "0"+days.getDate():days.getDate();
  38. let yearString=years+'-'+months+'-'+dayt;
  39. let hours = parseInt(days.getHours())<10 ? "0"+days.getHours():days.getHours();
  40. let minutes =parseInt(days.getMinutes())<10 ? "0"+days.getMinutes():days.getMinutes();
  41. let seconds =parseInt(days.getSeconds())<10 ? "0"+days.getSeconds():days.getSeconds();
  42. let pjstringY=hours+':'+minutes+':'+seconds ;
  43. let tags=''
  44. switch(values.tag){
  45. case '科技专家':tags=0; break;
  46. case '科研单位':tags=1; break;
  47. case '民间达人':tags=2; break;
  48. }
  49. if (!err) {
  50. this.setState({
  51. loading: true
  52. });
  53. $.ajax({
  54. method: "POST",
  55. dataType: "json",
  56. crossDomain: false,
  57. url: this.props.data.id ? globalConfig.context + '/api/admin/customer/updCustomer' : globalConfig.context + '/api/admin/customer/addCustomer',
  58. data: {
  59. id: this.props.data.id, //编号
  60. customerType:values.customerTyp ,//客户信息 1
  61. companyName: values.companyName,//公司名称 1
  62. companyIndustry: values.companyIndustry,//公司行业
  63. companyIntention: values.companyIntention,//公司意向1
  64. tag: tags,
  65. locationProvince: values.locationProvince,//省份1
  66. address: values.address,//详细地址1
  67. remarks: values.remarks,//备注1
  68. followSituation: values.followSituation,//最新跟进1
  69. customerStatus: values.customerStatus,//客户状态1
  70. name: values.name,//客户姓名1
  71. mobile: values.mobile,//座机1
  72. telNum: values.telNum,//手机号码1
  73. sex: values.sex,//性别1
  74. customerPosition: values.customerPosition,//职位1
  75. wechat: values.wechat,//微信号1
  76. qq: values.qq,//qq 1
  77. depatrment: values.depatrment,//部门 1
  78. email: values.email,//邮箱 1
  79. shareType:0,
  80. followDates:yearString+' '+pjstringY,//时间,
  81. primaryFlg:0,
  82. }
  83. }).done(function (data) {
  84. this.state.auditStatus = 0;
  85. this.setState({
  86. loading: false
  87. });
  88. if (!data.error.length) {
  89. message.success('保存成功!');
  90. this.props.handleOk();
  91. } else {
  92. message.warning(data.error[0].message);
  93. }
  94. }.bind(this));
  95. }
  96. });
  97. },
  98. componentWillMount() {
  99. this.state.therottleSearch = throttle(this.handleSearch, 1000, { leading: false }).bind(this);
  100. if (this.props.data && this.props.data.id) {
  101. this.loadData(this.props.data.id, this.props.detailApiUrl);
  102. };
  103. },
  104. componentWillReceiveProps(nextProps) {
  105. if (!this.props.visible && nextProps.visible) {
  106. if (nextProps.data && nextProps.data.id) {
  107. this.loadData(nextProps.data.id, nextProps.detailApiUrl);
  108. };
  109. this.state.data = {};
  110. this.state.tags = [];
  111. this.state.switchValue = false;
  112. this.state.radios = false;
  113. this.state.technicalPictureUrl = [];
  114. this.state.coverImg = [];
  115. this.state.maturityPictureUrl = [];
  116. this.state.textFileList = [];
  117. this.state.techPlanFileList = [];
  118. this.state.businessPlanFileList = [];
  119. this.props.form.resetFields();
  120. };
  121. },
  122. render() {
  123. const theData = this.state.data || {};
  124. const { getFieldDecorator } = this.props.form;
  125. const FormItem = Form.Item
  126. const formItemLayout = {
  127. labelCol: { span: 8 },
  128. wrapperCol: { span: 14 },
  129. };
  130. //let yearMonth = new Date().toLocaleDateString();
  131. //let yearString = yearMonth.split('/').join('-');
  132. let days = new Date();
  133. let years =days.getFullYear();
  134. let months=parseInt(days.getMonth()+1)<10? "0"+days.getMonth()+1:days.getMonth()+1;
  135. let dayt = parseInt(days.getDate())<10 ? "0"+days.getDate():days.getDate();
  136. let yearString=years+'-'+months+'-'+dayt;
  137. let hours = parseInt(days.getHours())<10 ? "0"+days.getHours():days.getHours();
  138. let minutes =parseInt(days.getMinutes())<10 ? "0"+days.getMinutes():days.getMinutes();
  139. let seconds =parseInt(days.getSeconds())<10 ? "0"+days.getSeconds():days.getSeconds();
  140. let pjstringY=hours+':'+minutes+':'+seconds ;
  141. const { RangePicker } = DatePicker;
  142. return (
  143. <Form horizontal onSubmit={this.handleSubmit} id="demand-form">
  144. <Spin spinning={this.state.loading}>
  145. <div className="clearfix">
  146. <FormItem className="half-item"
  147. {...formItemLayout}
  148. label="客户类型" >
  149. {getFieldDecorator('customerTyp', {
  150. rules: [{ required: true, message: '此项为必填项!' }],
  151. initialValue: theData.customerTyp
  152. })(
  153. <Select placeholder="选择客户类型" style={{ width: 160 }} >
  154. <Select.Option value="0" >个人客户</Select.Option>
  155. <Select.Option value="1" >公司客户</Select.Option>
  156. <Select.Option value="2" >团体客户</Select.Option>
  157. </Select>
  158. )}
  159. </FormItem>
  160. <div className="clearfix" style={{marginLeft:'40px',marginBottom:'20px',color:'#000000'}}>基本资料:</div>
  161. <div>
  162. <FormItem className="half-item"
  163. {...formItemLayout}
  164. label="录入时间" >
  165. {yearString+' '+pjstringY}
  166. </FormItem>
  167. </div>
  168. <div className="clearfix" style={{marginLeft:'40px',marginBottom:'20px',color:'#000000'}}>公司资料:</div>
  169. <div>
  170. <FormItem className="half-item"
  171. {...formItemLayout}
  172. label="公司名称" >
  173. {getFieldDecorator('companyName', {
  174. rules: [{ required: true, message: '此项为必填项!' }],
  175. initialValue: theData.companyName
  176. })(
  177. <Input />
  178. )}
  179. </FormItem>
  180. <FormItem className="half-item"
  181. {...formItemLayout}
  182. label="公司行业" >
  183. {getFieldDecorator('companyIndustry', {
  184. initialValue: theData.companyIndustry
  185. })(
  186. <Input />
  187. )}
  188. </FormItem>
  189. <FormItem className="half-item"
  190. {...formItemLayout}
  191. label="地区" >
  192. {getFieldDecorator('locationProvince', {
  193. initialValue: getcityArr(theData.locationProvince)
  194. })(
  195. <Select placeholder="选择地区" style={{ width: 160 }} >
  196. {
  197. cityArr.map(function (item) {
  198. return <Select.Option key={item.value} >{item.key}</Select.Option>
  199. })
  200. }
  201. </Select>
  202. )}
  203. </FormItem>
  204. <FormItem className="half-item"
  205. {...formItemLayout}
  206. label="最新跟进" >
  207. {getFieldDecorator('followSituation', {
  208. rules: [{ required: true, message: '此项为必填项!' }],
  209. initialValue: getfllowSituation(theData.followSituation)
  210. })(
  211. <Select placeholder="选择跟进进度" style={{ width: 160 }} >
  212. {
  213. newFollow.map(function (item) {
  214. return <Select.Option key={item.value} >{item.key}</Select.Option>
  215. })
  216. }
  217. </Select>
  218. )}
  219. </FormItem>
  220. <FormItem className="half-item"
  221. {...formItemLayout}
  222. label="客户状态" >
  223. {getFieldDecorator('customerStatus', {
  224. rules: [{ required: true, message: '此项为必填项!' }],
  225. initialValue: getcustomerStatue(theData.customerStatus)
  226. })(
  227. <Select placeholder="选择客户状态" style={{ width: 160 }} >
  228. {
  229. customerStatus.map(function (item) {
  230. return <Select.Option key={item.value} >{item.key}</Select.Option>
  231. })
  232. }
  233. </Select>
  234. )}
  235. </FormItem>
  236. <FormItem className="half-item"
  237. {...formItemLayout}
  238. label="详细地址" >
  239. {getFieldDecorator('address', {
  240. initialValue: theData.address
  241. })(
  242. <Input />
  243. )}
  244. </FormItem>
  245. <FormItem className="half-item"
  246. {...formItemLayout}
  247. label="标签" >
  248. {getFieldDecorator('tag', {
  249. initialValue: theData.tag
  250. })(
  251. <Select placeholder="选择客户标签" >
  252. {
  253. tag.map(function (item) {
  254. return <Select.Option key={item.key} >{item.key}</Select.Option>
  255. })
  256. }
  257. </Select>
  258. )}
  259. </FormItem>
  260. <div className="clearfix" >
  261. <FormItem className="half-item" style={{marginLeft:'80px'}}
  262. labelCol={{ span: 4 }}
  263. wrapperCol={{ span: 18 }}
  264. label="意向服务" >
  265. {getFieldDecorator('companyIntention', {
  266. rules: [{ required: true, message: '此项为必填项!' }],
  267. initialValue: theData.companyIntention
  268. })(
  269. <Select placeholder="选择意向服务" style={{ width: 160 }} >
  270. {
  271. intentionalService.map(function (item) {
  272. return <Select.Option key={item.value} >{item.key}</Select.Option>
  273. })
  274. }
  275. </Select>
  276. )}
  277. </FormItem>
  278. </div>
  279. <div className="clearfix">
  280. <FormItem
  281. labelCol={{ span: 4 }}
  282. wrapperCol={{ span: 18 }}
  283. label="备注" >
  284. {getFieldDecorator('remarks', {
  285. initialValue: theData.remarks
  286. })(
  287. <Input type="textarea" rows={4} />
  288. )}
  289. </FormItem>
  290. </div>
  291. </div>
  292. <div className="clearfix" style={{marginLeft:'40px',marginBottom:'20px',color:'#000000'}}>联系资料:</div>
  293. <div>
  294. <FormItem className="half-item"
  295. {...formItemLayout}
  296. label="姓名" >
  297. {getFieldDecorator('name', {
  298. rules: [{ required: true, message: '此项为必填项!' }],
  299. initialValue: theData.name
  300. })(
  301. <Input />
  302. )}
  303. </FormItem>
  304. <FormItem className="half-item"
  305. {...formItemLayout}
  306. label="手机号码" >
  307. {getFieldDecorator('telNum', {
  308. rules: [{ required: true, message: '此项为必填项!' }],
  309. initialValue: theData.telNum
  310. })(
  311. <Input />
  312. )}
  313. </FormItem>
  314. <FormItem className="half-item"
  315. {...formItemLayout}
  316. label="性别" >
  317. {getFieldDecorator('sex', {
  318. initialValue: getsex(theData.sex)
  319. })(
  320. <Radio.Group>
  321. <Radio value="0">男</Radio>
  322. <Radio value="1">女</Radio>
  323. </Radio.Group>
  324. )}
  325. </FormItem>
  326. <FormItem className="half-item"
  327. {...formItemLayout}
  328. label="座机号" >
  329. {getFieldDecorator('mobile', {
  330. initialValue: theData.mobile
  331. })(
  332. <Input />
  333. )}
  334. </FormItem>
  335. <FormItem className="half-item"
  336. {...formItemLayout}
  337. label="QQ号码" >
  338. {getFieldDecorator('qq', {
  339. initialValue: theData.qq
  340. })(
  341. <Input />
  342. )}
  343. </FormItem>
  344. <FormItem className="half-item"
  345. {...formItemLayout}
  346. label="邮箱号" >
  347. {getFieldDecorator('email', {
  348. initialValue: theData.email
  349. })(
  350. <Input />
  351. )}
  352. </FormItem>
  353. <FormItem className="half-item"
  354. {...formItemLayout}
  355. label="微信" >
  356. {getFieldDecorator('wechat', {
  357. initialValue: theData.wechat
  358. })(
  359. <Input />
  360. )}
  361. </FormItem>
  362. <FormItem className="half-item"
  363. {...formItemLayout}
  364. label="部门" >
  365. {getFieldDecorator('depatrment', {
  366. initialValue: theData.depatrment
  367. })(
  368. <Input />
  369. )}
  370. </FormItem>
  371. <FormItem className="half-item"
  372. {...formItemLayout}
  373. label="职位" >
  374. {getFieldDecorator('customerPosition', {
  375. initialValue: theData.customerPosition
  376. })(
  377. <Input />
  378. )}
  379. </FormItem>
  380. </div>
  381. </div>
  382. <FormItem wrapperCol={{ span: 12, offset: 4 }}>
  383. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  384. <Button className="set-submit" type="ghost" onClick={this.props.closeDesc}>取消</Button>
  385. </FormItem>
  386. </Spin>
  387. </Form >
  388. )
  389. }
  390. }));
  391. const CustomerDetail = React.createClass({
  392. getInitialState() {
  393. return {
  394. visible: false,
  395. tabsKey: 1,
  396. loading: false,
  397. dataSource: [],
  398. };
  399. },
  400. handleCancel(e) {
  401. this.setState({
  402. visible: false,
  403. });
  404. this.props.closeDesc(false);
  405. },
  406. handleOk(e) {
  407. this.setState({
  408. visible: false,
  409. });
  410. this.props.closeDesc(false, true);
  411. },
  412. componentWillReceiveProps(nextProps) {
  413. if (!this.state.visible && nextProps.showDesc) {
  414. this.state.tabsKey = "1";
  415. };
  416. this.state.visible = nextProps.showDesc;
  417. },
  418. render() {
  419. return (
  420. <div className="patent-desc">
  421. <Modal maskClosable={false} visible={this.state.visible}
  422. onOk={this.checkPatentProcess} onCancel={this.handleCancel}
  423. width='1000px'
  424. title='新建客户'
  425. footer=''
  426. className="admin-desc-content">
  427. <Spin spinning={this.state.loading}>
  428. <AchievementDetailForm
  429. data={this.props.data}
  430. closeDesc={this.handleCancel}
  431. visible={this.state.visible}
  432. handleOk={this.handleOk} />
  433. </Spin>
  434. </Modal>
  435. </div>
  436. );
  437. },
  438. });
  439. export default CustomerDetail;