followDetail.jsx 13 KB

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