index.jsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. import React, { Component } from "react";
  2. import TabelContent from "../../../common/tabelContent";
  3. import {
  4. Button,
  5. Modal,
  6. Form,
  7. DatePicker,
  8. Input,
  9. Radio,
  10. message,
  11. Spin,
  12. Select,
  13. Tabs,
  14. Table,
  15. } from "antd";
  16. import $ from "jquery/src/ajax";
  17. import { ShowModal, getPercentage } from "@/tools";
  18. import { salesList } from "@/dataDic.js";
  19. import moment from "moment";
  20. import { provinceSelect, getProvince } from "../../../NewDicProvinceList";
  21. import { ChooseList } from "../../../manageCenter/order/orderNew/chooseList";
  22. import OrderList from "./order"; //客户订单列表
  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. width: 120,
  77. onCellClick: (r) => {
  78. let cellData = {};
  79. cellData["province"] = r.province
  80. this.setState({
  81. visible: true,
  82. datas: cellData,
  83. })
  84. },
  85. render: (text, record) =>
  86. <span >
  87. {getProvince(text)}
  88. </span>
  89. },
  90. {
  91. title: "签单数(个)",
  92. dataIndex: "counts",
  93. key: "counts",
  94. width: 120,
  95. onCellClick: (r) => {
  96. let cellData = {};
  97. cellData["province"] = r.province
  98. this.setState({
  99. visible: true,
  100. datas: cellData,
  101. })
  102. },
  103. },
  104. {
  105. title: "签单金额(万元)",
  106. dataIndex: "totalAmount",
  107. key: "totalAmount",
  108. width: 170,
  109. onCellClick: (r) => {
  110. let cellData = {};
  111. cellData["province"] = r.province
  112. this.setState({
  113. visible: true,
  114. datas: cellData,
  115. })
  116. },
  117. },
  118. {
  119. title: "电话新开发/占比",
  120. dataIndex: "dhxkfl",
  121. key: "dhxkfl",
  122. width: 170,
  123. onCellClick: (r) => {
  124. let cellData = {};
  125. cellData["province"] = r.province
  126. cellData["salesType"] = 0
  127. this.setState({
  128. visible: true,
  129. datas: cellData,
  130. })
  131. },
  132. render: (text, record) =>
  133. <span >
  134. {record.dhxkf + "/" + getPercentage(text)}
  135. </span>
  136. },
  137. {
  138. title: "电话自带资源/占比",
  139. dataIndex: "dhzdzyl",
  140. key: "dhzdzyl",
  141. width: 150,
  142. onCellClick: (r) => {
  143. let cellData = {};
  144. cellData["province"] = r.province
  145. cellData["salesType"] = 1
  146. this.setState({
  147. visible: true,
  148. datas: cellData,
  149. })
  150. },
  151. render: (text, record) =>
  152. <span >
  153. {record.dhzdzy + "/" + getPercentage(text)}
  154. </span>
  155. },
  156. {
  157. title: "网络/占比",
  158. dataIndex: "wll",
  159. key: "wll",
  160. width: 150,
  161. onCellClick: (r) => {
  162. let cellData = {};
  163. cellData["province"] = r.province
  164. cellData["salesType"] = 2
  165. this.setState({
  166. visible: true,
  167. datas: cellData,
  168. })
  169. },
  170. render: (text, record) =>
  171. <span >
  172. {record.wl + "/" + getPercentage(text)}
  173. </span>
  174. },
  175. {
  176. title: "渠道/占比",
  177. dataIndex: "qdl",
  178. key: "qdl",
  179. width: 150,
  180. onCellClick: (r) => {
  181. let cellData = {};
  182. cellData["province"] = r.province
  183. cellData["salesType"] = 3
  184. this.setState({
  185. visible: true,
  186. datas: cellData,
  187. })
  188. },
  189. render: (text, record) =>
  190. <span >
  191. {record.qd + "/" + getPercentage(text)}
  192. </span>
  193. },
  194. {
  195. title: "高新复购/占比",
  196. dataIndex: "gxfgl",
  197. key: "gxfgl",
  198. width: 150,
  199. onCellClick: (r) => {
  200. let cellData = {};
  201. cellData["province"] = r.province
  202. cellData["salesType"] = 6
  203. this.setState({
  204. visible: true,
  205. datas: cellData,
  206. })
  207. },
  208. render: (text, record) =>
  209. <span >
  210. {record.gxfg + "/" + getPercentage(text)}
  211. </span>
  212. },
  213. {
  214. title: "其他复购/占比",
  215. dataIndex: "qtfgl",
  216. key: "qtfgl",
  217. width: 150,
  218. onCellClick: (r) => {
  219. let cellData = {};
  220. cellData["province"] = r.province
  221. cellData["salesType"] = 7
  222. this.setState({
  223. visible: true,
  224. datas: cellData,
  225. })
  226. },
  227. render: (text, record) =>
  228. <span >
  229. {record.qtfg + "/" + getPercentage(text)}
  230. </span>
  231. },
  232. {
  233. title: "转介绍/占比",
  234. dataIndex: "zjsl",
  235. key: "zjsl",
  236. width: 150,
  237. onCellClick: (r) => {
  238. let cellData = {};
  239. cellData["province"] = r.province
  240. cellData["salesType"] = 4
  241. this.setState({
  242. visible: true,
  243. datas: cellData,
  244. })
  245. },
  246. render: (text, record) =>
  247. <span >
  248. {record.zjs + "/" + getPercentage(text)}
  249. </span>
  250. },
  251. {
  252. title: "其他/占比",
  253. dataIndex: "qtl",
  254. key: "qtl",
  255. width: 150,
  256. onCellClick: (r) => {
  257. let cellData = {};
  258. cellData["province"] = r.province
  259. cellData["salesType"] = 5
  260. this.setState({
  261. visible: true,
  262. datas: cellData,
  263. })
  264. },
  265. render: (text, record) =>
  266. <span >
  267. {record.qt + "/" + getPercentage(text)}
  268. </span>
  269. },
  270. ],
  271. };
  272. }
  273. changeList(arr) {
  274. const newArr = [];
  275. this.state.columns.forEach((item) => {
  276. arr.forEach((val) => {
  277. if (val === item.title) {
  278. newArr.push(item);
  279. }
  280. });
  281. });
  282. this.setState({
  283. changeList: newArr,
  284. });
  285. }
  286. // 重置
  287. resetAll() {
  288. this.setState(
  289. {
  290. searchValues: JSON.parse(JSON.stringify({})),
  291. params: JSON.parse(JSON.stringify({})),
  292. selectedRowKeys: [],
  293. },
  294. () => {
  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. componentWillMount() {
  434. this.selectSuperId();
  435. this.loadData();
  436. }
  437. render() {
  438. const { searchValues, onelist, columns, changeList, contactsOption, visible, datas, params } = this.state;
  439. return (
  440. <div className="user-content signatureStatistics">
  441. <div className="content-title">
  442. <span
  443. style={{
  444. fontWeight: 900,
  445. fontSize: 16,
  446. display: "block",
  447. marginBottom: 10,
  448. }}
  449. >销售来源统计表 &nbsp;<spn style={{ color: "rgb(49,49,255)" }}>注:可通过签单数、签单金额查询统计</spn></span>
  450. </div>
  451. <Tabs defaultActiveKey="1">
  452. <TabPane tab="搜索" key="1">
  453. <div style={{ paddingTop: 10 }}>
  454. <Form layout="inline">
  455. <FormItem>
  456. <Select
  457. placeholder={"请选择部门"}
  458. style={{ width: 150 }}
  459. value={searchValues["depId"]
  460. ? searchValues["depId"]
  461. : undefined}
  462. onChange={(e) => {
  463. searchValues["depId"] = e;
  464. this.setState({
  465. searchValues: searchValues,
  466. });
  467. }}
  468. >
  469. {contactsOption.map((cit, index) => (
  470. <Option key={cit.value}>{cit.label}</Option>
  471. ))}
  472. </Select>
  473. </FormItem>
  474. <FormItem>
  475. <Select
  476. placeholder={"请选择省份"}
  477. style={{ width: 150 }}
  478. value={searchValues["province"]
  479. ? searchValues["province"]
  480. : undefined}
  481. onChange={(e) => {
  482. searchValues["province"] = e;
  483. this.setState({
  484. searchValues: searchValues,
  485. });
  486. }}
  487. >
  488. {provinceSelect().map((cit, cin) => (
  489. <Option key={cit.value}>{cit.label}</Option>
  490. ))}
  491. </Select>
  492. </FormItem>
  493. <FormItem>
  494. <Select
  495. placeholder={"请选择"}
  496. style={{ width: 150 }}
  497. value={searchValues["sort"]
  498. ? searchValues["sort"]
  499. : undefined}
  500. onChange={(e) => {
  501. searchValues["sort"] = e
  502. this.setState({
  503. searchValues: searchValues,
  504. });
  505. }}
  506. >
  507. {onelist.map((it, ins) => (
  508. <Option key={it.value}>{it.label}</Option>
  509. ))}
  510. </Select>
  511. </FormItem>
  512. <FormItem>
  513. <RangePicker
  514. value={[
  515. searchValues["startDate"]
  516. ? moment(searchValues["startDate"])
  517. : null,
  518. searchValues["endDate"] ? moment(searchValues["endDate"]) : null,
  519. ]}
  520. onChange={(data, dataString) => {
  521. searchValues["startDate"] = dataString[0],
  522. searchValues["endDate"] = dataString[1],
  523. this.setState({
  524. searchValues: searchValues,
  525. });
  526. }}
  527. />
  528. </FormItem>
  529. <Button
  530. type="primary"
  531. onClick={() => { this.submit() }}
  532. style={{ marginRight: "10px" }}
  533. >
  534. 搜索
  535. </Button>
  536. <Button
  537. onClick={() => { this.resetAll() }}
  538. style={{ marginRight: "10px" }}
  539. >
  540. 重置
  541. </Button>
  542. </Form>
  543. </div>
  544. </TabPane>
  545. <TabPane tab="更改表格显示数据" key="2">
  546. <div style={{ marginLeft: 10 }}>
  547. <ChooseList
  548. columns={columns}
  549. changeFn={this.changeList.bind(this)}
  550. changeList={changeList}
  551. top={55}
  552. margin={11}
  553. />
  554. </div>
  555. </TabPane>
  556. <TabPane tab="导出" key="3">
  557. <div
  558. style={{
  559. marginLeft: 10,
  560. padding: "10px 0",
  561. display: "flex",
  562. }}
  563. >
  564. <Button
  565. type="primary"
  566. onClick={() => { this.exportExec() }}
  567. style={{ marginLeft: "10px" }}
  568. >
  569. 导出excel
  570. </Button>
  571. </div>
  572. </TabPane>
  573. </Tabs>
  574. <div className="patent-table">
  575. <Spin spinning={this.state.loading}>
  576. <Table
  577. bordered
  578. size="middle"
  579. columns={changeList ? changeList : columns}
  580. dataSource={this.state.dataSource}
  581. pagination={this.state.pagination}
  582. />
  583. </Spin>
  584. </div>
  585. {
  586. visible &&
  587. <Modal
  588. visible={visible}
  589. // title="客户订单列表"
  590. title={
  591. <div>
  592. <span style={{ marginRight: 20 }}>客户订单列表</span>
  593. {!!datas["salesType"] && <span style={{ color: "red", marginRight: 20 }}>销售类型:{salesList[datas["salesType"]]}</span>}
  594. <span style={{ color: "red" }}>省份:{getProvince(datas["province"])}</span>
  595. </div>}
  596. width="90%"
  597. footer={null}
  598. onCancel={() => {
  599. this.setState({
  600. visible: false,
  601. datas: {},
  602. });
  603. }}
  604. >
  605. <OrderList
  606. data={Object.assign(datas, params)}
  607. />
  608. </Modal>
  609. }
  610. </div>
  611. );
  612. }
  613. }
  614. export default Source;