adminCustomerStatistics.jsx 13 KB

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