visit.jsx 6.5 KB

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