statusStatistics.jsx 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. import React from 'react';
  2. import ajax from 'jquery/src/ajax/xhr.js';
  3. import $ from 'jquery/src/ajax';
  4. import "./statistics.less"
  5. import { Button, Select, Table, Spin, message, Tabs, DatePicker } from 'antd';
  6. const TabPane = Tabs.TabPane;
  7. import moment from 'moment';
  8. import { intentionalService } from '../../../dataDic.js';
  9. import {ChooseList} from "../../order/orderNew/chooseList";
  10. const StatusStatistics = React.createClass({
  11. loadData(pageNo, nub) {
  12. this.state.data = [];
  13. this.setState({
  14. loading: true
  15. });
  16. let urls = '';
  17. switch(nub) {
  18. case "1":
  19. urls = "";
  20. break; //日
  21. case "2":
  22. urls = "daySpan";
  23. break; //日
  24. case "3":
  25. urls = "weekSpan";
  26. break; //周
  27. case "4":
  28. urls = "monthSpan";
  29. break; //月
  30. case "5":
  31. urls = "quarterSpan";
  32. break; //季
  33. case "6":
  34. urls = "yearSpan";
  35. break; //年
  36. default:
  37. urls ='';
  38. }
  39. $.ajax({
  40. method: "get",
  41. dataType: "json",
  42. crossDomain: false,
  43. url: globalConfig.context + "/api/admin/customer/customerStatistics",
  44. data: {
  45. pageNo: pageNo || 1,
  46. pageSize: this.state.pagination.pageSize,
  47. startDate: this.state.releaseDate[0],
  48. endDate: this.state.releaseDate[1],
  49. timeSpan:this.state.releaseDate[0]?'':urls,
  50. businessGlossoryId:this.state.intentionalSearch,
  51. depId:this.state.depId,
  52. depNo:this.state.departmentt
  53. },
  54. success: function(data) {
  55. let theArr = [];
  56. if(!data.data || !data.data.list) {
  57. if(data.error && data.error.length) {
  58. message.warning(data.error[0].message);
  59. };
  60. } else {
  61. for(let i = 0; i < data.data.list.length; i++) {
  62. let thisdata = data.data.list[i];
  63. theArr.push({
  64. key: i,
  65. id: thisdata.id,
  66. adminName: thisdata.adminName,
  67. departmentName: thisdata.departmentName,
  68. newNo: thisdata.newNo,
  69. intentionNo: thisdata.intentionNo,
  70. pointNo: thisdata.pointNo,
  71. interviewNo: thisdata.interviewNo,
  72. signNo: thisdata.signNo,
  73. refuseNo: thisdata.refuseNo,
  74. stopNo: thisdata.stopNo,
  75. });
  76. };
  77. this.state.pagination.current = data.data.pageNo;
  78. this.state.pagination.total = data.data.totalCount;
  79. };
  80. if(!data.data.list.length){
  81. this.state.pagination.current=0;
  82. this.state.pagination.total=0;
  83. }
  84. this.setState({
  85. dataSource: theArr,
  86. pagination: this.state.pagination
  87. });
  88. }.bind(this),
  89. }).always(function() {
  90. this.setState({
  91. loading: false
  92. });
  93. }.bind(this));
  94. },
  95. getInitialState() {
  96. return {
  97. releaseDate: [],
  98. loading: false,
  99. callnub:'1',
  100. pagination: {
  101. defaultCurrent: 1,
  102. defaultPageSize: 10,
  103. showQuickJumper: true,
  104. pageSize: 10,
  105. onChange: function(page) {
  106. this.call(page)
  107. }.bind(this),
  108. showTotal: function(total) {
  109. return '共' + total + '条数据';
  110. }
  111. },
  112. columns: [{
  113. title: '营销员',
  114. dataIndex: 'adminName',
  115. key: 'adminName',
  116. }, {
  117. title: '部门',
  118. dataIndex: 'departmentName',
  119. key: 'departmentName',
  120. }, {
  121. title: '新客户数',
  122. dataIndex: 'newNo',
  123. key: 'newNo',
  124. }, {
  125. title: '意向客户数',
  126. dataIndex: 'intentionNo',
  127. key: 'intentionNo',
  128. }, {
  129. title: '重点客户数',
  130. dataIndex: 'pointNo',
  131. key: 'pointNo',
  132. }, {
  133. title: '面谈客户数',
  134. dataIndex: 'interviewNo',
  135. key: 'interviewNo',
  136. }, {
  137. title: '签单客户数',
  138. dataIndex: 'stopNo',
  139. key: 'stopNo',
  140. }, {
  141. title: '被拒绝客户数',
  142. dataIndex: 'refuseNo',
  143. key: 'refuseNo',
  144. }]
  145. }
  146. },
  147. //部门
  148. departmentList() {
  149. this.setState({
  150. loading: true
  151. });
  152. $.ajax({
  153. method: "get",
  154. dataType: "json",
  155. crossDomain: false,
  156. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  157. data: {
  158. },
  159. success: function(data) {
  160. let thedata = data.data;
  161. let theArr=[];
  162. if(!thedata) {
  163. if(data.error && data.error.length) {
  164. message.warning(data.error[0].message);
  165. };
  166. thedata = {};
  167. }else{
  168. thedata.map(function(item,index){
  169. theArr.push({
  170. key:index,
  171. name:item.name,
  172. id:item.id,
  173. depNo:item.depNo
  174. })
  175. })
  176. }
  177. this.setState({
  178. departmentArr:theArr,
  179. })
  180. }.bind(this),
  181. }).always(function() {
  182. this.setState({
  183. loading: false
  184. });
  185. }.bind(this));
  186. },
  187. callback(e) {
  188. this.setState({
  189. callnub: e,
  190. releaseDate:[]
  191. })
  192. this.loadData(1, e)
  193. },
  194. call(a){
  195. this.loadData(a, this.state.callnub)
  196. },
  197. search() {
  198. if(this.state.releaseDate[0]){
  199. this.setState({
  200. callnub:'1'
  201. })
  202. }else{
  203. this.state.releaseDate=[]
  204. }
  205. this.loadData(1, this.state.callnub)
  206. },
  207. reset() {
  208. this.state.departmentt=undefined;
  209. this.state.releaseDate = [];
  210. this.state.intentionalSearch = undefined;
  211. this.loadData(1, this.state.callnub);
  212. },
  213. componentWillMount() {
  214. this.loadData();
  215. this.departmentList()
  216. },
  217. changeList(arr) {
  218. const newArr = [];
  219. this.state.columns.forEach(item => {
  220. arr.forEach(val => {
  221. if (val === item.title) {
  222. newArr.push(item);
  223. }
  224. });
  225. });
  226. this.setState({
  227. changeList: newArr
  228. });
  229. },
  230. render() {
  231. const { RangePicker } = DatePicker;
  232. let departmentArr = this.state.departmentArr || [];
  233. return <div className="visitContant">
  234. <div className="visitTitle">
  235. <Tabs defaultActiveKey="1" className="test">
  236. <TabPane tab="搜索" key="1">
  237. <div className="user-search" style={{paddingTop:'11px'}}>
  238. <span className="titleTime">起止时间</span>
  239. <RangePicker
  240. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  241. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  242. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  243. <span style={{marginRight:'15px',marginLeft:'15px'}}>业务类型:</span>
  244. <Select placeholder="业务品种" value={this.state.intentionalSearch} onChange={(e) => {
  245. this.setState({intentionalSearch:e})}} style={{width:'150px'}}>
  246. {
  247. intentionalService.map(function (item) {
  248. return <Select.Option key={item.value} >{item.key}</Select.Option>
  249. })
  250. }
  251. </Select>
  252. <span style={{marginRight:'15px',marginLeft:'15px'}}>部门:</span>
  253. <Select placeholder="选择部门" style={{width:'150px'}}
  254. value={this.state.departmentt}
  255. onChange={(e) => { this.setState({ departmentt: e }) }}>
  256. {
  257. departmentArr.map(function (item) {
  258. return <Select.Option key={item.depNo} >{item.name}</Select.Option>
  259. })
  260. }
  261. </Select>
  262. <Button onClick={this.search} className="blue" style={{background:'red',color:'#ffffff',border:'none'}}>统计</Button>
  263. <Button onClick={this.reset} className="green" style={{background:'green',color:'#ffffff',border:'none'}}>重置</Button>
  264. </div>
  265. </TabPane>
  266. <TabPane tab="更改表格显示数据" key="2">
  267. <div style={{ marginLeft: 10 }}>
  268. <ChooseList
  269. columns={this.state.columns}
  270. changeFn={this.changeList}
  271. changeList={this.state.changeList}
  272. top={55}
  273. margin={11}
  274. />
  275. </div>
  276. </TabPane>
  277. </Tabs>
  278. <div className="clearfix" style={{marginTop:'30px',marginLeft:'20px'}}>
  279. <Tabs onChange={this.callback} type="card" activeKey={this.state.callnub}>
  280. <TabPane tab="所有业务客户状态" key="1"></TabPane>
  281. <TabPane tab="本日业务客户状态" key="2"></TabPane>
  282. <TabPane tab="本周业务客户状态" key="3"></TabPane>
  283. <TabPane tab="本月业务客户状态" key="4"></TabPane>
  284. <TabPane tab="本季业务客户状态" key="5"></TabPane>
  285. <TabPane tab="本年业务客户状态" key="6"></TabPane>
  286. </Tabs>
  287. </div>
  288. <div className="clearfix">
  289. <div className="maintitle">业务客户状态情况统计表</div>
  290. <div className="patent-table">
  291. <Spin spinning={this.state.loading}>
  292. <Table size="middle" columns={
  293. this.state.changeList
  294. ? this.state.changeList
  295. : this.state.columns
  296. }
  297. dataSource={this.state.dataSource}
  298. pagination={this.state.pagination}
  299. onRowClick={this.tableRowClick} />
  300. </Spin>
  301. </div>
  302. </div>
  303. </div>
  304. </div>
  305. }
  306. });
  307. export default StatusStatistics;