customerDetails.jsx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import React,{Component} from 'react';
  2. import {message, Modal, Spin, Table} from "antd";
  3. import PropTypes from 'prop-types';
  4. import $ from "jquery/src/ajax";
  5. class CustomerDetails extends Component{
  6. constructor(props) {
  7. super(props);
  8. this.state={
  9. loading:false,
  10. columns: [{
  11. title: '客户名称',
  12. dataIndex: 'name',
  13. key: 'name'
  14. }, {
  15. title: '来源',
  16. dataIndex: 'sourceName',
  17. key: 'sourceName'
  18. }, {
  19. title: '联系人',
  20. dataIndex: 'contacts',
  21. key: 'contacts'
  22. }, {
  23. title: '联系人电话',
  24. dataIndex: 'contactMobile',
  25. key: 'contactMobile'
  26. }, {
  27. title: '创建时间',
  28. dataIndex: 'createTime',
  29. key: 'createTime',
  30. }, {
  31. title: '跟进时间',
  32. dataIndex: 'followTime',
  33. key: 'followTime',
  34. }],
  35. pagination: {
  36. defaultCurrent: 1,
  37. defaultPageSize: 10,
  38. showQuickJumper: true,
  39. pageSize: 10,
  40. onChange: function(page) {
  41. this.loadData(page);
  42. }.bind(this),
  43. showTotal: function(total) {
  44. return '共' + total + '条数据';
  45. }
  46. }
  47. }
  48. this.loadData = this.loadData.bind(this);
  49. }
  50. componentDidMount() {
  51. this.loadData();
  52. }
  53. loadData(pageNo) {
  54. this.setState({
  55. loading:true
  56. })
  57. $.ajax({
  58. method: "get",
  59. dataType: "json",
  60. crossDomain: false,
  61. url: globalConfig.context +"/api/admin/customer/selectAdminCustomerList",
  62. data: {
  63. pageNo:pageNo || 1,
  64. pageSize:this.state.pagination.pageSize,
  65. aid:this.props.aid,
  66. type:this.props.type, //0 所有 1新增 2领取 3已签 4面谈
  67. startTime:this.props.startTime,
  68. endTime:this.props.endTime,
  69. },
  70. success: function(data) {
  71. let theArr = [];
  72. if(data.error.length || data.data.list == "") {
  73. if(data.error && data.error.length) {
  74. message.warning(data.error[0].message);
  75. };
  76. } else {
  77. for (let i = 0; i < data.data.list.length; i++) {
  78. let thisdata = data.data.list[i];
  79. thisdata.key = i;
  80. theArr.push(thisdata);
  81. };
  82. this.state.pagination.current = pageNo;
  83. this.state.pagination.total = data.data.totalCount;
  84. };
  85. if(!data.data.list.length) {
  86. this.state.pagination.current = 0
  87. this.state.pagination.total = 0
  88. }
  89. this.setState({
  90. dataSource: theArr,
  91. pagination: this.state.pagination,
  92. });
  93. }.bind(this),
  94. }).always(function() {
  95. this.setState({
  96. loading: false
  97. });
  98. }.bind(this));
  99. }
  100. render() {
  101. return (
  102. <div>
  103. <Modal
  104. maskClosable={true}
  105. visible={this.props.visible}
  106. onOk={this.props.onCancel}
  107. onCancel={this.props.onCancel}
  108. width='1000px'
  109. title='客户详情'
  110. footer=''
  111. className="admin-desc-content">
  112. <div className="patent-table">
  113. <Spin spinning={this.state.loading}>
  114. <Table
  115. columns={this.state.columns}
  116. dataSource={this.state.dataSource}
  117. pagination={this.state.pagination}
  118. />
  119. </Spin>
  120. </div>
  121. </Modal>
  122. </div>
  123. );
  124. }
  125. }
  126. CustomerDetails.propTypes={
  127. visible: PropTypes.bool,
  128. onCancel: PropTypes.func,
  129. aid: PropTypes.number, //员工ID
  130. type: PropTypes.number, //列表类型 客户总数 成交客户总数 新增客户数等等
  131. startTime:PropTypes.string, //开始时间
  132. endTime:PropTypes.string, //结束时间
  133. }
  134. CustomerDetails.defaultProps={
  135. visible: false,
  136. onCancel: ()=>{}
  137. }
  138. export default CustomerDetails;