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. console.log(e);
  65. if(e.id) {
  66. this.setState({
  67. loading:true,
  68. selectedRowKeys: [],
  69. });
  70. $.ajax({
  71. method: "get",
  72. dataType: "json",
  73. crossDomain: false,
  74. url: globalConfig.context + "/api/admin/customer/againProjectTask",
  75. data: {
  76. uid: e.uid,
  77. projectId:e.businessName,
  78. }
  79. }).done(function(data) {
  80. if(!data.error.length) {
  81. message.success('签单成功');
  82. this.setState({
  83. loading: false,
  84. });
  85. } else {
  86. message.warning(data.error[0].message);
  87. };
  88. //this.deletelist(this.props.followData.id)
  89. }.bind(this));
  90. }
  91. },
  92. //拜访modul函数
  93. visitOk(e) {
  94. this.setState({
  95. addcontactModul:false,
  96. visitModul: false
  97. });
  98. },
  99. visitCancel(e) {
  100. this.setState({
  101. addcontactModul:false,
  102. visitModul: false
  103. });
  104. this.props.closeDesc(false,false)
  105. },
  106. //获取联系人下拉框
  107. getNewWoman(ids) {
  108. this.state.data = []
  109. $.ajax({
  110. method: "get",
  111. dataType: "json",
  112. crossDomain: false,
  113. url: globalConfig.context + "/api/admin/customer/findCustomerContacts",
  114. data: {
  115. uid: ids,
  116. },
  117. success: function(data) {
  118. let theArr = [];
  119. let thedata = data.data;
  120. if(!thedata) {
  121. if(data.error && data.error.length) {
  122. message.warning(data.error[0].message);
  123. };
  124. thedata = {};
  125. };
  126. var telNum = [];
  127. var contactIds = [];
  128. thedata.map(function(item, index) {
  129. contactIds.push(thedata[index].id);
  130. telNum.push(thedata[index].mobile);
  131. });
  132. for(let item in data.data) {
  133. let theData = data.data[item];
  134. theArr.push(
  135. <Select.Option value={item} key={theData.name}>{theData.name}</Select.Option>
  136. );
  137. };
  138. this.setState({
  139. contactsIdArr: thedata,
  140. telNum: telNum,
  141. orderStatusOption: theArr,
  142. });
  143. }.bind(this),
  144. }).always(function() {
  145. this.setState({
  146. deletId: ids,
  147. loading: false
  148. });
  149. }.bind(this));
  150. },
  151. //刷新新增拜访记录刷新
  152. deletelist(e) {
  153. this.setState({
  154. loading:true
  155. })
  156. $.ajax({
  157. method: "get",
  158. dataType: "json",
  159. url: globalConfig.context + '/api/admin/customer/toAddFollowOnLock',
  160. data: {
  161. uid: e,
  162. },
  163. success: function(data) {
  164. let listArr = [];
  165. let thedata = data.data;
  166. if(!thedata) {
  167. if(data.error && data.error.length) {
  168. message.warning(data.error[0].message);
  169. };
  170. thedata = {};
  171. };
  172. if(data.data.userBusinessList[0]!=null) {
  173. for(let i = 0; i < data.data.userBusinessList.length; i++) {
  174. let thisdata = data.data.userBusinessList[i];
  175. if(thisdata!=null){
  176. listArr.push({
  177. key:i,
  178. id:thisdata.businessId,
  179. businessName:thisdata.businessProjectId,
  180. businessVarietiesName:thisdata.businessVarietiesName,
  181. businessProjectName:thisdata.businessProjectName,
  182. followSituation: thisdata.followSituation==null?undefined : String(thisdata.followSituation),
  183. customerStatus: thisdata.customerStatus==null?undefined : String(thisdata.customerStatus),
  184. remarks: thisdata.remarks,
  185. uid:thisdata.uid
  186. });
  187. }
  188. };
  189. }
  190. this.setState({
  191. contacts: thedata.contacts,
  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. } else {
  289. message.warning(data.error[0].message);
  290. }
  291. }.bind(this));
  292. },
  293. componentWillReceiveProps(nextProps) {
  294. if (nextProps.visitModul && nextProps.followData.id) {
  295. this.setState({
  296. result: '',
  297. contactType: undefined,
  298. visitModul: true,
  299. loading: true,
  300. lastName:undefined,
  301. nub:'',
  302. busModul:false,
  303. addcontactModul:false
  304. })
  305. this.getNewWoman(nextProps.followData.id);
  306. this.deletelist(nextProps.followData.id)
  307. };
  308. },
  309. render() {
  310. const formItemLayout = {
  311. labelCol: { span: 8 },
  312. wrapperCol: { span: 14 },
  313. };
  314. return(
  315. <div>
  316. <Modal
  317. className="customeDetails"
  318. footer=''
  319. title="客户跟进详情"
  320. width='1000px'
  321. visible={this.state.visitModul}
  322. onOk={this.visitOk}
  323. onCancel={this.visitCancel}
  324. >
  325. <Form layout="horizontal" id="demand-form" onSubmit={this.visitSubmit}>
  326. <Spin spinning={this.state.loading}>
  327. <div className="clearfix">
  328. <FormItem
  329. labelCol={{ span: 4 }}
  330. wrapperCol={{ span: 20 }}
  331. label="跟进方式" >
  332. <Radio.Group value={this.state.contactType} onChange={(e) => {
  333. this.setState({ contactType: e.target.value })
  334. }}>
  335. <Radio value={0}>外出</Radio>
  336. <Radio value={1}>电话</Radio>
  337. <Radio value={2}>QQ</Radio>
  338. <Radio value={3}>微信</Radio>
  339. <Radio value={4}>邮箱</Radio>
  340. </Radio.Group>
  341. <span className="mandatory">*</span>
  342. </FormItem>
  343. <div className="clearfix">
  344. {this.state.contacts?<span></span>:
  345. <FormItem className="half-item"
  346. {...formItemLayout}
  347. label="联系人"
  348. >
  349. <Select placeholder="选择联系人" style={{ width: 140 }}
  350. value={this.state.lastName}
  351. onChange={this.hundleName}>
  352. {this.state.orderStatusOption}
  353. </Select>
  354. <span className="mandatory">*</span>
  355. </FormItem>
  356. }
  357. <FormItem className="half-item"
  358. {...formItemLayout}
  359. >
  360. <Button type="primary" onClick={this.newContacts} style={{marginLeft:'100px'}}>添加新联系人</Button>
  361. </FormItem>
  362. <FormItem className="half-item"
  363. {...formItemLayout}
  364. label="联系电话"
  365. >
  366. <span>{this.state.nub}</span>
  367. </FormItem>
  368. <FormItem className="half-item"
  369. {...formItemLayout}
  370. label="跟进时间"
  371. >
  372. <span>{this.state.followTime}</span>
  373. </FormItem>
  374. </div>
  375. <div className="clearfix">
  376. <FormItem
  377. labelCol={{ span: 4 }}
  378. wrapperCol={{ span: 16 }}
  379. label="跟进备注" >
  380. <Input type="textarea" rows={4} value={this.state.result}
  381. onChange={(e)=>{this.setState({result:e.target.value})}}/>
  382. </FormItem>
  383. </div>
  384. <div className="clearfix">
  385. <div style={{fontSize:'18px',marginLeft:'100px',marginTop:'15px',marginBottom:'10px'}}>业务意向</div>
  386. <div className="clearfix" >
  387. <Spin spinning={this.state.loading}>
  388. <Table
  389. pagination={false}
  390. columns={this.state.intentionList}
  391. dataSource={this.state.data}
  392. />
  393. </Spin>
  394. </div>
  395. </div>
  396. </div>
  397. <FormItem wrapperCol={{ span: 12, offset: 6 }}>
  398. <Button type="primary" size="large" htmlType="submit" style={{marginRight:'150px',marginTop:'20px'}}>保存</Button>
  399. <Button size="large" onClick={this.visitCancel}>取消</Button>
  400. </FormItem>
  401. </Spin>
  402. </Form>
  403. </Modal>
  404. <AddContact
  405. addcontactModul={this.state.addcontactModul}
  406. uids={this.state.uids}
  407. closeFollow={this.closeFollow}
  408. />
  409. </div>
  410. )
  411. }
  412. })
  413. export default FollowDetail;