myClientDesc.jsx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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. const { RangePicker } = DatePicker;
  127. return (
  128. <Form horizontal onSubmit={this.handleSubmit} id="demand-form">
  129. <Spin spinning={this.state.loading}>
  130. <div className="clearfix">
  131. <FormItem className="half-item"
  132. {...formItemLayout}
  133. label="客户类型" >
  134. {getFieldDecorator('customerTyp', {
  135. rules: [{ required: true, message: '此项为必填项!' }],
  136. initialValue: theData.customerTyp
  137. })(
  138. <Select placeholder="选择客户类型" style={{ width: 160 }} >
  139. <Select.Option value="0" >个人客户</Select.Option>
  140. <Select.Option value="1" >公司客户</Select.Option>
  141. <Select.Option value="2" >团体客户</Select.Option>
  142. </Select>
  143. )}
  144. </FormItem>
  145. <div className="clearfix" style={{marginLeft:'40px',marginBottom:'20px',color:'#000000'}}>基本资料:</div>
  146. <div>
  147. <FormItem className="half-item"
  148. {...formItemLayout}
  149. label="录入时间" >
  150. </FormItem>
  151. </div>
  152. <div className="clearfix" style={{marginLeft:'40px',marginBottom:'20px',color:'#000000'}}>公司资料:</div>
  153. <div>
  154. <FormItem className="half-item"
  155. {...formItemLayout}
  156. label="公司名称" >
  157. {getFieldDecorator('companyName', {
  158. rules: [{ required: true, message: '此项为必填项!' }],
  159. initialValue: theData.companyName
  160. })(
  161. <Input />
  162. )}
  163. </FormItem>
  164. <FormItem className="half-item"
  165. {...formItemLayout}
  166. label="公司行业" >
  167. {getFieldDecorator('companyIndustry', {
  168. initialValue: theData.companyIndustry
  169. })(
  170. <Input />
  171. )}
  172. </FormItem>
  173. <FormItem className="half-item"
  174. {...formItemLayout}
  175. label="地区" >
  176. {getFieldDecorator('locationProvince', {
  177. initialValue: getcityArr(theData.locationProvince)
  178. })(
  179. <Select placeholder="选择地区" style={{ width: 160 }} >
  180. {
  181. cityArr.map(function (item) {
  182. return <Select.Option key={item.value} >{item.key}</Select.Option>
  183. })
  184. }
  185. </Select>
  186. )}
  187. </FormItem>
  188. <FormItem className="half-item"
  189. {...formItemLayout}
  190. label="最新跟进" >
  191. {getFieldDecorator('followSituation', {
  192. rules: [{ required: true, message: '此项为必填项!' }],
  193. initialValue: getfllowSituation(theData.followSituation)
  194. })(
  195. <Select placeholder="选择跟进进度" style={{ width: 160 }} >
  196. {
  197. newFollow.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('customerStatus', {
  208. rules: [{ required: true, message: '此项为必填项!' }],
  209. initialValue: getcustomerStatue(theData.customerStatus)
  210. })(
  211. <Select placeholder="选择客户状态" style={{ width: 160 }} >
  212. {
  213. customerStatus.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('address', {
  224. initialValue: theData.address
  225. })(
  226. <Input />
  227. )}
  228. </FormItem>
  229. <FormItem className="half-item"
  230. {...formItemLayout}
  231. label="标签" >
  232. {getFieldDecorator('tag', {
  233. initialValue: theData.tag
  234. })(
  235. <Select placeholder="选择客户标签" >
  236. {
  237. tag.map(function (item) {
  238. return <Select.Option key={item.key} >{item.key}</Select.Option>
  239. })
  240. }
  241. </Select>
  242. )}
  243. </FormItem>
  244. <div className="clearfix" >
  245. <FormItem className="half-item" style={{marginLeft:'80px'}}
  246. labelCol={{ span: 4 }}
  247. wrapperCol={{ span: 18 }}
  248. label="意向服务" >
  249. {getFieldDecorator('companyIntention', {
  250. rules: [{ required: true, message: '此项为必填项!' }],
  251. initialValue: theData.companyIntention
  252. })(
  253. <Select placeholder="选择意向服务" style={{ width: 160 }} >
  254. {
  255. intentionalService.map(function (item) {
  256. return <Select.Option key={item.value} >{item.key}</Select.Option>
  257. })
  258. }
  259. </Select>
  260. )}
  261. </FormItem>
  262. </div>
  263. <div className="clearfix">
  264. <FormItem
  265. labelCol={{ span: 4 }}
  266. wrapperCol={{ span: 18 }}
  267. label="备注" >
  268. {getFieldDecorator('remarks', {
  269. initialValue: theData.remarks
  270. })(
  271. <Input type="textarea" rows={4} />
  272. )}
  273. </FormItem>
  274. </div>
  275. </div>
  276. <div className="clearfix" style={{marginLeft:'40px',marginBottom:'20px',color:'#000000'}}>联系资料:</div>
  277. <div>
  278. <FormItem className="half-item"
  279. {...formItemLayout}
  280. label="姓名" >
  281. {getFieldDecorator('name', {
  282. rules: [{ required: true, message: '此项为必填项!' }],
  283. initialValue: theData.name
  284. })(
  285. <Input />
  286. )}
  287. </FormItem>
  288. <FormItem className="half-item"
  289. {...formItemLayout}
  290. label="手机号码" >
  291. {getFieldDecorator('telNum', {
  292. rules: [{ required: true, message: '此项为必填项!' }],
  293. initialValue: theData.telNum
  294. })(
  295. <Input />
  296. )}
  297. </FormItem>
  298. <FormItem className="half-item"
  299. {...formItemLayout}
  300. label="性别" >
  301. {getFieldDecorator('sex', {
  302. initialValue: getsex(theData.sex)
  303. })(
  304. <Radio.Group>
  305. <Radio value="0">男</Radio>
  306. <Radio value="1">女</Radio>
  307. </Radio.Group>
  308. )}
  309. </FormItem>
  310. <FormItem className="half-item"
  311. {...formItemLayout}
  312. label="座机号" >
  313. {getFieldDecorator('mobile', {
  314. initialValue: theData.mobile
  315. })(
  316. <Input />
  317. )}
  318. </FormItem>
  319. <FormItem className="half-item"
  320. {...formItemLayout}
  321. label="QQ号码" >
  322. {getFieldDecorator('qq', {
  323. initialValue: theData.qq
  324. })(
  325. <Input />
  326. )}
  327. </FormItem>
  328. <FormItem className="half-item"
  329. {...formItemLayout}
  330. label="邮箱号" >
  331. {getFieldDecorator('email', {
  332. initialValue: theData.email
  333. })(
  334. <Input />
  335. )}
  336. </FormItem>
  337. <FormItem className="half-item"
  338. {...formItemLayout}
  339. label="微信" >
  340. {getFieldDecorator('wechat', {
  341. initialValue: theData.wechat
  342. })(
  343. <Input />
  344. )}
  345. </FormItem>
  346. <FormItem className="half-item"
  347. {...formItemLayout}
  348. label="部门" >
  349. {getFieldDecorator('depatrment', {
  350. initialValue: theData.depatrment
  351. })(
  352. <Input />
  353. )}
  354. </FormItem>
  355. <FormItem className="half-item"
  356. {...formItemLayout}
  357. label="职位" >
  358. {getFieldDecorator('customerPosition', {
  359. initialValue: theData.customerPosition
  360. })(
  361. <Input />
  362. )}
  363. </FormItem>
  364. </div>
  365. </div>
  366. <FormItem wrapperCol={{ span: 12, offset: 4 }}>
  367. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  368. <Button className="set-submit" type="ghost" onClick={this.props.closeDesc}>取消</Button>
  369. </FormItem>
  370. </Spin>
  371. </Form >
  372. )
  373. }
  374. }));
  375. const CustomerDetail = React.createClass({
  376. getInitialState() {
  377. return {
  378. visible: false,
  379. tabsKey: 1,
  380. loading: false,
  381. dataSource: [],
  382. };
  383. },
  384. handleCancel(e) {
  385. this.setState({
  386. visible: false,
  387. });
  388. this.props.closeDesc(false);
  389. },
  390. handleOk(e) {
  391. this.setState({
  392. visible: false,
  393. });
  394. this.props.closeDesc(false, true);
  395. },
  396. componentWillReceiveProps(nextProps) {
  397. if (!this.state.visible && nextProps.showDesc) {
  398. this.state.tabsKey = "1";
  399. };
  400. this.state.visible = nextProps.showDesc;
  401. },
  402. render() {
  403. return (
  404. <div className="patent-desc">
  405. <Modal maskClosable={false} visible={this.state.visible}
  406. onOk={this.checkPatentProcess} onCancel={this.handleCancel}
  407. width='1000px'
  408. title='新建客户'
  409. footer=''
  410. className="admin-desc-content">
  411. <Spin spinning={this.state.loading}>
  412. <AchievementDetailForm
  413. data={this.props.data}
  414. closeDesc={this.handleCancel}
  415. visible={this.state.visible}
  416. handleOk={this.handleOk} />
  417. </Spin>
  418. </Modal>
  419. </div>
  420. );
  421. },
  422. });
  423. export default CustomerDetail;