visitDetail.jsx 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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,getContactType} from '@/tools.js';
  7. const FormItem =Form.Item;
  8. const VisitDetail = React.createClass({
  9. getInitialState(){
  10. return{
  11. visitModul:false,
  12. loading:false,
  13. data:[],
  14. //业务意向列表
  15. intentionList:[
  16. {
  17. title: '业务名称',
  18. dataIndex: 'businessVarietiesName',
  19. width:120,
  20. key: 'businessVarietiesName'
  21. },
  22. {
  23. title: '项目名称',
  24. dataIndex: 'businessProjectName',
  25. key:'businessProjectName',
  26. width:120
  27. },
  28. {
  29. title: '最新进度',
  30. width:120,
  31. dataIndex: 'followSituation',
  32. key: 'followSituation',
  33. render: (text, record, index) => {
  34. return <div>
  35. <span>{getfllowSituation(text)}</span>
  36. </div>
  37. }
  38. }, {
  39. title: '最新状态',
  40. width:120,
  41. dataIndex: 'customerStatus',
  42. key: 'customerStatus',
  43. render: (text, record, index) => {
  44. return <div>
  45. <span>{getcustomerStatue(text)}</span>
  46. </div>
  47. }
  48. }, {
  49. title: '跟进说明',
  50. width:120,
  51. dataIndex: 'remarks',
  52. key: 'remarks',
  53. render: (text, record, index) => {
  54. return <div>
  55. <span title={text}>{text&&text.length>8?text.substr(0,8)+'…':text}</span>
  56. </div>
  57. }
  58. }
  59. ],
  60. }
  61. },
  62. //进入修改拜访记录
  63. visitModify(e) {
  64. this.setState({
  65. visitModul: true,
  66. loading: true
  67. });
  68. $.ajax({
  69. method: "get",
  70. dataType: "json",
  71. url: globalConfig.context + '/api/admin/customer/toUpdateFollow',
  72. data: {
  73. followId: e,
  74. },
  75. success: function(data) {
  76. let theArr = [];
  77. let thedata = data.data;
  78. if(!thedata) {
  79. if(data.error && data.error.length) {
  80. message.warning(data.error[0].message);
  81. };
  82. thedata = {};
  83. };
  84. for(let i = 0; i < data.data.userBusinessList.length; i++) {
  85. let thisdata = data.data.userBusinessList[i];
  86. theArr.push({
  87. key:i,
  88. readOnly:this.props.followData.readOnly,
  89. id: thisdata.ufbId,
  90. businessName:thisdata.businessProjectId,
  91. businessVarietiesName:thisdata.businessVarietiesName,
  92. businessProjectName:thisdata.businessProjectName,
  93. followSituation: thisdata.followSituation==null?undefined : String(thisdata.followSituation),
  94. customerStatus: thisdata.customerStatus==null?undefined : String(thisdata.customerStatus),
  95. remarks: thisdata.remarks,
  96. });
  97. };
  98. this.setState({
  99. followIds: thedata.followId,
  100. contacts: thedata.contacts,
  101. uid: thedata.uid,
  102. data: theArr,
  103. result: thedata.result,
  104. contactMobile:thedata.contactMobile,
  105. contactType: parseInt(thedata.contactType),
  106. followTime: thedata.followTime,
  107. followSituation: thedata.followSituation,
  108. customerStatus: thedata.customerStatus,
  109. });
  110. }.bind(this),
  111. }).always(function() {
  112. this.setState({
  113. loading: false
  114. });
  115. }.bind(this));
  116. },
  117. //拜访意向服务列表单个删除
  118. intentionDelet(e, index) {
  119. let detId = this.state.followIds;
  120. if(e.id) {
  121. this.setState({
  122. selectedRowKeys: [],
  123. });
  124. $.ajax({
  125. method: "get",
  126. dataType: "json",
  127. crossDomain: false,
  128. url: globalConfig.context + "/api/admin/customer/deleteFollowOneBusiness",
  129. data: {
  130. ufbId: e.id
  131. }
  132. }).done(function(data) {
  133. if(!data.error.length) {
  134. message.success('删除成功');
  135. this.setState({
  136. loading: false,
  137. });
  138. } else {
  139. message.warning(data.error[0].message);
  140. };
  141. this.visitModify(detId);
  142. }.bind(this));
  143. } else {
  144. this.visitModify(detId);
  145. }
  146. },
  147. //拜访modul函数
  148. visitOk(e) {
  149. this.setState({
  150. addcontactModul:false,
  151. visitModul: false
  152. });
  153. },
  154. visitCancel(e) {
  155. this.setState({
  156. addcontactModul:false,
  157. visitModul: false
  158. });
  159. },
  160. //详情保存
  161. visitSubmit(e){
  162. e.preventDefault();
  163. this.setState({
  164. loading: true
  165. });
  166. let contactsId = '';
  167. if(this.state.keys) {
  168. let conts = this.state.lastName;
  169. contactsId = this.state.contactsIdArr[conts].id;
  170. }
  171. let GlossoryId=false;
  172. this.state.data.map(function(item) {
  173. if(!item.followSituation||!item.customerStatus||!item.businessName) {
  174. GlossoryId = true
  175. }
  176. })
  177. if(this.state.data.length&&GlossoryId) {
  178. message.warning("项目名称/最新进度/最新状态不能为空!")
  179. return false;
  180. };
  181. let dataList=this.state.data,
  182. idsList=[];
  183. dataList.map((item,index) => {
  184. idsList.push({
  185. ufbId:item.id||'',
  186. businessProjectId:item.businessName,
  187. customerStatus:item.customerStatus,
  188. followSituation:item.followSituation,
  189. remarks:item.remarks||''
  190. })
  191. });
  192. //新增
  193. $.ajax({
  194. method: "post",
  195. dataType: "json",
  196. url: globalConfig.context + '/api/admin/customer/updateFollow',
  197. data: {
  198. followId: this.state.followIds,
  199. userBusinessList: JSON.stringify(idsList),
  200. uid: this.state.uid,
  201. contactType: this.state.contactType,
  202. result: this.state.result,
  203. followTime: this.state.followTime,
  204. }
  205. }).done(function(data) {
  206. this.setState({
  207. loading: false
  208. });
  209. if(!data.error.length) {
  210. message.success('保存成功!');
  211. this.props.closeDesc(false,true);
  212. this.visitCancel();
  213. } else {
  214. message.warning(data.error[0].message);
  215. }
  216. }.bind(this));
  217. },
  218. componentWillReceiveProps(nextProps) {
  219. if (nextProps.visitModul && nextProps.followData.followId) {
  220. this.setState({
  221. visitModul: true,
  222. loading: true,
  223. })
  224. this.visitModify(nextProps.followData.followId)
  225. };
  226. },
  227. render() {
  228. const formItemLayout = {
  229. labelCol: { span: 8 },
  230. wrapperCol: { span: 14 },
  231. };
  232. const followData= this.props.followData || []
  233. return(
  234. <div>
  235. <Modal
  236. className="customeDetails"
  237. footer=''
  238. title="客户跟进详情"
  239. width='1000px'
  240. visible={this.state.visitModul}
  241. onOk={this.visitOk}
  242. onCancel={this.visitCancel}
  243. >
  244. <Form layout="horizontal" id="demand-form" onSubmit={this.visitSubmit}>
  245. <Spin spinning={this.state.loading}>
  246. <div className="clearfix">
  247. <FormItem
  248. labelCol={{ span:4 }}
  249. wrapperCol={{ span: 20 }}
  250. style={{marginBottom:12}}
  251. label="跟进方式" >
  252. {!followData.readOnly?<Radio.Group value={this.state.contactType} onChange={(e) => {
  253. this.setState({ contactType: e.target.value })
  254. }}>
  255. <Radio value={0}>外出</Radio>
  256. <Radio value={1}>电话</Radio>
  257. <Radio value={2}>QQ</Radio>
  258. <Radio value={3}>微信</Radio>
  259. <Radio value={4}>邮箱</Radio>
  260. </Radio.Group>:
  261. <span>{getContactType(this.state.contactType)}</span>
  262. }
  263. </FormItem>
  264. <div className="clearfix">
  265. {!followData.readOnly&&<FormItem className="half-item"
  266. {...formItemLayout}
  267. label="当前联系人"
  268. >
  269. <span>{this.state.contacts}</span>
  270. </FormItem>}
  271. <FormItem className="half-item"
  272. {...formItemLayout}
  273. label="跟进时间"
  274. >
  275. <span>{this.state.followTime}</span>
  276. </FormItem>
  277. {!followData.readOnly&&<FormItem className="half-item"
  278. {...formItemLayout}
  279. label="联系电话"
  280. >
  281. <span>{this.state.contactMobile}</span>
  282. </FormItem>}
  283. </div>
  284. <div className="clearfix">
  285. <FormItem
  286. labelCol={{ span: 4 }}
  287. wrapperCol={{ span: 16 }}
  288. label="跟进备注" >
  289. {!followData.readOnly?<Input type="textarea" rows={4} value={this.state.result}
  290. onChange={(e)=>{this.setState({result:e.target.value})}}/>:
  291. <span>{this.state.result}</span>
  292. }
  293. </FormItem>
  294. </div>
  295. <div className="clearfix">
  296. <div style={{fontSize:'18px',marginLeft:'100px',marginTop:'15px',marginBottom:'10px'}}>业务意向</div>
  297. <div className="clearfix">
  298. <Spin spinning={this.state.loading}>
  299. <Table
  300. pagination={false}
  301. columns={this.state.intentionList}
  302. dataSource={this.state.data}
  303. />
  304. </Spin>
  305. </div>
  306. </div>
  307. </div>
  308. {!followData.readOnly&& <FormItem wrapperCol={{ span: 12, offset: 6 }}>
  309. <Button type="primary" size="large" htmlType="submit" style={{marginRight:'150px',marginTop:'20px'}}>保存</Button>
  310. <Button size="large" onClick={this.visitCancel}>取消</Button>
  311. </FormItem>}
  312. </Spin>
  313. </Form>
  314. </Modal>
  315. </div>
  316. )
  317. }
  318. })
  319. export default VisitDetail;