visit.jsx 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. import React from 'react';
  2. import {Form, Button, Spin, message, Table, Popconfirm, Tooltip} 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 Visit = React.createClass({
  9. getInitialState(){
  10. return {
  11. visitArrList: [],
  12. loading: false,
  13. visitModul: false,
  14. visitModuls: false,
  15. paginations: {
  16. defaultCurrent: 1,
  17. defaultPageSize: 10,
  18. showQuickJumper: true,
  19. pageSize: 10,
  20. onChange: function (page) {
  21. this.loadVisit(page);
  22. }.bind(this),
  23. showTotal: function (total) {
  24. return "共" + total + "条数据";
  25. },
  26. },
  27. visitsList: [
  28. {
  29. title: "客户名称",
  30. dataIndex: "nickname",
  31. key: "nickname",
  32. width: 150,
  33. render: (text) => {
  34. return (
  35. <Tooltip title={text}>
  36. <div style={{
  37. maxWidth:'150px',
  38. overflow:'hidden',
  39. textOverflow: "ellipsis",
  40. whiteSpace:'nowrap',
  41. }}>{text}</div>
  42. </Tooltip>
  43. )
  44. },
  45. },
  46. {
  47. title: "跟进方式",
  48. dataIndex: "contactType",
  49. key: "contactType",
  50. width: 100,
  51. render: (text) => {
  52. return getContactType(text);
  53. },
  54. },
  55. {
  56. title: "联系人",
  57. dataIndex: "contacts",
  58. key: "contacts",
  59. render: (text, record) => {
  60. return (
  61. <div>
  62. {record.readOnly ? <span>***</span> : <span>{text}</span>}
  63. </div>
  64. );
  65. },
  66. },
  67. {
  68. title: "联系电话",
  69. dataIndex: "contactMobile",
  70. key: "contactMobile",
  71. width: 120,
  72. render: (text, record) => {
  73. return (
  74. <div>
  75. {record.readOnly ? <span>***</span> : <span>{text}</span>}
  76. </div>
  77. );
  78. },
  79. },
  80. {
  81. title: "跟进人",
  82. dataIndex: "adminName",
  83. key: "adminName",
  84. },
  85. {
  86. title: "跟进说明",
  87. dataIndex: "result",
  88. key: "result",
  89. width: 300,
  90. render: (text, record) => {
  91. return (
  92. <div style={{wordBreak:"break-all"}}>
  93. {text}
  94. </div>
  95. )
  96. }
  97. },{
  98. title: "跟进时间",
  99. dataIndex: "followTime",
  100. key: "followTime",
  101. width: 125
  102. }
  103. ],
  104. };
  105. },
  106. //拜访记录删除
  107. visitDelet(e) {
  108. this.setState({
  109. visitModul:false,
  110. loading: true
  111. });
  112. $.ajax({
  113. method: "get",
  114. dataType: "json",
  115. crossDomain: false,
  116. url: globalConfig.context + "/api/admin/customer/deleteFollow",
  117. data: {
  118. followId: e.followId, //删除的ID
  119. }
  120. }).done(function(data) {
  121. if(!data.error.length) {
  122. message.success('删除成功!');
  123. this.setState({
  124. loading: false,
  125. });
  126. } else {
  127. message.warning(data.error[0].message);
  128. };
  129. this.loadVisit();
  130. }.bind(this));
  131. },
  132. //查看跟进记录列表
  133. loadVisit(pageNo) {
  134. this.setState({
  135. loading: true
  136. });
  137. $.ajax({
  138. method: "get",
  139. dataType: "json",
  140. crossDomain: false,
  141. url: globalConfig.context + '/api/admin/customer/listFollowHistory',
  142. data: {
  143. pageNo: pageNo || 1,
  144. pageSize: this.state.paginations.pageSize,
  145. uid: this.props.data.id, //名称1
  146. },
  147. success: function(data) {
  148. let theArr = [];
  149. if(data.error.length || data.data.list == "") {
  150. if(data.error && data.error.length) {
  151. message.warning(data.error[0].message);
  152. };
  153. } else {
  154. for(let i = 0; i < data.data.list.length; i++) {
  155. let thisdata = data.data.list[i];
  156. theArr.push({
  157. readOnly:thisdata.readOnly,
  158. followId: thisdata.followId,
  159. followTime: thisdata.followTime,
  160. identifyName: thisdata.identifyName,
  161. contacts: thisdata.contacts,
  162. contactMobile: thisdata.contactMobile,
  163. result: thisdata.result,
  164. adminName: thisdata.adminName,
  165. followSituation: thisdata.followSituation,
  166. customerStatus: thisdata.customerStatus,
  167. contactType: thisdata.contactType
  168. });
  169. };
  170. this.state.paginations.current = data.data.pageNo;
  171. this.state.paginations.total = data.data.totalCount;
  172. };
  173. if(data.data.list&&!data.data.list.length){
  174. this.state.paginations.current =0;
  175. this.state.paginations.total =0;
  176. };
  177. this.setState({
  178. visitArrList: theArr,
  179. paginations: this.state.paginations
  180. });
  181. }.bind(this),
  182. }).always(function() {
  183. this.setState({
  184. loading: false
  185. });
  186. }.bind(this));
  187. },
  188. componentWillMount(){
  189. this.loadVisit();
  190. },
  191. detailsModal(){
  192. this.props.closeDetail(false, false)
  193. },
  194. //点击整行
  195. VisitRowClick(record){
  196. this.setState({
  197. followData: record,
  198. visitModul:true,
  199. })
  200. },
  201. //进入新增拜访记录
  202. visit() {
  203. let obj = {
  204. id: this.props.data.id
  205. }
  206. this.setState({
  207. followData:obj,
  208. visitModuls:true,
  209. })
  210. },
  211. closeDesc(e,s){
  212. this.state.visitModul=e
  213. this.state.visitModuls=e
  214. if(s){
  215. this.loadVisit()
  216. }
  217. },
  218. componentWillReceiveProps(nextProps) {
  219. if(nextProps.data.id&&nextProps.visitState){
  220. this.loadVisit()
  221. }
  222. this.setState({
  223. visitModul:false
  224. })
  225. },
  226. render(){
  227. return(
  228. <div className="clearfix">
  229. <Button
  230. onClick={(e) => {
  231. e.stopPropagation(), this.visit();
  232. }}
  233. type="primary"
  234. style={{marginTop:'10px',float: 'right'}}
  235. >
  236. 客户跟进
  237. </Button>
  238. <Spin spinning={this.state.loading}>
  239. <Table
  240. size="middle"
  241. style={{marginTop:'60px'}}
  242. pagination={this.state.paginations}
  243. columns={this.state.visitsList}
  244. dataSource={this.state.visitArrList}
  245. scroll={{ y: 440 }}
  246. onRowClick={this.VisitRowClick}
  247. />
  248. </Spin>
  249. <VisitDetail
  250. categoryArr={this.props.categoryArr}
  251. followData={this.state.followData}
  252. visitModul={this.state.visitModul}
  253. closeDesc={this.closeDesc}
  254. mid={this.props.data.id}
  255. />
  256. <FollowDetail
  257. categoryArr={this.props.categoryArr}
  258. followData={this.state.followData}
  259. isFlag={true}
  260. visitModul={this.state.visitModuls}
  261. closeDesc={this.closeDesc}
  262. loadData={this.props.loadData}
  263. />
  264. </div>
  265. )
  266. }
  267. })
  268. export default Visit;