visit.jsx 12 KB

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