followDetail.jsx 12 KB

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