| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686 | 
							- import React, { Component } from "react";
 
- import {
 
-   Button,
 
-   Modal,
 
-   Form,
 
-   DatePicker,
 
-   message,
 
-   Spin,
 
-   Select,
 
-   Tabs,
 
-   Table,
 
- } from "antd";
 
- import $ from "jquery/src/ajax";
 
- import { ShowModal, getPercentage } from "@/tools";
 
- import { salesList } from "@/dataDic.js";
 
- import moment from "moment";
 
- import { provinceSelect, getProvince } from "../../../NewDicProvinceList";
 
- import { ChooseList } from "../../../manageCenter/order/orderNew/chooseList";
 
- import OrderList from "./order"; //客户订单列表
 
- import './index.less';
 
- import ShowModalDiv from "@/showModal.jsx";
 
- import Cascaders from "../../../common/cascaders";
 
- const { TabPane } = Tabs;
 
- const FormItem = Form.Item;
 
- const Option = Select.Option;
 
- const { RangePicker } = DatePicker;
 
- class Source extends Component {
 
-   constructor(props) {
 
-     super(props);
 
-     this.state = {
 
-       cellData: {},
 
-       searchValues: {},
 
-       params: {},
 
-       onelist: [
 
-         {
 
-           value: "0",
 
-           label: "按签单金额",
 
-         },
 
-         {
 
-           value: "1",
 
-           label: "按签单数",
 
-         },
 
-       ],
 
-       pagination: {
 
-         defaultCurrent: 1,
 
-         defaultPageSize: 10,
 
-         showQuickJumper: true,
 
-         pageSize: 10,
 
-         onChange: function (page) {
 
-           this.loadData(page);
 
-         }.bind(this),
 
-         showTotal: function (total) {
 
-           return "共" + total + "条数据";
 
-         },
 
-       },
 
-       contactsOption: [],
 
-       loading: false,
 
-       changeList: undefined,
 
-       dataSource: [],
 
-       visible: false,
 
-       columns: [
 
-         {
 
-           title: "序号",
 
-           dataIndex: "key",
 
-           key: "key",
 
-           width: 45,
 
-           render: (text, record, index) =>
 
-             <span >
 
-               {index + 1}
 
-             </span>
 
-         },
 
-         {
 
-           title: "省份",
 
-           dataIndex: "province",
 
-           key: "province",
 
-           onCellClick: (r) => {
 
-             let cellData = {};
 
-             cellData["province"] = r.province
 
-             this.setState({
 
-               visible: true,
 
-               datas: cellData,
 
-             })
 
-           },
 
-           render: (text, record) =>
 
-             <span >
 
-               {getProvince(text)}
 
-             </span>
 
-         },
 
-         {
 
-           title: "签单数(个)",
 
-           dataIndex: "counts",
 
-           key: "counts",
 
-           width: '9%',
 
-           onCellClick: (r) => {
 
-             let cellData = {};
 
-             cellData["province"] = r.province
 
-             this.setState({
 
-               visible: true,
 
-               datas: cellData,
 
-             })
 
-           },
 
-         },
 
-         {
 
-           title: "签单金额(万元)",
 
-           dataIndex: "totalAmount",
 
-           key: "totalAmount",
 
-           width: '9%',
 
-           onCellClick: (r) => {
 
-             let cellData = {};
 
-             cellData["province"] = r.province
 
-             this.setState({
 
-               visible: true,
 
-               datas: cellData,
 
-             })
 
-           },
 
-         },
 
-         {
 
-           title: "电话新开发/占比",
 
-           dataIndex: "dhxkfl",
 
-           key: "dhxkfl",
 
-           width: '9%',
 
-           onCellClick: (r) => {
 
-             let cellData = {};
 
-             cellData["province"] = r.province
 
-             cellData["salesType"] = 0
 
-             this.setState({
 
-               visible: true,
 
-               datas: cellData,
 
-             })
 
-           },
 
-           render: (text, record) =>
 
-             <span >
 
-               {record.dhxkf + "/" + getPercentage(text)}
 
-             </span>
 
-         },
 
-         {
 
-           title: "电话自带资源/占比",
 
-           dataIndex: "dhzdzyl",
 
-           key: "dhzdzyl",
 
-           width: '9%',
 
-           onCellClick: (r) => {
 
-             let cellData = {};
 
-             cellData["province"] = r.province
 
-             cellData["salesType"] = 1
 
-             this.setState({
 
-               visible: true,
 
-               datas: cellData,
 
-             })
 
-           },
 
-           render: (text, record) =>
 
-             <span >
 
-               {record.dhzdzy + "/" + getPercentage(text)}
 
-             </span>
 
-         },
 
-         {
 
-           title: "网络/占比",
 
-           dataIndex: "wll",
 
-           key: "wll",
 
-           width: '9%',
 
-           onCellClick: (r) => {
 
-             let cellData = {};
 
-             cellData["province"] = r.province
 
-             cellData["salesType"] = 2
 
-             this.setState({
 
-               visible: true,
 
-               datas: cellData,
 
-             })
 
-           },
 
-           render: (text, record) =>
 
-             <span >
 
-               {record.wl + "/" + getPercentage(text)}
 
-             </span>
 
-         },
 
-         {
 
-           title: "渠道/占比",
 
-           dataIndex: "qdl",
 
-           key: "qdl",
 
-           width: '9%',
 
-           onCellClick: (r) => {
 
-             let cellData = {};
 
-             cellData["province"] = r.province
 
-             cellData["salesType"] = 3
 
-             this.setState({
 
-               visible: true,
 
-               datas: cellData,
 
-             })
 
-           },
 
-           render: (text, record) =>
 
-             <span >
 
-               {record.qd + "/" + getPercentage(text)}
 
-             </span>
 
-         },
 
-         {
 
-           title: "高新复购/占比",
 
-           dataIndex: "gxfgl",
 
-           key: "gxfgl",
 
-           width: '9%',
 
-           onCellClick: (r) => {
 
-             let cellData = {};
 
-             cellData["province"] = r.province
 
-             cellData["salesType"] = 6
 
-             this.setState({
 
-               visible: true,
 
-               datas: cellData,
 
-             })
 
-           },
 
-           render: (text, record) =>
 
-             <span >
 
-               {record.gxfg + "/" + getPercentage(text)}
 
-             </span>
 
-         },
 
-         {
 
-           title: "其他复购/占比",
 
-           dataIndex: "qtfgl",
 
-           key: "qtfgl",
 
-           width: '9%',
 
-           onCellClick: (r) => {
 
-             let cellData = {};
 
-             cellData["province"] = r.province
 
-             cellData["salesType"] = 7
 
-             this.setState({
 
-               visible: true,
 
-               datas: cellData,
 
-             })
 
-           },
 
-           render: (text, record) =>
 
-             <span >
 
-               {record.qtfg + "/" + getPercentage(text)}
 
-             </span>
 
-         },
 
-         {
 
-           title: "转介绍/占比",
 
-           dataIndex: "zjsl",
 
-           key: "zjsl",
 
-           width: '9%',
 
-           onCellClick: (r) => {
 
-             let cellData = {};
 
-             cellData["province"] = r.province
 
-             cellData["salesType"] = 4
 
-             this.setState({
 
-               visible: true,
 
-               datas: cellData,
 
-             })
 
-           },
 
-           render: (text, record) =>
 
-             <span >
 
-               {record.zjs + "/" + getPercentage(text)}
 
-             </span>
 
-         },
 
-         {
 
-           title: "其他/占比",
 
-           dataIndex: "qtl",
 
-           key: "qtl",
 
-           width: '9%',
 
-           onCellClick: (r) => {
 
-             let cellData = {};
 
-             cellData["province"] = r.province
 
-             cellData["salesType"] = 5
 
-             this.setState({
 
-               visible: true,
 
-               datas: cellData,
 
-             })
 
-           },
 
-           render: (text, record) =>
 
-             <span >
 
-               {record.qt + "/" + getPercentage(text)}
 
-             </span>
 
-         },
 
-       ],
 
-     };
 
-   }
 
-   changeList(arr) {
 
-     const newArr = [];
 
-     this.state.columns.forEach((item) => {
 
-       arr.forEach((val) => {
 
-         if (val === item.title) {
 
-           newArr.push(item);
 
-         }
 
-       });
 
-     });
 
-     this.setState({
 
-       changeList: newArr,
 
-     });
 
-   }
 
-   // 重置
 
-   resetAll() {
 
-     this.setState(
 
-       {
 
-         searchValues: JSON.parse(JSON.stringify({})),
 
-         params: JSON.parse(JSON.stringify({})),
 
-         selectedRowKeys: [],
 
-       },
 
-       () => {
 
-         this.Cascaders.empty();
 
-         this.loadData();
 
-       }
 
-     );
 
-   }
 
-   // 搜索
 
-   submit() {
 
-     this.setState({
 
-       params: this.state.searchValues
 
-     })
 
-     this.loadData()
 
-   }
 
-   // 列表接口
 
-   loadData(pageNo) {
 
-     const { searchValues, pagination } = this.state;
 
-     this.setState({
 
-       loading: true,
 
-     });
 
-     let datas = Object.assign(searchValues, {
 
-       pageNo: pageNo || 1,
 
-       pageSize: pagination.pageSize,
 
-     });
 
-     $.ajax({
 
-       method: "get",
 
-       dataType: "json",
 
-       crossDomain: false,
 
-       url: globalConfig.context + "/api/admin/statistis/orderSalesSource",
 
-       data: datas,
 
-       success: function (data) {
 
-         ShowModal(this);
 
-         this.setState({
 
-           loading: false,
 
-         });
 
-         if (data.error && data.error.length === 0) {
 
-           if (data.data.list) {
 
-             pagination.current = data.data.pageNo;
 
-             pagination.total = data.data.totalCount;
 
-             if (data.data && data.data.list && !data.data.list.length) {
 
-               pagination.current = 0;
 
-               pagination.total = 0;
 
-             }
 
-             this.setState({
 
-               dataSource: data.data.list,
 
-               pagination: this.state.pagination,
 
-               pageNo: data.data.pageNo,
 
-             });
 
-           } else {
 
-             this.setState({
 
-               dataSource: data.data,
 
-               pagination: false,
 
-             });
 
-           }
 
-         } else {
 
-           message.warning(data.error[0].message);
 
-         }
 
-       }.bind(this),
 
-     }).always(
 
-       function () {
 
-         this.setState({
 
-           loading: false,
 
-         });
 
-       }.bind(this)
 
-     );
 
-   }
 
-   // 获取上级组织
 
-   selectSuperId() {
 
-     this.setState({
 
-       departmentLoading: true,
 
-     });
 
-     $.ajax({
 
-       method: "get",
 
-       dataType: "json",
 
-       crossDomain: false,
 
-       url: globalConfig.context + "/api/admin/organization/selectSuperId",
 
-       data: {},
 
-       success: function (data) {
 
-         let theArr = [];
 
-         if (data.error && data.error.length === 0) {
 
-           for (let i = 0; i < data.data.length; i++) {
 
-             let theData = data.data[i];
 
-             theArr.push({
 
-               value: theData.id,
 
-               label: theData.name,
 
-             });
 
-           }
 
-           this.setState({
 
-             contactsOption: theArr,
 
-           });
 
-         } else {
 
-           message.warning(data.error[0].message);
 
-         }
 
-       }.bind(this),
 
-     }).always(
 
-       function () {
 
-         this.setState({
 
-           departmentLoading: false,
 
-         });
 
-       }.bind(this)
 
-     );
 
-   }
 
-   // 导出excel
 
-   exportExec() {
 
-     message.config({
 
-       duration: 20,
 
-     });
 
-     let loading = message.loading("下载中...");
 
-     this.setState({
 
-       exportPendingLoading: true,
 
-     });
 
-     let data = {};
 
-     let obj1 = JSON.parse(JSON.stringify(this.state.searchValues));
 
-     data = Object.assign(data, obj1);
 
-     $.ajax({
 
-       method: "get",
 
-       dataType: "json",
 
-       crossDomain: false,
 
-       url: "/api/admin/statistis/orderSalesSource/export",
 
-       data,
 
-       success: function (data) {
 
-         if (data.error.length === 0) {
 
-           this.download(data.data);
 
-         } else {
 
-           message.warning(data.error[0].message);
 
-         }
 
-       }.bind(this),
 
-     }).always(
 
-       function () {
 
-         loading();
 
-         this.setState({
 
-           exportPendingLoading: false,
 
-         });
 
-       }.bind(this)
 
-     );
 
-   }
 
-   // 下载
 
-   download(fileName) {
 
-     window.location.href =
 
-       globalConfig.context + "/open/download?fileName=" + fileName;
 
-   }
 
-   getBarChartOption(data) {
 
-     const wz = data.counts - data.qt - data.zjs - data.qtfg - data.gxfg - data.qd - data.wl - data.dhzdzy - data.dhxkf;
 
-     return {
 
-       title: {
 
-         text: '湖南',
 
-         subtext: '签单金额(万元): ' + data.totalAmount,
 
-         left: 'center',
 
-         padding: 20,
 
-       },
 
-       tooltip: {
 
-         trigger: 'item',
 
-         formatter: '{a} <br/>{b}/占比 : {c} ({d}%)',
 
-       },
 
-       legend: {
 
-         orient: 'vertical',
 
-         left: 'left',
 
-       },
 
-       series: [
 
-         {
 
-           name: '签单数: ' + data.counts,
 
-           type: 'pie',
 
-           radius: '60%',
 
-           avoidLabelOverlap: true,
 
-           data: [
 
-             { value: data.dhxkf, name: '电话新开发' },
 
-             { value: data.dhzdzy, name: '电话自带资源' },
 
-             { value: data.wl, name: '网络' },
 
-             { value: data.qd, name: '渠道' },
 
-             { value: data.gxfg, name: '高新复购' },
 
-             { value: data.qtfg, name: '其他复购' },
 
-             { value: data.zjs, name: '转介绍' },
 
-             { value: data.qt, name: '其他' },
 
-             { value: wz, name: '未知' },
 
-           ],
 
-           emphasis: {
 
-             itemStyle: {
 
-               shadowBlur: 10,
 
-               shadowOffsetX: 0,
 
-               shadowColor: 'rgba(0, 0, 0, 0.5)',
 
-             }
 
-           }
 
-         }
 
-       ]
 
-     }
 
-   }
 
-   componentWillMount() {
 
-     // this.selectSuperId();
 
-     this.loadData();
 
-   }
 
-   render() {
 
-     const { searchValues, onelist, columns, changeList, contactsOption, visible, datas, params } = this.state;
 
-     return (
 
-       <div className="user-content">
 
-         <ShowModalDiv ShowModal={this.state.showModal} />
 
-         <div className="content-title" style={{ marginBottom: 10 }}>
 
-           <span style={{ fontWeight: 900, fontSize: 16, }}>销售来源统计表
 
-              <spn style={{ color: "rgb(49,49,255)", fontSize: 15, }}>注:可通过签单数、签单金额查询统计</spn>
 
-           </span>
 
-         </div>
 
-         <Tabs defaultActiveKey="1" onChange={() => { }}>
 
-           <TabPane tab="搜索" key="1">
 
-             <div style={{ paddingTop: 10 }}>
 
-               <Form layout="inline">
 
-                 <FormItem>
 
-                   <Cascaders
 
-                     ref={node => this.Cascaders = node}
 
-                     placeholder="请选择部门"
 
-                     id="id"
 
-                     name="name"
 
-                     children="list"
 
-                     height={28}
 
-                     onSel={(e) => {
 
-                       searchValues["deps"] = JSON.stringify(e);
 
-                       this.setState({
 
-                         searchValues: searchValues,
 
-                       });
 
-                     }}
 
-                   />
 
-                   {/* <Select
 
-                     placeholder={"请选择部门"}
 
-                     style={{ width: 200 }}
 
-                     value={searchValues["depId"]
 
-                       ? searchValues["depId"]
 
-                       : undefined}
 
-                     onChange={(e) => {
 
-                       searchValues["depId"] = e;
 
-                       this.setState({
 
-                         searchValues: searchValues,
 
-                       });
 
-                     }}
 
-                   >
 
-                     {contactsOption.map((cit, index) => (
 
-                       <Option key={cit.value}>{cit.label}</Option>
 
-                     ))}
 
-                   </Select> */}
 
-                 </FormItem>
 
-                 <FormItem>
 
-                   <Select
 
-                     placeholder={"请选择省份"}
 
-                     style={{ width: 150 }}
 
-                     value={searchValues["province"]
 
-                       ? searchValues["province"]
 
-                       : undefined}
 
-                     onChange={(e) => {
 
-                       searchValues["province"] = e;
 
-                       this.setState({
 
-                         searchValues: searchValues,
 
-                       });
 
-                     }}
 
-                   >
 
-                     {provinceSelect().map((cit, cin) => (
 
-                       <Option key={cit.value}>{cit.label}</Option>
 
-                     ))}
 
-                   </Select>
 
-                 </FormItem>
 
-                 <FormItem>
 
-                   <Select
 
-                     placeholder={"请选择"}
 
-                     style={{ width: 150 }}
 
-                     value={searchValues["sort"]
 
-                       ? searchValues["sort"]
 
-                       : undefined}
 
-                     onChange={(e) => {
 
-                       searchValues["sort"] = e
 
-                       this.setState({
 
-                         searchValues: searchValues,
 
-                       });
 
-                     }}
 
-                   >
 
-                     {onelist.map((it, ins) => (
 
-                       <Option key={it.value}>{it.label}</Option>
 
-                     ))}
 
-                   </Select>
 
-                 </FormItem>
 
-                 <FormItem>
 
-                   <RangePicker
 
-                     value={[
 
-                       searchValues["startDate"]
 
-                         ? moment(searchValues["startDate"])
 
-                         : null,
 
-                       searchValues["endDate"] ? moment(searchValues["endDate"]) : null,
 
-                     ]}
 
-                     onChange={(data, dataString) => {
 
-                       searchValues["startDate"] = dataString[0],
 
-                         searchValues["endDate"] = dataString[1],
 
-                         this.setState({
 
-                           searchValues: searchValues,
 
-                         });
 
-                     }}
 
-                   />
 
-                 </FormItem>
 
-                 <Button
 
-                   type="primary"
 
-                   onClick={() => { this.submit() }}
 
-                   style={{ marginRight: "10px" }}
 
-                 >
 
-                   搜索
 
-                 </Button>
 
-                 <Button
 
-                   onClick={() => { this.resetAll() }}
 
-                   style={{ marginRight: "10px" }}
 
-                 >
 
-                   重置
 
-                 </Button>
 
-               </Form>
 
-             </div>
 
-           </TabPane>
 
-           <TabPane tab="更改表格显示数据" key="2">
 
-             <div style={{ marginLeft: 10 }}>
 
-               <ChooseList
 
-                 columns={columns}
 
-                 changeFn={this.changeList.bind(this)}
 
-                 changeList={changeList}
 
-                 top={55}
 
-                 margin={11}
 
-               />
 
-             </div>
 
-           </TabPane>
 
-           <TabPane tab="导出" key="3">
 
-             <div
 
-               style={{
 
-                 marginLeft: 10,
 
-                 padding: "10px 0",
 
-                 display: "flex",
 
-               }}
 
-             >
 
-               <Button
 
-                 type="primary"
 
-                 onClick={() => { this.exportExec() }}
 
-                 style={{ marginLeft: "10px" }}
 
-               >
 
-                 导出excel
 
-               </Button>
 
-             </div>
 
-           </TabPane>
 
-         </Tabs>
 
-         <div className="patent-table">
 
-           <Spin spinning={this.state.loading}>
 
-             <Table
 
-               bordered
 
-               size="middle"
 
-               columns={changeList ? changeList : columns}
 
-               dataSource={this.state.dataSource}
 
-               pagination={this.state.pagination}
 
-             />
 
-           </Spin>
 
-           {
 
-             // this.state.dataSource.length > 0 &&
 
-             false &&
 
-             <ReactEcharts
 
-               style={{ height: "500px" }}
 
-               option={this.getBarChartOption(this.state.dataSource[0])}
 
-               echarts={echarts}
 
-             />
 
-           }
 
-         </div>
 
-         {
 
-           visible &&
 
-           <Modal
 
-             visible={visible}
 
-             title={
 
-               <div>
 
-                 <span style={{ marginRight: 20 }}>客户订单列表</span>
 
-                 {!!salesList[datas["salesType"]] && <span style={{ color: "red", marginRight: 20 }}>销售类型:{salesList[datas["salesType"]]}</span>}
 
-                 <span style={{ color: "red" }}>省份:{getProvince(datas["province"])}</span>
 
-               </div>}
 
-             width="90%"
 
-             footer={null}
 
-             onCancel={() => {
 
-               this.setState({
 
-                 visible: false,
 
-                 datas: {},
 
-               });
 
-             }}
 
-           >
 
-             <OrderList
 
-               data={Object.assign(datas, params)}
 
-             />
 
-           </Modal>
 
-         }
 
-       </div>
 
-     );
 
-   }
 
- }
 
- export default Source;
 
 
  |