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