addIntention.jsx 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. import React from 'react';
  2. import { Modal, message, Spin, Input, Select, Button, Form, Col, Cascader, Tag, Tooltip, AutoComplete, Icon } from 'antd';
  3. import $ from 'jquery/src/ajax';
  4. import { areaSelect } from '@/NewDicProvinceList';
  5. import { socialAttribute, customerSource } from '@/dataDic.js';
  6. import TextArea from "antd/es/input/TextArea";
  7. const confirm = Modal.confirm;
  8. const AchievementDetailForm = Form.create()(React.createClass({
  9. getInitialState() {
  10. return {
  11. loading: false,
  12. data: {},
  13. detailApi: '',
  14. businessScope: [],
  15. inputVisible: false,
  16. cooperationProjects: [],
  17. selectCooperationProjects: []
  18. };
  19. },
  20. handleSubmit(e) {
  21. // if (/.*[\u4e00-\u9fa5]+.*$/.test(this.state.content)) {
  22. // } else {
  23. // message.error("请填写正确的姓名,且至少包含一个汉字");
  24. // return;
  25. // }
  26. e.preventDefault();
  27. this.props.form.validateFields((err, values) => {
  28. let re = new RegExp("^[\u4e00-\u9fa5]");
  29. if (!re.test(values.name)) {
  30. message.warning('公司名称必须以汉字开头!')
  31. return
  32. }
  33. if (!re.test(values.name.charAt(values.name.length - 1))) {
  34. message.warning('公司名称必须以汉字结尾!')
  35. return
  36. }
  37. if (values.name.length > 64) {
  38. message.warning('公司名称字数不超过64个!')
  39. return false;
  40. };
  41. let regu = /[`~!#$%^&*'_[\]+=<>?:"{}|~!#¥%……&*=-@-!{}|/《》?:“”【】、;;‘’,,.。、\s+]/g;
  42. if (regu.test(values.name)) {
  43. message.warning('公司名称不能存在特殊符号或空格!')
  44. return false;
  45. }
  46. if (!/^[A-Z0-9]{15}$|^[A-Z0-9]{17}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$/.test(values.orgCode)) {
  47. message.warning('请输入正确的统一社会信用代码!')
  48. return
  49. }
  50. if (/.*[\u4e00-\u9fa5]+.*$/.test(values.content)) {
  51. } else {
  52. message.error("请填写正确的联系人,且至少包含一个汉字");
  53. return false;
  54. };
  55. if (/.*[\u4e00-\u9fa5]+.*$/.test(values.position)) {
  56. } else {
  57. message.error("请填写正确的职位,且至少包含一个汉字");
  58. return false;
  59. };
  60. if (!values.ProvinceCity[1]) {
  61. message.warning('请选择地区');
  62. return false;
  63. };
  64. if (values.content.length > 32) {
  65. message.warning('联系人字数不超过32个')
  66. return false;
  67. };
  68. if (values.length > 13) {
  69. message.warning('电话号码字数不超过13个')
  70. return false;
  71. };
  72. if (this.state.businessScope.length === 0) {
  73. message.warning('请选择主营产品')
  74. return false;
  75. }
  76. if (this.state.selectCooperationProjects.length === 0) {
  77. message.warning('请选择意向合作项目')
  78. return false;
  79. }
  80. if (!this.state.level && this.state.level != 0) {
  81. message.warning('请选择客户类型')
  82. return false;
  83. }
  84. let arr = [];
  85. for (let i of this.state.selectCooperationProjects) {
  86. arr.push(i.label)
  87. }
  88. if (!err) {
  89. this.setState({
  90. loading: true
  91. });
  92. $.ajax({
  93. method: "POST",
  94. dataType: "json",
  95. crossDomain: false,
  96. url: globalConfig.context + '/api/admin/customer/addCustomer',
  97. data: {
  98. name: values.name,
  99. orgCode: values.orgCode,
  100. contacts: values.content,
  101. contactMobile: values.telnum,
  102. societyTag: '0', //社会属性默认为 社会企业
  103. //source:values.customerSource,
  104. province: (values.ProvinceCity)[0],//省
  105. city: (values.ProvinceCity)[1],//市
  106. area: (values.ProvinceCity)[2],//区
  107. type: '1',
  108. intendedProject: arr.join(','),
  109. businessScope: this.state.businessScope.join(','),
  110. position: values.position,
  111. level: this.state.level,
  112. }
  113. }).done(function (data) {
  114. this.setState({
  115. loading: false
  116. });
  117. if (!data.error.length) {
  118. message.success('保存成功!');
  119. this.setState({
  120. verification: false
  121. })
  122. this.props.handleOk();
  123. } else {
  124. message.warning(data.error[0].message);
  125. }
  126. }.bind(this));
  127. }
  128. });
  129. },
  130. componentWillMount() {
  131. this.state.name = '';
  132. this.state.content = '';
  133. this.state.position = '';
  134. this.state.telnum = '';
  135. // this.state.societyTagt='0';
  136. this.state.customerSource = '0';
  137. this.state.inputValue = '';
  138. this.state.businessScope = [];
  139. this.state.inputVisible = false;
  140. this.state.cooperationProjects = [];
  141. this.state.selectCooperationProjects = [];
  142. },
  143. componentWillReceiveProps(nextProps) {
  144. if (!this.props.visible && nextProps.visible) {
  145. this.state.name = '';
  146. this.state.content = '';
  147. this.state.position = '';
  148. this.state.telnum = '';
  149. this.state.inputValue = '';
  150. this.state.businessScope = [];
  151. this.state.inputVisible = false;
  152. this.state.cooperationProjects = [];
  153. this.state.selectCooperationProjects = [];
  154. // this.state.societyTagt='0';
  155. this.props.form.resetFields();
  156. };
  157. },
  158. handleClose(removedTag) {
  159. let businessScope = this.state.businessScope.filter(tag => { return tag !== removedTag });
  160. this.setState({ businessScope });
  161. },
  162. handleCloseCooperation(removedTag) {
  163. let selectCooperationProjects = this.state.selectCooperationProjects.filter(tag => { return tag.value !== removedTag.value });
  164. this.setState({ selectCooperationProjects });
  165. },
  166. showInput() {
  167. let str = this.state.businessScope.join('/')
  168. this.setState({
  169. inputVisible: true,
  170. inputValue: str
  171. });
  172. },
  173. handleInputConfirm() {
  174. let inputValue = this.state.inputValue;
  175. let arr = inputValue.split('/');
  176. let lv = true;
  177. for (let i of arr) {
  178. if (!i.replace(/\s+/g, '')) {
  179. message.warning("请填写关键词且不为空");
  180. return;
  181. }
  182. if (i.length > 16) {
  183. message.warning('单个标签字数不能超过16个字符')
  184. lv = false;
  185. return;
  186. }
  187. }
  188. if (lv) {
  189. arr = Array.from(new Set(arr));
  190. arr = arr.filter(v => v);
  191. this.setState({
  192. businessScope: arr,
  193. inputVisible: false,
  194. inputValue: '',
  195. });
  196. }
  197. },
  198. //加载(自动补全)
  199. supervisor(value) {
  200. $.ajax({
  201. method: "get",
  202. dataType: "json",
  203. crossDomain: false,
  204. url: globalConfig.context + '/api/admin/order/getBusinessProjectByName',
  205. data: {
  206. businessName: value
  207. },
  208. success: function (data) {
  209. let thedata = data.data;
  210. if (data.error.length === 0) {
  211. this.setState({
  212. cooperationProjects: thedata,
  213. });
  214. } else {
  215. message.warning(data.error[0].message);
  216. }
  217. }.bind(this),
  218. }).always(
  219. function () {
  220. }.bind(this)
  221. );
  222. },
  223. onSelect(value) {
  224. let arr = this.state.cooperationProjects.filter(v => v.id === value);
  225. let arr1 = this.state.selectCooperationProjects.filter(v => v.value === value);
  226. if (arr.length > 0) {
  227. if (arr1.length > 0) {
  228. message.warning('选项已存在');
  229. } else {
  230. this.state.selectCooperationProjects.push({
  231. label: arr[0].bname,
  232. value: arr[0].id,
  233. })
  234. this.setState({
  235. selectCooperationProjects: this.state.selectCooperationProjects
  236. })
  237. }
  238. }
  239. },
  240. checkUserName() {
  241. this.setState({
  242. verification: false
  243. })
  244. let yzName = this.props.form.getFieldValue('name')
  245. if (!yzName) {
  246. message.warning('请输入公司名称');
  247. return;
  248. }
  249. let re = new RegExp("^[\u4e00-\u9fa5]");
  250. if (!re.test(yzName)) {
  251. message.warning('公司名称必须以汉字开头!')
  252. return
  253. }
  254. if (!re.test(yzName.charAt(yzName.length - 1))) {
  255. message.warning('公司名称必须以汉字结尾!')
  256. return
  257. }
  258. if (yzName.length > 64) {
  259. message.warning('公司名称字数不超过64个!')
  260. return;
  261. };
  262. let regu = /[`~!#$%^&*'_[\]+=<>?:"{}|~!#¥%……&*=-@-!{}|/《》?:“”【】、;;‘’,,.。、\s+]/g;
  263. if (regu.test(yzName)) {
  264. message.warning('公司名称不能存在特殊符号或空格!')
  265. return false;
  266. }
  267. $.ajax({
  268. method: "get",
  269. dataType: "json",
  270. crossDomain: false,
  271. url: globalConfig.context + '/api/admin/customer/checkUserName',
  272. data: {
  273. userName: this.props.form.getFieldValue('name')
  274. },
  275. success: function (data) {
  276. if (data.error.length === 0) {
  277. if (!data.data) {
  278. this.setState({
  279. verification: true
  280. })
  281. } else {
  282. Modal.info({
  283. title: '提醒',
  284. content: (
  285. <div>
  286. <p>企业客户已存在!请在“客户管理-企业客户-企业客户查询”输入企业全称查询所属人信息</p>
  287. </div>
  288. ),
  289. });
  290. this.setState({
  291. verification: false
  292. })
  293. }
  294. } else {
  295. message.warning(data.error[0].message);
  296. }
  297. }.bind(this),
  298. }).always(
  299. function () {
  300. }.bind(this)
  301. );
  302. },
  303. render() {
  304. const theData = this.state.data || {};
  305. const { getFieldDecorator } = this.props.form;
  306. const FormItem = Form.Item
  307. const formItemLayout = {
  308. labelCol: { span: 6 },
  309. wrapperCol: { span: 14 },
  310. };
  311. return (
  312. <div>
  313. <Form layout="horizontal" onSubmit={this.handleSubmit} id="demand-form">
  314. <Spin spinning={this.state.loading}>
  315. <div>
  316. <Col style={{ color: 'red', marginBottom: '10px' }} span={12} offset={6}>注意:请录入真实有效的客户信息</Col>
  317. <div className="clearfix">
  318. <FormItem className="mid-item"
  319. {...formItemLayout}
  320. label="公司名称" >
  321. {getFieldDecorator('name', {
  322. rules: [{ required: true, message: '此项为必填项!' }],
  323. initialValue: this.state.name
  324. })(
  325. <span style={{ display: 'flex', alignItems: 'center', position: 'relative' }}>
  326. <Input placeholder="公司名称" />
  327. {this.state.verification && <Icon type="check-circle" style={{
  328. fontSize: 16,
  329. color: '#30e031',
  330. position: 'absolute',
  331. right: '80px',
  332. }} />}
  333. <Button onClick={this.checkUserName} type="primary" style={{ marginLeft: '10px' }}>验证</Button>
  334. </span>
  335. )}
  336. </FormItem>
  337. </div>
  338. <div className="clearfix">
  339. <FormItem
  340. {...formItemLayout}
  341. label="统一社会信用代码"
  342. >
  343. {getFieldDecorator('orgCode', {
  344. rules: [{ required: true, message: '此项为必填项!' }],
  345. initialValue: this.state.orgCode
  346. })(
  347. <Input placeholder="统一社会信用代码" />
  348. )}
  349. </FormItem>
  350. </div>
  351. <Col style={{ color: 'red', marginBottom: '10px' }} span={12} offset={6}>如,科德集团则填写91430105670766451M</Col>
  352. <div className="clearfix">
  353. <FormItem
  354. {...formItemLayout}
  355. label="省-市-区"
  356. >
  357. {getFieldDecorator('ProvinceCity', {
  358. rules: [{ required: true, message: '此项为必填项!' }],
  359. initialValue: this.state.ProvinceCity
  360. })(
  361. <Cascader options={areaSelect()} placeholder="选择城市" />
  362. )}
  363. </FormItem>
  364. </div>
  365. <div className="clearfix">
  366. <FormItem className="mid-item"
  367. {...formItemLayout}
  368. label="联系人" >
  369. {getFieldDecorator('content', {
  370. rules: [{ required: true, message: '此项为必填项!' }],
  371. initialValue: this.state.content
  372. })(
  373. <Input placeholder="联系人姓名" />
  374. )}
  375. </FormItem>
  376. </div>
  377. <div className="clearfix">
  378. <FormItem className="mid-item"
  379. {...formItemLayout}
  380. label="职位" >
  381. {getFieldDecorator('position', {
  382. rules: [{ required: true, message: '此项为必填项!' }],
  383. initialValue: this.state.position
  384. })(
  385. <Input placeholder="联系人职位" />
  386. )}
  387. </FormItem>
  388. </div>
  389. <div className="clearfix">
  390. <FormItem className="mid-item"
  391. {...formItemLayout}
  392. label="联系电话" >
  393. {getFieldDecorator('telnum', {
  394. rules: [{ required: true, message: '此项为必填项!' }],
  395. initialValue: this.state.telnum
  396. })(
  397. <Input placeholder="请填写手机号,仅填座机号时,请后续补充手机号" />
  398. )}
  399. </FormItem>
  400. </div>
  401. <div className="clearfix">
  402. <FormItem className="mid-item"
  403. {...formItemLayout}
  404. required
  405. label="主营产品" >
  406. <div>
  407. {this.state.businessScope.map((tag, index) => {
  408. const isLongTag = tag.length > 20;
  409. const tagElem = (
  410. <Tag closable key={tag} afterClose={() => this.handleClose(tag)}>
  411. {isLongTag ? `${tag.slice(0, 20)}...` : tag}
  412. </Tag>
  413. );
  414. return isLongTag ? <Tooltip title={tag} key={tag}>{tagElem}</Tooltip> : tagElem;
  415. })}
  416. {
  417. !this.state.inputVisible &&
  418. <Button
  419. size="small"
  420. type="primary"
  421. onClick={this.showInput}>
  422. + 新增主营产品
  423. </Button>
  424. }
  425. </div>
  426. {this.state.inputVisible && (<div>
  427. <TextArea
  428. style={{ width: '300px', height: '100px' }}
  429. value={this.state.inputValue}
  430. onChange={(e) => {
  431. this.setState({
  432. inputValue: e.target.value
  433. })
  434. }} />
  435. <div style={{ color: '#f00' }}>提示:请用 / 符号隔开关键字</div>
  436. <div>
  437. <Button
  438. size="small"
  439. type="primary"
  440. onClick={this.handleInputConfirm}>
  441. 确定
  442. </Button>
  443. <Button
  444. size="small"
  445. style={{ marginLeft: '5px' }}
  446. onClick={() => {
  447. this.setState({
  448. inputVisible: false,
  449. inputValue: ''
  450. })
  451. }}>
  452. 取消
  453. </Button>
  454. </div>
  455. </div>)}
  456. </FormItem>
  457. </div>
  458. <div className="clearfix">
  459. <FormItem
  460. className="mid-item"
  461. {...formItemLayout}
  462. required
  463. label="意向合作项目" >
  464. <div>
  465. <div style={{ paddingBottom: this.state.selectCooperationProjects.length === 0 ? 0 : '10px' }}>
  466. {this.state.selectCooperationProjects.map((tag, index) => {
  467. const isLongTag = tag.label.length > 20;
  468. const tagElem = (
  469. <Tag closable key={tag.label} afterClose={() => this.handleCloseCooperation(tag)}>
  470. {isLongTag ? `${tag.label.slice(0, 20)}...` : tag.label}
  471. </Tag>
  472. );
  473. return isLongTag ? <Tooltip title={tag.label} key={tag.label}>{tagElem}</Tooltip> : tagElem;
  474. })}
  475. </div>
  476. <div>
  477. <AutoComplete
  478. style={{ width: 200 }}
  479. onSearch={this.supervisor}
  480. onSelect={this.onSelect}
  481. placeholder="请输入关键字"
  482. >
  483. {
  484. this.state.cooperationProjects.map(function (item) {
  485. return <Select.Option key={item.id} value={item.id}>{item.bname}</Select.Option>
  486. })
  487. }
  488. </AutoComplete>
  489. </div>
  490. </div>
  491. </FormItem>
  492. </div>
  493. <div className="clearfix">
  494. <FormItem
  495. className="mid-item"
  496. {...formItemLayout}
  497. required
  498. label="客户类型" >
  499. <Select
  500. placeholder="请选择客户类型"
  501. value={this.state.level}
  502. onChange={(e) => {
  503. this.setState({ level: e });
  504. }}
  505. >
  506. <Option value={0}>一般客户(一年以上预签)</Option>
  507. <Option value={1}>意向客户(半年内预签)</Option>
  508. <Option value={2}>重点客户(一个月内预签)</Option>
  509. </Select>
  510. </FormItem>
  511. </div>
  512. {/*<div className="clearfix">*/}
  513. {/* <FormItem className="mid-item"*/}
  514. {/* {...formItemLayout}*/}
  515. {/* label="社会属性"*/}
  516. {/* >*/}
  517. {/* {getFieldDecorator('societyTagt', {*/}
  518. {/* rules: [{ required: true, message: '此项为必填项!' }],*/}
  519. {/* initialValue: this.state.societyTagt*/}
  520. {/* })(*/}
  521. {/* <Select placeholder="客户社会属性">*/}
  522. {/* {*/}
  523. {/* socialAttribute.map(function (item) {*/}
  524. {/* return <Select.Option key={item.value} >{item.key}</Select.Option>*/}
  525. {/* })*/}
  526. {/* }*/}
  527. {/* </Select>*/}
  528. {/* )}*/}
  529. {/* </FormItem>*/}
  530. {/*</div>*/}
  531. </div>
  532. <FormItem wrapperCol={{ span: 12, offset: 6 }}>
  533. <Button type="primary" htmlType="submit" style={{ marginRight: '50px' }}>保存</Button>
  534. <Button type="ghost" onClick={this.props.closeDesc}>取消</Button>
  535. </FormItem>
  536. </Spin>
  537. </Form >
  538. </div>
  539. )
  540. }
  541. }));
  542. const AddPerson = Form.create()(React.createClass({
  543. getInitialState() {
  544. return {
  545. loading: false,
  546. data: {},
  547. detailApi: ''
  548. };
  549. },
  550. handleSubmit(e) {
  551. e.preventDefault();
  552. this.props.form.validateFields((err, values) => {
  553. if (values.companyNamet.length > 64) {
  554. message.warning('联系人字数不超过64个')
  555. return false;
  556. };
  557. if (!values.ProvinceCity[1]) {
  558. message.warning('请选择地区');
  559. return false;
  560. };
  561. if (values.telnums.length > 13) {
  562. message.warning('电话号码字数不超过13个')
  563. return false;
  564. };
  565. if (!err) {
  566. this.setState({
  567. loading: true
  568. });
  569. $.ajax({
  570. method: "POST",
  571. dataType: "json",
  572. crossDomain: false,
  573. url: globalConfig.context + '/api/admin/customer/addCustomer',
  574. data: {
  575. contacts: values.companyNamet,
  576. societyTag: values.societyTagt,
  577. name: values.companyNamet,
  578. contactMobile: values.telnums,
  579. source: values.customerSource,
  580. province: (values.ProvinceCity)[0],//省
  581. city: (values.ProvinceCity)[1],//市
  582. area: (values.ProvinceCity)[2],//区
  583. type: '0'
  584. }
  585. }).done(function (data) {
  586. this.setState({
  587. loading: false
  588. });
  589. if (!data.error.length) {
  590. message.success('保存成功!');
  591. this.props.handleOk();
  592. } else {
  593. message.warning(data.error[0].message);
  594. }
  595. }.bind(this));
  596. }
  597. });
  598. },
  599. componentWillMount() {
  600. this.state.companyNamet = '';
  601. this.state.telnum = '';
  602. this.state.societyTagt = '0';
  603. this.state.customerSource = '0';
  604. },
  605. componentWillReceiveProps(nextProps) {
  606. if (!this.props.visible && nextProps.visible) {
  607. this.state.companyNamet = '';
  608. this.state.telnum = '';
  609. this.state.societyTagt = '0';
  610. this.state.customerSource = '0';
  611. this.props.form.resetFields();
  612. };
  613. },
  614. render() {
  615. const theData = this.state.data || {};
  616. const { getFieldDecorator } = this.props.form;
  617. const FormItem = Form.Item
  618. const formItemLayout = {
  619. labelCol: { span: 6 },
  620. wrapperCol: { span: 14 },
  621. };
  622. return (
  623. <div>
  624. <Form layout="horizontal" onSubmit={this.handleSubmit} id="demand-form">
  625. <Spin spinning={this.state.loading}>
  626. <Col style={{ color: 'red', marginBottom: '10px' }} span={12} offset={6}>注意:请录入真实有效的客户信息</Col>
  627. <div className="clearfix">
  628. <FormItem className="mid-item"
  629. {...formItemLayout}
  630. label="客户姓名" >
  631. {getFieldDecorator('companyNamet', {
  632. rules: [{ required: true, message: '此项为必填项!' }],
  633. initialValue: this.state.companyNamet
  634. })(
  635. <Input placeholder="客户姓名" />
  636. )}
  637. </FormItem>
  638. </div>
  639. <div className="clearfix">
  640. <FormItem
  641. {...formItemLayout}
  642. label="省-市-区"
  643. >
  644. {getFieldDecorator('ProvinceCity', {
  645. rules: [{ required: true, message: '此项为必填项!' }],
  646. initialValue: this.state.ProvinceCity
  647. })(
  648. <Cascader options={areaSelect()} placeholder="选择城市" />
  649. )}
  650. </FormItem>
  651. </div>
  652. <div className="clearfix">
  653. <FormItem className="mid-item"
  654. {...formItemLayout}
  655. label="联系电话" >
  656. {getFieldDecorator('telnums', {
  657. rules: [{ required: true, message: '此项为必填项!' }],
  658. initialValue: this.state.telnums
  659. })(
  660. <Input placeholder="联系电话" />
  661. )}
  662. </FormItem>
  663. </div>
  664. <div className="clearfix">
  665. <FormItem className="mid-item"
  666. {...formItemLayout}
  667. label="社会属性"
  668. >
  669. {getFieldDecorator('societyTagt', {
  670. rules: [{ required: true, message: '此项为必填项!' }],
  671. initialValue: this.state.societyTagt
  672. })(
  673. <Select placeholder="客户社会属性">
  674. {
  675. socialAttribute.map(function (item) {
  676. return <Select.Option key={item.value} >{item.key}</Select.Option>
  677. })
  678. }
  679. </Select>
  680. )}
  681. </FormItem>
  682. </div>
  683. <div className="clearfix">
  684. <FormItem className="mid-item"
  685. {...formItemLayout}
  686. label="客户来源"
  687. >
  688. {getFieldDecorator('customerSource', {
  689. rules: [{ required: true, message: '此项为必填项!' }],
  690. initialValue: this.state.customerSource
  691. })(
  692. <Select placeholder="客户来源">
  693. {
  694. customerSource.map(function (item) {
  695. return <Select.Option key={item.value} >{item.key}</Select.Option>
  696. })
  697. }
  698. </Select>
  699. )}
  700. </FormItem>
  701. </div>
  702. <FormItem wrapperCol={{ span: 12, offset: 6 }}>
  703. <Button style={{ marginRight: '50px' }} type="primary" htmlType="submit">保存</Button>
  704. <Button type="ghost" onClick={this.props.closeDesc}>取消</Button>
  705. </FormItem>
  706. </Spin>
  707. </Form >
  708. </div>
  709. )
  710. }
  711. }));
  712. const AddIntention = React.createClass({
  713. getInitialState() {
  714. return {
  715. visible: false,
  716. tabsKey: 1,
  717. loading: false,
  718. dataSource: [],
  719. };
  720. },
  721. handleCancel(e) {
  722. this.setState({
  723. visible: false,
  724. });
  725. this.props.closeDesc(false);
  726. },
  727. handleOk(e) {
  728. this.setState({
  729. visible: false,
  730. });
  731. this.props.closeDesc(false, true);
  732. },
  733. componentWillReceiveProps(nextProps) {
  734. if (!this.state.visible && nextProps.showDesc) {
  735. this.state.tabsKey = "1";
  736. };
  737. this.state.visible = nextProps.showDesc;
  738. },
  739. render() {
  740. return (
  741. <div className="patent-desc">
  742. {
  743. this.state.visible &&
  744. <Modal maskClosable={false} visible={this.state.visible}
  745. onOk={this.checkPatentProcess} onCancel={this.handleCancel}
  746. width='600px'
  747. title='新建客户'
  748. footer=''
  749. className="admin-desc-content">
  750. <Spin spinning={this.state.loading}>
  751. {this.props.api.indexOf('Personal') < 0 ? <AchievementDetailForm
  752. data={this.props.data}
  753. newmodal={this.props.newmodal}
  754. closeDesc={this.handleCancel}
  755. visible={this.state.visible}
  756. handleOk={this.handleOk} /> : <AddPerson
  757. data={this.props.data}
  758. newmodal={this.props.newmodal}
  759. closeDesc={this.handleCancel}
  760. visible={this.state.visible}
  761. handleOk={this.handleOk}
  762. />}
  763. </Spin>
  764. </Modal>
  765. }
  766. </div>
  767. );
  768. },
  769. });
  770. export default Form.create({})(AddIntention);