adminCustomerStatistics.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  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 ManagementDetaile from "../../order/settlementOrder/settlementManage/managementDetaile.2.jsx";
  8. import moment from 'moment';
  9. import '../../order/userMangagement.less';
  10. import { orderState, orderChannel, orderType } from '../../../dataDic.js';
  11. import { getProjectState, getOrderChannel, getOrderType, getOrderState, getPaymentState, getApprovedState } from '../../../tools.js';
  12. const AdminCustomerStatistics = Form.create()(React.createClass({
  13. loadData(pageNo) {
  14. this.state.data = [];
  15. this.setState({
  16. loading: true
  17. });
  18. $.ajax({
  19. method: "get",
  20. dataType: "json",
  21. crossDomain: false,
  22. url: globalConfig.context + '/api/admin/customer/selectAdminCustomerStatistics',
  23. data: {
  24. pageNo: pageNo || 1,
  25. pageSize: this.state.pagination.pageSize,
  26. depId: this.state.departmenttSearch, //部门
  27. startTime: this.state.releaseDate[0],
  28. endTime: this.state.releaseDate[1],
  29. },
  30. success: function(data) {
  31. let theArr = [];
  32. if(!data.data) {
  33. if(data.error && data.error.length) {
  34. message.warning(data.error[0].message);
  35. };
  36. } else {
  37. for(let i = 0; i < data.data.list.length; i++) {
  38. let thisdata = data.data.list[i];
  39. theArr.push({
  40. key: i+1,
  41. aid:thisdata.aid,
  42. aName:thisdata.aName,
  43. depName:thisdata.depName,
  44. userCount:thisdata.userCount,
  45. timeCount:thisdata.timeCount,
  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. }, {
  243. title: '营销员名称',
  244. dataIndex: 'aName',
  245. key: 'aName',
  246. }, {
  247. title: '部门名称',
  248. dataIndex: 'depName',
  249. key: 'depName',
  250. }, {
  251. title: '客户数',
  252. dataIndex: 'userCount',
  253. key: 'userCount',
  254. }, {
  255. title: '时间内客户数',
  256. dataIndex: 'timeCount',
  257. key: 'timeCount'
  258. }],
  259. dataSource: [],
  260. dataSourceX: [],
  261. columnsX: [{
  262. title: '客户名称',
  263. dataIndex: 'name',
  264. key: 'name'
  265. }, {
  266. title: '来源',
  267. dataIndex: 'sourceName',
  268. key: 'sourceName'
  269. }, {
  270. title: '联系人',
  271. dataIndex: 'contacts',
  272. key: 'contacts'
  273. }, {
  274. title: '联系人电话',
  275. dataIndex: 'contactMobile',
  276. key: 'contactMobile'
  277. }, {
  278. title: '创建时间',
  279. dataIndex: 'createTime',
  280. key: 'createTime',
  281. }, {
  282. title: '跟进时间',
  283. dataIndex: 'followTime',
  284. key: 'followTime',
  285. }]
  286. };
  287. },
  288. tableRowClick(record, index) {
  289. this.xiangmu(1,record);
  290. this.setState({
  291. visible: true,
  292. rowKey: record.key
  293. });
  294. },
  295. xiangmu(pageNo,record) {
  296. this.state.data = [];
  297. this.setState({
  298. loading:true
  299. })
  300. console.log(typeof record.timeCount);
  301. console.log(typeof parseInt(record.timeCount));
  302. $.ajax({
  303. method: "get",
  304. dataType: "json",
  305. crossDomain: false,
  306. url: globalConfig.context +"/api/admin/customer/selectAdminCustomerList",
  307. data: {
  308. pageNo:pageNo || 1,
  309. pageSize:this.state.pagination.pageSizeX,
  310. startTime: this.state.releaseDate[0],
  311. endTime: this.state.releaseDate[1],
  312. aid:record.aid,
  313. },
  314. success: function(data) {
  315. let theArr = [];
  316. if(data.error.length || data.data.list == "") {
  317. if(data.error && data.error.length) {
  318. message.warning(data.error[0].message);
  319. };
  320. } else {
  321. console.log(data.data.list.length);
  322. for (let i = 0; i < data.data.list.length; i++) {
  323. let thisdata = data.data.list[i];
  324. theArr.push({
  325. key: i,
  326. id:thisdata.id,
  327. name:thisdata.name,
  328. sourceName:thisdata.sourceName,
  329. contacts:thisdata.contacts,
  330. contactMobile:thisdata.contactMobile,
  331. createTime:thisdata.createTime,
  332. followTime:thisdata.followTime,
  333. });
  334. };
  335. this.state.paginationX.current = pageNo;
  336. console.log();
  337. this.state.paginationX.total = data.data.totalCount;
  338. };
  339. if(!data.data.list.length) {
  340. this.state.paginationX.current = 0
  341. this.state.paginationX.total = 0
  342. }
  343. this.setState({
  344. dataSourceX: theArr,
  345. paginationX: this.state.paginationX,
  346. // selectedRowKeys: [],
  347. // signBillVisible: false
  348. });
  349. }.bind(this),
  350. }).always(function() {
  351. this.setState({
  352. loading: false
  353. });
  354. }.bind(this));
  355. },
  356. visitCancel(e){
  357. this.setState({
  358. visible:false
  359. })
  360. },
  361. visitOk(e){
  362. this.setState({
  363. visible:false
  364. })
  365. },
  366. closeDesc(e, s) {
  367. this.state.userDetaile = false;
  368. this.state.showDesc = e;
  369. if(s) {
  370. this.loadData(this.state.pageNo);
  371. };
  372. },
  373. searchSwitch() {
  374. this.setState({
  375. searchMore: !this.state.searchMore
  376. });
  377. },
  378. search() {
  379. this.loadData();
  380. },
  381. //分配时搜索
  382. searchOrder() {
  383. this.contactList();
  384. },
  385. //分配时重置
  386. resetOrder() {
  387. this.setState({
  388. departmenttList: undefined,
  389. financeNameSearch: ''
  390. })
  391. },
  392. reset() {
  393. this.state.releaseDate[0] = undefined;
  394. this.state.releaseDate[1] = undefined;
  395. this.state.departmenttSearch = undefined;
  396. this.state.approved = undefined;
  397. this.state.isDistributionFinance = undefined;
  398. this.loadData();
  399. },
  400. render() {
  401. const rowSelection = {
  402. selectedRowKeys: this.state.selectedRowKeys,
  403. onChange: (selectedRowKeys, selectedRows) => {
  404. this.setState({
  405. selectedRows: selectedRows.slice(-1),
  406. selectedRowKeys: selectedRowKeys.slice(-1)
  407. });
  408. },
  409. onSelectAll: (selected, selectedRows, changeRows) => {
  410. this.setState({
  411. selectedRowKeys: []
  412. })
  413. },
  414. };
  415. let departmentArr = this.state.departmentArr || [];
  416. const hasSelected = this.state.selectedRowKeys.length > 0;
  417. const {
  418. RangePicker
  419. } = DatePicker;
  420. return(
  421. <div className="user-content" >
  422. <div className="content-title">
  423. <span style={{fontSize:'16px'}}>部门客户统计</span>
  424. <div className="user-search">
  425. {/*<Input placeholder="客户名称" style={{width:'150px'}}
  426. value={this.state.buyerNameSearch}
  427. onChange={(e) => { this.setState({ buyerNameSearch: e.target.value }); }} />
  428. */}
  429. <RangePicker
  430. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  431. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  432. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  433. <Select placeholder="订单部门"
  434. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  435. value={this.state.departmenttSearch}
  436. onChange={(e) => { this.setState({ departmenttSearch: e }) }}>
  437. {
  438. departmentArr.map(function (item) {
  439. return <Select.Option key={item.id} >{item.name}</Select.Option>
  440. })
  441. }
  442. </Select>
  443. <Button type="primary" onClick={this.search} style={{marginLeft:'10px'}}>搜索</Button>
  444. <Button onClick={this.reset}>重置</Button>
  445. {/*<span style={{marginLeft:'10px',marginRight:'20px'}}>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  446. */}
  447. </div>
  448. <div className="patent-table">
  449. <Spin spinning={this.state.loading}>
  450. <Table columns={this.state.columns}
  451. dataSource={this.state.dataSource}
  452. rowSelection={rowSelection}
  453. pagination={this.state.pagination}
  454. onRowClick={this.tableRowClick} />
  455. </Spin>
  456. </div>
  457. <Modal maskClosable={false} visible={this.state.visible}
  458. onOk={this.visitOk} onCancel={this.visitCancel}
  459. width='1000px'
  460. title='客户详情'
  461. footer=''
  462. className="admin-desc-content">
  463. <div className="patent-table">
  464. <Spin spinning={this.state.loading}>
  465. <Table columns={this.state.columnsX}
  466. dataSource={this.state.dataSourceX}
  467. pagination={this.state.paginationX} />
  468. </Spin>
  469. </div>
  470. </Modal>
  471. </div >
  472. </div>
  473. );
  474. }
  475. }));
  476. export default AdminCustomerStatistics;