adminCustomerStatistics.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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 {
  7. Form,
  8. Radio,
  9. Icon,
  10. Button,
  11. Input,
  12. Select,
  13. Spin,
  14. Table,
  15. Switch,
  16. message,
  17. DatePicker,
  18. Modal,
  19. Upload,
  20. Popconfirm,
  21. Tabs, Tag
  22. } from 'antd';
  23. import moment from 'moment';
  24. import '../../order/userMangagement.less';
  25. import { orderState, orderChannel, orderType } from '../../../dataDic.js';
  26. import { getProjectState, getOrderChannel, getOrderType, getOrderState, getPaymentState, getApprovedState } from '../../../tools.js';
  27. import { ChooseList } from "../../order/orderNew/chooseList";
  28. const { TabPane } = Tabs
  29. const AdminCustomerStatistics = Form.create()(React.createClass({
  30. loadData(pageNo) {
  31. this.state.data = [];
  32. this.setState({
  33. loading: true
  34. });
  35. $.ajax({
  36. method: "get",
  37. dataType: "json",
  38. crossDomain: false,
  39. url: globalConfig.context + '/api/admin/customer/selectAdminCustomerStatistics',
  40. data: {
  41. pageNo: pageNo || 1,
  42. pageSize: this.state.pagination.pageSize,
  43. depId: this.state.departmenttSearch, //部门
  44. startTime: this.state.releaseDate[0],
  45. endTime: this.state.releaseDate[1],
  46. },
  47. success: function (data) {
  48. let theArr = [];
  49. if (!data.data) {
  50. if (data.error && data.error.length) {
  51. message.warning(data.error[0].message);
  52. };
  53. } else {
  54. for (let i = 0; i < data.data.list.length; i++) {
  55. let thisdata = data.data.list[i];
  56. theArr.push({
  57. key: pageNo ? (i + 1 + (pageNo - 1) * 10) : i + 1,
  58. aid: thisdata.aid,
  59. aName: thisdata.aName,
  60. depName: thisdata.depName,
  61. userCount: thisdata.userCount,
  62. signCount: thisdata.signCount,
  63. newCount: thisdata.newCount,
  64. receiveCount: thisdata.receiveCount,
  65. transferCount: thisdata.transferCount,
  66. });
  67. };
  68. this.state.pagination.current = data.data.pageNo;
  69. this.state.pagination.total = data.data.totalCount;
  70. };
  71. if (!data.data.list.length) {
  72. this.state.pagination.current = 0
  73. this.state.pagination.total = 0
  74. }
  75. this.setState({
  76. pageNo: pageNo,
  77. dataSource: theArr,
  78. pagination: this.state.pagination,
  79. // selectedRowKeys: [],
  80. // signBillVisible: false
  81. });
  82. }.bind(this),
  83. }).always(function () {
  84. this.setState({
  85. loading: false
  86. });
  87. }.bind(this));
  88. },
  89. //部门
  90. departmentList() {
  91. this.setState({
  92. loading: true
  93. });
  94. $.ajax({
  95. method: "get",
  96. dataType: "json",
  97. crossDomain: false,
  98. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  99. data: {
  100. },
  101. success: function (data) {
  102. let thedata = data.data;
  103. let theArr = [];
  104. if (!thedata) {
  105. if (data.error && data.error.length) {
  106. message.warning(data.error[0].message);
  107. };
  108. thedata = {};
  109. } else {
  110. thedata.map(function (item, index) {
  111. theArr.push({
  112. key: index,
  113. name: item.name,
  114. id: item.id,
  115. })
  116. })
  117. }
  118. this.setState({
  119. departmentArr: theArr,
  120. })
  121. }.bind(this),
  122. }).always(function () {
  123. this.setState({
  124. loading: false
  125. });
  126. }.bind(this));
  127. },
  128. //操作分配
  129. confirmDelet(index) {
  130. this.setState({
  131. orderNot: index.orderNo,
  132. userDetaile: false,
  133. distributionVisible: true
  134. });
  135. },
  136. distributionCancel() {
  137. this.setState({
  138. distributionVisible: false
  139. })
  140. },
  141. distributionOk() {
  142. this.setState({
  143. distributionVisible: false
  144. })
  145. },
  146. //分配对象列表
  147. contactList() {
  148. $.ajax({
  149. method: "get",
  150. dataType: "json",
  151. crossDomain: false,
  152. url: globalConfig.context + '/api/admin/superviser/adminList',
  153. data: {
  154. pageNo: 1,
  155. pageSize: 99,
  156. departmentId: this.state.departmenttList,
  157. name: this.state.financeNameSearch,
  158. },
  159. success: function (data) {
  160. let theArr = [];
  161. if (!data.data) {
  162. if (data.error && data.error.length) {
  163. message.warning(data.error[0].message);
  164. };
  165. } else {
  166. for (let i = 0; i < data.data.list.length; i++) {
  167. let thisdata = data.data.list[i];
  168. theArr.push({
  169. key: i,
  170. id: thisdata.id,
  171. userNo: thisdata.userNo,
  172. name: thisdata.name,
  173. departmentName: thisdata.departmentName,
  174. departmentId: thisdata.departmentId,
  175. position: thisdata.position,
  176. mobile: thisdata.mobile,
  177. });
  178. };
  179. };
  180. this.setState({
  181. distributionList: theArr,
  182. });
  183. }.bind(this),
  184. }).always(function () {
  185. this.setState({
  186. loading: false
  187. });
  188. }.bind(this));
  189. },
  190. //选定对象
  191. confirmSelect(record) {
  192. this.setState({
  193. loading: true
  194. });
  195. $.ajax({
  196. method: "POST",
  197. dataType: "json",
  198. crossDomain: false,
  199. url: globalConfig.context + "/api/admin/order/distributionOrder",
  200. data: {
  201. orderNo: this.state.orderNot,
  202. financeId: record.id
  203. }
  204. }).done(function (data) {
  205. if (!data.error.length) {
  206. message.success('分派成功!');
  207. this.setState({
  208. loading: false,
  209. });
  210. this.distributionOk();
  211. } else {
  212. message.warning(data.error[0].message);
  213. };
  214. this.loadData(this.state.pageNo);
  215. }.bind(this));
  216. },
  217. componentWillMount() {
  218. this.departmentList();
  219. this.loadData();
  220. },
  221. getInitialState() {
  222. return {
  223. rowKey: 0,
  224. datauser: {},
  225. selectedRowKeys: [],
  226. releaseDate: [],
  227. selectedRows: [],
  228. departmentArr: [],
  229. searchMore: true,
  230. loading: false,
  231. distributionVisible: false,
  232. visible: false,
  233. showDesc: false,
  234. pagination: {
  235. defaultCurrent: 1,
  236. defaultPageSize: 10,
  237. showQuickJumper: true,
  238. pageSize: 10,
  239. onChange: function (page) {
  240. this.loadData(page);
  241. }.bind(this),
  242. showTotal: function (total) {
  243. return '共' + total + '条数据';
  244. }
  245. },
  246. paginationX: {
  247. defaultCurrent: 1,
  248. defaultPageSize: 10,
  249. showQuickJumper: true,
  250. pageSize: 10,
  251. onChange: function (page) {
  252. this.xiangmu(page, this.state.rowKey, this.state.type);
  253. }.bind(this),
  254. showTotal: function (total) {
  255. return '共' + total + '条数据';
  256. }
  257. },
  258. columns: [{
  259. title: '编号',
  260. dataIndex: 'key',
  261. key: 'key',
  262. align: 'center',
  263. },
  264. {
  265. title: '营销员名称',
  266. dataIndex: 'aName',
  267. key: 'aName',
  268. align: 'center',
  269. },
  270. {
  271. title: '部门名称',
  272. dataIndex: 'depName',
  273. key: 'depName',
  274. align: 'center',
  275. },
  276. {
  277. title: '私有客户数',
  278. dataIndex: 'userCount',
  279. key: 'userCount',
  280. align: 'center',
  281. render: (text, record, index) => {
  282. return <div style={{ padding: "10px 8px" }} onClick={() => {
  283. this.userCount(record, index)
  284. }} className="single">{text}</div>
  285. }
  286. },
  287. {
  288. title: '签单客户数量',
  289. dataIndex: 'signCount',
  290. key: 'signCount',
  291. render: (text, record, index) => {
  292. return <div style={{ padding: "10px 8px" }} onClick={() => {
  293. this.signedQuantity(record, index)
  294. }} className="single">{text}</div>
  295. }
  296. },
  297. {
  298. title: '时间内新增客户数',
  299. dataIndex: 'newCount',
  300. key: 'newCount',
  301. render: (text, record, index) => {
  302. return <div style={{ padding: "10px 8px" }} onClick={() => {
  303. this.inputCount(record, index)
  304. }} className="single">{text}</div>
  305. }
  306. },
  307. {
  308. title: '时间内领取客户数',
  309. dataIndex: 'receiveCount',
  310. key: 'receiveCount',
  311. render: (text, record, index) => {
  312. return <div style={{ padding: "10px 8px" }} onClick={() => {
  313. this.receiveCount(record, index)
  314. }} className="single">{text}</div>
  315. }
  316. },
  317. {
  318. title: '时间内转交客户数',
  319. dataIndex: 'transferCount',
  320. key: 'transferCount',
  321. render: (text, record, index) => {
  322. return <div style={{ padding: "10px 8px" }} onClick={() => {
  323. this.transferCount(record, index)
  324. }} className="single">{text}</div>
  325. }
  326. }
  327. ],
  328. dataSource: [],
  329. dataSourceX: [],
  330. columnsX: [{
  331. title: '客户名称',
  332. dataIndex: 'name',
  333. key: 'name'
  334. }, {
  335. title: '来源',
  336. dataIndex: 'sourceName',
  337. key: 'sourceName'
  338. }, {
  339. title: '联系人',
  340. dataIndex: 'contacts',
  341. key: 'contacts'
  342. }, {
  343. title: '联系人电话',
  344. dataIndex: 'contactMobile',
  345. key: 'contactMobile'
  346. }, {
  347. title: '创建时间',
  348. dataIndex: 'createTime',
  349. key: 'createTime',
  350. }, {
  351. title: '跟进时间',
  352. dataIndex: 'followTime',
  353. key: 'followTime',
  354. }]
  355. };
  356. },
  357. // 私有客户数
  358. userCount(record, index) {
  359. this.tableRowClick(record, index, 0)
  360. },
  361. // 签单客户数量
  362. signedQuantity(record, index) {
  363. this.tableRowClick(record, index, 2)
  364. },
  365. // 时间内新增客户数
  366. inputCount(record, index) {
  367. this.tableRowClick(record, index, 3)
  368. },
  369. // 时间内领取客户数
  370. receiveCount(record, index) {
  371. this.tableRowClick(record, index, 7)
  372. },
  373. // 时间内转交客户数
  374. transferCount(record, index) {
  375. this.tableRowClick(record, index, 8)
  376. },
  377. tableRowClick(record, index, type) {
  378. this.xiangmu(1, record, type);
  379. this.setState({
  380. visible: true,
  381. rowKey: record,
  382. type: type,
  383. aName: record.aName
  384. });
  385. },
  386. xiangmu(pageNo, record, type) {
  387. this.state.data = [];
  388. this.setState({
  389. loading: true
  390. })
  391. $.ajax({
  392. method: "get",
  393. dataType: "json",
  394. crossDomain: false,
  395. url: globalConfig.context + "/api/admin/customer/selectAdminCustomerList",
  396. data: {
  397. pageNo: pageNo || 1,
  398. pageSize: this.state.paginationX.pageSize,
  399. startTime: this.state.releaseDate[0],
  400. endTime: this.state.releaseDate[1],
  401. aid: record.aid,
  402. type: type,
  403. },
  404. success: function (data) {
  405. let theArr = [];
  406. if (data.error.length || data.data.list == "") {
  407. if (data.error && data.error.length) {
  408. message.warning(data.error[0].message);
  409. };
  410. } else {
  411. for (let i = 0; i < data.data.list.length; i++) {
  412. let thisdata = data.data.list[i];
  413. theArr.push({
  414. key: i,
  415. id: thisdata.id,
  416. name: thisdata.name,
  417. sourceName: thisdata.sourceName,
  418. contacts: thisdata.contacts,
  419. contactMobile: thisdata.contactMobile,
  420. createTime: thisdata.createTime,
  421. followTime: thisdata.followTime,
  422. });
  423. };
  424. this.state.paginationX.current = pageNo;
  425. this.state.paginationX.total = data.data.totalCount;
  426. };
  427. if (!data.data.list.length) {
  428. this.state.paginationX.current = 0
  429. this.state.paginationX.total = 0
  430. }
  431. this.setState({
  432. dataSourceX: theArr,
  433. paginationX: this.state.paginationX,
  434. // selectedRowKeys: [],
  435. // signBillVisible: false
  436. });
  437. }.bind(this),
  438. }).always(function () {
  439. this.setState({
  440. loading: false
  441. });
  442. }.bind(this));
  443. },
  444. visitCancel(e) {
  445. this.setState({
  446. visible: false
  447. })
  448. },
  449. visitOk(e) {
  450. this.setState({
  451. visible: false
  452. })
  453. },
  454. closeDesc(e, s) {
  455. this.state.userDetaile = false;
  456. this.state.showDesc = e;
  457. if (s) {
  458. this.loadData(this.state.pageNo);
  459. };
  460. },
  461. searchSwitch() {
  462. this.setState({
  463. searchMore: !this.state.searchMore
  464. });
  465. },
  466. search() {
  467. this.loadData();
  468. },
  469. //分配时搜索
  470. searchOrder() {
  471. this.contactList();
  472. },
  473. //分配时重置
  474. resetOrder() {
  475. this.setState({
  476. departmenttList: undefined,
  477. financeNameSearch: ''
  478. })
  479. },
  480. reset() {
  481. this.state.releaseDate[0] = undefined;
  482. this.state.releaseDate[1] = undefined;
  483. this.state.departmenttSearch = undefined;
  484. this.state.approved = undefined;
  485. this.state.isDistributionFinance = undefined;
  486. this.loadData();
  487. },
  488. changeList(arr) {
  489. const newArr = [];
  490. this.state.columns.forEach(item => {
  491. arr.forEach(val => {
  492. if (val === item.title) {
  493. newArr.push(item);
  494. }
  495. });
  496. });
  497. this.setState({
  498. changeList: newArr
  499. });
  500. },
  501. render() {
  502. const rowSelection = {
  503. selectedRowKeys: this.state.selectedRowKeys,
  504. onChange: (selectedRowKeys, selectedRows) => {
  505. this.setState({
  506. selectedRows: selectedRows.slice(-1),
  507. selectedRowKeys: selectedRowKeys.slice(-1)
  508. });
  509. },
  510. onSelectAll: (selected, selectedRows, changeRows) => {
  511. this.setState({
  512. selectedRowKeys: []
  513. })
  514. },
  515. };
  516. let departmentArr = this.state.departmentArr || [];
  517. const hasSelected = this.state.selectedRowKeys.length > 0;
  518. const {
  519. RangePicker
  520. } = DatePicker;
  521. return (
  522. <div className="user-content" >
  523. <div className="content-title">
  524. <span>部门客户统计</span>
  525. <Tabs
  526. defaultActiveKey="1"
  527. onChange={this.callback}
  528. className="test"
  529. >
  530. <TabPane tab="搜索" key="1">
  531. <div className="user-search">
  532. {/*<Input placeholder="客户名称" style={{width:'150px'}}
  533. value={this.state.buyerNameSearch}
  534. onChange={(e) => { this.setState({ buyerNameSearch: e.target.value }); }} />
  535. */}
  536. <RangePicker
  537. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  538. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  539. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  540. <Select placeholder="订单部门"
  541. style={{ width: 150, marginRight: '10px', marginLeft: '10px' }}
  542. value={this.state.departmenttSearch}
  543. onChange={(e) => { this.setState({ departmenttSearch: e }) }}>
  544. {
  545. departmentArr.map(function (item) {
  546. return <Select.Option key={item.id} >{item.name}</Select.Option>
  547. })
  548. }
  549. </Select>
  550. <Button type="primary" onClick={this.search} style={{ marginLeft: '10px' }}>搜索</Button>
  551. <Button onClick={this.reset}>重置</Button>
  552. {/*<span style={{marginLeft:'10px',marginRight:'20px'}}>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  553. */}
  554. </div>
  555. </TabPane>
  556. <TabPane tab="更改表格显示数据" key="2">
  557. <div style={{ marginLeft: 10 }}>
  558. <ChooseList
  559. columns={this.state.columns}
  560. changeFn={this.changeList}
  561. changeList={this.state.changeList}
  562. top={55}
  563. margin={11}
  564. />
  565. </div>
  566. </TabPane>
  567. </Tabs>
  568. <div className="patent-table">
  569. <Spin spinning={this.state.loading}>
  570. <Table
  571. size="middle"
  572. columns={
  573. this.state.changeList
  574. ? this.state.changeList
  575. : this.state.columns
  576. }
  577. dataSource={this.state.dataSource}
  578. pagination={this.state.pagination} />
  579. </Spin>
  580. </div>
  581. <Modal maskClosable={false} visible={this.state.visible}
  582. onOk={this.visitOk} onCancel={this.visitCancel}
  583. width='1200px'
  584. title={
  585. <span>
  586. <span style={{ marginRight: '15px' }}>客户详情</span>
  587. <Tag color="#f50">{this.state.aName}</Tag>
  588. <Tag color="#108ee9">
  589. {
  590. this.state.type === 0 ?
  591. '私有客户数' :
  592. this.state.type === 2 ?
  593. '签单客户数量' :
  594. this.state.type === 3 ?
  595. '时间内新增客户数' :
  596. this.state.type === 7 ?
  597. '时间内领取客户数' :
  598. this.state.type === 8 ?
  599. '时间内转交客户数' : '未知'
  600. }
  601. </Tag>
  602. </span>
  603. }
  604. footer=''
  605. className="admin-desc-content">
  606. <div className="patent-table">
  607. <Spin spinning={this.state.loading}>
  608. <Table columns={this.state.columnsX}
  609. dataSource={this.state.dataSourceX}
  610. pagination={this.state.paginationX}
  611. />
  612. </Spin>
  613. </div>
  614. </Modal>
  615. </div >
  616. </div>
  617. );
  618. }
  619. }));
  620. export default AdminCustomerStatistics;