visit.jsx 10 KB

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