followDetail.jsx 12 KB

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