visit.jsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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 {getContactType} from '@/tools.js';
  6. import VisitDetail from './visitDetail.jsx';
  7. const Visit = React.createClass({
  8. getInitialState(){
  9. return{
  10. visitArrList:[],
  11. loading:false,
  12. visitModul:false,
  13. paginations: {
  14. defaultCurrent: 1,
  15. defaultPageSize: 10,
  16. showQuickJumper: true,
  17. pageSize: 10,
  18. onChange: function(page) {
  19. this.loadVisit(page);
  20. }.bind(this),
  21. showTotal: function(total) {
  22. return '共' + total + '条数据';
  23. }
  24. },
  25. visitsList: [{
  26. title: '拜访时间',
  27. dataIndex: 'followTime',
  28. key: 'followTime'
  29. }, {
  30. title: '客户名称',
  31. dataIndex: 'identifyName',
  32. key: 'identifyName'
  33. }, {
  34. title: '拜访方式',
  35. dataIndex: 'contactType',
  36. key: 'contactType',
  37. render: text => { return getContactType(text) }
  38. }, {
  39. title: '联系人',
  40. dataIndex: 'contacts',
  41. key: 'contacts'
  42. }, {
  43. title: '联系电话',
  44. dataIndex: 'contactMobile',
  45. key: 'contactMobile'
  46. }, {
  47. title: '拜访人',
  48. dataIndex: 'adminName',
  49. key: 'adminName'
  50. }, {
  51. title: '拜访说明',
  52. dataIndex: 'result',
  53. key: 'result'
  54. }, {
  55. title: '操作',
  56. dataIndex: 'ttt',
  57. key: 'ttt',
  58. render: (text, record, index) => {
  59. return <div>
  60. <Popconfirm title="是否删除?" onConfirm={(e)=>{this.visitDelet(record)}} okText="删除" cancelText="不删除">
  61. <Button style={{marginRight:'10px',color:'#ffffff',background:'#f00',border:'none'}} onClick={(e)=>{e.stopPropagation()}}>删除</Button>
  62. </Popconfirm>
  63. </div>
  64. }
  65. }],
  66. }
  67. },
  68. //拜访记录删除
  69. visitDelet(e) {
  70. this.setState({
  71. visitModul:false,
  72. loading: true
  73. });
  74. $.ajax({
  75. method: "get",
  76. dataType: "json",
  77. crossDomain: false,
  78. url: globalConfig.context + "/api/admin/customer/deleteFollow",
  79. data: {
  80. followId: e.followId, //删除的ID
  81. }
  82. }).done(function(data) {
  83. if(!data.error.length) {
  84. message.success('删除成功!');
  85. this.setState({
  86. loading: false,
  87. });
  88. } else {
  89. message.warning(data.error[0].message);
  90. };
  91. this.loadVisit();
  92. }.bind(this));
  93. },
  94. //查看跟进记录列表
  95. loadVisit(pageNo) {
  96. this.setState({
  97. loading: true
  98. });
  99. $.ajax({
  100. method: "get",
  101. dataType: "json",
  102. crossDomain: false,
  103. url: globalConfig.context + '/api/admin/customer/listFollowHistory',
  104. data: {
  105. pageNo: pageNo || 1,
  106. pageSize: this.state.paginations.pageSize,
  107. uid: this.props.data.id, //名称1
  108. },
  109. success: function(data) {
  110. let theArr = [];
  111. if(data.error.length || data.data.list == "") {
  112. if(data.error && data.error.length) {
  113. message.warning(data.error[0].message);
  114. };
  115. } else {
  116. for(let i = 0; i < data.data.list.length; i++) {
  117. let thisdata = data.data.list[i];
  118. theArr.push({
  119. followId: thisdata.followId,
  120. followTime: thisdata.followTime,
  121. identifyName: thisdata.identifyName,
  122. contacts: thisdata.contacts,
  123. contactMobile: thisdata.contactMobile,
  124. result: thisdata.result,
  125. adminName: thisdata.adminName,
  126. followSituation: thisdata.followSituation,
  127. customerStatus: thisdata.customerStatus,
  128. contactType: thisdata.contactType
  129. });
  130. };
  131. this.state.paginations.current = data.data.pageNo;
  132. this.state.paginations.total = data.data.totalCount;
  133. };
  134. if(data.data.list&&!data.data.list.length){
  135. this.state.paginations.current =0;
  136. this.state.paginations.total =0;
  137. };
  138. this.setState({
  139. visitArrList: theArr,
  140. paginations: this.state.paginations
  141. });
  142. }.bind(this),
  143. }).always(function() {
  144. this.setState({
  145. loading: false
  146. });
  147. }.bind(this));
  148. },
  149. componentWillMount(){
  150. this.loadVisit();
  151. },
  152. detailsModal(){
  153. this.props.closeDetail(false, false)
  154. },
  155. //点击整行
  156. VisitRowClick(record){
  157. this.setState({
  158. followData: record,
  159. visitModul:true,
  160. })
  161. },
  162. closeDesc(e,s){
  163. this.state.visitModul=e
  164. if(s){
  165. this.loadVisit()
  166. }
  167. },
  168. componentWillReceiveProps(nextProps) {
  169. if(nextProps.data.id&&nextProps.visitState){
  170. this.loadVisit()
  171. }
  172. this.setState({
  173. visitModul:false
  174. })
  175. },
  176. render(){
  177. return(
  178. <div className="clearfix">
  179. <Spin spinning={this.state.loading}>
  180. <Table
  181. pagination={this.state.paginations}
  182. columns={this.state.visitsList}
  183. dataSource={this.state.visitArrList}
  184. onRowClick={this.VisitRowClick}
  185. />
  186. </Spin>
  187. <VisitDetail
  188. categoryArr={this.props.categoryArr}
  189. followData={this.state.followData}
  190. visitModul={this.state.visitModul}
  191. closeDesc={this.closeDesc}
  192. />
  193. </div>
  194. )
  195. }
  196. })
  197. export default Visit;