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