visitStatistics.jsx 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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, Table, Spin, message, Tabs, DatePicker, Select } from 'antd';
  6. var intentionalService = [];
  7. const TabPane = Tabs.TabPane;
  8. import moment from 'moment';
  9. import {ChooseList} from "../../order/orderNew/chooseList";
  10. const VisitStatistics = 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/followStatistic",
  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. depId: this.state.depId,
  51. depNo:this.state.departmentt
  52. },
  53. success: function(data) {
  54. let theArr = [];
  55. if(!data.data || !data.data.list) {
  56. if(data.error && data.error.length) {
  57. message.warning(data.error[0].message);
  58. };
  59. } else {
  60. for(let i = 0; i < data.data.list.length; i++) {
  61. let thisdata = data.data.list[i];
  62. theArr.push({
  63. key: i,
  64. id: thisdata.id,
  65. adminName: thisdata.adminName,
  66. departmentName: thisdata.departmentName,
  67. followNo: thisdata.followNo,
  68. customerNo: thisdata.customerNo,
  69. telNo: thisdata.telNo,
  70. qqNo: thisdata.qqNo,
  71. visitNo: thisdata.visitNo,
  72. emailNo: thisdata.emailNo,
  73. letterNo: thisdata.letterNo,
  74. wxNo: thisdata.wxNo,
  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: 'followNo',
  123. key: 'followNo',
  124. }, {
  125. title: '拜访客户数',
  126. dataIndex: 'customerNo',
  127. key: 'customerNo',
  128. }, {
  129. title: '电话量',
  130. dataIndex: 'telNo',
  131. key: 'telNo',
  132. }, {
  133. title: '外拜量',
  134. dataIndex: 'visitNo',
  135. key: 'visitNo',
  136. }, {
  137. title: 'QQ量',
  138. dataIndex: 'qqNo',
  139. key: 'qqNo',
  140. }, {
  141. title: '邮件量',
  142. dataIndex: 'emailNo',
  143. key: 'emailNo',
  144. }, {
  145. title: '书信量',
  146. dataIndex: 'letterNo',
  147. key: 'letterNo',
  148. }, {
  149. title: '微信量',
  150. dataIndex: 'wxNo',
  151. key: 'wxNo',
  152. }, ]
  153. }
  154. },
  155. callback(e) {
  156. this.setState({
  157. callnub: e,
  158. releaseDate: []
  159. })
  160. this.loadData(1, e)
  161. },
  162. call(a) {
  163. this.loadData(a, this.state.callnub)
  164. },
  165. search() {
  166. if(this.state.releaseDate[0]) {
  167. this.setState({
  168. callnub: '1'
  169. })
  170. } else {
  171. this.state.releaseDate = []
  172. }
  173. this.loadData(1, this.state.callnub)
  174. },
  175. //部门
  176. departmentList() {
  177. this.setState({
  178. loading: true
  179. });
  180. $.ajax({
  181. method: "get",
  182. dataType: "json",
  183. crossDomain: false,
  184. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  185. data: {
  186. },
  187. success: function(data) {
  188. let thedata = data.data;
  189. let theArr=[];
  190. if(!thedata) {
  191. if(data.error && data.error.length) {
  192. message.warning(data.error[0].message);
  193. };
  194. thedata = {};
  195. }else{
  196. thedata.map(function(item,index){
  197. theArr.push({
  198. key:index,
  199. name:item.name,
  200. id:item.id,
  201. depNo:item.depNo
  202. })
  203. })
  204. }
  205. this.setState({
  206. departmentArr:theArr,
  207. })
  208. }.bind(this),
  209. }).always(function() {
  210. this.setState({
  211. loading: false
  212. });
  213. }.bind(this));
  214. },
  215. reset() {
  216. this.state.departmentt=undefined;
  217. this.state.releaseDate = [];
  218. this.loadData(1, this.state.callnub);
  219. },
  220. componentWillMount() {
  221. this.loadData();
  222. this.departmentList()
  223. },
  224. changeList(arr) {
  225. const newArr = [];
  226. this.state.columns.forEach(item => {
  227. arr.forEach(val => {
  228. if (val === item.title) {
  229. newArr.push(item);
  230. }
  231. });
  232. });
  233. this.setState({
  234. changeList: newArr
  235. });
  236. },
  237. render() {
  238. const { RangePicker } = DatePicker;
  239. let departmentArr = this.state.departmentArr || [];
  240. return <div className="visitContant">
  241. <div className="visitTitle">
  242. <Tabs
  243. defaultActiveKey="1"
  244. onChange={this.callback}
  245. className="test"
  246. >
  247. <TabPane tab="搜索" key="1">
  248. <div className="user-search" style={{paddingTop:'11px'}}>
  249. <span className="titleTime">起止时间</span>
  250. <RangePicker
  251. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  252. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  253. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  254. <span style={{marginRight:'15px',marginLeft:'15px'}}>部门:</span>
  255. <Select placeholder="选择部门" style={{width:'150px'}}
  256. value={this.state.departmentt}
  257. onChange={(e) => { this.setState({ departmentt: e }) }}>
  258. {
  259. departmentArr.map(function (item) {
  260. return <Select.Option key={item.depNo} >{item.name}</Select.Option>
  261. })
  262. }
  263. </Select>
  264. <Button onClick={this.search} className="blue" style={{background:'red',color:'#ffffff',border:'none'}}>统计</Button>
  265. <Button onClick={this.reset} className="green" style={{background:'green',color:'#ffffff',border:'none'}}>重置</Button>
  266. </div>
  267. </TabPane>
  268. <TabPane tab="更改表格显示数据" key="2">
  269. <div style={{ marginLeft: 10 }}>
  270. <ChooseList
  271. columns={this.state.columns}
  272. changeFn={this.changeList}
  273. changeList={this.state.changeList}
  274. top={55}
  275. margin={11}
  276. />
  277. </div>
  278. </TabPane>
  279. </Tabs>
  280. <div className="clearfix" style={{marginTop:'30px',marginLeft:'20px'}}>
  281. <Tabs onChange={this.callback} type="card" activeKey={this.state.callnub} >
  282. <TabPane tab="所有客户拜访统计" key="1"></TabPane>
  283. <TabPane tab="本日客户拜访统计" key="2"></TabPane>
  284. <TabPane tab="本周客户拜访统计" key="3"></TabPane>
  285. <TabPane tab="本月客户拜访统计" key="4"></TabPane>
  286. <TabPane tab="本季客户拜访统计" key="5"></TabPane>
  287. <TabPane tab="本年客户拜访统计" key="6"></TabPane>
  288. </Tabs>
  289. </div>
  290. <div className="clearfix">
  291. <div className="maintitle">客户拜访情况统计表</div>
  292. <div className="patent-table">
  293. <Spin spinning={this.state.loading}>
  294. <Table size="middle" columns={
  295. this.state.changeList
  296. ? this.state.changeList
  297. : this.state.columns
  298. }
  299. dataSource={this.state.dataSource}
  300. pagination={this.state.pagination}
  301. onRowClick={this.tableRowClick} />
  302. </Spin>
  303. </div>
  304. </div>
  305. </div>
  306. </div>
  307. }
  308. })
  309. export default VisitStatistics;