followDetail.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. import React from 'react'
  2. import ajax from 'jquery/src/ajax/xhr.js';
  3. import $ from 'jquery/src/ajax';
  4. import {Modal,Form,layout,Radio,Button,Input,Spin,Table,Select,Popconfirm,message} from 'antd';
  5. import {intentionalService,newFollow,customerStatus} from '@/dataDic.js';
  6. import {getCompanyIntention} from '@/tools.js';
  7. const FormItem =Form.Item;
  8. import AddContact from './followDetail/addContact.jsx';
  9. import BusName from './followDetail/businessName.jsx';
  10. const FollowDetail = React.createClass({
  11. getInitialState(){
  12. return{
  13. visitModul:false,
  14. loading:false,
  15. data:[],
  16. businessName:'',
  17. projectName:'',
  18. busModul:false,
  19. intentionList:[{
  20. title: '业务名称',
  21. dataIndex: 'businessGlossoryId',
  22. width:120,
  23. key: 'businessGlossoryId',
  24. render: (text, record, index) => {
  25. return (
  26. <div>
  27. {!record.id?<Select placeholder="选择业务名称" value={record.businessGlossoryId} onChange={(e) => { record.businessGlossoryId = e; this.setState({ data: this.state.data }); }}>
  28. {
  29. this.props.categoryArr.map(function (item) {
  30. return <Select.Option key={item.value} >{item.key}</Select.Option>
  31. })
  32. }
  33. </Select>:
  34. <span>{record.businessVarietiesName}</span>}
  35. </div>
  36. )
  37. }
  38. },
  39. {
  40. title: '项目名称',
  41. dataIndex: 'businessName',
  42. key:'businessName',
  43. width:120,
  44. render:(text,record,index)=>{
  45. return(
  46. <div>
  47. {!record.id?<div>
  48. <Button onClick={(e)=>{e.stopPropagation(),this.businessFn(record,index)}} type="small">{record.projectName}</Button>
  49. </div>:
  50. <span>{record.businessProjectName}</span>
  51. }
  52. </div>
  53. )
  54. }
  55. },
  56. {
  57. title: '最新进度',
  58. width:120,
  59. dataIndex: 'followSituation',
  60. key: 'followSituation',
  61. render: (text, record, index) => {
  62. return <Select placeholder="选择最新进度" value={record.followSituation} onChange={(e) => { record.followSituation = e; this.setState({ data: this.state.data }); }}>
  63. {
  64. newFollow.map(function (item) {
  65. return <Select.Option key={item.value} >{item.key}</Select.Option>
  66. })
  67. }
  68. </Select>
  69. }
  70. }, {
  71. title: '最新状态',
  72. width:120,
  73. dataIndex: 'customerStatus',
  74. key: 'customerStatus',
  75. render: (text, record, index) => {
  76. return <Select value={record.customerStatus} placeholder="选择最新状态" onChange={(e) => { record.customerStatus = e; this.setState({ data: this.state.data }); }}>
  77. {
  78. customerStatus.map(function (item) {
  79. return <Select.Option key={item.value} >{item.key}</Select.Option>
  80. })
  81. }
  82. </Select>
  83. }
  84. }, {
  85. title: '跟进说明',
  86. width:120,
  87. dataIndex: 'remarks',
  88. key: 'remarks',
  89. render: (text, record, index) => {
  90. return <Input value={record.remarks} placeholder="跟进说明"
  91. onChange={(e) => { record.remarks = e.target.value; this.setState({ data: this.state.data }); }}
  92. />
  93. }
  94. }, {
  95. title: '操作',
  96. width:120,
  97. dataIndex: 'rrr',
  98. key: 'rrr',
  99. render: (text, record, index) => {
  100. return <div>
  101. {!record.id&&<Popconfirm title="是否删除?" onConfirm={(e)=>{this.intentionDelet(record,index)}} okText="删除" cancelText="不删除">
  102. <Button style={{marginRight:'10px',color:'#ffffff',background:'#f00',border:'none'}}>删除</Button>
  103. </Popconfirm>}
  104. </div>
  105. }
  106. }
  107. ],
  108. }
  109. },
  110. //选择子项目
  111. businessFn(record,index){
  112. if(!record.businessGlossoryId){
  113. message.warn('请先选择业务名称!');
  114. return;
  115. }
  116. this.setState({
  117. businessId:record.businessGlossoryId,
  118. busModul:true,
  119. index:index,
  120. addcontactModul:false
  121. })
  122. },
  123. closeBus(datas,e,s){
  124. this.state.addcontactModul=e;
  125. this.state.busModul=false;
  126. if(s){
  127. this.state.data[this.state.index].businessName=datas.id;
  128. this.state.data[this.state.index].projectName=datas.name;
  129. this.setState({
  130. busModul:false,
  131. data:this.state.data
  132. })
  133. }
  134. },
  135. //拜访意向服务列表单个删除
  136. intentionDelet(e, index) {
  137. let deteluserBusinessList = (this.state.data).splice(index, 1)
  138. this.setState({
  139. selectedRowKeys: [],
  140. });
  141. },
  142. //拜访modul函数
  143. visitOk(e) {
  144. this.setState({
  145. addcontactModul:false,
  146. visitModul: false
  147. });
  148. },
  149. visitCancel(e) {
  150. this.setState({
  151. addcontactModul:false,
  152. visitModul: false
  153. });
  154. },
  155. //获取联系人下拉框
  156. getNewWoman(ids) {
  157. this.state.data = []
  158. $.ajax({
  159. method: "get",
  160. dataType: "json",
  161. crossDomain: false,
  162. url: globalConfig.context + "/api/admin/customer/findCustomerContacts",
  163. data: {
  164. uid: ids,
  165. },
  166. success: function(data) {
  167. let theArr = [];
  168. let thedata = data.data;
  169. if(!thedata) {
  170. if(data.error && data.error.length) {
  171. message.warning(data.error[0].message);
  172. };
  173. thedata = {};
  174. };
  175. var telNum = [];
  176. var contactIds = [];
  177. thedata.map(function(item, index) {
  178. contactIds.push(thedata[index].id);
  179. telNum.push(thedata[index].mobile);
  180. });
  181. for(let item in data.data) {
  182. let theData = data.data[item];
  183. theArr.push(
  184. <Select.Option value={item} key={theData.name}>{theData.name}</Select.Option>
  185. );
  186. };
  187. this.setState({
  188. contactsIdArr: thedata,
  189. telNum: telNum,
  190. orderStatusOption: theArr,
  191. });
  192. }.bind(this),
  193. }).always(function() {
  194. this.setState({
  195. deletId: ids,
  196. loading: false
  197. });
  198. }.bind(this));
  199. },
  200. //刷新新增拜访记录刷新
  201. deletelist(e) {
  202. $.ajax({
  203. method: "get",
  204. dataType: "json",
  205. url: globalConfig.context + '/api/admin/customer/toAddFollow',
  206. data: {
  207. uid: e,
  208. },
  209. success: function(data) {
  210. let listArr = [];
  211. let thedata = data.data;
  212. if(!thedata) {
  213. if(data.error && data.error.length) {
  214. message.warning(data.error[0].message);
  215. };
  216. thedata = {};
  217. };
  218. for(let i = 0; i < data.data.userBusinessList.length; i++) {
  219. let thisdata = data.data.userBusinessList[i];
  220. listArr.push({
  221. id: thisdata.businessId,
  222. businessName:thisdata.businessProjectId,
  223. businessGlossoryId:i,
  224. businessVarietiesName:thisdata.businessVarietiesName,
  225. businessProjectName:thisdata.businessProjectName,
  226. followSituation: String(thisdata.followSituation),
  227. customerStatus: String(thisdata.customerStatus),
  228. remarks: thisdata.remarks,
  229. });
  230. };
  231. this.setState({
  232. contacts: thedata.contacts,
  233. uid: thedata.uid,
  234. data: listArr,
  235. followTime: thedata.followTime,
  236. remarks: thedata.remarks,
  237. });
  238. }.bind(this),
  239. }).always(function() {
  240. this.setState({
  241. loading: false
  242. });
  243. }.bind(this));
  244. },
  245. //当选择联系人的列表变化时,则执行
  246. hundleName(e) {
  247. let changNub = this.state.telNum[e];
  248. this.setState({
  249. nub: this.state.telNum[e],
  250. lastName: e,
  251. });
  252. },
  253. //点击添加联系人
  254. newContacts() {
  255. this.setState({
  256. busModul:false,
  257. uids: this.state.uid,
  258. addcontactModul: true
  259. });
  260. },
  261. //页面刷新
  262. closeFollow(e, s) {
  263. this.state.addcontactModul=false;
  264. this.state.visitModul = true;
  265. if(s) {
  266. this.getNewWoman(this.props.followData.id);
  267. this.deletelist(this.props.followData.id)
  268. };
  269. },
  270. //详情保存
  271. visitSubmit(e){
  272. e.preventDefault();
  273. let GlossoryId=false;
  274. this.state.data.map(function(item) {
  275. if(!item.followSituation||!item.customerStatus||!item.businessName) {
  276. GlossoryId = true
  277. }
  278. })
  279. if(this.state.contactType == undefined) {
  280. message.warning('请选择拜访方式')
  281. return false;
  282. };
  283. if(this.state.lastName == undefined) {
  284. message.warning('请选择联系人')
  285. return false;
  286. }
  287. if(GlossoryId) {
  288. message.warning("项目名称/最新进度/最新状态不能为空!")
  289. return false;
  290. };
  291. let dataList=this.state.data,
  292. idsList=[];
  293. dataList.map((item,index) => {
  294. idsList.push({
  295. businessId:item.id||'',
  296. businessProjectId:item.businessName,
  297. customerStatus:item.customerStatus,
  298. followSituation:item.followSituation,
  299. remarks:item.remarks||''
  300. })
  301. })
  302. this.setState({
  303. loading: true
  304. });
  305. let contactsId = '';
  306. let conts = this.state.lastName;
  307. contactsId = this.state.contactsIdArr[conts].id;
  308. //新增
  309. $.ajax({
  310. method: "post",
  311. dataType: "json",
  312. url: globalConfig.context + '/api/admin/customer/addFollow',
  313. data: {
  314. userBusinessList: JSON.stringify(idsList),
  315. uid: this.state.uid,
  316. ocbId: contactsId,
  317. contactType: this.state.contactType,
  318. result: this.state.result,
  319. followTime: this.state.followTime,
  320. }
  321. }).done(function(data) {
  322. this.setState({
  323. loading: false
  324. });
  325. if(!data.error.length) {
  326. message.success('保存成功!');
  327. this.props.closeDesc(false,true)
  328. this.visitCancel();
  329. } else {
  330. message.warning(data.error[0].message);
  331. }
  332. }.bind(this));
  333. },
  334. //添加新业务
  335. addNew(){
  336. this.state.data.push({
  337. projectName:'选择',
  338. businessName:'',
  339. customerStatus: undefined,
  340. businessGlossoryId: undefined,
  341. followSituation: undefined,
  342. remarks: '',
  343. });
  344. this.setState({
  345. addcontactModul:false,
  346. data: this.state.data
  347. })
  348. },
  349. componentWillReceiveProps(nextProps) {
  350. if (nextProps.visitModul && nextProps.followData.id) {
  351. this.setState({
  352. result: '',
  353. contactType: undefined,
  354. visitModul: true,
  355. loading: true,
  356. lastName:undefined,
  357. nub:'',
  358. busModul:false,
  359. addcontactModul:false,
  360. })
  361. this.getNewWoman(nextProps.followData.id);
  362. this.deletelist(nextProps.followData.id)
  363. };
  364. },
  365. render() {
  366. const formItemLayout = {
  367. labelCol: { span: 8 },
  368. wrapperCol: { span: 14 },
  369. };
  370. return(
  371. <div>
  372. <Modal
  373. className="customeDetails"
  374. footer=''
  375. title="客户跟进详情"
  376. width='1000px'
  377. visible={this.state.visitModul}
  378. onOk={this.visitOk}
  379. onCancel={this.visitCancel}
  380. >
  381. <Form layout="horizontal" id="demand-form" onSubmit={this.visitSubmit}>
  382. <Spin spinning={this.state.loading}>
  383. <div className="clearfix">
  384. <FormItem
  385. labelCol={{ span: 4 }}
  386. wrapperCol={{ span: 20 }}
  387. label="拜访方式" >
  388. <Radio.Group value={this.state.contactType} onChange={(e) => {
  389. this.setState({ contactType: e.target.value })
  390. }}>
  391. <Radio value={0}>外出</Radio>
  392. <Radio value={1}>电话</Radio>
  393. <Radio value={2}>QQ</Radio>
  394. <Radio value={3}>微信</Radio>
  395. <Radio value={4}>邮箱</Radio>
  396. </Radio.Group>
  397. <span className="mandatory">*</span>
  398. </FormItem>
  399. <div className="clearfix">
  400. {this.state.contacts?<span></span>:
  401. <FormItem className="half-item"
  402. {...formItemLayout}
  403. label="联系人"
  404. >
  405. <Select placeholder="选择联系人" style={{ width: 140 }}
  406. value={this.state.lastName}
  407. onChange={this.hundleName}>
  408. {this.state.orderStatusOption}
  409. </Select>
  410. <span className="mandatory">*</span>
  411. </FormItem>
  412. }
  413. <FormItem className="half-item"
  414. {...formItemLayout}
  415. >
  416. <Button type="primary" onClick={this.newContacts} style={{marginLeft:'100px'}}>添加新联系人</Button>
  417. </FormItem>
  418. <FormItem className="half-item"
  419. {...formItemLayout}
  420. label="联系电话"
  421. >
  422. <span>{this.state.nub}</span>
  423. </FormItem>
  424. <FormItem className="half-item"
  425. {...formItemLayout}
  426. label="跟进时间"
  427. >
  428. <span>{this.state.followTime}</span>
  429. </FormItem>
  430. </div>
  431. <div className="clearfix">
  432. <FormItem
  433. labelCol={{ span: 4 }}
  434. wrapperCol={{ span: 16 }}
  435. label="跟进备注" >
  436. <Input type="textarea" rows={4} value={this.state.result}
  437. onChange={(e)=>{this.setState({result:e.target.value})}}/>
  438. </FormItem>
  439. </div>
  440. <div className="clearfix">
  441. <div style={{fontSize:'18px',marginLeft:'100px',marginTop:'15px',marginBottom:'10px'}}>业务意向<Button onClick={this.addNew} style={{marginLeft:'420px',background:'green',color:'#ffffff'}}>添加新业务</Button></div>
  442. <div className="clearfix" >
  443. <Spin spinning={this.state.loading}>
  444. <Table
  445. rowKey={record => record.id}
  446. pagination={false}
  447. columns={this.state.intentionList}
  448. dataSource={this.state.data}
  449. />
  450. </Spin>
  451. </div>
  452. </div>
  453. </div>
  454. <FormItem wrapperCol={{ span: 12, offset: 6 }}>
  455. <Button type="primary" size="large" htmlType="submit" style={{marginRight:'150px',marginTop:'20px'}}>保存</Button>
  456. <Button size="large" onClick={this.visitCancel}>取消</Button>
  457. </FormItem>
  458. </Spin>
  459. </Form>
  460. </Modal>
  461. <AddContact
  462. addcontactModul={this.state.addcontactModul}
  463. uids={this.state.uids}
  464. closeFollow={this.closeFollow}
  465. />
  466. <BusName
  467. businessId={this.state.businessId}
  468. busModul={this.state.busModul}
  469. closeBus={this.closeBus}
  470. />
  471. </div>
  472. )
  473. }
  474. })
  475. export default FollowDetail;