index.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. import React, { Component } from "react";
  2. import {
  3. Button,
  4. Modal,
  5. Form,
  6. DatePicker,
  7. message,
  8. Spin,
  9. Select,
  10. Tabs,
  11. Table,
  12. } from "antd";
  13. import $ from "jquery/src/ajax";
  14. import { ShowModal, getPercentage } from "@/tools";
  15. import { salesList } from "@/dataDic.js";
  16. import moment from "moment";
  17. import { provinceSelect, getProvince } from "../../../NewDicProvinceList";
  18. import { ChooseList } from "../../../manageCenter/order/orderNew/chooseList";
  19. import OrderList from "./order"; //客户订单列表
  20. import './index.less';
  21. import ShowModalDiv from "@/showModal.jsx";
  22. import Cascaders from "../../../common/cascaders";
  23. const { TabPane } = Tabs;
  24. const FormItem = Form.Item;
  25. const Option = Select.Option;
  26. const { RangePicker } = DatePicker;
  27. class Source extends Component {
  28. constructor(props) {
  29. super(props);
  30. this.state = {
  31. cellData: {},
  32. searchValues: {},
  33. params: {},
  34. onelist: [
  35. {
  36. value: "0",
  37. label: "按签单金额",
  38. },
  39. {
  40. value: "1",
  41. label: "按签单数",
  42. },
  43. ],
  44. pagination: {
  45. defaultCurrent: 1,
  46. defaultPageSize: 10,
  47. showQuickJumper: true,
  48. pageSize: 10,
  49. onChange: function (page) {
  50. this.loadData(page);
  51. }.bind(this),
  52. showTotal: function (total) {
  53. return "共" + total + "条数据";
  54. },
  55. },
  56. contactsOption: [],
  57. loading: false,
  58. changeList: undefined,
  59. dataSource: [],
  60. visible: false,
  61. columns: [
  62. {
  63. title: "序号",
  64. dataIndex: "key",
  65. key: "key",
  66. width: 45,
  67. render: (text, record, index) =>
  68. <span >
  69. {index + 1}
  70. </span>
  71. },
  72. {
  73. title: "省份",
  74. dataIndex: "province",
  75. key: "province",
  76. onCellClick: (r) => {
  77. let cellData = {};
  78. cellData["province"] = r.province
  79. this.setState({
  80. visible: true,
  81. datas: cellData,
  82. })
  83. },
  84. render: (text, record) =>
  85. <span >
  86. {getProvince(text)}
  87. </span>
  88. },
  89. {
  90. title: "签单数(个)",
  91. dataIndex: "counts",
  92. key: "counts",
  93. width: '9%',
  94. onCellClick: (r) => {
  95. let cellData = {};
  96. cellData["province"] = r.province
  97. this.setState({
  98. visible: true,
  99. datas: cellData,
  100. })
  101. },
  102. },
  103. {
  104. title: "签单金额(万元)",
  105. dataIndex: "totalAmount",
  106. key: "totalAmount",
  107. width: '9%',
  108. onCellClick: (r) => {
  109. let cellData = {};
  110. cellData["province"] = r.province
  111. this.setState({
  112. visible: true,
  113. datas: cellData,
  114. })
  115. },
  116. },
  117. {
  118. title: "电话新开发/占比",
  119. dataIndex: "dhxkfl",
  120. key: "dhxkfl",
  121. width: '9%',
  122. onCellClick: (r) => {
  123. let cellData = {};
  124. cellData["province"] = r.province
  125. cellData["salesType"] = 0
  126. this.setState({
  127. visible: true,
  128. datas: cellData,
  129. })
  130. },
  131. render: (text, record) =>
  132. <span >
  133. {record.dhxkf + "/" + getPercentage(text)}
  134. </span>
  135. },
  136. {
  137. title: "电话自带资源/占比",
  138. dataIndex: "dhzdzyl",
  139. key: "dhzdzyl",
  140. width: '9%',
  141. onCellClick: (r) => {
  142. let cellData = {};
  143. cellData["province"] = r.province
  144. cellData["salesType"] = 1
  145. this.setState({
  146. visible: true,
  147. datas: cellData,
  148. })
  149. },
  150. render: (text, record) =>
  151. <span >
  152. {record.dhzdzy + "/" + getPercentage(text)}
  153. </span>
  154. },
  155. {
  156. title: "网络/占比",
  157. dataIndex: "wll",
  158. key: "wll",
  159. width: '9%',
  160. onCellClick: (r) => {
  161. let cellData = {};
  162. cellData["province"] = r.province
  163. cellData["salesType"] = 2
  164. this.setState({
  165. visible: true,
  166. datas: cellData,
  167. })
  168. },
  169. render: (text, record) =>
  170. <span >
  171. {record.wl + "/" + getPercentage(text)}
  172. </span>
  173. },
  174. {
  175. title: "渠道/占比",
  176. dataIndex: "qdl",
  177. key: "qdl",
  178. width: '9%',
  179. onCellClick: (r) => {
  180. let cellData = {};
  181. cellData["province"] = r.province
  182. cellData["salesType"] = 3
  183. this.setState({
  184. visible: true,
  185. datas: cellData,
  186. })
  187. },
  188. render: (text, record) =>
  189. <span >
  190. {record.qd + "/" + getPercentage(text)}
  191. </span>
  192. },
  193. {
  194. title: "高新复购/占比",
  195. dataIndex: "gxfgl",
  196. key: "gxfgl",
  197. width: '9%',
  198. onCellClick: (r) => {
  199. let cellData = {};
  200. cellData["province"] = r.province
  201. cellData["salesType"] = 6
  202. this.setState({
  203. visible: true,
  204. datas: cellData,
  205. })
  206. },
  207. render: (text, record) =>
  208. <span >
  209. {record.gxfg + "/" + getPercentage(text)}
  210. </span>
  211. },
  212. {
  213. title: "其他复购/占比",
  214. dataIndex: "qtfgl",
  215. key: "qtfgl",
  216. width: '9%',
  217. onCellClick: (r) => {
  218. let cellData = {};
  219. cellData["province"] = r.province
  220. cellData["salesType"] = 7
  221. this.setState({
  222. visible: true,
  223. datas: cellData,
  224. })
  225. },
  226. render: (text, record) =>
  227. <span >
  228. {record.qtfg + "/" + getPercentage(text)}
  229. </span>
  230. },
  231. {
  232. title: "转介绍/占比",
  233. dataIndex: "zjsl",
  234. key: "zjsl",
  235. width: '9%',
  236. onCellClick: (r) => {
  237. let cellData = {};
  238. cellData["province"] = r.province
  239. cellData["salesType"] = 4
  240. this.setState({
  241. visible: true,
  242. datas: cellData,
  243. })
  244. },
  245. render: (text, record) =>
  246. <span >
  247. {record.zjs + "/" + getPercentage(text)}
  248. </span>
  249. },
  250. {
  251. title: "其他/占比",
  252. dataIndex: "qtl",
  253. key: "qtl",
  254. width: '9%',
  255. onCellClick: (r) => {
  256. let cellData = {};
  257. cellData["province"] = r.province
  258. cellData["salesType"] = 5
  259. this.setState({
  260. visible: true,
  261. datas: cellData,
  262. })
  263. },
  264. render: (text, record) =>
  265. <span >
  266. {record.qt + "/" + getPercentage(text)}
  267. </span>
  268. },
  269. ],
  270. };
  271. }
  272. changeList(arr) {
  273. const newArr = [];
  274. this.state.columns.forEach((item) => {
  275. arr.forEach((val) => {
  276. if (val === item.title) {
  277. newArr.push(item);
  278. }
  279. });
  280. });
  281. this.setState({
  282. changeList: newArr,
  283. });
  284. }
  285. // 重置
  286. resetAll() {
  287. this.setState(
  288. {
  289. searchValues: JSON.parse(JSON.stringify({})),
  290. params: JSON.parse(JSON.stringify({})),
  291. selectedRowKeys: [],
  292. },
  293. () => {
  294. this.Cascaders.empty();
  295. this.loadData();
  296. }
  297. );
  298. }
  299. // 搜索
  300. submit() {
  301. this.setState({
  302. params: this.state.searchValues
  303. })
  304. this.loadData()
  305. }
  306. // 列表接口
  307. loadData(pageNo) {
  308. const { searchValues, pagination } = this.state;
  309. this.setState({
  310. loading: true,
  311. });
  312. let datas = Object.assign(searchValues, {
  313. pageNo: pageNo || 1,
  314. pageSize: pagination.pageSize,
  315. });
  316. $.ajax({
  317. method: "get",
  318. dataType: "json",
  319. crossDomain: false,
  320. url: globalConfig.context + "/api/admin/statistis/orderSalesSource",
  321. data: datas,
  322. success: function (data) {
  323. ShowModal(this);
  324. this.setState({
  325. loading: false,
  326. });
  327. if (data.error && data.error.length === 0) {
  328. if (data.data.list) {
  329. pagination.current = data.data.pageNo;
  330. pagination.total = data.data.totalCount;
  331. if (data.data && data.data.list && !data.data.list.length) {
  332. pagination.current = 0;
  333. pagination.total = 0;
  334. }
  335. this.setState({
  336. dataSource: data.data.list,
  337. pagination: this.state.pagination,
  338. pageNo: data.data.pageNo,
  339. });
  340. } else {
  341. this.setState({
  342. dataSource: data.data,
  343. pagination: false,
  344. });
  345. }
  346. } else {
  347. message.warning(data.error[0].message);
  348. }
  349. }.bind(this),
  350. }).always(
  351. function () {
  352. this.setState({
  353. loading: false,
  354. });
  355. }.bind(this)
  356. );
  357. }
  358. // 获取上级组织
  359. selectSuperId() {
  360. this.setState({
  361. departmentLoading: true,
  362. });
  363. $.ajax({
  364. method: "get",
  365. dataType: "json",
  366. crossDomain: false,
  367. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  368. data: {},
  369. success: function (data) {
  370. let theArr = [];
  371. if (data.error && data.error.length === 0) {
  372. for (let i = 0; i < data.data.length; i++) {
  373. let theData = data.data[i];
  374. theArr.push({
  375. value: theData.id,
  376. label: theData.name,
  377. });
  378. }
  379. this.setState({
  380. contactsOption: theArr,
  381. });
  382. } else {
  383. message.warning(data.error[0].message);
  384. }
  385. }.bind(this),
  386. }).always(
  387. function () {
  388. this.setState({
  389. departmentLoading: false,
  390. });
  391. }.bind(this)
  392. );
  393. }
  394. // 导出excel
  395. exportExec() {
  396. message.config({
  397. duration: 20,
  398. });
  399. let loading = message.loading("下载中...");
  400. this.setState({
  401. exportPendingLoading: true,
  402. });
  403. let data = {};
  404. let obj1 = JSON.parse(JSON.stringify(this.state.searchValues));
  405. data = Object.assign(data, obj1);
  406. $.ajax({
  407. method: "get",
  408. dataType: "json",
  409. crossDomain: false,
  410. url: "/api/admin/statistis/orderSalesSource/export",
  411. data,
  412. success: function (data) {
  413. if (data.error.length === 0) {
  414. this.download(data.data);
  415. } else {
  416. message.warning(data.error[0].message);
  417. }
  418. }.bind(this),
  419. }).always(
  420. function () {
  421. loading();
  422. this.setState({
  423. exportPendingLoading: false,
  424. });
  425. }.bind(this)
  426. );
  427. }
  428. // 下载
  429. download(fileName) {
  430. window.location.href =
  431. globalConfig.context + "/open/download?fileName=" + fileName;
  432. }
  433. getBarChartOption(data) {
  434. const wz = data.counts - data.qt - data.zjs - data.qtfg - data.gxfg - data.qd - data.wl - data.dhzdzy - data.dhxkf;
  435. return {
  436. title: {
  437. text: '湖南',
  438. subtext: '签单金额(万元): ' + data.totalAmount,
  439. left: 'center',
  440. padding: 20,
  441. },
  442. tooltip: {
  443. trigger: 'item',
  444. formatter: '{a} <br/>{b}/占比 : {c} ({d}%)',
  445. },
  446. legend: {
  447. orient: 'vertical',
  448. left: 'left',
  449. },
  450. series: [
  451. {
  452. name: '签单数: ' + data.counts,
  453. type: 'pie',
  454. radius: '60%',
  455. avoidLabelOverlap: true,
  456. data: [
  457. { value: data.dhxkf, name: '电话新开发' },
  458. { value: data.dhzdzy, name: '电话自带资源' },
  459. { value: data.wl, name: '网络' },
  460. { value: data.qd, name: '渠道' },
  461. { value: data.gxfg, name: '高新复购' },
  462. { value: data.qtfg, name: '其他复购' },
  463. { value: data.zjs, name: '转介绍' },
  464. { value: data.qt, name: '其他' },
  465. { value: wz, name: '未知' },
  466. ],
  467. emphasis: {
  468. itemStyle: {
  469. shadowBlur: 10,
  470. shadowOffsetX: 0,
  471. shadowColor: 'rgba(0, 0, 0, 0.5)',
  472. }
  473. }
  474. }
  475. ]
  476. }
  477. }
  478. componentWillMount() {
  479. // this.selectSuperId();
  480. this.loadData();
  481. }
  482. render() {
  483. const { searchValues, onelist, columns, changeList, contactsOption, visible, datas, params } = this.state;
  484. return (
  485. <div className="user-content">
  486. <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
  487. <div className="content-title" style={{ marginBottom: 10 }}>
  488. <span style={{ fontWeight: 900, fontSize: 16, }}>销售来源统计表
  489. &nbsp;<spn style={{ color: "rgb(49,49,255)", fontSize: 15, }}>注:可通过签单数、签单金额查询统计</spn>
  490. </span>
  491. </div>
  492. <Tabs defaultActiveKey="1" onChange={() => { }}>
  493. <TabPane tab="搜索" key="1">
  494. <div style={{ paddingTop: 10 }}>
  495. <Form layout="inline">
  496. <FormItem>
  497. <Cascaders
  498. ref={node => this.Cascaders = node}
  499. placeholder="请选择部门"
  500. id="id"
  501. name="name"
  502. children="list"
  503. height={28}
  504. onSel={(e) => {
  505. searchValues["deps"] = JSON.stringify(e);
  506. this.setState({
  507. searchValues: searchValues,
  508. });
  509. }}
  510. />
  511. {/* <Select
  512. placeholder={"请选择部门"}
  513. style={{ width: 200 }}
  514. value={searchValues["depId"]
  515. ? searchValues["depId"]
  516. : undefined}
  517. onChange={(e) => {
  518. searchValues["depId"] = e;
  519. this.setState({
  520. searchValues: searchValues,
  521. });
  522. }}
  523. >
  524. {contactsOption.map((cit, index) => (
  525. <Option key={cit.value}>{cit.label}</Option>
  526. ))}
  527. </Select> */}
  528. </FormItem>
  529. <FormItem>
  530. <Select
  531. placeholder={"请选择省份"}
  532. style={{ width: 150 }}
  533. value={searchValues["province"]
  534. ? searchValues["province"]
  535. : undefined}
  536. onChange={(e) => {
  537. searchValues["province"] = e;
  538. this.setState({
  539. searchValues: searchValues,
  540. });
  541. }}
  542. >
  543. {provinceSelect().map((cit, cin) => (
  544. <Option key={cit.value}>{cit.label}</Option>
  545. ))}
  546. </Select>
  547. </FormItem>
  548. <FormItem>
  549. <Select
  550. placeholder={"请选择"}
  551. style={{ width: 150 }}
  552. value={searchValues["sort"]
  553. ? searchValues["sort"]
  554. : undefined}
  555. onChange={(e) => {
  556. searchValues["sort"] = e
  557. this.setState({
  558. searchValues: searchValues,
  559. });
  560. }}
  561. >
  562. {onelist.map((it, ins) => (
  563. <Option key={it.value}>{it.label}</Option>
  564. ))}
  565. </Select>
  566. </FormItem>
  567. <FormItem>
  568. <RangePicker
  569. value={[
  570. searchValues["startDate"]
  571. ? moment(searchValues["startDate"])
  572. : null,
  573. searchValues["endDate"] ? moment(searchValues["endDate"]) : null,
  574. ]}
  575. onChange={(data, dataString) => {
  576. searchValues["startDate"] = dataString[0],
  577. searchValues["endDate"] = dataString[1],
  578. this.setState({
  579. searchValues: searchValues,
  580. });
  581. }}
  582. />
  583. </FormItem>
  584. <Button
  585. type="primary"
  586. onClick={() => { this.submit() }}
  587. style={{ marginRight: "10px" }}
  588. >
  589. 搜索
  590. </Button>
  591. <Button
  592. onClick={() => { this.resetAll() }}
  593. style={{ marginRight: "10px" }}
  594. >
  595. 重置
  596. </Button>
  597. </Form>
  598. </div>
  599. </TabPane>
  600. <TabPane tab="更改表格显示数据" key="2">
  601. <div style={{ marginLeft: 10 }}>
  602. <ChooseList
  603. columns={columns}
  604. changeFn={this.changeList.bind(this)}
  605. changeList={changeList}
  606. top={55}
  607. margin={11}
  608. />
  609. </div>
  610. </TabPane>
  611. <TabPane tab="导出" key="3">
  612. <div
  613. style={{
  614. marginLeft: 10,
  615. padding: "10px 0",
  616. display: "flex",
  617. }}
  618. >
  619. <Button
  620. type="primary"
  621. onClick={() => { this.exportExec() }}
  622. style={{ marginLeft: "10px" }}
  623. >
  624. 导出excel
  625. </Button>
  626. </div>
  627. </TabPane>
  628. </Tabs>
  629. <div className="patent-table">
  630. <Spin spinning={this.state.loading}>
  631. <Table
  632. bordered
  633. size="middle"
  634. columns={changeList ? changeList : columns}
  635. dataSource={this.state.dataSource}
  636. pagination={this.state.pagination}
  637. />
  638. </Spin>
  639. {
  640. // this.state.dataSource.length > 0 &&
  641. false &&
  642. <ReactEcharts
  643. style={{ height: "500px" }}
  644. option={this.getBarChartOption(this.state.dataSource[0])}
  645. echarts={echarts}
  646. />
  647. }
  648. </div>
  649. {
  650. visible &&
  651. <Modal
  652. visible={visible}
  653. title={
  654. <div>
  655. <span style={{ marginRight: 20 }}>客户订单列表</span>
  656. {!!salesList[datas["salesType"]] && <span style={{ color: "red", marginRight: 20 }}>销售类型:{salesList[datas["salesType"]]}</span>}
  657. <span style={{ color: "red" }}>省份:{getProvince(datas["province"])}</span>
  658. </div>}
  659. width="90%"
  660. footer={null}
  661. onCancel={() => {
  662. this.setState({
  663. visible: false,
  664. datas: {},
  665. });
  666. }}
  667. >
  668. <OrderList
  669. data={Object.assign(datas, params)}
  670. />
  671. </Modal>
  672. }
  673. </div>
  674. );
  675. }
  676. }
  677. export default Source;