followDetail.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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. $.ajax({
  161. method: "get",
  162. dataType: "json",
  163. url: globalConfig.context + '/api/admin/customer/toAddFollowOnLock',
  164. data: {
  165. uid: e,
  166. },
  167. success: function(data) {
  168. let listArr = [];
  169. let thedata = data.data;
  170. if(!thedata) {
  171. if(data.error && data.error.length) {
  172. message.warning(data.error[0].message);
  173. };
  174. thedata = {};
  175. };
  176. if(data.data.userBusinessList[0]!=null) {
  177. for(let i = 0; i < data.data.userBusinessList.length; i++) {
  178. let thisdata = data.data.userBusinessList[i];
  179. if(thisdata!=null){
  180. listArr.push({
  181. key:i,
  182. businessName:thisdata.businessProjectId,
  183. businessVarietiesName:thisdata.businessVarietiesName,
  184. businessProjectName:thisdata.businessProjectName,
  185. followSituation: thisdata.followSituation==null?undefined : String(thisdata.followSituation),
  186. customerStatus: thisdata.customerStatus==null?undefined : String(thisdata.customerStatus),
  187. remarks: thisdata.remarks
  188. });
  189. }
  190. };
  191. }
  192. this.setState({
  193. contacts: thedata.contacts,
  194. uid: thedata.uid,
  195. data: listArr,
  196. followTime: thedata.followTime,
  197. remarks: thedata.remarks,
  198. });
  199. }.bind(this),
  200. }).always(function() {
  201. this.setState({
  202. loading: false
  203. });
  204. }.bind(this));
  205. },
  206. //当选择联系人的列表变化时,则执行
  207. hundleName(e) {
  208. let changNub = this.state.telNum[e];
  209. this.setState({
  210. nub: this.state.telNum[e],
  211. lastName: e,
  212. });
  213. },
  214. //点击添加联系人
  215. newContacts() {
  216. this.setState({
  217. busModul:false,
  218. uids: this.state.uid,
  219. addcontactModul: true
  220. });
  221. },
  222. //页面刷新
  223. closeFollow(e, s) {
  224. this.state.addcontactModul=false;
  225. this.state.visitModul = true;
  226. if(s) {
  227. this.getNewWoman(this.props.followData.id);
  228. this.deletelist(this.props.followData.id)
  229. };
  230. },
  231. //详情保存
  232. visitSubmit(e){
  233. e.preventDefault();
  234. let GlossoryId=false;
  235. this.state.data.map(function(item) {
  236. if(!item.followSituation||!item.customerStatus||!item.businessName) {
  237. GlossoryId = true
  238. }
  239. })
  240. if(this.state.contactType == undefined) {
  241. message.warning('请选择拜访方式')
  242. return false;
  243. };
  244. if(this.state.lastName == undefined) {
  245. message.warning('请选择联系人')
  246. return false;
  247. }
  248. if(this.state.data.length&&GlossoryId) {
  249. message.warning("项目名称/最新进度/最新状态不能为空!")
  250. return false;
  251. };
  252. this.setState({
  253. loading: true
  254. });
  255. let dataList=this.state.data,
  256. idsList=[];
  257. dataList.map((item,index) => {
  258. idsList.push({
  259. businessId:item.id||'',
  260. businessProjectId:item.businessName,
  261. customerStatus:item.customerStatus,
  262. followSituation:item.followSituation,
  263. remarks:item.remarks||''
  264. })
  265. });
  266. let contactsId = '';
  267. let conts = this.state.lastName;
  268. contactsId = this.state.contactsIdArr[conts].id;
  269. //新增
  270. $.ajax({
  271. method: "post",
  272. dataType: "json",
  273. url: globalConfig.context + '/api/admin/customer/addFollow',
  274. data: {
  275. userBusinessList: JSON.stringify(idsList),
  276. uid: this.state.uid,
  277. ocbId: contactsId,
  278. contactType: this.state.contactType,
  279. result: this.state.result,
  280. followTime: this.state.followTime,
  281. }
  282. }).done(function(data) {
  283. this.setState({
  284. loading: false
  285. });
  286. if(!data.error.length) {
  287. message.success('保存成功!');
  288. this.props.closeDesc(false,true);
  289. this.visitCancel();
  290. } else {
  291. message.warning(data.error[0].message);
  292. }
  293. }.bind(this));
  294. },
  295. componentWillReceiveProps(nextProps) {
  296. if (nextProps.visitModul && nextProps.followData.id) {
  297. this.setState({
  298. result: '',
  299. contactType: undefined,
  300. visitModul: true,
  301. loading: true,
  302. lastName:undefined,
  303. nub:'',
  304. busModul:false,
  305. addcontactModul:false
  306. })
  307. this.getNewWoman(nextProps.followData.id);
  308. this.deletelist(nextProps.followData.id)
  309. };
  310. },
  311. render() {
  312. const formItemLayout = {
  313. labelCol: { span: 8 },
  314. wrapperCol: { span: 14 },
  315. };
  316. return(
  317. <div>
  318. <Modal
  319. className="customeDetails"
  320. footer=''
  321. title="客户跟进详情"
  322. width='1000px'
  323. visible={this.state.visitModul}
  324. onOk={this.visitOk}
  325. onCancel={this.visitCancel}
  326. >
  327. <Form layout="horizontal" id="demand-form" onSubmit={this.visitSubmit}>
  328. <Spin spinning={this.state.loading}>
  329. <div className="clearfix">
  330. <FormItem
  331. labelCol={{ span: 4 }}
  332. wrapperCol={{ span: 20 }}
  333. label="拜访方式" >
  334. <Radio.Group value={this.state.contactType} onChange={(e) => {
  335. this.setState({ contactType: e.target.value })
  336. }}>
  337. <Radio value={0}>外出</Radio>
  338. <Radio value={1}>电话</Radio>
  339. <Radio value={2}>QQ</Radio>
  340. <Radio value={3}>微信</Radio>
  341. <Radio value={4}>邮箱</Radio>
  342. </Radio.Group>
  343. <span className="mandatory">*</span>
  344. </FormItem>
  345. <div className="clearfix">
  346. {this.state.contacts?<span></span>:
  347. <FormItem className="half-item"
  348. {...formItemLayout}
  349. label="联系人"
  350. >
  351. <Select placeholder="选择联系人" style={{ width: 140 }}
  352. value={this.state.lastName}
  353. onChange={this.hundleName}>
  354. {this.state.orderStatusOption}
  355. </Select>
  356. <span className="mandatory">*</span>
  357. </FormItem>
  358. }
  359. <FormItem className="half-item"
  360. {...formItemLayout}
  361. >
  362. <Button type="primary" onClick={this.newContacts} style={{marginLeft:'100px'}}>添加新联系人</Button>
  363. </FormItem>
  364. <FormItem className="half-item"
  365. {...formItemLayout}
  366. label="联系电话"
  367. >
  368. <span>{this.state.nub}</span>
  369. </FormItem>
  370. <FormItem className="half-item"
  371. {...formItemLayout}
  372. label="跟进时间"
  373. >
  374. <span>{this.state.followTime}</span>
  375. </FormItem>
  376. </div>
  377. <div className="clearfix">
  378. <FormItem
  379. labelCol={{ span: 4 }}
  380. wrapperCol={{ span: 16 }}
  381. label="跟进备注" >
  382. <Input type="textarea" rows={4} value={this.state.result}
  383. onChange={(e)=>{this.setState({result:e.target.value})}}/>
  384. </FormItem>
  385. </div>
  386. <div className="clearfix">
  387. <div style={{fontSize:'18px',marginLeft:'100px',marginTop:'15px',marginBottom:'10px'}}>业务意向</div>
  388. <div className="clearfix" >
  389. <Spin spinning={this.state.loading}>
  390. <Table
  391. pagination={false}
  392. columns={this.state.intentionList}
  393. dataSource={this.state.data}
  394. />
  395. </Spin>
  396. </div>
  397. </div>
  398. </div>
  399. <FormItem wrapperCol={{ span: 12, offset: 6 }}>
  400. <Button type="primary" size="large" htmlType="submit" style={{marginRight:'150px',marginTop:'20px'}}>保存</Button>
  401. <Button size="large" onClick={this.visitCancel}>取消</Button>
  402. </FormItem>
  403. </Spin>
  404. </Form>
  405. </Modal>
  406. <AddContact
  407. addcontactModul={this.state.addcontactModul}
  408. uids={this.state.uids}
  409. closeFollow={this.closeFollow}
  410. />
  411. </div>
  412. )
  413. }
  414. })
  415. export default FollowDetail;