channelStatistics.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. import React,{Component} from "react";
  2. import {Button, DatePicker, message, Select, Spin, Table, Tabs} from "antd";
  3. import moment from "moment";
  4. import {ChooseList} from "../../../order/orderNew/chooseList";
  5. import $ from "jquery/src/ajax";
  6. import {
  7. ShowModal,
  8. } from "@/tools.js";
  9. import ShowModalDiv from "@/showModal.jsx";
  10. import StatisticalDetails from './statisticalDetails';
  11. import './channelStatistics.less';
  12. const {TabPane} = Tabs;
  13. const { RangePicker } = DatePicker;
  14. class ChannelStatistics extends Component{
  15. constructor(props) {
  16. super(props);
  17. this.state={
  18. columns: [
  19. {
  20. title: "编号",
  21. dataIndex: "key",
  22. key: "key",
  23. },
  24. {
  25. title: "外联专员",
  26. dataIndex: "name",
  27. key: "name",
  28. },
  29. {
  30. title: "当前客户总数",
  31. dataIndex: "counts",
  32. key: "counts",
  33. className:'content',
  34. render: (text, record, index) => {
  35. return (
  36. <div className='item' onClick={()=>{
  37. this.tableRowClick(1,record);
  38. }}>
  39. {text}
  40. </div>
  41. )
  42. }
  43. },
  44. {
  45. title: "释放客数",
  46. dataIndex: "common",
  47. key: "common",
  48. className:'content',
  49. render: (text, record, index) => {
  50. return (
  51. <div className='item' onClick={()=>{
  52. this.tableRowClick(4,record);
  53. }}>
  54. {text}
  55. </div>
  56. )
  57. }
  58. },
  59. {
  60. title: "未分配数",
  61. dataIndex: "unallocated",
  62. key: "unallocated",
  63. className:'content',
  64. render: (text, record, index) => {
  65. return (
  66. <div className='item' onClick={()=>{
  67. this.tableRowClick(5,record);
  68. }}>
  69. {text}
  70. </div>
  71. )
  72. }
  73. },
  74. {
  75. title: "已分配数",
  76. dataIndex: "allocated",
  77. key: "allocated",
  78. className:'content',
  79. render: (text, record, index) => {
  80. return (
  81. <div className='item' onClick={()=>{
  82. this.tableRowClick(6,record);
  83. }}>
  84. {text}
  85. </div>
  86. )
  87. }
  88. },
  89. {
  90. title: "已签单数",
  91. dataIndex: "sign",
  92. key: "sign",
  93. className:'content',
  94. render: (text, record, index) => {
  95. return (
  96. <div className='item' onClick={()=>{
  97. this.tableRowClick(7,record);
  98. }}>
  99. {text}
  100. </div>
  101. )
  102. }
  103. },
  104. ],
  105. changeList:[],
  106. dataSource:[],
  107. detailsType:'',// 0营销员 1外联专员 2营销总监 3营销经理 4释放 5未分配 6已分配 7已签单
  108. pagination: {
  109. defaultCurrent: 1,
  110. defaultPageSize: 10,
  111. showQuickJumper: true,
  112. pageSize: 10,
  113. onChange: function (page) {
  114. this.loadData(page);
  115. }.bind(this),
  116. showTotal: function (total) {
  117. return "共" + total + "条数据";
  118. },
  119. },
  120. pageNo:1,
  121. listLoading:false,
  122. releaseDate:[],
  123. visible: false,
  124. }
  125. this.tableRowClick = this.tableRowClick.bind(this);
  126. this.loadData = this.loadData.bind(this);
  127. this.search = this.search.bind(this);
  128. this.reset = this.reset.bind(this);
  129. this.changeList = this.changeList.bind(this);
  130. this.onCancel = this.onCancel.bind(this);
  131. }
  132. componentDidMount() {
  133. this.loadData();
  134. }
  135. loadData(pageNo = 1) {
  136. this.setState({
  137. listLoading: true,
  138. selectedRows: [],
  139. selectedRowKeys: [],
  140. });
  141. $.ajax({
  142. method: "get",
  143. dataType: "json",
  144. crossDomain: false,
  145. url: globalConfig.context + '/api/admin/customer/listChannelCounts',
  146. data: {
  147. pageNo: pageNo || 1,
  148. pageSize: this.state.pagination.pageSize,
  149. startTime: this.state.releaseDate[0],
  150. endTime: this.state.releaseDate[1],
  151. },
  152. success: function (data) {
  153. ShowModal(this);
  154. let theArr = [];
  155. if (data.error.length > 0) {
  156. message.warning(data.error[0].message);
  157. } else {
  158. if(data.data.list.length === 0 && pageNo !== 1){
  159. this.loadData(pageNo - 1)
  160. }else{
  161. for (let i = 0; i < data.data.list.length; i++) {
  162. let thisdata = data.data.list[i];
  163. thisdata.key = (pageNo - 1) * 10 + i + 1;
  164. theArr.push(thisdata);
  165. }
  166. this.state.pagination.current = data.data.pageNo;
  167. this.state.pagination.total = data.data.totalCount;
  168. this.setState({
  169. pageNo: data.data.pageNo,
  170. dataSource: theArr,
  171. pagination: this.state.pagination,
  172. })
  173. }
  174. }
  175. }.bind(this),
  176. }).always(
  177. function () {
  178. this.setState({
  179. listLoading: false,
  180. });
  181. }.bind(this)
  182. );
  183. }
  184. search(){
  185. this.loadData();
  186. }
  187. reset(){
  188. this.setState({
  189. releaseDate:[],
  190. },()=>{
  191. this.loadData();
  192. })
  193. }
  194. onCancel(){
  195. this.setState({
  196. aid:'',
  197. visible: false,
  198. detailsType:'',
  199. })
  200. }
  201. changeList(arr) {
  202. const newArr = [];
  203. this.state.columns.forEach(item => {
  204. arr.forEach(val => {
  205. if (val === item.title) {
  206. newArr.push(item);
  207. }
  208. });
  209. });
  210. this.setState({
  211. changeList: newArr
  212. });
  213. }
  214. tableRowClick(type,record) {
  215. this.setState({
  216. visible: true,
  217. aid:record.aid,
  218. detailsType:type,
  219. aName:record.name,
  220. })
  221. }
  222. render() {
  223. return (
  224. <div className="user-content">
  225. <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
  226. <div className="content-title" style={{ marginBottom: 10 }}>
  227. <span style={{ fontWeight: 900, fontSize: 16 }}>外联客户统计</span>
  228. </div>
  229. <div className="user-search">
  230. <Tabs
  231. defaultActiveKey="1"
  232. className="test"
  233. >
  234. <TabPane tab="搜索" key="1" style={{paddingTop:'10px'}}>
  235. <RangePicker
  236. value={[
  237. this.state.releaseDate[0]
  238. ? moment(this.state.releaseDate[0])
  239. : null,
  240. this.state.releaseDate[1]
  241. ? moment(this.state.releaseDate[1])
  242. : null,
  243. ]}
  244. onChange={(data, dataString) => {
  245. this.setState({ releaseDate: dataString });
  246. }}
  247. />
  248. <Button
  249. type="primary"
  250. style={{ marginLeft: "10px", marginRight: 10 }}
  251. onClick={this.search}
  252. >
  253. 搜索
  254. </Button>
  255. <Button onClick={this.reset}>重置</Button>
  256. </TabPane>
  257. <TabPane tab="更改表格显示数据" key="3">
  258. <div style={{ marginLeft: 10 }}>
  259. <ChooseList
  260. columns={this.state.columns}
  261. changeFn={this.changeList}
  262. changeList={this.state.changeList}
  263. top={55}
  264. margin={11}
  265. />
  266. </div>
  267. </TabPane>
  268. </Tabs>
  269. </div>
  270. <div className="patent-table">
  271. <Spin spinning={this.state.listLoading}>
  272. <Table
  273. size="middle"
  274. className={'intentionCustomerTable'}
  275. columns={
  276. this.state.changeList.length !== 0
  277. ? this.state.changeList
  278. : this.state.columns
  279. }
  280. dataSource={this.state.dataSource}
  281. pagination={this.state.pagination}
  282. />
  283. </Spin>
  284. </div>
  285. <StatisticalDetails
  286. visible={this.state.visible}
  287. onCancel={this.onCancel}
  288. aid={this.state.aid}
  289. type={this.state.detailsType}
  290. aName={this.state.aName}
  291. />
  292. </div>
  293. )
  294. }
  295. }
  296. export default ChannelStatistics;