followDetail.jsx 12 KB

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