adminCustomerStatistics.jsx 13 KB

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