eslint autofix .

feature/2.0-sales-trade
lyt 2 years ago committed by lot
parent 0ec6966e75
commit 1ab0c7d0c7

@ -1,30 +1,40 @@
import "./App.css";
import React, { useContext } from "react";
import { HomeOutlined, TeamOutlined, DashboardOutlined, FileProtectOutlined, CustomerServiceTwoTone, SnippetsTwoTone, DollarOutlined, AreaChartOutlined, WechatOutlined, UserOutlined } from "@ant-design/icons";
import { Layout, Menu, Image, Spin } from "antd";
import { BrowserRouter, Route, Routes, NavLink } from "react-router-dom";
import Home from "./views/Home";
import Dashboard from "./views/Dashboard";
import Orders from "./views/Orders";
import Orders_sub from "./views/Orders_sub";
import ProtectedRoute from "./views/ProtectedRoute";
import Customer_care_inchina from "./charts/Customer_care_inchina";
import Customer_care_potential from "./charts/Customer_care_potential";
import Customer_care_regular from "./charts/Customer_care_regular";
import Wechat_session from "./charts/Wechat_session";
import WhatsApp_session from "./charts/WhatsApp_session";
import AgentGroupCount from "./views/AgentGroupCount";
import AgentGroupList from "./views/AgentGroupList";
import DestinationGroupCount from "./views/DestinationGroupCount";
import DestinationGroupList from "./views/DestinationGroupList";
import Credit_card_bill from "./views/Credit_card_bill";
import exchange_rate from "./charts/ExchangeRate";
import Sale from "./views/Sale";
import Sale_sub from "./views/Sale_sub";
import Logo from "./logo.png";
import { stores_Context } from "./config";
import { observer } from "mobx-react";
import ExchangeRate from "./charts/ExchangeRate";
import './App.css';
import React, { useContext } from 'react';
import {
HomeOutlined,
TeamOutlined,
DashboardOutlined,
FileProtectOutlined,
CustomerServiceTwoTone,
SnippetsTwoTone,
DollarOutlined,
AreaChartOutlined,
WechatOutlined,
UserOutlined,
} from '@ant-design/icons';
import { Layout, Menu, Image, Spin } from 'antd';
import { BrowserRouter, Route, Routes, NavLink } from 'react-router-dom';
import Home from './views/Home';
import Dashboard from './views/Dashboard';
import Orders from './views/Orders';
import Orders_sub from './views/Orders_sub';
import ProtectedRoute from './views/ProtectedRoute';
import Customer_care_inchina from './charts/Customer_care_inchina';
import Customer_care_potential from './charts/Customer_care_potential';
import Customer_care_regular from './charts/Customer_care_regular';
import Wechat_session from './charts/Wechat_session';
import WhatsApp_session from './charts/WhatsApp_session';
import AgentGroupCount from './views/AgentGroupCount';
import AgentGroupList from './views/AgentGroupList';
import DestinationGroupCount from './views/DestinationGroupCount';
import DestinationGroupList from './views/DestinationGroupList';
import Credit_card_bill from './views/Credit_card_bill';
import Sale from './views/Sale';
import Sale_sub from './views/Sale_sub';
import Logo from './logo.png';
import { stores_Context } from './config';
import { observer } from 'mobx-react';
import ExchangeRate from './charts/ExchangeRate';
const App = () => {
const { Content, Footer, Sider } = Layout;
@ -34,75 +44,127 @@ const App = () => {
{ key: 1, label: <NavLink to="/">主页</NavLink>, icon: <HomeOutlined /> },
{
key: 2,
label: "市场",
label: '市场',
icon: <AreaChartOutlined />,
children: [
{ key: 21, label: <NavLink to="/orders">订单数据</NavLink>, icon: <FileProtectOutlined /> },
{ key: 22, label: <NavLink to="/dashboard">仪表盘</NavLink>, icon: <DashboardOutlined /> },
{
key: 21,
label: <NavLink to="/orders">订单数据</NavLink>,
icon: <FileProtectOutlined />,
},
{
key: 22,
label: <NavLink to="/dashboard">仪表盘</NavLink>,
icon: <DashboardOutlined />,
},
],
},
{
key: 5,
label: "销售",
label: '销售',
icon: <SnippetsTwoTone />,
children: [{ key: 51, label: <NavLink to="/sale">业绩数据</NavLink> }],
},
{
key: 3,
label: "客运",
label: '客运',
icon: <WechatOutlined />,
children: [
{ key: 31, label: <NavLink to="/customer_care_potential">潜力客户</NavLink> },
{ key: 32, label: <NavLink to="/customer_care_regular">老客户</NavLink> },
{ key: 33, label: <NavLink to="/customer_care_inchina">在华客户</NavLink> },
{ key: 34, label: <NavLink to="/wechat_session">微信会话存档</NavLink> },
{ key: 35, label: <NavLink to="/whatsapp_session">WhatsApp会话存档</NavLink> },
{
key: 31,
label: <NavLink to="/customer_care_potential">潜力客户</NavLink>,
},
{
key: 32,
label: <NavLink to="/customer_care_regular">老客户</NavLink>,
},
{
key: 33,
label: <NavLink to="/customer_care_inchina">在华客户</NavLink>,
},
{
key: 34,
label: <NavLink to="/wechat_session">微信会话存档</NavLink>,
},
{
key: 35,
label: <NavLink to="/whatsapp_session">WhatsApp会话存档</NavLink>,
},
],
},
{
key: 4,
label: "财务",
label: '财务',
icon: <DollarOutlined />,
children: [
{ key: 41, label: <NavLink to="/credit_card_bill">信用卡账单</NavLink> },
{
key: 41,
label: <NavLink to="/credit_card_bill">信用卡账单</NavLink>,
},
{ key: 42, label: <NavLink to="/exchange_rate">汇率</NavLink> },
],
},
{
key: 6,
label: "客服",
label: '客服',
icon: <WechatOutlined />,
children: [
{ key: 61, label: <NavLink to="/agent/group/count">地接社接团</NavLink> },
{ key: 62, label: <NavLink to="/destination/group/count">目的地接团</NavLink> },
{
key: 61,
label: <NavLink to="/agent/group/count">地接社接团</NavLink>,
},
{
key: 62,
label: <NavLink to="/destination/group/count">目的地接团</NavLink>,
},
],
}
},
];
return (
<BrowserRouter>
<Layout
hasSider
style={{
minHeight: '100vh',
}}
>
<Sider
collapsible={true}
breakpoint="lg"
style={{
minHeight: "100vh",
}}>
<Sider collapsible={true} breakpoint="lg">
overflow: 'auto',
height: '100vh',
position: 'sticky',
left: 0,
top: 0,
bottom: 0,
}}
>
<Image src={Logo} preview={false} />
<Menu theme="dark" defaultSelectedKeys={["1"]} defaultOpenKeys={["2", "5"]} mode="inline" items={menu_items} />
<Menu
theme="dark"
defaultSelectedKeys={['1']}
defaultOpenKeys={['2', '5']}
mode="inline"
items={menu_items}
/>
</Sider>
<Layout className="site-layout">
<Content
style={{
padding: 16,
minHeight: 480,
}}>
}}
>
<Routes>
<Route path="/" element={<Home />} />
<Route element={<ProtectedRoute auth={["admin", "director_bu", "marketing"]} />}>
<Route element={<ProtectedRoute auth={['admin', 'director_bu', 'marketing']} />}>
<Route path="/orders" element={<Orders />} />
<Route path="/orders_sub/:ordertype/:ordertype_sub/:ordertype_title" element={<Orders_sub />} />
<Route path="/dashboard" element={<Dashboard />} />
</Route>
<Route element={<ProtectedRoute auth={["admin", "director_bu", "customer_care"]} />}>
<Route element={<ProtectedRoute auth={['admin', 'director_bu', 'customer_care']} />}>
<Route path="/customer_care_inchina" element={<Customer_care_inchina />} />
<Route path="/customer_care_regular" element={<Customer_care_regular />} />
<Route path="/customer_care_potential" element={<Customer_care_potential />} />
@ -113,11 +175,11 @@ const App = () => {
<Route path="/agent/:agentId/group/list" element={<AgentGroupList />} />
<Route path="/destination/:destinationId/group/list" element={<DestinationGroupList />} />
</Route>
<Route element={<ProtectedRoute auth={["admin", "director_bu", "financial"]} />}>
<Route element={<ProtectedRoute auth={['admin', 'director_bu', 'financial']} />}>
<Route path="/credit_card_bill" element={<Credit_card_bill />} />
<Route path="/exchange_rate" element={<ExchangeRate />} />
</Route>
<Route element={<ProtectedRoute auth={["admin", "director_bu", "sale"]} />}>
<Route element={<ProtectedRoute auth={['admin', 'director_bu', 'sale']} />}>
<Route path="/sale" element={<Sale />} />
<Route path="/sale_sub/:type_sub" element={<Sale_sub />} />
</Route>
@ -125,9 +187,11 @@ const App = () => {
</Content>
<Footer
style={{
textAlign: "center",
}}>
<UserOutlined /> {auth_store.user.name} ({auth_store.user.userid})<br />
textAlign: 'center',
}}
>
<UserOutlined /> {auth_store.user.name} ({auth_store.user.userid})
<br />
Hainatravel Dashboard ©2022 Created by IT
</Footer>
</Layout>

@ -1,18 +1,20 @@
import React, { Component } from 'react';
import { Row, Col, Button, Tabs, Table, Space } from 'antd';
import {
ContainerOutlined, CarryOutOutlined,
SmileOutlined, TagsOutlined, GlobalOutlined,
ContainerOutlined,
CarryOutOutlined,
SmileOutlined,
TagsOutlined,
GlobalOutlined,
SearchOutlined,
} from '@ant-design/icons';
import {stores_Context} from '../config'
import {Line} from "@ant-design/charts";
import SiteSelect from "./SiteSelect";
import { stores_Context } from '../config';
import { Line } from '@ant-design/charts';
import SiteSelect from './SiteSelect';
import { observer } from 'mobx-react';
import DatePickerCharts from './DatePickerCharts'
import DatePickerCharts from './DatePickerCharts';
class Orders extends Component {
static contextType = stores_Context;
constructor(props) {
@ -51,7 +53,7 @@ class Orders extends Component {
},
},
},
}
};
return (
<div>
@ -59,9 +61,16 @@ class Orders extends Component {
<div>
<Space>
<DatePickerCharts hide_vs={true} />
<Button type="primary" icon={<SearchOutlined/>} loading={orders_data.loading} onClick={() => {
<Button
type="primary"
icon={<SearchOutlined />}
loading={orders_data.loading}
onClick={() => {
orders_data.getOrderCount_all();
}}>统计</Button>
}}
>
统计
</Button>
</Space>
</div>
<br />

@ -19,7 +19,7 @@ class AuthStore {
if (Object.keys(requireds).length == 0) {
return true;
}
let has_permission = requireds.filter(item => this.auth.includes(item));
const has_permission = requireds.filter(item => this.auth.includes(item));
if (Object.keys(has_permission).length !== 0) {
return true;
}
@ -28,14 +28,14 @@ class AuthStore {
// 请求权限
get_auth() {
let _this = this;
const _this = this;
const CORPID = "ding48bce8fd3957c96b"; // 企业的id
dd.runtime.permission.requestAuthCode({
corpId: CORPID,
onSuccess: function (res) {
console.log(res);
let code = res.code;
let url = "/dingtalk/dingtalkwork/Getusers_auth?code=" + code;
const code = res.code;
const url = "/dingtalk/dingtalkwork/Getusers_auth?code=" + code;
// 请求获取HT接口获取用户权限和用户信息
fetch(config.HT_HOST + url)
.then(response => response.json())

@ -14,19 +14,19 @@ class ChatSessionStore {
wechat_data = {
counselors: [],// 顾问列表
customers: [],// 客户列表
}
};
// 请求权限
get_auth() {
let _this = this;
const _this = this;
const CORPID = 'ding48bce8fd3957c96b';// 企业的id
dd.runtime.permission.requestAuthCode({
corpId: CORPID,
onSuccess: function (res) {
console.log(res);
let code = res.code;
let url = '/dingtalk/dingtalkwork/Getusers_auth?code=' + code;
const code = res.code;
const url = '/dingtalk/dingtalkwork/Getusers_auth?code=' + code;
// 请求获取HT接口获取用户权限和用户信息
fetch(config.HT_HOST + url)
.then((response) => response.json())
@ -34,14 +34,14 @@ class ChatSessionStore {
runInAction(() => {
_this.user = json.result;
_this.auth = json.result.authlist;
})
});
})
.catch((error) => {
console.log('fetch data failed', error);
});
},
onFail: function (err) {
console.log(err)
console.log(err);
}
});
}

@ -1,4 +1,4 @@
import {makeAutoObservable, runInAction} from "mobx"
import {makeAutoObservable, runInAction} from "mobx";
import moment from "moment";
import { NavLink } from "react-router-dom";
import * as config from "../config";
@ -512,7 +512,7 @@ class CustomerServices {
if (record.EOI_ObjSN === -1) {
return text;
} else {
return <a>{text}</a>
return <a>{text}</a>;
}
}
},

@ -14,7 +14,7 @@ class CustomerStore {
potential_customer_order(get_detail = false) {
this.potential_data.loading = true;
const date_picker_store = this.rootStore.date_picker_store;
let url = '/service-tourdesign/PotentialCusOrder'
let url = '/service-tourdesign/PotentialCusOrder';
url += '?Website=' + this.potential_data.webcode + '&DEI_SNList=' + this.potential_data.groups.toString();
if (this.potential_data.date_type == 'applyDate') {
url += '&ApplydateCheck=1&EntrancedateCheck=0&ConfirmDateCheck=0';
@ -27,9 +27,9 @@ class CustomerStore {
url += '&EntrancedateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&EntrancedateEnd=' + date_picker_store.end_date.format(config.DATE_FORMAT) + '%2023:59:59';
url += '&ConfirmdateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&ConfirmdateEnd=' + date_picker_store.end_date.format(config.DATE_FORMAT) + '%2023:59:59';
if (get_detail) {
url += '&IsDetail=1'
url += '&IsDetail=1';
} else {
url += '&IsDetail=0'
url += '&IsDetail=0';
}
fetch(config.HT_HOST + url)
.then((response) => response.json())
@ -41,7 +41,7 @@ class CustomerStore {
this.potential_data.data = json;
}
this.potential_data.loading = false;
})
});
})
.catch((error) => {
this.potential_data.loading = false;
@ -79,7 +79,7 @@ class CustomerStore {
potential_customer_order: this.potential_customer_order.bind(this),
onChange_show_detail_table: this.onChange_show_detail_table.bind(this),
handleChange_webcode: this.handleChange_webcode.bind(this),
}
};
// 潜力客户 end
@ -87,7 +87,7 @@ class CustomerStore {
regular_customer_order(get_detail = false) {
this.regular_data.loading = true;
const date_picker_store = this.rootStore.date_picker_store;
let url = '/service-tourdesign/RegularCusOrder'
let url = '/service-tourdesign/RegularCusOrder';
url += '?Website=' + this.regular_data.webcode + '&DEI_SNList=' + this.regular_data.groups.toString();
if (this.regular_data.date_type == 'applyDate') {
url += '&ApplydateCheck=1&EntrancedateCheck=0&ConfirmDateCheck=0';
@ -100,9 +100,9 @@ class CustomerStore {
url += '&EntrancedateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&EntrancedateEnd=' + date_picker_store.end_date.format(config.DATE_FORMAT) + '%2023:59:59';
url += '&ConfirmdateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&ConfirmdateEnd=' + date_picker_store.end_date.format(config.DATE_FORMAT) + '%2023:59:59';
if (get_detail) {
url += '&IsDetail=1'
url += '&IsDetail=1';
} else {
url += '&IsDetail=0'
url += '&IsDetail=0';
}
fetch(config.HT_HOST + url)
.then((response) => response.json())
@ -114,7 +114,7 @@ class CustomerStore {
this.regular_data.data = json;
}
this.regular_data.loading = false;
})
});
})
.catch((error) => {
this.regular_data.loading = false;
@ -152,7 +152,7 @@ class CustomerStore {
regular_customer_order: this.regular_customer_order.bind(this),
onChange_show_detail_table: this.onChange_show_detail_table_regular.bind(this),
handleChange_webcode: this.handleChange_webcode_regular.bind(this),
}
};
// 老客户 end
@ -160,7 +160,7 @@ class CustomerStore {
inchina_customer_order(get_detail = false) {
this.inchina_data.loading = true;
const date_picker_store = this.rootStore.date_picker_store;
let url = '/service-tourdesign/RegularCusInChinaOrder'
let url = '/service-tourdesign/RegularCusInChinaOrder';
url += '?Website=' + this.inchina_data.webcode + '&DEI_SNList=' + this.inchina_data.groups.toString();
if (this.inchina_data.date_type == 'applyDate') {
url += '&ApplydateCheck=1&EntrancedateCheck=0&ConfirmDateCheck=0';
@ -170,9 +170,9 @@ class CustomerStore {
url += '&ApplydateCheck=0&EntrancedateCheck=1&ConfirmDateCheck=0';
}
if (get_detail) {
url += '&IsDetail=1'
url += '&IsDetail=1';
} else {
url += '&IsDetail=0'
url += '&IsDetail=0';
}
url += '&ApplydateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&ApplydateEnd=' + date_picker_store.end_date.format(config.DATE_FORMAT) + '%2023:59:59';
url += '&EntrancedateStart=' + date_picker_store.start_date.format(config.DATE_FORMAT) + '&EntrancedateEnd=' + date_picker_store.end_date.format(config.DATE_FORMAT) + '%2023:59:59';
@ -187,7 +187,7 @@ class CustomerStore {
this.inchina_data.data = json;
}
this.inchina_data.loading = false;
})
});
})
.catch((error) => {
this.inchina_data.loading = false;
@ -225,7 +225,7 @@ class CustomerStore {
inchina_customer_order: this.inchina_customer_order.bind(this),
onChange_show_detail_table: this.onChange_show_detail_table_inchina.bind(this),
handleChange_webcode: this.handleChange_webcode_inchina.bind(this),
}
};
// 在华客人 end
}

@ -131,7 +131,7 @@ class DashboardStore {
fetch(config.HT_HOST + url)
.then(response => response.json())
.then(json => {
let table_data = [];
const table_data = [];
json &&
json.map((item, index) => {
table_data.push({

@ -1,4 +1,4 @@
import {makeAutoObservable} from "mobx"
import {makeAutoObservable} from "mobx";
import moment from "moment";
class DatePickerStore {
@ -16,7 +16,7 @@ class DatePickerStore {
onChange_dataPicker = (dates) => {
this.start_date = dates[0];
this.end_date = dates[1];
}
};
onChange_dataPicker_cp = (dates) => {
if (dates) {
@ -26,7 +26,7 @@ class DatePickerStore {
this.start_date_cp = false;
this.end_date_cp = false;
}
}
};
// 计算上一个时间段
previous_date() {

@ -1,7 +1,7 @@
import {makeAutoObservable, runInAction} from "mobx";
import * as dd from 'dingtalk-jsapi';
import * as config from "../config";
import * as comm from '../utils/commons'
import * as comm from '../utils/commons';
// 财务管理
@ -18,7 +18,7 @@ class FinancialStore {
bill_type_mode: false,
bill_types: ['ALL'],
bt_handleChange: this.bt_handleChange.bind(this),
}
};
bt_handleChange(value) {
this.bill_type_data.bill_types = value;
@ -26,13 +26,13 @@ class FinancialStore {
get_bill_types() {
const date_picker_store = this.rootStore.date_picker_store;
let url = '/service-web/QueryData/GetCreditCardBillType';
const url = '/service-web/QueryData/GetCreditCardBillType';
fetch(config.HT_HOST + url)
.then((response) => response.json())
.then((json) => {
runInAction(() => {
this.bill_type_data.data = json.billtype;
})
});
})
.catch((error) => {
console.log('fetch data failed', error);
@ -54,7 +54,7 @@ class FinancialStore {
}
set_table_handleChange = (pagination, filters, sorter) => {
let filters_arr = Object.values(filters);
const filters_arr = Object.values(filters);
if (!comm.empty(filters_arr)) {
this.set_bill_filtered(filters_arr[0]);
}
@ -99,7 +99,7 @@ class FinancialStore {
.then((json) => {
runInAction(() => {
this.credit_card_data.data = json;
})
});
})
.catch((error) => {
console.log('fetch data failed', error);
@ -120,7 +120,7 @@ class FinancialStore {
.then((json) => {
runInAction(() => {
this.credit_card_data.data_by_type = json;
})
});
})
.catch((error) => {
console.log('fetch data failed', error);

@ -1,4 +1,4 @@
import {makeAutoObservable} from "mobx"
import {makeAutoObservable} from "mobx";
import OrdersStore from "./OrdersStore";
import DashboardStore from "./DashboardStore";
import DatePickerStore from "./DatePickerStore";

@ -37,8 +37,8 @@ class OrdersStore {
// 计算两个时间段的有多少天
get diff_count_day() {
const date_picker_store = this.rootStore.date_picker_store;
let _start_date = moment(date_picker_store.start_date.format(config.DATE_FORMAT));
let _end_date = moment(date_picker_store.end_date.format(config.DATE_FORMAT));
const _start_date = moment(date_picker_store.start_date.format(config.DATE_FORMAT));
const _end_date = moment(date_picker_store.end_date.format(config.DATE_FORMAT));
return _end_date.diff(_start_date, "days") + 1;
}
@ -51,6 +51,7 @@ class OrdersStore {
handleChange_webcode = value => {
this.webcode = value;
};
// 是否包含门票
handleChange_include_tickets = value => {
this.include_tickets = value;
@ -67,8 +68,8 @@ class OrdersStore {
// 比如2022-10-01~2022-10-30 vs 2021-10-01~2021-10-30 则需要在2021年的时间段加365天的时间映射成2022起始时间段
// 相差的天数用a.diff(b, 'days')计算
format_data_source(data_source, start_date, end_date) {
let result = [];
for (let item of data_source.ordercount1) {
const result = [];
for (const item of data_source.ordercount1) {
if (result[item.ApplyDate]) {
result[item.ApplyDate].yField += item.orderCount;
} else {
@ -81,12 +82,12 @@ class OrdersStore {
}
if (data_source.ordercount2 && end_date) {
// 不能直接用diff计算因为日期是含有时间的会导致计算差一天先转成格式化的日期再比较
let _start_date = moment(start_date.format(config.DATE_FORMAT));
let _end_date = moment(end_date.format(config.DATE_FORMAT));
let diff_days = _start_date.diff(_end_date, "days");
for (let item of data_source.ordercount2) {
let ApplyDate = moment(item.ApplyDate).add(diff_days, "days").format(config.DATE_FORMAT);
let ApplyDate_key = ApplyDate + "_";//这个作为key
const _start_date = moment(start_date.format(config.DATE_FORMAT));
const _end_date = moment(end_date.format(config.DATE_FORMAT));
const diff_days = _start_date.diff(_end_date, "days");
for (const item of data_source.ordercount2) {
const ApplyDate = moment(item.ApplyDate).add(diff_days, "days").format(config.DATE_FORMAT);
const ApplyDate_key = ApplyDate + "_";// 这个作为key
if (result[ApplyDate_key]) {
result[ApplyDate_key].yField += item.orderCount;
} else {

@ -37,6 +37,7 @@ class SaleStore {
group_handleChange(value) {
this.groups = value;
}
// 选择站点
handleChange_webcode = value => {
this.webcode = value;
@ -56,6 +57,7 @@ class SaleStore {
onChange_Country(value) {
this.filter_country = value;
}
// 选择成员关系
onChange_GuestGroupType(value) {
this.filter_guest_type = value;
@ -105,7 +107,7 @@ class SaleStore {
// 按类型获取业绩
get_department_order_ml_by_type(date_moment) {
let result = { dataSource: [], columns: [] };
const result = { dataSource: [], columns: [] };
const date1_start = date_moment.start_date.format(config.DATE_FORMAT);
const date1_end = date_moment.end_date.format(config.DATE_FORMAT);
const date2_start = comm.empty(date_moment.start_date_cp) ? "" : date_moment.start_date_cp.format(config.DATE_FORMAT);
@ -281,18 +283,18 @@ class SaleStore {
} else {
// if (this.active_tab_key == "Country")
// 获取类型的项目,去掉重复,作为列名
let type_name_arr = [];
const type_name_arr = [];
json.result1.map(item => {
type_name_arr[item.SubTypeSN] = { SubTypeSN: item.SubTypeSN, SubTypeName: item.SubTypeName };
});
let type_data = [];
let type_data_arr = [];
const type_data = [];
const type_data_arr = [];
for (let item of json.result1) {
let op_sn = "OP_" + item.OPI_SN; //顾问的SN
let items = json.result1.filter(d => d.OPI_SN == item.OPI_SN); //筛选出有当前顾问的记录
let total_data_value = items.length ? items.reduce((a, b) => a + b.COLI_YJLY, 0) : ""; //记录累加
for (const item of json.result1) {
const op_sn = "OP_" + item.OPI_SN; // 顾问的SN
const items = json.result1.filter(d => d.OPI_SN == item.OPI_SN); // 筛选出有当前顾问的记录
const total_data_value = items.length ? items.reduce((a, b) => a + b.COLI_YJLY, 0) : ""; // 记录累加
if (comm.empty(type_data[op_sn])) {
type_data[op_sn] = [{ key: item.OPI_SN }, { T_name: item.OPI_Name }, { T_total: total_data_value }];
}
@ -312,9 +314,9 @@ class SaleStore {
{ title: "合计", children: [{ title: type_data_arr.reduce((a, b) => a + b.T_total, 0), dataIndex: "T_total" }], sorter: (a, b) => b.T_total - a.T_total }
);
Object.values(type_name_arr).map((item, index) => {
let data_index = "T_" + item.SubTypeSN;
let items = type_data_arr.filter(d => d[data_index]); //筛选出有对应类型的记录
let total_data_value = items.length ? items.reduce((a, b) => a + b[data_index], 0) : ""; //记录累加
const data_index = "T_" + item.SubTypeSN;
const items = type_data_arr.filter(d => d[data_index]); // 筛选出有对应类型的记录
const total_data_value = items.length ? items.reduce((a, b) => a + b[data_index], 0) : ""; // 记录累加
result.columns.push({
title: item.SubTypeName,
children: [{ title: total_data_value, dataIndex: data_index }],
@ -338,7 +340,7 @@ class SaleStore {
// 子维度查询
get_department_order_ml_by_type_sub(date_moment, type_sub) {
this.spinning = true;
let result = { dataSource: [], columns: [] };
const result = { dataSource: [], columns: [] };
const date1_start = date_moment.start_date.format(config.DATE_FORMAT);
const date1_end = date_moment.end_date.format(config.DATE_FORMAT);
const date2_start = comm.empty(date_moment.start_date_cp) ? "" : date_moment.start_date_cp.format(config.DATE_FORMAT);
@ -389,10 +391,10 @@ class SaleStore {
},
];
// 数据处理,把相同类型放入同一个数组
let type_data = [];
const type_data = [];
!comm.empty(json.result1) &&
Object.values(json.result1).map(item => {
let subtype_sn = "type_" + item.subType;
const subtype_sn = "type_" + item.subType;
if (comm.empty(type_data[subtype_sn])) {
type_data[subtype_sn] = { subType: item.subType, subType_name: item.subTypeVal, data: [item] };
} else {

@ -1,4 +1,4 @@
import {makeAutoObservable, runInAction} from "mobx"
import {makeAutoObservable, runInAction} from "mobx";
import * as config from "../config";
import * as req from '../utils/request';

@ -1,4 +1,4 @@
import {makeAutoObservable, runInAction} from "mobx"
import {makeAutoObservable, runInAction} from "mobx";
import * as config from "../config";
import * as req from '../utils/request';

@ -50,8 +50,8 @@ export function formatPrice(price) {
// 千分符的金额转成数字默认为0
export function price_to_number(price) {
let num_string = (price + "").replace(/,/g, "");
let number = parseFloat(num_string);
const num_string = (price + "").replace(/,/g, "");
const number = parseFloat(num_string);
return isNaN(number) ? 0 : number;
}
@ -128,7 +128,7 @@ export class UrlBuilder {
append(name, value) {
if (isNotEmpty(value)) {
this.paramList.push({ name: name, value: value });
this.paramList.push({ name, value });
}
return this;
}
@ -180,10 +180,10 @@ export function debounce(fn, delay = 500) {
}
export function throttle(fn, delay, atleast) {
let timeout = null,
startTime = new Date();
let timeout = null;
let startTime = new Date();
return function () {
let curTime = new Date();
const curTime = new Date();
clearTimeout(timeout);
if (curTime - startTime >= atleast) {
fn();
@ -228,13 +228,13 @@ export function show_vs_tag(vs, vs_diff, data1, data2) {
// 数组去掉重复
export function unique(arr) {
let x = new Set(arr);
const x = new Set(arr);
return [...x];
}
export function getWeek(date) {
// 参数时间戳
let week = moment(date).day();
const week = moment(date).day();
switch (week) {
case 1:
return "周一";
@ -255,10 +255,10 @@ export function getWeek(date) {
// 把非数字下标的数组设置下标因为非数字数组的length为0导致读取失败
export function set_array_index(result) {
let result_array = [];
let result_keys = Object.keys(result);
const result_array = [];
const result_keys = Object.keys(result);
result_keys.sort(); // 必须做一次排序用for in循环会导致顺序错误
for (let key of result_keys) {
for (const key of result_keys) {
result_array.push(result[key]);
}
return result_array;

@ -1,18 +1,15 @@
import React, { useContext, useEffect } from 'react';
import { Row, Col, Typography, Space, DatePicker, Button, Select, Table, Divider } from 'antd';
import {
SearchOutlined,
} from '@ant-design/icons';
import { stores_Context } from '../config'
import * as config from "../config";
import { SearchOutlined } from '@ant-design/icons';
import { stores_Context } from '../config';
import * as config from '../config';
import { observer } from 'mobx-react';
import 'moment/locale/zh-cn';
import moment from "moment";
import moment from 'moment';
import zhCNlocale from 'antd/es/date-picker/locale/zh_CN';
import { utils, writeFileXLSX } from "xlsx";
import { utils, writeFileXLSX } from 'xlsx';
const AgentGroupCount = () => {
const { customerServicesStore } = useContext(stores_Context);
const agentList = customerServicesStore.agentList;
const agentGroupList = customerServicesStore.agentGroupList;
@ -25,7 +22,7 @@ const AgentGroupCount = () => {
const handleSearchClick = () => {
customerServicesStore.fetchAgentGroupCount();
}
};
const renderAgentItem = (agent) => {
return (
@ -33,7 +30,7 @@ const AgentGroupCount = () => {
{agent.VEI2_CompanyBN}
</Select.Option>
);
}
};
return (
<>
@ -42,7 +39,7 @@ const AgentGroupCount = () => {
<Col span={4}>
<Select
value={customerServicesStore.selectedAgent}
style={{ width: "95%" }}
style={{ width: '95%' }}
showSearch
onSearch={(value) => {
console.log('search:', value);
@ -50,40 +47,85 @@ const AgentGroupCount = () => {
filterOption={(input, option) => {
return option.children.indexOf(input) > -1;
}}
onChange={(value) => customerServicesStore.selectAgent(value)}>
<Select.Option key="0" value="">所有地接社</Select.Option>
onChange={(value) => customerServicesStore.selectAgent(value)}
>
<Select.Option key="0" value="">
所有地接社
</Select.Option>
{agentList.map(renderAgentItem)}
</Select>
</Col>
<Col span={4}>
<Select
style={{ width: "95%" }}
style={{ width: '95%' }}
value={customerServicesStore.selectedTeam}
onChange={(value) => customerServicesStore.selectTeam(value)}
>
<Select.Option key="0" value="">所有小组</Select.Option>
<Select.Option key="31" value="1,2,28,7">GH事业部</Select.Option>
<Select.Option key="32" value="8,9,11,12,20,21">国际事业部</Select.Option>
<Select.Option key="33" value="10,18,16,30">孵化学院</Select.Option>
<Select.Option key="1" value="1">CH直销</Select.Option>
<Select.Option key="2" value="2">CH大客户</Select.Option>
<Select.Option key="28" value="28">AH</Select.Option>
<Select.Option key="7" value="7">市场推广</Select.Option>
<Select.Option key="8" value="8">德语</Select.Option>
<Select.Option key="9" value="9">日语</Select.Option>
<Select.Option key="11" value="11">法语</Select.Option>
<Select.Option key="12" value="12">西语</Select.Option>
<Select.Option key="20" value="20">俄语</Select.Option>
<Select.Option key="21" value="21">意语</Select.Option>
<Select.Option key="10" value="10">商旅</Select.Option>
<Select.Option key="18" value="18">CT</Select.Option>
<Select.Option key="16" value="16">APP</Select.Option>
<Select.Option key="30" value="30">Trippest</Select.Option>
<Select.Option key="31" value="31">花梨鹰</Select.Option>
<Select.Option key="0" value="">
所有小组
</Select.Option>
<Select.Option key="31" value="1,2,28,7">
GH事业部
</Select.Option>
<Select.Option key="32" value="8,9,11,12,20,21">
国际事业部
</Select.Option>
<Select.Option key="33" value="10,18,16,30">
孵化学院
</Select.Option>
<Select.Option key="1" value="1">
CH直销
</Select.Option>
<Select.Option key="2" value="2">
CH大客户
</Select.Option>
<Select.Option key="28" value="28">
AH
</Select.Option>
<Select.Option key="7" value="7">
市场推广
</Select.Option>
<Select.Option key="8" value="8">
德语
</Select.Option>
<Select.Option key="9" value="9">
日语
</Select.Option>
<Select.Option key="11" value="11">
法语
</Select.Option>
<Select.Option key="12" value="12">
西语
</Select.Option>
<Select.Option key="20" value="20">
俄语
</Select.Option>
<Select.Option key="21" value="21">
意语
</Select.Option>
<Select.Option key="10" value="10">
商旅
</Select.Option>
<Select.Option key="18" value="18">
CT
</Select.Option>
<Select.Option key="16" value="16">
APP
</Select.Option>
<Select.Option key="30" value="30">
Trippest
</Select.Option>
<Select.Option key="31" value="31">
花梨鹰
</Select.Option>
</Select>
</Col>
<Col span={4}>
<Select value={customerServicesStore.selectedCountry} style={{ width: "95%" }} onChange={(value) => customerServicesStore.selectCountry(value)}>
<Select
value={customerServicesStore.selectedCountry}
style={{ width: '95%' }}
onChange={(value) => customerServicesStore.selectCountry(value)}
>
<Select.Option key="ALL" value="">
所有国家
</Select.Option>
@ -96,7 +138,11 @@ const AgentGroupCount = () => {
</Select>
</Col>
<Col span={4}>
<Select value={dateType} style={{ width: "95%" }} onChange={(value) => customerServicesStore.selectDateType(value)}>
<Select
value={dateType}
style={{ width: '95%' }}
onChange={(value) => customerServicesStore.selectDateType(value)}
>
<Select.Option key="startDate" value="startDate">
走团日期
</Select.Option>
@ -107,19 +153,28 @@ const AgentGroupCount = () => {
</Col>
<Col span={4}>
<DatePicker.RangePicker
format={config.DATE_FORMAT} locale={zhCNlocale}
format={config.DATE_FORMAT}
locale={zhCNlocale}
allowClear={false}
value={[startDate, endDate]}
onChange={(dates) => { customerServicesStore.selectDateRange(dates[0], dates[1]) }}
onChange={(dates) => {
customerServicesStore.selectDateRange(dates[0], dates[1]);
}}
ranges={{
'本周': [moment().startOf('week'), moment().endOf('week')],
'上周': [moment().startOf('week').subtract(7, 'days'), moment().endOf('week').subtract(7, 'days')],
'本月': [moment().startOf('month'), moment().endOf('month')],
'上个月': [moment().subtract(1, 'months').startOf('month'), moment(new Date()).subtract(1, 'months').endOf('month')],
'上个月': [
moment().subtract(1, 'months').startOf('month'),
moment(new Date()).subtract(1, 'months').endOf('month'),
],
'近30天': [moment().subtract(30, 'days'), moment()],
'近三个月': [moment().subtract(2, 'month').startOf('month'), moment().endOf('month')],
'今年': [moment().startOf('year').subtract(1, 'month'), moment().endOf('year').subtract(1, 'month')],
'去年': [moment().subtract(1, 'year').startOf('year').subtract(1, 'month'), moment().subtract(1, 'year').endOf('year').subtract(1, 'month')],
'去年': [
moment().subtract(1, 'year').startOf('year').subtract(1, 'month'),
moment().subtract(1, 'year').endOf('year').subtract(1, 'month'),
],
}}
/>
</Col>
@ -130,7 +185,8 @@ const AgentGroupCount = () => {
loading={inProgress}
onClick={() => {
handleSearchClick();
}}>
}}
>
统计
</Button>
</Col>
@ -146,14 +202,17 @@ const AgentGroupCount = () => {
rowKey={(record) => record.key}
loading={inProgress}
pagination={false}
scroll={{ x: "100%" }}
scroll={{ x: '100%' }}
/>
<Divider orientation="right" plain>
<a
onClick={() => {
const wb = utils.table_to_book(document.getElementById("agentGroupList").getElementsByTagName("table")[0]);
writeFileXLSX(wb, "地接社团信息.xlsx");
}}>
const wb = utils.table_to_book(
document.getElementById('agentGroupList').getElementsByTagName('table')[0]
);
writeFileXLSX(wb, '地接社团信息.xlsx');
}}
>
导出excel
</a>
</Divider>
@ -162,6 +221,6 @@ const AgentGroupCount = () => {
</Space>
</>
);
}
};
export default observer(AgentGroupCount);
Loading…
Cancel
Save