visitDetail.jsx 16 KB

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