followDetail.jsx 13 KB

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