visit.jsx 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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: "nickname",
  31. key: "nickname",
  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. title: "跟进时间",
  87. dataIndex: "followTime",
  88. key: "followTime",
  89. }
  90. ],
  91. };
  92. },
  93. //拜访记录删除
  94. visitDelet(e) {
  95. this.setState({
  96. visitModul:false,
  97. loading: true
  98. });
  99. $.ajax({
  100. method: "get",
  101. dataType: "json",
  102. crossDomain: false,
  103. url: globalConfig.context + "/api/admin/customer/deleteFollow",
  104. data: {
  105. followId: e.followId, //删除的ID
  106. }
  107. }).done(function(data) {
  108. if(!data.error.length) {
  109. message.success('删除成功!');
  110. this.setState({
  111. loading: false,
  112. });
  113. } else {
  114. message.warning(data.error[0].message);
  115. };
  116. this.loadVisit();
  117. }.bind(this));
  118. },
  119. //查看跟进记录列表
  120. loadVisit(pageNo) {
  121. this.setState({
  122. loading: true
  123. });
  124. $.ajax({
  125. method: "get",
  126. dataType: "json",
  127. crossDomain: false,
  128. url: globalConfig.context + '/api/admin/customer/listFollowHistory',
  129. data: {
  130. pageNo: pageNo || 1,
  131. pageSize: this.state.paginations.pageSize,
  132. uid: this.props.data.id, //名称1
  133. },
  134. success: function(data) {
  135. let theArr = [];
  136. if(data.error.length || data.data.list == "") {
  137. if(data.error && data.error.length) {
  138. message.warning(data.error[0].message);
  139. };
  140. } else {
  141. for(let i = 0; i < data.data.list.length; i++) {
  142. let thisdata = data.data.list[i];
  143. theArr.push({
  144. readOnly:thisdata.readOnly,
  145. followId: thisdata.followId,
  146. followTime: thisdata.followTime,
  147. identifyName: thisdata.identifyName,
  148. contacts: thisdata.contacts,
  149. contactMobile: thisdata.contactMobile,
  150. result: thisdata.result,
  151. adminName: thisdata.adminName,
  152. followSituation: thisdata.followSituation,
  153. customerStatus: thisdata.customerStatus,
  154. contactType: thisdata.contactType
  155. });
  156. };
  157. this.state.paginations.current = data.data.pageNo;
  158. this.state.paginations.total = data.data.totalCount;
  159. };
  160. if(data.data.list&&!data.data.list.length){
  161. this.state.paginations.current =0;
  162. this.state.paginations.total =0;
  163. };
  164. this.setState({
  165. visitArrList: theArr,
  166. paginations: this.state.paginations
  167. });
  168. }.bind(this),
  169. }).always(function() {
  170. this.setState({
  171. loading: false
  172. });
  173. }.bind(this));
  174. },
  175. componentWillMount(){
  176. this.loadVisit();
  177. },
  178. detailsModal(){
  179. this.props.closeDetail(false, false)
  180. },
  181. //点击整行
  182. VisitRowClick(record){
  183. this.setState({
  184. followData: record,
  185. visitModul:true,
  186. })
  187. },
  188. //进入新增拜访记录
  189. visit() {
  190. let obj = {
  191. id: this.props.data.id
  192. }
  193. this.setState({
  194. followData:obj,
  195. visitModuls:true,
  196. })
  197. },
  198. closeDesc(e,s){
  199. this.state.visitModul=e
  200. this.state.visitModuls=e
  201. if(s){
  202. this.loadVisit()
  203. }
  204. },
  205. componentWillReceiveProps(nextProps) {
  206. if(nextProps.data.id&&nextProps.visitState){
  207. this.loadVisit()
  208. }
  209. this.setState({
  210. visitModul:false
  211. })
  212. },
  213. render(){
  214. return(
  215. <div className="clearfix">
  216. <Button
  217. onClick={(e) => {
  218. e.stopPropagation(), this.visit();
  219. }}
  220. type="primary"
  221. style={{marginTop:'10px',float: 'right'}}
  222. >
  223. 客户跟进
  224. </Button>
  225. <Spin spinning={this.state.loading}>
  226. <Table
  227. size="middle"
  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. isFlag={true}
  246. visitModul={this.state.visitModuls}
  247. closeDesc={this.closeDesc}
  248. loadData={this.props.loadData}
  249. />
  250. </div>
  251. )
  252. }
  253. })
  254. export default Visit;