adminCustomerStatistics.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. "use strict";
  2. import React from 'react';
  3. import ReactDom from 'react-dom';
  4. import ajax from 'jquery/src/ajax/xhr.js';
  5. import $ from 'jquery/src/ajax';
  6. import {
  7. Form,
  8. Radio,
  9. Icon,
  10. Button,
  11. Input,
  12. Select,
  13. Spin,
  14. Table,
  15. Switch,
  16. message,
  17. DatePicker,
  18. Modal,
  19. Upload,
  20. Popconfirm,
  21. Tabs, Tag
  22. } from 'antd';
  23. import moment from 'moment';
  24. import '../../order/userMangagement.less';
  25. import { orderState, orderChannel, orderType } from '../../../dataDic.js';
  26. import { getProjectState, getOrderChannel, getOrderType, getOrderState, getPaymentState, getApprovedState } from '../../../tools.js';
  27. import {ChooseList} from "../../order/orderNew/chooseList";
  28. const {TabPane} = Tabs
  29. const AdminCustomerStatistics = Form.create()(React.createClass({
  30. loadData(pageNo) {
  31. this.state.data = [];
  32. this.setState({
  33. loading: true
  34. });
  35. $.ajax({
  36. method: "get",
  37. dataType: "json",
  38. crossDomain: false,
  39. url: globalConfig.context + '/api/admin/customer/selectAdminCustomerStatistics',
  40. data: {
  41. pageNo: pageNo || 1,
  42. pageSize: this.state.pagination.pageSize,
  43. depId: this.state.departmenttSearch, //部门
  44. startTime: this.state.releaseDate[0],
  45. endTime: this.state.releaseDate[1],
  46. },
  47. success: function(data) {
  48. let theArr = [];
  49. if(!data.data) {
  50. if(data.error && data.error.length) {
  51. message.warning(data.error[0].message);
  52. };
  53. } else {
  54. for(let i = 0; i < data.data.list.length; i++) {
  55. let thisdata = data.data.list[i];
  56. theArr.push({
  57. key: pageNo?(i+1+(pageNo-1)*10):i+1,
  58. aid:thisdata.aid,
  59. aName:thisdata.aName,
  60. depName:thisdata.depName,
  61. userCount:thisdata.userCount,
  62. signCount:thisdata.signCount,
  63. inputCount:thisdata.inputCount,
  64. receiveCount:thisdata.receiveCount,
  65. });
  66. };
  67. this.state.pagination.current = data.data.pageNo;
  68. this.state.pagination.total = data.data.totalCount;
  69. };
  70. if(!data.data.list.length) {
  71. this.state.pagination.current = 0
  72. this.state.pagination.total = 0
  73. }
  74. this.setState({
  75. pageNo: pageNo,
  76. dataSource: theArr,
  77. pagination: this.state.pagination,
  78. // selectedRowKeys: [],
  79. // signBillVisible: false
  80. });
  81. }.bind(this),
  82. }).always(function() {
  83. this.setState({
  84. loading: false
  85. });
  86. }.bind(this));
  87. },
  88. //部门
  89. departmentList() {
  90. this.setState({
  91. loading: true
  92. });
  93. $.ajax({
  94. method: "get",
  95. dataType: "json",
  96. crossDomain: false,
  97. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  98. data: {
  99. },
  100. success: function(data) {
  101. let thedata = data.data;
  102. let theArr = [];
  103. if(!thedata) {
  104. if(data.error && data.error.length) {
  105. message.warning(data.error[0].message);
  106. };
  107. thedata = {};
  108. } else {
  109. thedata.map(function(item, index) {
  110. theArr.push({
  111. key: index,
  112. name: item.name,
  113. id: item.id,
  114. })
  115. })
  116. }
  117. this.setState({
  118. departmentArr: theArr,
  119. })
  120. }.bind(this),
  121. }).always(function() {
  122. this.setState({
  123. loading: false
  124. });
  125. }.bind(this));
  126. },
  127. //操作分配
  128. confirmDelet(index) {
  129. this.setState({
  130. orderNot: index.orderNo,
  131. userDetaile: false,
  132. distributionVisible: true
  133. });
  134. },
  135. distributionCancel() {
  136. this.setState({
  137. distributionVisible: false
  138. })
  139. },
  140. distributionOk() {
  141. this.setState({
  142. distributionVisible: false
  143. })
  144. },
  145. //分配对象列表
  146. contactList() {
  147. $.ajax({
  148. method: "get",
  149. dataType: "json",
  150. crossDomain: false,
  151. url: globalConfig.context + '/api/admin/superviser/adminList',
  152. data: {
  153. pageNo: 1,
  154. pageSize: 99,
  155. departmentId: this.state.departmenttList,
  156. name: this.state.financeNameSearch,
  157. },
  158. success: function(data) {
  159. let theArr = [];
  160. if(!data.data) {
  161. if(data.error && data.error.length) {
  162. message.warning(data.error[0].message);
  163. };
  164. } else {
  165. for(let i = 0; i < data.data.list.length; i++) {
  166. let thisdata = data.data.list[i];
  167. theArr.push({
  168. key: i,
  169. id: thisdata.id,
  170. userNo: thisdata.userNo,
  171. name: thisdata.name,
  172. departmentName: thisdata.departmentName,
  173. departmentId: thisdata.departmentId,
  174. position: thisdata.position,
  175. mobile: thisdata.mobile,
  176. });
  177. };
  178. };
  179. this.setState({
  180. distributionList: theArr,
  181. });
  182. }.bind(this),
  183. }).always(function() {
  184. this.setState({
  185. loading: false
  186. });
  187. }.bind(this));
  188. },
  189. //选定对象
  190. confirmSelect(record) {
  191. this.setState({
  192. loading: true
  193. });
  194. $.ajax({
  195. method: "POST",
  196. dataType: "json",
  197. crossDomain: false,
  198. url: globalConfig.context + "/api/admin/order/distributionOrder",
  199. data: {
  200. orderNo: this.state.orderNot,
  201. financeId: record.id
  202. }
  203. }).done(function(data) {
  204. if(!data.error.length) {
  205. message.success('分派成功!');
  206. this.setState({
  207. loading: false,
  208. });
  209. this.distributionOk();
  210. } else {
  211. message.warning(data.error[0].message);
  212. };
  213. this.loadData(this.state.pageNo);
  214. }.bind(this));
  215. },
  216. componentWillMount() {
  217. this.departmentList();
  218. this.loadData();
  219. },
  220. getInitialState() {
  221. return {
  222. rowKey : 0,
  223. datauser: {},
  224. selectedRowKeys: [],
  225. releaseDate: [],
  226. selectedRows: [],
  227. departmentArr: [],
  228. searchMore: true,
  229. loading: false,
  230. distributionVisible: false,
  231. visible: false,
  232. showDesc: false,
  233. pagination: {
  234. defaultCurrent: 1,
  235. defaultPageSize: 10,
  236. showQuickJumper: true,
  237. pageSize: 10,
  238. onChange: function(page) {
  239. this.loadData(page);
  240. }.bind(this),
  241. showTotal: function(total) {
  242. return '共' + total + '条数据';
  243. }
  244. },
  245. paginationX: {
  246. defaultCurrent: 1,
  247. defaultPageSize: 10,
  248. showQuickJumper: true,
  249. pageSize: 10,
  250. onChange: function(page) {
  251. this.xiangmu(page,this.state.rowKey,this.state.type);
  252. }.bind(this),
  253. showTotal: function(total) {
  254. return '共' + total + '条数据';
  255. }
  256. },
  257. columns: [{
  258. title: '编号',
  259. dataIndex: 'key',
  260. key: 'key',
  261. align:'center',
  262. }, {
  263. title: '营销员名称',
  264. dataIndex: 'aName',
  265. key: 'aName',
  266. align:'center',
  267. }, {
  268. title: '部门名称',
  269. dataIndex: 'depName',
  270. key: 'depName',
  271. align:'center',
  272. }, {
  273. title: '私有客户数',
  274. dataIndex: 'userCount',
  275. key: 'userCount',
  276. align:'center',
  277. render:(text,record,index)=>{
  278. return <span onClick={()=>{
  279. this.userCount(record,index)
  280. }} className="single">{text}</span>
  281. }
  282. },{
  283. title: '签单客户数量',
  284. dataIndex: 'signCount',
  285. key: 'signCount',
  286. render:(text,record,index)=>{
  287. return <span onClick={()=>{
  288. this.signedQuantity(record,index)
  289. }} className="single">{text}</span>
  290. }
  291. },{
  292. title: '时间内新增客户数',
  293. dataIndex: 'inputCount',
  294. key: 'inputCount',
  295. render:(text,record,index)=>{
  296. return <span onClick={()=>{
  297. this.inputCount(record,index,1)
  298. }} className="single">{text}</span>
  299. }
  300. }, {
  301. title: '时间内领取客户数',
  302. dataIndex: 'receiveCount',
  303. key: 'receiveCount',
  304. render:(text,record,index)=>{
  305. return <span onClick={()=>{
  306. this.receiveCount(record,index,2)
  307. }} className="single">{text}</span>
  308. }
  309. }],
  310. dataSource: [],
  311. dataSourceX: [],
  312. columnsX: [{
  313. title: '客户名称',
  314. dataIndex: 'name',
  315. key: 'name'
  316. }, {
  317. title: '来源',
  318. dataIndex: 'sourceName',
  319. key: 'sourceName'
  320. }, {
  321. title: '联系人',
  322. dataIndex: 'contacts',
  323. key: 'contacts'
  324. }, {
  325. title: '联系人电话',
  326. dataIndex: 'contactMobile',
  327. key: 'contactMobile'
  328. }, {
  329. title: '创建时间',
  330. dataIndex: 'createTime',
  331. key: 'createTime',
  332. }, {
  333. title: '跟进时间',
  334. dataIndex: 'followTime',
  335. key: 'followTime',
  336. }]
  337. };
  338. },
  339. userCount(record,index){
  340. this.tableRowClick(record,index,0)
  341. },
  342. signedQuantity(record,index){
  343. this.tableRowClick(record,index,5)
  344. },
  345. inputCount(record,index){
  346. this.tableRowClick(record,index,1)
  347. },
  348. receiveCount(record,index){
  349. this.tableRowClick(record,index,2)
  350. },
  351. tableRowClick(record, index ,type) {
  352. this.xiangmu(1,record,type);
  353. this.setState({
  354. visible: true,
  355. rowKey: record,
  356. type: type,
  357. aName:record.aName
  358. });
  359. },
  360. xiangmu(pageNo,record,type) {
  361. this.state.data = [];
  362. this.setState({
  363. loading:true
  364. })
  365. $.ajax({
  366. method: "get",
  367. dataType: "json",
  368. crossDomain: false,
  369. url: globalConfig.context +"/api/admin/customer/selectAdminCustomerList",
  370. data: {
  371. pageNo:pageNo || 1,
  372. pageSize:this.state.paginationX.pageSize,
  373. startTime: this.state.releaseDate[0],
  374. endTime: this.state.releaseDate[1],
  375. aid:record.aid,
  376. type:type,
  377. },
  378. success: function(data) {
  379. let theArr = [];
  380. if(data.error.length || data.data.list == "") {
  381. if(data.error && data.error.length) {
  382. message.warning(data.error[0].message);
  383. };
  384. } else {
  385. for (let i = 0; i < data.data.list.length; i++) {
  386. let thisdata = data.data.list[i];
  387. theArr.push({
  388. key: i,
  389. id:thisdata.id,
  390. name:thisdata.name,
  391. sourceName:thisdata.sourceName,
  392. contacts:thisdata.contacts,
  393. contactMobile:thisdata.contactMobile,
  394. createTime:thisdata.createTime,
  395. followTime:thisdata.followTime,
  396. });
  397. };
  398. this.state.paginationX.current = pageNo;
  399. this.state.paginationX.total = data.data.totalCount;
  400. };
  401. if(!data.data.list.length) {
  402. this.state.paginationX.current = 0
  403. this.state.paginationX.total = 0
  404. }
  405. this.setState({
  406. dataSourceX: theArr,
  407. paginationX: this.state.paginationX,
  408. // selectedRowKeys: [],
  409. // signBillVisible: false
  410. });
  411. }.bind(this),
  412. }).always(function() {
  413. this.setState({
  414. loading: false
  415. });
  416. }.bind(this));
  417. },
  418. visitCancel(e){
  419. this.setState({
  420. visible:false
  421. })
  422. },
  423. visitOk(e){
  424. this.setState({
  425. visible:false
  426. })
  427. },
  428. closeDesc(e, s) {
  429. this.state.userDetaile = false;
  430. this.state.showDesc = e;
  431. if(s) {
  432. this.loadData(this.state.pageNo);
  433. };
  434. },
  435. searchSwitch() {
  436. this.setState({
  437. searchMore: !this.state.searchMore
  438. });
  439. },
  440. search() {
  441. this.loadData();
  442. },
  443. //分配时搜索
  444. searchOrder() {
  445. this.contactList();
  446. },
  447. //分配时重置
  448. resetOrder() {
  449. this.setState({
  450. departmenttList: undefined,
  451. financeNameSearch: ''
  452. })
  453. },
  454. reset() {
  455. this.state.releaseDate[0] = undefined;
  456. this.state.releaseDate[1] = undefined;
  457. this.state.departmenttSearch = undefined;
  458. this.state.approved = undefined;
  459. this.state.isDistributionFinance = undefined;
  460. this.loadData();
  461. },
  462. changeList(arr) {
  463. const newArr = [];
  464. this.state.columns.forEach(item => {
  465. arr.forEach(val => {
  466. if (val === item.title) {
  467. newArr.push(item);
  468. }
  469. });
  470. });
  471. this.setState({
  472. changeList: newArr
  473. });
  474. },
  475. render() {
  476. const rowSelection = {
  477. selectedRowKeys: this.state.selectedRowKeys,
  478. onChange: (selectedRowKeys, selectedRows) => {
  479. this.setState({
  480. selectedRows: selectedRows.slice(-1),
  481. selectedRowKeys: selectedRowKeys.slice(-1)
  482. });
  483. },
  484. onSelectAll: (selected, selectedRows, changeRows) => {
  485. this.setState({
  486. selectedRowKeys: []
  487. })
  488. },
  489. };
  490. let departmentArr = this.state.departmentArr || [];
  491. const hasSelected = this.state.selectedRowKeys.length > 0;
  492. const {
  493. RangePicker
  494. } = DatePicker;
  495. return(
  496. <div className="user-content" >
  497. <div className="content-title">
  498. <span style={{fontSize:'16px'}}>部门客户统计</span>
  499. <Tabs
  500. defaultActiveKey="1"
  501. onChange={this.callback}
  502. className="test"
  503. >
  504. <TabPane tab="搜索" key="1">
  505. <div className="user-search">
  506. {/*<Input placeholder="客户名称" style={{width:'150px'}}
  507. value={this.state.buyerNameSearch}
  508. onChange={(e) => { this.setState({ buyerNameSearch: e.target.value }); }} />
  509. */}
  510. <RangePicker
  511. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  512. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  513. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  514. <Select placeholder="订单部门"
  515. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  516. value={this.state.departmenttSearch}
  517. onChange={(e) => { this.setState({ departmenttSearch: e }) }}>
  518. {
  519. departmentArr.map(function (item) {
  520. return <Select.Option key={item.id} >{item.name}</Select.Option>
  521. })
  522. }
  523. </Select>
  524. <Button type="primary" onClick={this.search} style={{marginLeft:'10px'}}>搜索</Button>
  525. <Button onClick={this.reset}>重置</Button>
  526. {/*<span style={{marginLeft:'10px',marginRight:'20px'}}>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  527. */}
  528. </div>
  529. </TabPane>
  530. <TabPane tab="更改表格显示数据" key="2">
  531. <div style={{ marginLeft: 10 }}>
  532. <ChooseList
  533. columns={this.state.columns}
  534. changeFn={this.changeList}
  535. changeList={this.state.changeList}
  536. top={55}
  537. margin={11}
  538. />
  539. </div>
  540. </TabPane>
  541. </Tabs>
  542. <div className="patent-table">
  543. <Spin spinning={this.state.loading}>
  544. <Table columns={
  545. this.state.changeList
  546. ? this.state.changeList
  547. : this.state.columns
  548. }
  549. dataSource={this.state.dataSource}
  550. pagination={this.state.pagination} />
  551. </Spin>
  552. </div>
  553. <Modal maskClosable={false} visible={this.state.visible}
  554. onOk={this.visitOk} onCancel={this.visitCancel}
  555. width='1000px'
  556. title={
  557. <span>
  558. <span style={{marginRight:'15px'}}>客户详情</span>
  559. <Tag color="#f50">{this.state.aName}</Tag>
  560. <Tag color="#108ee9">
  561. {
  562. this.state.type === 0?
  563. '私有客户数':
  564. this.state.type === 5?
  565. '签单客户数量':
  566. this.state.type === 1?
  567. '时间内新增客户数':
  568. this.state.type === 2?
  569. '时间内领取客户数': ''
  570. }
  571. </Tag>
  572. </span>
  573. }
  574. footer=''
  575. className="admin-desc-content">
  576. <div className="patent-table">
  577. <Spin spinning={this.state.loading}>
  578. <Table columns={this.state.columnsX}
  579. dataSource={this.state.dataSourceX}
  580. pagination={this.state.paginationX}
  581. />
  582. </Spin>
  583. </div>
  584. </Modal>
  585. </div >
  586. </div>
  587. );
  588. }
  589. }));
  590. export default AdminCustomerStatistics;