adminCustomerStatistics.jsx 13 KB

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