adminCustomerStatistics.jsx 14 KB

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