followDetail.jsx 13 KB

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