departmentReport.jsx 15 KB

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