visit.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. import React from 'react';
  2. import {Button, Spin, message, Table, Tooltip, Input, Modal, Alert} from 'antd';
  3. import $ from 'jquery/src/ajax';
  4. import FollowDetail from '../../followDetail.jsx'
  5. import {getContactType} from '@/tools.js';
  6. import VisitDetail from './visitDetail.jsx';
  7. import PublicSupplement from '../../../../../../publicSupplement';
  8. const confirm = Modal.confirm;
  9. const Visit = React.createClass({
  10. getInitialState(){
  11. return {
  12. visitArrList: [],
  13. loading: false,
  14. visitModul: false,
  15. visitModuls: false,
  16. followId:0,
  17. ispage:1,
  18. paginations: {
  19. defaultCurrent: 1,
  20. defaultPageSize: 10,
  21. showQuickJumper: true,
  22. pageSize: 10,
  23. onChange: function (page) {
  24. this.loadVisit(page);
  25. }.bind(this),
  26. showTotal: function (total) {
  27. return "共" + total + "条数据";
  28. },
  29. },
  30. visitsList: [
  31. {
  32. title: "客户名称",
  33. dataIndex: "nickname",
  34. key: "nickname",
  35. width: 150,
  36. render: (text) => {
  37. return (
  38. <Tooltip title={text}>
  39. <div style={{
  40. maxWidth:'150px',
  41. overflow:'hidden',
  42. textOverflow: "ellipsis",
  43. whiteSpace:'nowrap',
  44. }}>{text}</div>
  45. </Tooltip>
  46. )
  47. },
  48. },
  49. {
  50. title: "跟进方式",
  51. dataIndex: "contactType",
  52. key: "contactType",
  53. width: 100,
  54. render: (text) => {
  55. return getContactType(text);
  56. },
  57. },
  58. {
  59. title: "联系人",
  60. dataIndex: "contacts",
  61. key: "contacts",
  62. width: 150,
  63. render: (text, record) => {
  64. return (
  65. <div>
  66. {record.readOnly ? <span>***</span> : <span>{text}</span>}
  67. </div>
  68. );
  69. },
  70. },
  71. {
  72. title: "联系电话",
  73. dataIndex: "contactMobile",
  74. key: "contactMobile",
  75. width: 120,
  76. render: (text, record) => {
  77. return (
  78. <div>
  79. {record.readOnly ? <span>***</span> : <span>{text}</span>}
  80. </div>
  81. );
  82. },
  83. },
  84. {
  85. title: "跟进人",
  86. dataIndex: "adminName",
  87. key: "adminName",
  88. width: 120
  89. },
  90. {
  91. title: "跟进说明",
  92. dataIndex: "result",
  93. key: "result",
  94. width: 300,
  95. render: (text, record) => {
  96. return (
  97. <div style={{wordBreak:"break-all"}}>
  98. <div>{text}</div>
  99. {
  100. getContactType(record.contactType) === '公出打卡' && <div style={{
  101. paddingTop: '15px',
  102. wordBreak: "break-all",
  103. display: "flex",
  104. alignItems: 'flex-end'
  105. }}>
  106. 补充说明:
  107. {record.supplement}
  108. <div style={{paddingLeft: '10px'}}>
  109. <PublicSupplement infor={record} onCancel={() => {
  110. this.loadVisit(this.state.ispage);
  111. }}/>
  112. </div>
  113. </div>
  114. }
  115. </div>
  116. )
  117. }
  118. },
  119. {
  120. title: "跟进时间",
  121. dataIndex: "followTime",
  122. key: "followTime",
  123. width: 125
  124. },
  125. {
  126. title: "指导意见",
  127. dataIndex: "abc",
  128. key: "abc",
  129. width: 150,
  130. render: (text, record) => {
  131. return (
  132. <div>
  133. {record.guidance ?
  134. <Tooltip placement="topLeft" title={<div style={{wordBreak:"break-all"}}>{(record.guidanceName ? '('+record.guidanceName+')' : '') + record.guidance}</div>}>
  135. <div style={{
  136. cursor:"pointer",
  137. width: '150px',
  138. whiteSpace: 'nowrap',
  139. overflow: 'hidden',
  140. textOverflow: 'ellipsis',
  141. }}>
  142. {record.guidanceName ? '('+record.guidanceName+')' : null}
  143. {record.guidance}
  144. </div>
  145. </Tooltip> : (this.props.isEditGuidanceLv ? <Button
  146. onClick={(e) => {
  147. e.stopPropagation();
  148. this.setState({
  149. guidanceVisible: true,
  150. visitModul: false,
  151. followId: record.followId
  152. })
  153. }}
  154. type="primary"
  155. >
  156. 立即指导
  157. </Button> : <span>暂未指导</span>)}
  158. </div>
  159. );
  160. },
  161. },
  162. {
  163. title: "指导时间",
  164. dataIndex: "guidanceTime",
  165. key: "guidanceTime",
  166. width: 125,
  167. render: (text, record) => {
  168. return (
  169. <span>{text ? text : ''}</span>
  170. )
  171. }
  172. }
  173. ],
  174. guidanceVisible: false,
  175. guidance: ''
  176. };
  177. },
  178. //拜访记录删除
  179. visitDelet(e) {
  180. this.setState({
  181. visitModul:false,
  182. loading: true
  183. });
  184. $.ajax({
  185. method: "get",
  186. dataType: "json",
  187. crossDomain: false,
  188. url: globalConfig.context + "/api/admin/customer/deleteFollow",
  189. data: {
  190. followId: e.followId, //删除的ID
  191. }
  192. }).done(function(data) {
  193. if(!data.error.length) {
  194. message.success('删除成功!');
  195. this.setState({
  196. loading: false,
  197. });
  198. } else {
  199. message.warning(data.error[0].message);
  200. };
  201. this.loadVisit();
  202. }.bind(this));
  203. },
  204. //查看跟进记录列表
  205. loadVisit(pageNo) {
  206. this.setState({
  207. loading: true
  208. });
  209. $.ajax({
  210. method: "get",
  211. dataType: "json",
  212. crossDomain: false,
  213. url: globalConfig.context + '/api/admin/customer/listFollowHistory',
  214. data: {
  215. pageNo: pageNo || 1,
  216. pageSize: this.state.paginations.pageSize,
  217. uid: this.props.data.id, //名称1
  218. },
  219. success: function(data) {
  220. let theArr = [];
  221. if(data.error.length || data.data.list == "") {
  222. if(data.error && data.error.length) {
  223. message.warning(data.error[0].message);
  224. };
  225. } else {
  226. for(let i = 0; i < data.data.list.length; i++) {
  227. let thisdata = data.data.list[i];
  228. theArr.push(thisdata);
  229. };
  230. this.state.paginations.current = data.data.pageNo;
  231. this.state.paginations.total = data.data.totalCount;
  232. this.setState({
  233. ispage: data.data.pageNo
  234. })
  235. };
  236. if(data.data.list&&!data.data.list.length){
  237. this.state.paginations.current =0;
  238. this.state.paginations.total =0;
  239. };
  240. this.setState({
  241. visitArrList: theArr,
  242. paginations: this.state.paginations
  243. });
  244. }.bind(this),
  245. }).always(function() {
  246. this.setState({
  247. loading: false
  248. });
  249. }.bind(this));
  250. },
  251. componentWillMount(){
  252. this.loadVisit();
  253. },
  254. detailsModal(){
  255. this.props.closeDetail(false, false)
  256. },
  257. //点击整行
  258. VisitRowClick(record){
  259. this.setState({
  260. followData: record,
  261. visitModul:true,
  262. })
  263. },
  264. //进入新增拜访记录
  265. visit() {
  266. let obj = {
  267. id: this.props.data.id
  268. }
  269. this.setState({
  270. followData:obj,
  271. visitModuls:true,
  272. })
  273. },
  274. closeDesc(e,s){
  275. this.state.visitModul=e
  276. this.state.visitModuls=e
  277. if(s){
  278. this.loadVisit()
  279. }
  280. },
  281. //发布指导意见
  282. releaseGuidance(e){
  283. e.stopPropagation();
  284. if(!this.state.guidance){
  285. message.info('指导意见不能为空')
  286. return;
  287. }
  288. this.setState({
  289. loading: true,
  290. });
  291. $.ajax({
  292. method: "post",
  293. dataType: "json",
  294. crossDomain: false,
  295. url: globalConfig.context + "/api/admin/customer/addGuidance",
  296. data: {
  297. guidance: this.state.guidance,
  298. followId: this.state.followId,
  299. },
  300. }).done(function(data) {
  301. if(!data.error.length) {
  302. message.success("发布成功");
  303. this.loadVisit(this.state.ispage);
  304. this.setState({
  305. loading: false,
  306. guidanceVisible: false,
  307. });
  308. } else {
  309. message.warning(data.error[0].message);
  310. }
  311. }.bind(this));
  312. },
  313. componentWillReceiveProps(nextProps) {
  314. if(nextProps.data.id&&nextProps.visitState){
  315. this.loadVisit()
  316. }
  317. this.setState({
  318. visitModul:false
  319. })
  320. },
  321. render(){
  322. return(
  323. <div className="clearfix">
  324. <Alert message="注:面谈公出补充,沟通完后记录今天交流的情况。计划下一次什么时候再面谈?该如何面谈?该如何跟进?" banner />
  325. {!this.props.isGuidanceLv ? <Button
  326. onClick={(e) => {
  327. e.stopPropagation();
  328. this.visit();
  329. }}
  330. type="primary"
  331. style={{marginTop:'10px',float: 'right'}}
  332. >
  333. 客户跟进
  334. </Button> : <div/>}
  335. <Spin spinning={this.state.loading}>
  336. <Table
  337. size="middle"
  338. style={{marginTop:this.props.isGuidanceLv ? '0px' : '60px',cursor: 'pointer',}}
  339. pagination={this.state.paginations}
  340. columns={this.state.visitsList}
  341. dataSource={this.state.visitArrList}
  342. onRowClick={this.VisitRowClick}
  343. scroll={{ y: 440 }}
  344. />
  345. </Spin>
  346. <VisitDetail
  347. categoryArr={this.props.categoryArr}
  348. followData={this.state.followData}
  349. visitModul={this.state.visitModul}
  350. closeDesc={this.closeDesc}
  351. mid={this.props.data.id}
  352. />
  353. <FollowDetail
  354. categoryArr={this.props.categoryArr}
  355. followData={this.state.followData}
  356. visitModul={this.state.visitModuls}
  357. closeDesc={this.closeDesc}
  358. loadData={this.loadVisit}
  359. />
  360. {/*指导意见*/}
  361. {this.state.guidanceVisible ? <Modal
  362. className="customeDetails"
  363. title="指导意见"
  364. width='500px'
  365. visible={this.state.guidanceVisible}
  366. onOk={()=>{
  367. this.setState({
  368. guidanceVisible: false,
  369. guidance: '',
  370. },()=>{
  371. this.loadVisit();
  372. })
  373. }}
  374. onCancel={()=>{
  375. this.setState({
  376. guidanceVisible: false,
  377. guidance: '',
  378. },()=>{
  379. this.loadVisit();
  380. })
  381. }}
  382. footer=''
  383. >
  384. <Spin spinning={this.state.loading}>
  385. <div style={{
  386. display:'flex',
  387. flexFlow:'column',
  388. }}>
  389. <Input
  390. style={{ width: '400px',height:'50px' }}
  391. placeholder="请输入指导意见"
  392. type={'textarea'}
  393. onChange={(e)=>{
  394. this.setState({
  395. guidance: e.target.value,
  396. })
  397. }}
  398. />
  399. <Button
  400. type="primary"
  401. style={{ marginTop: "10px", marginBottom: '10px' }}
  402. onClick={(e)=>{
  403. let _this = this;
  404. confirm({
  405. title: '确定要提交本次指导意见吗?',
  406. content: '指导意见提交成功后无法修改',
  407. onOk() {
  408. _this.releaseGuidance(e);
  409. },
  410. onCancel() {},
  411. });
  412. }}
  413. >
  414. 保存
  415. </Button>
  416. </div>
  417. </Spin>
  418. </Modal> : <div/>}
  419. </div>
  420. )
  421. }
  422. })
  423. export default Visit;