visit.jsx 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. render: (text) => {
  51. return getContactType(text);
  52. },
  53. },
  54. {
  55. title: "联系人",
  56. dataIndex: "contacts",
  57. key: "contacts",
  58. render: (text, record) => {
  59. return (
  60. <div>
  61. {record.readOnly ? <span>***</span> : <span>{text}</span>}
  62. </div>
  63. );
  64. },
  65. },
  66. {
  67. title: "联系电话",
  68. dataIndex: "contactMobile",
  69. key: "contactMobile",
  70. render: (text, record) => {
  71. return (
  72. <div>
  73. {record.readOnly ? <span>***</span> : <span>{text}</span>}
  74. </div>
  75. );
  76. },
  77. },
  78. {
  79. title: "跟进人",
  80. dataIndex: "adminName",
  81. key: "adminName",
  82. },
  83. {
  84. title: "跟进说明",
  85. dataIndex: "result",
  86. key: "result",
  87. // }, {
  88. // title: '操作',
  89. // dataIndex: 'ttt',
  90. // key: 'ttt',
  91. // render: (text, record, index) => {
  92. // return <div>
  93. // {!record.readOnly&&<Popconfirm title="是否删除?" onConfirm={(e)=>{this.visitDelet(record)}} okText="删除" cancelText="不删除">
  94. // <Button style={{marginRight:'10px',color:'#ffffff',background:'#f00',border:'none'}} onClick={(e)=>{e.stopPropagation()}}>删除</Button>
  95. // </Popconfirm>}
  96. // </div>
  97. // }
  98. },{
  99. title: "跟进时间",
  100. dataIndex: "followTime",
  101. key: "followTime",
  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. onRowClick={this.VisitRowClick}
  246. />
  247. </Spin>
  248. <VisitDetail
  249. categoryArr={this.props.categoryArr}
  250. followData={this.state.followData}
  251. visitModul={this.state.visitModul}
  252. closeDesc={this.closeDesc}
  253. mid={this.props.data.id}
  254. />
  255. <FollowDetail
  256. categoryArr={this.props.categoryArr}
  257. followData={this.state.followData}
  258. isFlag={true}
  259. visitModul={this.state.visitModuls}
  260. closeDesc={this.closeDesc}
  261. loadData={this.props.loadData}
  262. />
  263. </div>
  264. )
  265. }
  266. })
  267. export default Visit;