visit.jsx 6.0 KB

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