adminCustomerStatistics.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  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.dataSource[this.state.rowKey-1]);
  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.key
  325. });
  326. },
  327. xiangmu(pageNo,record,type) {
  328. this.state.data = [];
  329. this.setState({
  330. loading:true
  331. })
  332. $.ajax({
  333. method: "get",
  334. dataType: "json",
  335. crossDomain: false,
  336. url: globalConfig.context +"/api/admin/customer/selectAdminCustomerList",
  337. data: {
  338. pageNo:pageNo || 1,
  339. pageSize:this.state.pagination.pageSizeX,
  340. startTime: this.state.releaseDate[0],
  341. endTime: this.state.releaseDate[1],
  342. aid:record.aid,
  343. type:type,
  344. },
  345. success: function(data) {
  346. let theArr = [];
  347. if(data.error.length || data.data.list == "") {
  348. if(data.error && data.error.length) {
  349. message.warning(data.error[0].message);
  350. };
  351. } else {
  352. for (let i = 0; i < data.data.list.length; i++) {
  353. let thisdata = data.data.list[i];
  354. theArr.push({
  355. key: i,
  356. id:thisdata.id,
  357. name:thisdata.name,
  358. sourceName:thisdata.sourceName,
  359. contacts:thisdata.contacts,
  360. contactMobile:thisdata.contactMobile,
  361. createTime:thisdata.createTime,
  362. followTime:thisdata.followTime,
  363. });
  364. };
  365. this.state.paginationX.current = pageNo;
  366. this.state.paginationX.total = data.data.totalCount;
  367. };
  368. if(!data.data.list.length) {
  369. this.state.paginationX.current = 0
  370. this.state.paginationX.total = 0
  371. }
  372. this.setState({
  373. dataSourceX: theArr,
  374. paginationX: this.state.paginationX,
  375. // selectedRowKeys: [],
  376. // signBillVisible: false
  377. });
  378. }.bind(this),
  379. }).always(function() {
  380. this.setState({
  381. loading: false
  382. });
  383. }.bind(this));
  384. },
  385. visitCancel(e){
  386. this.setState({
  387. visible:false
  388. })
  389. },
  390. visitOk(e){
  391. this.setState({
  392. visible:false
  393. })
  394. },
  395. closeDesc(e, s) {
  396. this.state.userDetaile = false;
  397. this.state.showDesc = e;
  398. if(s) {
  399. this.loadData(this.state.pageNo);
  400. };
  401. },
  402. searchSwitch() {
  403. this.setState({
  404. searchMore: !this.state.searchMore
  405. });
  406. },
  407. search() {
  408. this.loadData();
  409. },
  410. //分配时搜索
  411. searchOrder() {
  412. this.contactList();
  413. },
  414. //分配时重置
  415. resetOrder() {
  416. this.setState({
  417. departmenttList: undefined,
  418. financeNameSearch: ''
  419. })
  420. },
  421. reset() {
  422. this.state.releaseDate[0] = undefined;
  423. this.state.releaseDate[1] = undefined;
  424. this.state.departmenttSearch = undefined;
  425. this.state.approved = undefined;
  426. this.state.isDistributionFinance = undefined;
  427. this.loadData();
  428. },
  429. render() {
  430. const rowSelection = {
  431. selectedRowKeys: this.state.selectedRowKeys,
  432. onChange: (selectedRowKeys, selectedRows) => {
  433. this.setState({
  434. selectedRows: selectedRows.slice(-1),
  435. selectedRowKeys: selectedRowKeys.slice(-1)
  436. });
  437. },
  438. onSelectAll: (selected, selectedRows, changeRows) => {
  439. this.setState({
  440. selectedRowKeys: []
  441. })
  442. },
  443. };
  444. let departmentArr = this.state.departmentArr || [];
  445. const hasSelected = this.state.selectedRowKeys.length > 0;
  446. const {
  447. RangePicker
  448. } = DatePicker;
  449. return(
  450. <div className="user-content" >
  451. <div className="content-title">
  452. <span style={{fontSize:'16px'}}>部门客户统计</span>
  453. <div className="user-search">
  454. {/*<Input placeholder="客户名称" style={{width:'150px'}}
  455. value={this.state.buyerNameSearch}
  456. onChange={(e) => { this.setState({ buyerNameSearch: e.target.value }); }} />
  457. */}
  458. <RangePicker
  459. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  460. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  461. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  462. <Select placeholder="订单部门"
  463. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  464. value={this.state.departmenttSearch}
  465. onChange={(e) => { this.setState({ departmenttSearch: e }) }}>
  466. {
  467. departmentArr.map(function (item) {
  468. return <Select.Option key={item.id} >{item.name}</Select.Option>
  469. })
  470. }
  471. </Select>
  472. <Button type="primary" onClick={this.search} style={{marginLeft:'10px'}}>搜索</Button>
  473. <Button onClick={this.reset}>重置</Button>
  474. {/*<span style={{marginLeft:'10px',marginRight:'20px'}}>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  475. */}
  476. </div>
  477. <div className="patent-table">
  478. <Spin spinning={this.state.loading}>
  479. <Table columns={this.state.columns}
  480. dataSource={this.state.dataSource}
  481. pagination={this.state.pagination} />
  482. </Spin>
  483. </div>
  484. <Modal maskClosable={false} visible={this.state.visible}
  485. onOk={this.visitOk} onCancel={this.visitCancel}
  486. width='1000px'
  487. title='客户详情'
  488. footer=''
  489. className="admin-desc-content">
  490. <div className="patent-table">
  491. <Spin spinning={this.state.loading}>
  492. <Table columns={this.state.columnsX}
  493. dataSource={this.state.dataSourceX}
  494. pagination={this.state.paginationX} />
  495. </Spin>
  496. </div>
  497. </Modal>
  498. </div >
  499. </div>
  500. );
  501. }
  502. }));
  503. export default AdminCustomerStatistics;