visit.jsx 15 KB

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