visit.jsx 9.6 KB

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