visitDetail.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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,getContactType,getfllowSituation,getcustomerStatue} from '@/tools.js';
  7. const FormItem =Form.Item;
  8. import BusName from '../../followDetail/businessName.jsx';
  9. const VisitDetail = React.createClass({
  10. getInitialState(){
  11. return{
  12. visitModul:false,
  13. loading:false,
  14. data:[],
  15. //业务意向列表
  16. intentionList: [{
  17. title: '业务名称',
  18. dataIndex: 'businessGlossoryId',
  19. width:120,
  20. key: 'businessGlossoryId',
  21. render: (text, record, index) => {
  22. return (
  23. <div>
  24. {!record.id?<Select placeholder="选择业务名称" value={record.businessGlossoryId} onChange={(e) => { record.businessGlossoryId = e; this.setState({ data: this.state.data }); }}>
  25. {
  26. this.props.categoryArr.map(function (item) {
  27. return <Select.Option key={item.value} >{item.key}</Select.Option>
  28. })
  29. }
  30. </Select>:
  31. <span>{record.businessVarietiesName}</span>}
  32. </div>
  33. )
  34. }
  35. },
  36. {
  37. title: '项目名称',
  38. dataIndex: 'businessName',
  39. key:'businessName',
  40. width:200,
  41. render:(text,record,index)=>{
  42. return(
  43. <div>
  44. {!record.id?<div>
  45. <Button onClick={(e)=>{e.stopPropagation(),this.businessFn(record,index)}} type="small">{record.projectName}</Button>
  46. </div>:
  47. <span>{record.businessProjectName}</span>
  48. }
  49. </div>
  50. )
  51. }
  52. },
  53. {
  54. title: '最新进度',
  55. width:120,
  56. dataIndex: 'followSituation',
  57. key: 'followSituation',
  58. render: (text, record, index) => {
  59. return <div>
  60. <span>{getfllowSituation(text)}</span>
  61. </div>
  62. }
  63. }, {
  64. title: '最新状态',
  65. width:120,
  66. dataIndex: 'customerStatus',
  67. key: 'customerStatus',
  68. render: (text, record, index) => {
  69. return <div>
  70. <span>{getcustomerStatue(text)}</span>
  71. </div>
  72. }
  73. }, {
  74. title: '跟进说明',
  75. width:180,
  76. dataIndex: 'remarks',
  77. key: 'remarks',
  78. render: (text, record, index) => {
  79. return <div>
  80. <span title={text}>{text&&text.length>8?text.substr(0,8)+'…':text}</span>
  81. </div>
  82. }
  83. // }, {
  84. // title: '操作',
  85. // dataIndex: 'rrr',
  86. // key: 'rrr',
  87. // render: (text, record, index) => {
  88. // return <div>
  89. // {!record.readOnly&&<Popconfirm title="是否删除?" onConfirm={(e)=>{this.intentionDelet(record,index)}} okText="删除" cancelText="不删除">
  90. // <Button style={{marginRight:'10px',color:'#ffffff',background:'#f00',border:'none'}}>删除</Button>
  91. // </Popconfirm>}
  92. // </div>
  93. // }
  94. }
  95. ],
  96. }
  97. },
  98. //选择子项目
  99. businessFn(record,index){
  100. if(!record.businessGlossoryId){
  101. message.warn('请先选择业务名称!');
  102. return;
  103. }
  104. this.setState({
  105. businessId:record.businessGlossoryId,
  106. busModul:true,
  107. index:index,
  108. addcontactModul:false
  109. })
  110. },
  111. closeBus(datas,e,s){
  112. this.state.addcontactModul=e;
  113. this.state.busModul=false;
  114. if(s){
  115. this.state.data[this.state.index].businessName=datas.id;
  116. this.state.data[this.state.index].projectName=datas.name;
  117. this.setState({
  118. busModul:false,
  119. data:this.state.data
  120. })
  121. }
  122. },
  123. //进入修改拜访记录
  124. visitModify(e) {
  125. this.setState({
  126. visitModul: true,
  127. loading: true
  128. });
  129. $.ajax({
  130. method: "get",
  131. dataType: "json",
  132. url: globalConfig.context + '/api/admin/customer/toUpdateFollow',
  133. data: {
  134. followId: e,
  135. },
  136. success: function(data) {
  137. let theArr = [];
  138. let thedata = data.data;
  139. if(!thedata) {
  140. if(data.error && data.error.length) {
  141. message.warning(data.error[0].message);
  142. };
  143. thedata = {};
  144. };
  145. if(thedata&&thedata.userBusinessList){
  146. for(let i = 0; i < data.data.userBusinessList.length; i++) {
  147. let thisdata = data.data.userBusinessList[i];
  148. theArr.push({
  149. id: thisdata.ufbId,
  150. readOnly:this.props.followData.readOnly,
  151. businessName:thisdata.businessProjectId,
  152. businessGlossoryId:i,
  153. businessVarietiesName:thisdata.businessVarietiesName,
  154. businessProjectName:thisdata.businessProjectName,
  155. followSituation: thisdata.followSituation==null?undefined : String(thisdata.followSituation),
  156. customerStatus: thisdata.customerStatus==null?undefined : String(thisdata.customerStatus),
  157. remarks: thisdata.remarks,
  158. });
  159. }
  160. };
  161. if(parseInt(thedata.contactType)==0){
  162. this.setState({
  163. contactType:'外出'
  164. })
  165. }else if(parseInt(thedata.contactType)==1){
  166. this.setState({
  167. contactType:'电话'
  168. })
  169. }else if(parseInt(thedata.contactType)==2){
  170. this.setState({
  171. contactType:'QQ'
  172. })
  173. }else if(parseInt(thedata.contactType)==3){
  174. this.setState({
  175. contactType:'微信'
  176. })
  177. }else if(parseInt(thedata.contactType)==4){
  178. this.setState({
  179. contactType:'邮箱'
  180. })
  181. }
  182. this.setState({
  183. followIds: thedata.followId,
  184. contacts: thedata.contacts,
  185. contactMobile:thedata.contactMobile,
  186. uid: thedata.uid,
  187. data: theArr,
  188. result: thedata.result,
  189. // contactType: parseInt(thedata.contactType),
  190. followTime:thedata.followTime
  191. });
  192. }.bind(this),
  193. }).always(function() {
  194. this.setState({
  195. loading: false
  196. });
  197. }.bind(this));
  198. },
  199. //拜访意向服务列表单个删除
  200. intentionDelet(e, index) {
  201. let detId = this.state.followIds;
  202. if(e.id) {
  203. this.setState({
  204. selectedRowKeys: [],
  205. });
  206. $.ajax({
  207. method: "get",
  208. dataType: "json",
  209. crossDomain: false,
  210. url: globalConfig.context + "/api/admin/customer/deleteFollowOneBusiness",
  211. data: {
  212. ufbId: e.id
  213. }
  214. }).done(function(data) {
  215. if(!data.error.length) {
  216. message.success('删除成功');
  217. this.setState({
  218. loading: false,
  219. });
  220. } else {
  221. message.warning(data.error[0].message);
  222. };
  223. this.visitModify(detId);
  224. }.bind(this));
  225. } else {
  226. this.visitModify(detId);
  227. }
  228. },
  229. //拜访modul函数
  230. visitOk(e) {
  231. this.setState({
  232. addcontactModul:false,
  233. visitModul: false
  234. });
  235. },
  236. visitCancel(e) {
  237. this.setState({
  238. addcontactModul:false,
  239. visitModul: false
  240. });
  241. },
  242. //详情保存
  243. visitSubmit(e){
  244. e.preventDefault();
  245. let GlossoryId=false;
  246. this.state.data.map(function(item) {
  247. if(!item.followSituation||!item.customerStatus||!item.businessName) {
  248. GlossoryId = true
  249. }
  250. })
  251. if(this.state.data.length&&GlossoryId) {
  252. message.warning("业务名称/项目名称/最新进度/最新状态不能为空!")
  253. return false;
  254. };
  255. let dataList=this.state.data,
  256. idsList=[];
  257. dataList.map((item,index) => {
  258. idsList.push({
  259. ufbId:item.id||'',
  260. businessProjectId:item.businessName,
  261. customerStatus:item.customerStatus,
  262. followSituation:item.followSituation,
  263. remarks:item.remarks||''
  264. })
  265. });
  266. this.setState({
  267. loading: true
  268. });
  269. //新增
  270. $.ajax({
  271. method: "post",
  272. dataType: "json",
  273. url: globalConfig.context + '/api/admin/customer/updateFollow',
  274. data: {
  275. userBusinessList: JSON.stringify(idsList),
  276. followId: this.state.followIds,
  277. uid: this.state.uid,
  278. contactType: this.state.contactType,
  279. result: this.state.result,
  280. followTime: this.state.followTime,
  281. }
  282. }).done(function(data) {
  283. this.setState({
  284. loading: false
  285. });
  286. if(!data.error.length) {
  287. message.success('保存成功!');
  288. this.props.closeDesc(false,true);
  289. this.visitCancel();
  290. } else {
  291. message.warning(data.error[0].message);
  292. }
  293. }.bind(this));
  294. },
  295. //添加新业务
  296. addNew(){
  297. this.state.data.push({
  298. projectName:'选择',
  299. businessName:'',
  300. customerStatus: undefined,
  301. businessGlossoryId: undefined,
  302. followSituation: undefined,
  303. remarks: '',
  304. });
  305. this.setState({
  306. addcontactModul:false,
  307. data: this.state.data
  308. })
  309. },
  310. componentWillReceiveProps(nextProps) {
  311. if (nextProps.visitModul && nextProps.followData.followId) {
  312. this.setState({
  313. visitModul: true,
  314. loading: true,
  315. })
  316. this.visitModify(nextProps.followData.followId)
  317. };
  318. },
  319. render() {
  320. const formItemLayout = {
  321. labelCol: { span: 8 },
  322. wrapperCol: { span: 14 },
  323. };
  324. const followData= this.props.followData || []
  325. return(
  326. <div>
  327. <Modal
  328. className="customeDetails"
  329. footer=''
  330. title="客户跟进详情"
  331. width='1000px'
  332. visible={this.state.visitModul}
  333. onOk={this.visitOk}
  334. onCancel={this.visitCancel}
  335. >
  336. <Form layout="horizontal" id="demand-form" onSubmit={this.visitSubmit}>
  337. <Spin spinning={this.state.loading}>
  338. <div className="clearfix">
  339. <FormItem
  340. labelCol={{ span:4 }}
  341. wrapperCol={{ span: 20 }}
  342. label="跟进方式" >
  343. <span>{this.state.contactType}</span>
  344. </FormItem>
  345. <div className="clearfix">
  346. {!followData.readOnly&&<FormItem className="half-item"
  347. {...formItemLayout}
  348. label="当前联系人"
  349. >
  350. <span>{this.state.contacts}</span>
  351. </FormItem>}
  352. <FormItem className="half-item"
  353. {...formItemLayout}
  354. label="跟进时间"
  355. >
  356. <span>{this.state.followTime}</span>
  357. </FormItem>
  358. {!followData.readOnly&&<FormItem className="half-item"
  359. {...formItemLayout}
  360. label="联系电话"
  361. >
  362. <span>{this.state.contactMobile}</span>
  363. </FormItem>}
  364. </div>
  365. <div className="clearfix">
  366. <FormItem
  367. labelCol={{ span: 4 }}
  368. wrapperCol={{ span: 16 }}
  369. label="跟进备注" >
  370. {
  371. <span>{this.state.result}</span>
  372. }
  373. </FormItem>
  374. </div>
  375. <div className="clearfix">
  376. <div style={{fontSize:'18px',marginLeft:'100px',marginTop:'15px',marginBottom:'10px'}}>业务意向</div>
  377. <div className="clearfix" >
  378. <Spin spinning={this.state.loading}>
  379. <Table
  380. rowKey={record => record.id}
  381. pagination={false}
  382. columns={this.state.intentionList}
  383. dataSource={this.state.data}
  384. />
  385. </Spin>
  386. </div>
  387. </div>
  388. </div>
  389. {!followData.readOnly&&<FormItem wrapperCol={{ span: 12, offset: 6 }}>
  390. {/* <Button type="primary" size="large" htmlType="submit" style={{marginRight:'150px',marginTop:'20px'}}>保存</Button>
  391. <Button size="large" onClick={this.visitCancel}>取消</Button> */}
  392. </FormItem>}
  393. </Spin>
  394. </Form>
  395. </Modal>
  396. <BusName
  397. businessId={this.state.businessId}
  398. busModul={this.state.busModul}
  399. closeBus={this.closeBus}
  400. mid={this.props.mid}
  401. />
  402. </div>
  403. )
  404. }
  405. })
  406. export default VisitDetail;