visitDetail.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. import React from 'react'
  2. import $ from 'jquery/src/ajax';
  3. import {Modal, Form, Button, Spin, Table, message, Tag, Tooltip} from 'antd';
  4. import {getfllowSituation,getcustomerStatue,getClockState,splitUrl,getContactType} from '@/tools.js';
  5. import ImgList from "../../../../../../common/imgList";
  6. const FormItem =Form.Item;
  7. const VisitDetail = React.createClass({
  8. getInitialState(){
  9. return{
  10. visitModul:false,
  11. loading:false,
  12. data:[],
  13. publicReleaseLog:[],
  14. followDtails:{},
  15. enclosure:[],
  16. intentionPublicReleaseLog:[
  17. {
  18. title: '状态',
  19. dataIndex: 'status',
  20. key: 'status',
  21. render: (text) => (
  22. <Tag color={getClockState(text,true).color}>{getClockState(text,true).title}</Tag>
  23. )
  24. },
  25. {
  26. title: '操作人',
  27. dataIndex: 'aname',
  28. key: 'aname',
  29. },
  30. {
  31. title: '操作时间',
  32. dataIndex: 'createTimes',
  33. key: 'createTimes',
  34. },
  35. {
  36. title: '备注',
  37. width:120,
  38. dataIndex: 'remarks',
  39. key: 'remarks',
  40. render: (text) => {
  41. return (
  42. <Tooltip placement="topLeft" title={text}>
  43. <div style={{
  44. maxWidth:'120px',
  45. overflow:'hidden',
  46. textOverflow: "ellipsis",
  47. whiteSpace:'nowrap',
  48. }}>{text}</div>
  49. </Tooltip>
  50. )
  51. }
  52. },
  53. {
  54. title: '操作',
  55. width:120,
  56. dataIndex: 'photoUrl',
  57. key: 'photoUrl',
  58. render: (text) => {
  59. let arr = splitUrl(
  60. text,
  61. ",",
  62. globalConfig.avatarHost + "/upload"
  63. )
  64. return (
  65. arr.length !== 0 ? <Button ype="primary" onClick={()=>{
  66. // console.log(arr)
  67. this.setState({
  68. visitImgModul:true,
  69. enclosure:arr
  70. })
  71. }}>
  72. 查看附件
  73. </Button> : null
  74. )
  75. }
  76. },
  77. ],
  78. //业务意向列表
  79. intentionList:[
  80. {
  81. title: '业务名称',
  82. dataIndex: 'businessVarietiesName',
  83. width:120,
  84. key: 'businessVarietiesName'
  85. },
  86. {
  87. title: '项目名称',
  88. dataIndex: 'businessProjectName',
  89. key:'businessProjectName',
  90. width:120
  91. },
  92. {
  93. title: '最新进度',
  94. width:120,
  95. dataIndex: 'followSituation',
  96. key: 'followSituation',
  97. render: (text, record, index) => {
  98. return <div>
  99. <span>{getfllowSituation(text)}</span>
  100. </div>
  101. }
  102. }, {
  103. title: '最新状态',
  104. width:120,
  105. dataIndex: 'customerStatus',
  106. key: 'customerStatus',
  107. render: (text, record, index) => {
  108. return <div>
  109. <span>{getcustomerStatue(text)}</span>
  110. </div>
  111. }
  112. }, {
  113. title: '跟进说明',
  114. width:120,
  115. dataIndex: 'remarks',
  116. key: 'remarks',
  117. render: (text, record, index) => {
  118. return <div>
  119. <span title={text}>{text&&text.length>8?text.substr(0,8)+'…':text}</span>
  120. </div>
  121. }
  122. }
  123. ],
  124. }
  125. },
  126. //进入修改拜访记录
  127. visitModify(e) {
  128. this.setState({
  129. visitModul: true,
  130. loading: true
  131. });
  132. $.ajax({
  133. method: "get",
  134. dataType: "json",
  135. url: globalConfig.context + '/api/admin/customer/toUpdateFollow',
  136. data: {
  137. followId: e,
  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. for(let i = 0; i < data.data.userBusinessList.length; i++) {
  149. let thisdata = data.data.userBusinessList[i];
  150. theArr.push({
  151. key:i,
  152. readOnly:this.props.followData.readOnly,
  153. id: thisdata.ufbId,
  154. businessName:thisdata.businessProjectId,
  155. businessVarietiesName:thisdata.businessVarietiesName,
  156. businessProjectName:thisdata.businessProjectName,
  157. followSituation: thisdata.followSituation==null?undefined : String(thisdata.followSituation),
  158. customerStatus: thisdata.customerStatus==null?undefined : String(thisdata.customerStatus),
  159. remarks: thisdata.remarks,
  160. });
  161. };
  162. this.setState({
  163. followIds: thedata.followId,
  164. contacts: thedata.contacts,
  165. uid: thedata.uid,
  166. data: theArr,
  167. result: thedata.result,
  168. contactMobile:thedata.contactMobile,
  169. contactType:getContactType(thedata.contactType),
  170. followTime: thedata.followTime,
  171. followSituation: thedata.followSituation,
  172. customerStatus: thedata.customerStatus,
  173. });
  174. }.bind(this),
  175. }).always(function() {
  176. this.setState({
  177. loading: false
  178. });
  179. }.bind(this));
  180. },
  181. //拜访意向服务列表单个删除
  182. intentionDelet(e, index) {
  183. let detId = this.state.followIds;
  184. if(e.id) {
  185. this.setState({
  186. selectedRowKeys: [],
  187. });
  188. $.ajax({
  189. method: "get",
  190. dataType: "json",
  191. crossDomain: false,
  192. url: globalConfig.context + "/api/admin/customer/deleteFollowOneBusiness",
  193. data: {
  194. ufbId: e.id
  195. }
  196. }).done(function(data) {
  197. if(!data.error.length) {
  198. message.success('删除成功');
  199. this.setState({
  200. loading: false,
  201. });
  202. } else {
  203. message.warning(data.error[0].message);
  204. };
  205. this.visitModify(detId);
  206. }.bind(this));
  207. } else {
  208. this.visitModify(detId);
  209. }
  210. },
  211. //拜访modul函数
  212. visitOk(e) {
  213. this.setState({
  214. addcontactModul:false,
  215. visitModul: false
  216. });
  217. },
  218. visitCancel(e) {
  219. this.setState({
  220. addcontactModul:false,
  221. visitModul: false
  222. });
  223. },
  224. //详情保存
  225. visitSubmit(e){
  226. e.preventDefault();
  227. this.setState({
  228. loading: true
  229. });
  230. let contactsId = '';
  231. if(this.state.keys) {
  232. let conts = this.state.lastName;
  233. contactsId = this.state.contactsIdArr[conts].id;
  234. }
  235. let GlossoryId=false;
  236. this.state.data.map(function(item) {
  237. if(!item.followSituation||!item.customerStatus||!item.businessName) {
  238. GlossoryId = true
  239. }
  240. })
  241. if(this.state.data.length&&GlossoryId) {
  242. message.warning("项目名称/最新进度/最新状态不能为空!")
  243. return false;
  244. };
  245. let dataList=this.state.data,
  246. idsList=[];
  247. dataList.map((item,index) => {
  248. idsList.push({
  249. ufbId:item.id||'',
  250. businessProjectId:item.businessName,
  251. customerStatus:item.customerStatus,
  252. followSituation:item.followSituation,
  253. remarks:item.remarks||''
  254. })
  255. });
  256. //新增
  257. $.ajax({
  258. method: "post",
  259. dataType: "json",
  260. url: globalConfig.context + '/api/admin/customer/updateFollow',
  261. data: {
  262. followId: this.state.followIds,
  263. userBusinessList: JSON.stringify(idsList),
  264. uid: this.state.uid,
  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. getFollowDtails(e) {
  283. this.setState({
  284. loading: true
  285. });
  286. $.ajax({
  287. method: "get",
  288. dataType: "json",
  289. url: globalConfig.context + '/api/admin/release/followDtails',
  290. data: {
  291. id: e,
  292. },
  293. success: function(data) {
  294. if(data.error.length === 0){
  295. this.setState({
  296. followDtails:data.data || {}
  297. })
  298. }else{
  299. message.warning(data.error[0].message)
  300. }
  301. }.bind(this),
  302. }).always(function() {
  303. this.setState({
  304. loading: false
  305. });
  306. }.bind(this));
  307. },
  308. getListPublicReleaseLog(e) {
  309. this.setState({
  310. loading: true
  311. });
  312. $.ajax({
  313. method: "get",
  314. dataType: "json",
  315. url: globalConfig.context + '/api/admin/release/listPublicReleaseLog',
  316. data: {
  317. ufid: e,
  318. },
  319. success: function(data) {
  320. if(data.error.length === 0){
  321. this.setState({
  322. publicReleaseLog:data.data || []
  323. })
  324. }else{
  325. message.warning(data.error[0].message)
  326. }
  327. }.bind(this),
  328. }).always(function() {
  329. this.setState({
  330. loading: false
  331. });
  332. }.bind(this));
  333. },
  334. componentWillReceiveProps(nextProps) {
  335. if (nextProps.visitModul && nextProps.followData.followId) {
  336. this.setState({
  337. visitModul: true,
  338. loading: true,
  339. })
  340. if(nextProps.followData.contactType === "5"){
  341. this.getListPublicReleaseLog(nextProps.followData.followId);
  342. this.getFollowDtails(nextProps.followData.followId);
  343. }
  344. this.visitModify(nextProps.followData.followId)
  345. };
  346. },
  347. render() {
  348. const formItemLayout = {
  349. labelCol: { span: 8 },
  350. wrapperCol: { span: 14 },
  351. };
  352. const followData= this.props.followData || []
  353. return(
  354. <div>
  355. <Modal
  356. className="customeDetails"
  357. footer=''
  358. title="客户跟进详情"
  359. width='1200px'
  360. visible={this.state.visitModul}
  361. onOk={this.visitOk}
  362. onCancel={this.visitCancel}
  363. >
  364. <Form layout="horizontal" id="demand-form" onSubmit={this.visitSubmit}>
  365. <Spin spinning={this.state.loading}>
  366. <div className="clearfix">
  367. {!(this.state.contactType === '公出打卡' && Object.keys(this.state.followDtails).length > 0) ?
  368. <div>
  369. <FormItem
  370. labelCol={{ span:4 }}
  371. wrapperCol={{ span: 20 }}
  372. label="跟进方式" >
  373. <span>{this.state.contactType}</span>
  374. </FormItem>
  375. <div className="clearfix">
  376. {!followData.readOnly&&<FormItem className="half-item"
  377. {...formItemLayout}
  378. label="当前联系人"
  379. >
  380. <span>{this.state.contacts}</span>
  381. </FormItem>}
  382. <FormItem className="half-item"
  383. {...formItemLayout}
  384. label="跟进时间"
  385. >
  386. <span>{this.state.followTime}</span>
  387. </FormItem>
  388. {!followData.readOnly&&<FormItem className="half-item"
  389. {...formItemLayout}
  390. label="联系电话"
  391. >
  392. <span>{this.state.contactMobile}</span>
  393. </FormItem>}
  394. </div>
  395. <div className="clearfix">
  396. <FormItem
  397. labelCol={{ span: 4 }}
  398. wrapperCol={{ span: 16 }}
  399. label="跟进备注" >
  400. {
  401. <span style={{wordWrap: 'breakWord'}}>{this.state.result}</span>
  402. }
  403. </FormItem>
  404. </div>
  405. </div>: null}
  406. {this.state.contactType === '公出打卡' && Object.keys(this.state.followDtails).length > 0 ? <div>
  407. <div className="clearfix">
  408. <FormItem
  409. labelCol={{ span: 4 }}
  410. wrapperCol={{ span: 16 }}
  411. label="公出企业" >
  412. <span>{this.state.followDtails.nickname}</span>
  413. </FormItem>
  414. <FormItem
  415. labelCol={{ span: 4 }}
  416. wrapperCol={{ span: 16 }}
  417. label="公出时间" >
  418. <span>{this.state.followDtails.releaseStarts + '~' + this.state.followDtails.releaseEnds}</span>
  419. </FormItem>
  420. <FormItem
  421. labelCol={{ span: 4 }}
  422. wrapperCol={{ span: 16 }}
  423. label="公出地点" >
  424. <span>{this.state.followDtails.districtName}</span>
  425. </FormItem>
  426. <FormItem
  427. labelCol={{ span: 4 }}
  428. wrapperCol={{ span: 16 }}
  429. label="当前状态" >
  430. <span>
  431. <Tag color={getClockState(this.state.followDtails.status).color}>{getClockState(this.state.followDtails.status).title}</Tag>
  432. </span>
  433. </FormItem>
  434. </div>
  435. <div className="clearfix">
  436. <div style={{fontSize:'18px',marginLeft:'100px',marginTop:'15px',marginBottom:'10px'}}>公出日志</div>
  437. <Table
  438. pagination={false}
  439. columns={this.state.intentionPublicReleaseLog}
  440. dataSource={this.state.publicReleaseLog}
  441. />
  442. </div>
  443. </div> : null}
  444. {!(this.state.contactType === '公出打卡' && Object.keys(this.state.followDtails).length > 0) ? <div className="clearfix">
  445. <div style={{fontSize:'18px',marginLeft:'100px',marginTop:'15px',marginBottom:'10px'}}>业务意向</div>
  446. <div className="clearfix" >
  447. <Spin spinning={this.state.loading}>
  448. <Table
  449. size="middle"
  450. rowKey={record => record.id}
  451. pagination={false}
  452. columns={this.state.intentionList}
  453. dataSource={this.state.data}
  454. />
  455. </Spin>
  456. </div>
  457. </div> : null}
  458. </div>
  459. {!followData.readOnly&&<FormItem wrapperCol={{ span: 12, offset: 6 }}>
  460. {/* <Button type="primary" size="large" htmlType="submit" style={{marginRight:'150px',marginTop:'20px'}}>保存</Button>
  461. <Button size="large" onClick={this.visitCancel}>取消</Button> */}
  462. </FormItem>}
  463. </Spin>
  464. </Form>
  465. </Modal>
  466. {this.state.visitImgModul ? <Modal
  467. className="customeDetails"
  468. footer=''
  469. title="附件"
  470. width='600px'
  471. visible={this.state.visitImgModul}
  472. onOk={()=>{
  473. this.setState({
  474. visitImgModul:false,
  475. enclosure:[],
  476. })
  477. }}
  478. onCancel={()=>{
  479. this.setState({
  480. visitImgModul:false,
  481. enclosure:[]
  482. })
  483. }}
  484. >
  485. <ImgList fileList={this.state.enclosure} domId={'visitDetail'}/>
  486. </Modal> : null}
  487. </div>
  488. )
  489. }
  490. })
  491. export default VisitDetail;