followDetail.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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. businessName:'',
  16. busModul:false,
  17. intentionList:[{
  18. title: '业务名称',
  19. dataIndex: 'businessGlossoryId',
  20. width:120,
  21. key: 'businessGlossoryId',
  22. render: (text, record, index) => {
  23. return (
  24. <div>
  25. <span>{getCompanyIntention(text)}</span>
  26. </div>
  27. )
  28. }
  29. },
  30. {
  31. title: '项目名称',
  32. dataIndex: 'businessName',
  33. key:'businessName',
  34. width:200,
  35. render:(text,record,index)=>{
  36. return(
  37. <div>
  38. <span title={text}>{text&&text.length>14?(text.substr(0,14)+'…'):text}</span>
  39. </div>
  40. )
  41. }
  42. },
  43. {
  44. title: '最新进度',
  45. width:120,
  46. dataIndex: 'followSituation',
  47. key: 'followSituation',
  48. render: (text, record, index) => {
  49. return <span>{getfllowSituation(text)}</span>
  50. }
  51. }, {
  52. title: '最新状态',
  53. width:120,
  54. dataIndex: 'customerStatus',
  55. key: 'customerStatus',
  56. render: (text, record, index) => {
  57. return <span>{getcustomerStatue(text)}</span>
  58. }
  59. }, {
  60. title: '跟进说明',
  61. width:120,
  62. dataIndex: 'remarks',
  63. key: 'remarks',
  64. render: (text, record, index) => {
  65. return(
  66. <div>
  67. <span title={text}>{text&&text.length>14?(text.substr(0,14)+'…'):text}</span>
  68. </div>
  69. )
  70. }
  71. }, {
  72. title: '操作',
  73. width:120,
  74. dataIndex: 'rrr',
  75. key: 'rrr',
  76. render: (text, record, index) => {
  77. return <div>
  78. <Popconfirm title="是否删除?" onConfirm={(e)=>{this.intentionDelet(record,index)}} okText="删除" cancelText="不删除">
  79. <Button style={{marginRight:'10px',color:'#ffffff',background:'#f00',border:'none'}}>删除</Button>
  80. </Popconfirm>
  81. </div>
  82. }
  83. }
  84. ],
  85. }
  86. },
  87. //拜访意向服务列表单个删除
  88. intentionDelet(e, index) {
  89. if(e.id) {
  90. this.setState({
  91. loading:true,
  92. selectedRowKeys: [],
  93. });
  94. $.ajax({
  95. method: "get",
  96. dataType: "json",
  97. crossDomain: false,
  98. url: globalConfig.context + "/api/admin/customer/deleteFollowOneBusiness",
  99. data: {
  100. ufbId: e.id
  101. }
  102. }).done(function(data) {
  103. if(!data.error.length) {
  104. message.success('删除成功');
  105. this.setState({
  106. loading: false,
  107. });
  108. } else {
  109. message.warning(data.error[0].message);
  110. };
  111. this.deletelist(this.props.followData.id)
  112. }.bind(this));
  113. }
  114. },
  115. //拜访modul函数
  116. visitOk(e) {
  117. this.setState({
  118. addcontactModul:false,
  119. visitModul: false
  120. });
  121. },
  122. visitCancel(e) {
  123. this.setState({
  124. addcontactModul:false,
  125. visitModul: false
  126. });
  127. },
  128. //获取联系人下拉框
  129. getNewWoman(ids) {
  130. this.state.data = []
  131. $.ajax({
  132. method: "get",
  133. dataType: "json",
  134. crossDomain: false,
  135. url: globalConfig.context + "/api/admin/customer/findCustomerContacts",
  136. data: {
  137. uid: ids,
  138. },
  139. success: function(data) {
  140. let theArr = [];
  141. let thedata = data.data;
  142. if(!thedata) {
  143. if(data.error && data.error.length) {
  144. message.warning(data.error[0].message);
  145. };
  146. thedata = {};
  147. };
  148. var telNum = [];
  149. var contactIds = [];
  150. thedata.map(function(item, index) {
  151. contactIds.push(thedata[index].id);
  152. telNum.push(thedata[index].mobile);
  153. });
  154. for(let item in data.data) {
  155. let theData = data.data[item];
  156. theArr.push(
  157. <Select.Option value={item} key={theData.name}>{theData.name}</Select.Option>
  158. );
  159. };
  160. this.setState({
  161. contactsIdArr: thedata,
  162. telNum: telNum,
  163. orderStatusOption: theArr,
  164. });
  165. }.bind(this),
  166. }).always(function() {
  167. this.setState({
  168. deletId: ids,
  169. loading: false
  170. });
  171. }.bind(this));
  172. },
  173. //刷新新增拜访记录刷新
  174. deletelist(e) {
  175. $.ajax({
  176. method: "get",
  177. dataType: "json",
  178. url: globalConfig.context + '/api/admin/customer/toAddFollow',
  179. data: {
  180. uid: e,
  181. },
  182. success: function(data) {
  183. let listArr = [];
  184. let thedata = data.data;
  185. if(!thedata) {
  186. if(data.error && data.error.length) {
  187. message.warning(data.error[0].message);
  188. };
  189. thedata = {};
  190. };
  191. for(let i = 0; i < data.data.userBusinessList.length; i++) {
  192. let thisdata = data.data.userBusinessList[i];
  193. listArr.push({
  194. id: thisdata.id,
  195. businessName:thisdata.businessName,
  196. businessGlossoryId: String(thisdata.businessGlossoryId),
  197. followSituation: String(thisdata.followSituation),
  198. customerStatus: String(thisdata.customerStatus),
  199. remarks: thisdata.remarks,
  200. });
  201. };
  202. this.setState({
  203. contacts: thedata.contacts,
  204. uid: thedata.uid,
  205. data: listArr,
  206. identifyName: thedata.identifyName,
  207. followTime: thedata.followTime,
  208. businessGlossoryId: thedata.businessGlossoryId,
  209. followSituation: thedata.followSituation,
  210. customerStatus: thedata.customerStatus,
  211. remarks: thedata.remarks,
  212. });
  213. }.bind(this),
  214. }).always(function() {
  215. this.setState({
  216. loading: false
  217. });
  218. }.bind(this));
  219. },
  220. //当选择联系人的列表变化时,则执行
  221. hundleName(e) {
  222. let changNub = this.state.telNum[e];
  223. this.setState({
  224. nub: this.state.telNum[e],
  225. lastName: e,
  226. });
  227. },
  228. //点击添加联系人
  229. newContacts() {
  230. this.setState({
  231. busModul:false,
  232. uids: this.state.uid,
  233. addcontactModul: true
  234. });
  235. },
  236. //页面刷新
  237. closeFollow(e, s) {
  238. this.state.addcontactModul=false;
  239. this.state.visitModul = true;
  240. if(s) {
  241. this.getNewWoman(this.props.followData.id);
  242. this.deletelist(this.props.followData.id)
  243. };
  244. },
  245. //详情保存
  246. visitSubmit(e){
  247. e.preventDefault();
  248. let GlossoryId=false;
  249. this.state.data.map(function(item) {
  250. if(!item.businessGlossoryId||!item.followSituation||!item.customerStatus) {
  251. GlossoryId = true
  252. }
  253. })
  254. if(this.state.contactType == undefined) {
  255. message.warning('请选择拜访方式')
  256. return false;
  257. };
  258. if(this.state.lastName == undefined) {
  259. message.warning('请选择联系人')
  260. return false;
  261. }
  262. if(GlossoryId) {
  263. message.warning("业务名称/最新进度/最新状态不能为空!")
  264. return false;
  265. };
  266. this.setState({
  267. loading: true
  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(this.state.data),
  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. rowKey={record => record.id}
  395. pagination={false}
  396. columns={this.state.intentionList}
  397. dataSource={this.state.data}
  398. />
  399. </Spin>
  400. </div>
  401. </div>
  402. </div>
  403. <FormItem wrapperCol={{ span: 12, offset: 6 }}>
  404. <Button type="primary" size="large" htmlType="submit" style={{marginRight:'150px',marginTop:'20px'}}>保存</Button>
  405. <Button size="large" onClick={this.visitCancel}>取消</Button>
  406. </FormItem>
  407. </Spin>
  408. </Form>
  409. </Modal>
  410. <AddContact
  411. addcontactModul={this.state.addcontactModul}
  412. uids={this.state.uids}
  413. closeFollow={this.closeFollow}
  414. />
  415. </div>
  416. )
  417. }
  418. })
  419. export default FollowDetail;