visit.jsx 5.2 KB

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