adminCustomerStatistics.jsx 13 KB

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