personalReport.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. import React from 'react';
  2. import {Select, Spin, Input, Table, Button, message, DatePicker, Tabs} from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import './report.less';
  6. import { post } from '../../../dataDic.js';
  7. import {SearchInput} from "../../order/orderNew/changeComponent/searchInput";
  8. import {ChooseList} from "../../order/orderNew/chooseList";
  9. const { TabPane } = Tabs;
  10. const PersonalReport = React.createClass({
  11. loadData(totalArr,pageNo) {
  12. if(this.state.selTime){
  13. var newTime=this.state.selTime;
  14. var timeArr=newTime.split('-');
  15. var txtTime=timeArr[0]+'年'+timeArr[1]+'月'+timeArr[2]+'日';
  16. this.setState({
  17. timeState:true,
  18. txtTime:txtTime,
  19. })
  20. }
  21. let total=totalArr;
  22. this.setState({
  23. loading: true
  24. });
  25. $.ajax({
  26. method: "get",
  27. dataType: "json",
  28. crossDomain: false,
  29. url: globalConfig.context + "/api/admin/report/sales/personal",
  30. data: {
  31. pNo: pageNo || 1,
  32. pSize: 10,
  33. date:this.state.selTime?(this.state.selTime+' '+'00:00:00'):'',
  34. depName:this.state.departmentSearch,
  35. name:this.state.uesrNameSearch,
  36. },
  37. success: function(data) {
  38. let thedata = data.data;
  39. let theArr = [];
  40. if(!data.data) {
  41. if(data.error && data.error.length) {
  42. message.warning(data.error[0].message);
  43. };
  44. thedata = {};
  45. } else {
  46. thedata.map(function(item, index) {
  47. var yTime=new Date(item.enrollTime).toLocaleDateString();
  48. let nub=index+1;
  49. theArr.push({
  50. key: index,
  51. theNumber:false,
  52. nub:nub,
  53. id: item.id,
  54. name:item.name, //姓名
  55. departmentName:item.departmentName,//部门
  56. position:item.position, //职务
  57. enrollTime:yTime,// 入职时间
  58. dailyOrderCount:item.values.daily.orderCount,//日签单业绩
  59. dailyOrderAmount:item.values.daily.orderAmount,//日签单业绩
  60. weeklyOrderCount:item.values.weekly.orderCount,//周签单业绩
  61. weeklyOrderAmount:item.values.weekly.orderAmount,//周签单业绩
  62. monthlyOrderCount:item.values.monthly.orderCount,//月签单业绩
  63. monthlyOrderAmount:item.values.monthly.orderAmount,//月签单业绩
  64. quarterlyOrderCount:item.values.quarterly.orderCount,//季签单业绩
  65. quarterlyOrderAmount:item.values.quarterly.orderAmount,//季签单业绩
  66. annuallyOrderCount:item.values.annually.orderCount,//年签单业绩
  67. annuallyOrderAmount:item.values.annually.orderAmount,//年签单业绩
  68. })
  69. })
  70. this.state.pagination.current =pageNo;
  71. this.state.pagination.total=total.totalRecordCount+Math.floor(total.totalRecordCount/10);
  72. };
  73. if(!data.data.length){
  74. this.state.pagination.total=0;
  75. };
  76. if(theArr.length){
  77. theArr.push(
  78. {
  79. key:9999999,
  80. theNumber:true,
  81. nub:data.data.length+1,
  82. name:'',
  83. position:'', //职务
  84. enrollTime:'',// 入职时间
  85. departmentName:'合计',
  86. dailyOrderCount:total.dailyTotalCount,//日签单业绩
  87. dailyOrderAmount:total.dailyTotalAmount,//日签单业绩
  88. weeklyOrderCount:total.weeklyTotalCount,//周签单业绩
  89. weeklyOrderAmount:total.weeklyTotalAmount,//周签单业绩
  90. monthlyOrderCount:total.monthlyTotalCount,//月签单业绩
  91. monthlyOrderAmount:total.monthlyTotalAmount,//月签单业绩
  92. quarterlyOrderCount:total.quarterlyTotalCount,//季签单业绩
  93. quarterlyOrderAmount:total.quarterlyTotalAmount,//季签单业绩
  94. annuallyOrderCount:total.annuallyTotalCount,//年签单业绩
  95. annuallyOrderAmount:total.annuallyTotalAmount,//年签单业绩
  96. }
  97. )
  98. }
  99. this.setState({
  100. dataSource: theArr,
  101. pagination: this.state.pagination,
  102. })
  103. }.bind(this),
  104. }).always(function() {
  105. this.setState({
  106. loading: false
  107. });
  108. }.bind(this));
  109. },
  110. totalData(page) {
  111. this.setState({
  112. loading: true
  113. });
  114. $.ajax({
  115. method: "get",
  116. dataType: "json",
  117. crossDomain: false,
  118. url: globalConfig.context + "/api/admin/report/sales/total",
  119. data: {
  120. date:this.state.selTime?(this.state.selTime+' '+'00:00:00'):'',
  121. depName:this.state.departmentSearch,
  122. name:this.state.uesrNameSearch,
  123. },
  124. success: function(data) {
  125. let thedata = data.data;
  126. let theArr = [];
  127. if(!thedata) {
  128. if(data.error && data.error.length) {
  129. message.warning(data.error[0].message);
  130. };
  131. thedata = {};
  132. }
  133. this.loadData(thedata,page)
  134. }.bind(this),
  135. }).always(function() {
  136. this.setState({
  137. loading: false
  138. });
  139. }.bind(this));
  140. },
  141. departmentList() {
  142. this.setState({
  143. loading: true
  144. });
  145. $.ajax({
  146. method: "get",
  147. dataType: "json",
  148. crossDomain: false,
  149. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  150. data: {
  151. },
  152. success: function(data) {
  153. let thedata = data.data;
  154. let theArr = [];
  155. if(!thedata) {
  156. if(data.error && data.error.length) {
  157. message.warning(data.error[0].message);
  158. };
  159. thedata = {};
  160. } else {
  161. thedata.map(function(item, index) {
  162. theArr.push({
  163. key: index,
  164. name: item.name,
  165. id: item.id,
  166. depNo: item.depNo
  167. })
  168. })
  169. }
  170. this.setState({
  171. departmentArr: theArr,
  172. })
  173. }.bind(this),
  174. }).always(function() {
  175. this.setState({
  176. loading: false
  177. });
  178. }.bind(this));
  179. },
  180. getInitialState() {
  181. return {
  182. selectedRowKeys: [],
  183. selectedRows: [],
  184. loading: false,
  185. visible: false,
  186. showDesc: false,
  187. timeState:false,
  188. pagination: {
  189. defaultCurrent: 1,
  190. defaultPageSize: 11,
  191. showQuickJumper: true,
  192. pageSize: 11,
  193. onChange: function (page) {
  194. this.totalData(page);
  195. }.bind(this),
  196. showTotal: function (total) {
  197. return '共' + total + '条数据';
  198. }
  199. },
  200. columns: [
  201. {
  202. title: '序号',
  203. dataIndex: 'nub',
  204. width:50,
  205. fixed:true,
  206. key: 'nub',
  207. render:(text,record)=>{
  208. if(!record.theNumber){
  209. return text
  210. }else{
  211. return {
  212. children: text,
  213. props: {
  214. colSpan:1
  215. },
  216. }
  217. }
  218. }
  219. },
  220. {
  221. title: '姓名',
  222. dataIndex: 'name',
  223. width:100,
  224. fixed:true,
  225. key: 'name',
  226. render:(text,record)=>{
  227. if(!record.theNumber){
  228. return text
  229. }else{
  230. return {
  231. children: text,
  232. props: {
  233. colSpan:0
  234. },
  235. }
  236. }
  237. }
  238. },{
  239. title: '部门',
  240. dataIndex: 'departmentName',
  241. width:100,
  242. fixed:true,
  243. key: 'departmentName',
  244. render:(text,record)=>{
  245. if(!record.theNumber){
  246. return text&&text.length>6?<span title={text}>{text.substr(0,6)+'…'}</span>:text
  247. }else{
  248. return {
  249. children: text,
  250. props: {
  251. colSpan:4
  252. },
  253. }
  254. }
  255. }
  256. },
  257. {
  258. title: '职务',
  259. dataIndex: 'position',
  260. key: 'position',
  261. fixed:true,
  262. width:100,
  263. render:(text,record)=>{
  264. if(!record.theNumber){
  265. return text
  266. }else{
  267. return {
  268. children: text,
  269. props: {
  270. colSpan:0
  271. },
  272. }
  273. }
  274. }
  275. },{
  276. title: '入职时间',
  277. width:100,
  278. fixed:true,
  279. dataIndex: 'enrollTime',
  280. key: 'enrollTime',
  281. render:(text,record)=>{
  282. if(!record.theNumber){
  283. return text
  284. }else{
  285. return {
  286. children: text,
  287. props: {
  288. colSpan:0
  289. },
  290. }
  291. }
  292. }
  293. },{
  294. title: '当日营销客户数',
  295. children: [
  296. {
  297. title: '总数',
  298. dataIndex: 'num',
  299. width:70,
  300. key: 'num',
  301. sorter: (a, b) => a.num - b.num,
  302. },{
  303. title: '新增',
  304. dataIndex: 'age2',
  305. width:70,
  306. key: 'age2',
  307. sorter: (a, b) => a.age - b.age,
  308. },{
  309. title: '回访',
  310. width:70,
  311. dataIndex: 'age3',
  312. key: 'age3',
  313. sorter: (a, b) => a.age - b.age,
  314. },{
  315. title: '有效',
  316. width:70,
  317. dataIndex: 'age4',
  318. key: 'age4',
  319. sorter: (a, b) => a.age - b.age,
  320. },
  321. ],
  322. }, {
  323. title: '当日营销方式',
  324. children: [
  325. {
  326. title: '总数',
  327. width:70,
  328. dataIndex: 'age11',
  329. key: 'age11',
  330. sorter: (a, b) => a.age - b.age,
  331. },{
  332. title: '电话',
  333. width:70,
  334. dataIndex: 'age22',
  335. key: 'age22',
  336. sorter: (a, b) => a.age - b.age,
  337. },{
  338. title: '外拜',
  339. width:70,
  340. dataIndex: 'age33',
  341. key: 'age33',
  342. sorter: (a, b) => a.age - b.age,
  343. },{
  344. title: '邮件',
  345. width:70,
  346. dataIndex: 'age44',
  347. key: 'age44',
  348. sorter: (a, b) => a.age - b.age,
  349. },{
  350. title: '微信',
  351. width:70,
  352. dataIndex: 'age55',
  353. key: 'age55',
  354. sorter: (a, b) => a.age - b.age,
  355. }
  356. ],
  357. },
  358. {
  359. title: '本日签单业绩',
  360. children: [
  361. {
  362. title: '数量',
  363. width:70,
  364. dataIndex: 'dailyOrderCount',
  365. key: 'dailyOrderCount',
  366. sorter: (a, b) => a.dailyOrderCount - b.dailyOrderCount,
  367. },{
  368. title: '金额',
  369. width:70,
  370. dataIndex: 'dailyOrderAmount',
  371. key: 'dailyOrderAmount',
  372. sorter: (a, b) => a.dailyOrderAmount - b.dailyOrderAmount,
  373. }
  374. ],
  375. },{
  376. title: '本周签单业绩',
  377. children: [
  378. {
  379. title: '数量',
  380. width:70,
  381. dataIndex: 'weeklyOrderCount',
  382. key: 'weeklyOrderCount',
  383. sorter: (a, b) => a.weeklyOrderCount - b.weeklyOrderCount,
  384. },{
  385. title: '金额',
  386. width:70,
  387. dataIndex: 'weeklyOrderAmount',
  388. key: 'weeklyOrderAmount',
  389. sorter: (a, b) => a.weeklyOrderAmount - b.weeklyOrderAmount,
  390. }
  391. ],
  392. },{
  393. title: '本月签单业绩',
  394. children: [
  395. {
  396. title: '数量',
  397. width:70,
  398. dataIndex: 'monthlyOrderCount',
  399. key: 'monthlyOrderCount',
  400. sorter: (a, b) => a.monthlyOrderCount - b.monthlyOrderCount,
  401. },{
  402. title: '金额',
  403. width:70,
  404. dataIndex: 'monthlyOrderAmount',
  405. key: 'monthlyOrderAmount',
  406. sorter: (a, b) => a.monthlyOrderAmount - b.monthlyOrderAmount,
  407. }
  408. ],
  409. },{
  410. title: '本季签单业绩',
  411. children: [
  412. {
  413. title: '数量',
  414. width:70,
  415. dataIndex: 'quarterlyOrderCount',
  416. key: 'quarterlyOrderCount',
  417. sorter: (a, b) => a.quarterlyOrderCount - b.quarterlyOrderCount,
  418. },{
  419. title: '金额',
  420. width:70,
  421. dataIndex: 'quarterlyOrderAmount',
  422. key: 'quarterlyOrderAmount',
  423. sorter: (a, b) => a.quarterlyOrderAmount - b.quarterlyOrderAmount,
  424. }
  425. ],
  426. },{
  427. title: '本年签单业绩',
  428. children: [
  429. {
  430. title: '数量',
  431. width:70,
  432. dataIndex: 'annuallyOrderCount',
  433. key: 'annuallyOrderCount',
  434. sorter: (a, b) => a.annuallyOrderCount - b.annuallyOrderCount,
  435. },{
  436. title: '金额',
  437. width:70,
  438. dataIndex: 'annuallyOrderAmount',
  439. key: 'annuallyOrderAmount',
  440. sorter: (a, b) => a.annuallyOrderAmount - b.annuallyOrderAmount,
  441. }
  442. ],
  443. }
  444. ],
  445. dataSource: [],
  446. };
  447. },
  448. search() {
  449. this.totalData()
  450. },
  451. reset() {
  452. this.state.departmentSearch = undefined;
  453. this.state.postSearch = undefined;
  454. this.state.uesrNameSearch = '';
  455. this.state.Dtime = undefined;
  456. this.state.selTime='';
  457. this.state.timeState=false;
  458. this.totalData();
  459. },
  460. //时间选择
  461. selTime(value,index){
  462. this.setState({
  463. Dtime:value,
  464. selTime:index
  465. })
  466. },
  467. componentWillMount() {
  468. this.departmentList();
  469. this.totalData();
  470. let times=new Date();
  471. let nowTime=times.getFullYear()+'年'+(times.getMonth()+1)+'月'+times.getDate()+'日';
  472. this.setState({
  473. Nowtime:nowTime
  474. })
  475. },
  476. changeList(arr) {
  477. const newArr = [];
  478. this.state.columns.forEach(item => {
  479. arr.forEach(val => {
  480. if (val === item.title) {
  481. newArr.push(item);
  482. }
  483. });
  484. });
  485. this.setState({
  486. changeList: newArr
  487. });
  488. },
  489. render() {
  490. let departmentArr = this.state.departmentArr || [];
  491. return(
  492. <div className='set-content'>
  493. <span style={{fontSize:'20px'}}>个人业绩统计报表</span>
  494. <Tabs defaultActiveKey="1" className="test">
  495. <TabPane tab="搜索" key="1">
  496. <div className="clearfix">
  497. <Select placeholder="部门机构"
  498. style={{ width: 150 ,marginRight:'10px',marginTop:'10px',marginBottom:'10px'}}
  499. value={this.state.departmentSearch}
  500. onChange={(e) => { this.setState({ departmentSearch: e }) }}>
  501. {
  502. departmentArr.map(function (item) {
  503. return <Select.Option key={item.name} >{item.name}</Select.Option>
  504. })
  505. }
  506. </Select>
  507. <Input value={this.state.uesrNameSearch} placeholder="用户姓名" style={{width:'150px',marginRight:'5px'}}
  508. onChange={(e)=>{this.setState({uesrNameSearch:e.target.value})}} />
  509. <span style={{fontSize:'16px'}}>选择日期 : </span>
  510. <DatePicker onChange={this.selTime} value={this.state.Dtime}/>
  511. <Button type="primary" onClick={this.search} style={{marginLeft:'10px',marginRight:'10px'}}>搜索</Button>
  512. <Button onClick={this.reset}>重置</Button>
  513. </div>
  514. </TabPane>
  515. <TabPane tab="更改表格显示数据" key="2">
  516. <div style={{ marginLeft: 10 }}>
  517. <ChooseList
  518. columns={this.state.columns}
  519. changeFn={this.changeList}
  520. changeList={this.state.changeList}
  521. top={55}
  522. margin={11}
  523. />
  524. </div>
  525. </TabPane>
  526. </Tabs>
  527. <div className="surfaceTitle">
  528. <span className="nowtime">{this.state.timeState?this.state.txtTime:this.state.Nowtime}</span>
  529. <span>个人营销业绩统计表</span>
  530. <span>(每日17:00统计当天数据)</span>
  531. </div>
  532. <div className="patent-table">
  533. <div className="scroll">
  534. <Spin spinning={this.state.loading}>
  535. <Table columns={
  536. this.state.changeList
  537. ? this.state.changeList
  538. : this.state.columns
  539. }
  540. dataSource={this.state.dataSource}
  541. bordered
  542. scroll={{x:1780}}
  543. pagination={this.state.pagination}
  544. />
  545. </Spin>
  546. </div>
  547. </div>
  548. </div>
  549. )
  550. }
  551. });
  552. export default PersonalReport;