myClientDesc.jsx 22 KB

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