adminCustomerStatistics.jsx 13 KB

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