eslint autofix .

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

@ -1,139 +1,203 @@
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;
const { auth_store } = useContext(stores_Context);
const { Content, Footer, Sider } = Layout;
const { auth_store } = useContext(stores_Context);
const menu_items = [
{ key: 1, label: <NavLink to="/">主页</NavLink>, icon: <HomeOutlined /> },
{
key: 2,
label: "市场",
icon: <AreaChartOutlined />,
children: [
{ key: 21, label: <NavLink to="/orders">订单数据</NavLink>, icon: <FileProtectOutlined /> },
{ key: 22, label: <NavLink to="/dashboard">仪表盘</NavLink>, icon: <DashboardOutlined /> },
],
},
{
key: 5,
label: "销售",
icon: <SnippetsTwoTone />,
children: [{ key: 51, label: <NavLink to="/sale">业绩数据</NavLink> }],
},
{
key: 3,
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: 4,
label: "财务",
icon: <DollarOutlined />,
children: [
{ key: 41, label: <NavLink to="/credit_card_bill">信用卡账单</NavLink> },
{ key: 42, label: <NavLink to="/exchange_rate">汇率</NavLink> },
],
},
{
key: 6,
label: "客服",
icon: <WechatOutlined />,
children: [
{ key: 61, label: <NavLink to="/agent/group/count">地接社接团</NavLink> },
{ key: 62, label: <NavLink to="/destination/group/count">目的地接团</NavLink> },
],
}
];
const menu_items = [
{ key: 1, label: <NavLink to="/">主页</NavLink>, icon: <HomeOutlined /> },
{
key: 2,
label: '市场',
icon: <AreaChartOutlined />,
children: [
{
key: 21,
label: <NavLink to="/orders">订单数据</NavLink>,
icon: <FileProtectOutlined />,
},
{
key: 22,
label: <NavLink to="/dashboard">仪表盘</NavLink>,
icon: <DashboardOutlined />,
},
],
},
{
key: 5,
label: '销售',
icon: <SnippetsTwoTone />,
children: [{ key: 51, label: <NavLink to="/sale">业绩数据</NavLink> }],
},
{
key: 3,
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: 4,
label: '财务',
icon: <DollarOutlined />,
children: [
{
key: 41,
label: <NavLink to="/credit_card_bill">信用卡账单</NavLink>,
},
{ key: 42, label: <NavLink to="/exchange_rate">汇率</NavLink> },
],
},
{
key: 6,
label: '客服',
icon: <WechatOutlined />,
children: [
{
key: 61,
label: <NavLink to="/agent/group/count">地接社接团</NavLink>,
},
{
key: 62,
label: <NavLink to="/destination/group/count">目的地接团</NavLink>,
},
],
},
];
return (
<BrowserRouter>
<Layout
style={{
minHeight: "100vh",
}}>
<Sider collapsible={true} breakpoint="lg">
<Image src={Logo} preview={false} />
<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 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 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 />} />
<Route path="/whatsapp_session" element={<WhatsApp_session />} />
<Route path="/wechat_session" element={<Wechat_session />} />
<Route path="/agent/group/count" element={<AgentGroupCount />} />
<Route path="/destination/group/count" element={<DestinationGroupCount />} />
<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 path="/credit_card_bill" element={<Credit_card_bill />} />
<Route path="/exchange_rate" element={<ExchangeRate />} />
</Route>
<Route element={<ProtectedRoute auth={["admin", "director_bu", "sale"]} />}>
<Route path="/sale" element={<Sale />} />
<Route path="/sale_sub/:type_sub" element={<Sale_sub />} />
</Route>
</Routes>
</Content>
<Footer
style={{
textAlign: "center",
}}>
<UserOutlined /> {auth_store.user.name} ({auth_store.user.userid})<br />
Hainatravel Dashboard ©2022 Created by IT
</Footer>
</Layout>
</Layout>
</BrowserRouter>
);
return (
<BrowserRouter>
<Layout
hasSider
style={{
minHeight: '100vh',
}}
>
<Sider
collapsible={true}
breakpoint="lg"
style={{
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}
/>
</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 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 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 />} />
<Route path="/whatsapp_session" element={<WhatsApp_session />} />
<Route path="/wechat_session" element={<Wechat_session />} />
<Route path="/agent/group/count" element={<AgentGroupCount />} />
<Route path="/destination/group/count" element={<DestinationGroupCount />} />
<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 path="/credit_card_bill" element={<Credit_card_bill />} />
<Route path="/exchange_rate" element={<ExchangeRate />} />
</Route>
<Route element={<ProtectedRoute auth={['admin', 'director_bu', 'sale']} />}>
<Route path="/sale" element={<Sale />} />
<Route path="/sale_sub/:type_sub" element={<Sale_sub />} />
</Route>
</Routes>
</Content>
<Footer
style={{
textAlign: 'center',
}}
>
<UserOutlined /> {auth_store.user.name} ({auth_store.user.userid})
<br />
Hainatravel Dashboard ©2022 Created by IT
</Footer>
</Layout>
</Layout>
</BrowserRouter>
);
};
export default observer(App);

@ -1,74 +1,83 @@
import React, {Component} from 'react';
import {Row, Col, Button, Tabs, Table, Space} from 'antd';
import React, { Component } from 'react';
import { Row, Col, Button, Tabs, Table, Space } from 'antd';
import {
ContainerOutlined, CarryOutOutlined,
SmileOutlined, TagsOutlined, GlobalOutlined,
SearchOutlined,
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 {observer} from 'mobx-react';
import DatePickerCharts from './DatePickerCharts'
import { stores_Context } from '../config';
import { Line } from '@ant-design/charts';
import SiteSelect from './SiteSelect';
import { observer } from 'mobx-react';
import DatePickerCharts from './DatePickerCharts';
class Orders extends Component {
static contextType = stores_Context;
static contextType = stores_Context;
constructor(props) {
super(props);
}
constructor(props) {
super(props);
}
// componentDidMount() {
// const {orders_store} = this.context;
// orders_store.getOrderCount();
// orders_store.onChange_Tabs(orders_store.active_tab_key);
// }
// componentDidMount() {
// const {orders_store} = this.context;
// orders_store.getOrderCount();
// orders_store.onChange_Tabs(orders_store.active_tab_key);
// }
render() {
const { dashboard_store } = this.context;
const orders_data = dashboard_store.orders_data;
const line_config = {
data: orders_data.data,
padding: 'auto',
xField: 'ApplyDate',
yField: 'orderCount',
seriesField: 'WebCode',
xAxis: {
type: 'timeCat',
},
smooth: true,
legend: {
position: 'right-top',
title: {
text: '总合计 ' + orders_data.data.reduce((a, b) => a + b.orderCount, 0),
},
itemMarginBottom: 12, // 垂直间距
itemValue: {
formatter: (text, item) => {
const items = orders_data.data.filter((d) => d.WebCode === item.value); // 按站点筛选
return items.length ? items.reduce((a, b) => a + b.orderCount, 0) : ''; // 计算总数
},
},
},
};
render() {
const {dashboard_store} = this.context;
const orders_data = dashboard_store.orders_data;
const line_config = {
data: orders_data.data,
padding: 'auto',
xField: 'ApplyDate',
yField: 'orderCount',
seriesField: 'WebCode',
xAxis: {
type: 'timeCat',
},
smooth: true,
legend: {
position: 'right-top',
title: {
text: '总合计 ' + orders_data.data.reduce((a, b) => a + b.orderCount, 0),
},
itemMarginBottom: 12,//垂直间距
itemValue: {
formatter: (text, item) => {
const items = orders_data.data.filter((d) => d.WebCode === item.value);//按站点筛选
return items.length ? items.reduce((a, b) => a + b.orderCount, 0) : '';//计算总数
},
},
},
}
return (
<div>
<h2>全网站订单数统计</h2>
<div>
<Space>
<DatePickerCharts hide_vs={true}/>
<Button type="primary" icon={<SearchOutlined/>} loading={orders_data.loading} onClick={() => {
orders_data.getOrderCount_all();
}}>统计</Button>
</Space>
</div>
<br/>
<Line {...line_config}/>
</div>
);
}
return (
<div>
<h2>全网站订单数统计</h2>
<div>
<Space>
<DatePickerCharts hide_vs={true} />
<Button
type="primary"
icon={<SearchOutlined />}
loading={orders_data.loading}
onClick={() => {
orders_data.getOrderCount_all();
}}
>
统计
</Button>
</Space>
</div>
<br />
<Line {...line_config} />
</div>
);
}
}
export default observer(Orders);

@ -2,41 +2,41 @@ import { makeAutoObservable, runInAction } from "mobx";
import * as dd from "dingtalk-jsapi";
import * as config from "../config";
//权限管理
// 权限管理
class AuthStore {
constructor(rootStore) {
this.rootStore = rootStore;
makeAutoObservable(this);
if (process.env.NODE_ENV == "production") {
this.get_auth(); //放到钉钉环境才能开启
this.get_auth(); // 放到钉钉环境才能开启
}
}
auth = ["admin"]; //开发时候用,正式环境留空
user = { name: "loading", userid: "..." }; //开发时候用,正式环境留空
auth = ["admin"]; // 开发时候用,正式环境留空
user = { name: "loading", userid: "..." }; // 开发时候用,正式环境留空
has_permission(requireds) {
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;
}
return false;
}
//请求权限
// 请求权限
get_auth() {
let _this = this;
const CORPID = "ding48bce8fd3957c96b"; //企业的id
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;
//请求获取HT接口获取用户权限和用户信息
const code = res.code;
const url = "/dingtalk/dingtalkwork/Getusers_auth?code=" + code;
// 请求获取HT接口获取用户权限和用户信息
fetch(config.HT_HOST + url)
.then(response => response.json())
.then(json => {

@ -3,7 +3,7 @@ import * as dd from 'dingtalk-jsapi';
import * as config from "../config";
//会话管理
// 会话管理
class ChatSessionStore {
constructor(rootStore) {
@ -12,36 +12,36 @@ class ChatSessionStore {
}
wechat_data = {
counselors: [],//顾问列表
customers: [],//客户列表
}
counselors: [],// 顾问列表
customers: [],// 客户列表
};
//请求权限
// 请求权限
get_auth() {
let _this = this;
const CORPID = 'ding48bce8fd3957c96b';//企业的id
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;
//请求获取HT接口获取用户权限和用户信息
const code = res.code;
const url = '/dingtalk/dingtalkwork/Getusers_auth?code=' + code;
// 请求获取HT接口获取用户权限和用户信息
fetch(config.HT_HOST + url)
.then((response) => response.json())
.then((json) => {
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;
@ -70,8 +70,8 @@ class CustomerStore {
data: [],
data_detail: [],
webcode: 'GHKYZG',
site_select_mode: false,//站点是否多选
group_select_mode: 'multiple',//是否多选分组
site_select_mode: false,// 站点是否多选
group_select_mode: 'multiple',// 是否多选分组
groups: ['1', '2', '7'],
date_type: 'applyDate',
group_handleChange: this.handleChange_group_select.bind(this),
@ -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;
@ -143,8 +143,8 @@ class CustomerStore {
data: [],
data_detail: [],
webcode: 'ALL',
site_select_mode: false,//站点是否多选
group_select_mode: 'multiple',//是否多选分组
site_select_mode: false,// 站点是否多选
group_select_mode: 'multiple',// 是否多选分组
groups: ['1', '2', '28', '7'],
date_type: 'applyDate',
group_handleChange: this.handleChange_group_select_regular.bind(this),
@ -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;
@ -216,8 +216,8 @@ class CustomerStore {
data: [],
data_detail: [],
webcode: 'ALL',
site_select_mode: false,//站点是否多选
group_select_mode: 'multiple',//是否多选分组
site_select_mode: false,// 站点是否多选
group_select_mode: 'multiple',// 是否多选分组
groups: ['1', '2', '28', '7'],
date_type: 'applyDate',
group_handleChange: this.handleChange_group_select_inchina.bind(this),
@ -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
}

@ -8,10 +8,10 @@ class DashboardStore {
}
loading = false;
site_select_mode = "multiple"; //是否多选站点
site_select_mode = "multiple"; // 是否多选站点
webcode = ["CHT", "AH", "GH"];
//订单统计 begin
// 订单统计 begin
orders_data = {
loading: false,
data: [],
@ -19,7 +19,7 @@ class DashboardStore {
};
getOrderCount_all() {
//统计所有站点订单数量
// 统计所有站点订单数量
this.orders_data.loading = true;
const date_picker_store = this.rootStore.date_picker_store;
let url = "/service-web/QueryData/GetOrderCount";
@ -39,7 +39,7 @@ class DashboardStore {
});
}
//订单统计 end
// 订单统计 end
// 临时订单 begin
@ -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({
@ -156,7 +156,7 @@ class DashboardStore {
mobile_data = {
loading: false,
data: [],
group_select_mode: "multiple", //是否多选分组
group_select_mode: "multiple", // 是否多选分组
groups: ["1", "2", "28", "7", "8", "9", "11", "12", "20", "21", "18"],
columns: [
{

@ -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,14 +26,14 @@ class DatePickerStore {
this.start_date_cp = false;
this.end_date_cp = false;
}
}
};
//计算上一个时间段
// 计算上一个时间段
previous_date() {
return [moment(this.start_date).subtract(this.end_date.diff(this.start_date, 'days') + 1, 'days'), moment(this.start_date).subtract(1, 'days')];
}
//去年同期
// 去年同期
previous_year() {
return [moment(this.start_date).subtract(1, 'year'), moment(this.end_date).subtract(1, 'year')];
}

@ -1,10 +1,10 @@
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';
//财务管理
// 财务管理
class FinancialStore {
constructor(rootStore) {
@ -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]);
}
@ -69,7 +69,7 @@ class FinancialStore {
business_units: ['ALL'],
group_select_mode: false,
groups: ['ALL'],
filteredValue: [],//默认的筛选值
filteredValue: [],// 默认的筛选值
bu_handleChange: this.bu_handleChange.bind(this),
group_handleChange: this.group_handleChange.bind(this),
set_bill_filtered: this.set_bill_filtered.bind(this),
@ -85,7 +85,7 @@ class FinancialStore {
this.credit_card_data.groups = value;
};
//请求信用卡账单
// 请求信用卡账单
get_credit_card_bills() {
const date_picker_store = this.rootStore.date_picker_store;
let url = '/service-web/QueryData/GetCreditCardBills';
@ -99,14 +99,14 @@ class FinancialStore {
.then((json) => {
runInAction(() => {
this.credit_card_data.data = json;
})
});
})
.catch((error) => {
console.log('fetch data failed', error);
});
}
//请求信用卡账单
// 请求信用卡账单
get_credit_card_bills_by_type() {
const date_picker_store = this.rootStore.date_picker_store;
let url = '/service-web/QueryData/GetCreditCardBillsByType';
@ -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";

@ -13,62 +13,63 @@ class OrdersStore {
}
loading = false;
site_select_mode = false; //是否多选站点
site_select_mode = false; // 是否多选站点
group_select_mode = false;
groups = ["1,2,28,7,33"];
webcode = "ALL";
date_type = "applyDate";
include_tickets = "1"; //是否包含门票1是含有0不含
//diff_count_day = 0; //开始日期和结束日期的间隔,用于计算平均数
active_tab_key = "Form"; //当前切换的标签页
active_tab_key_sub = "detail"; //当前切换的子维度标签页
orderCountData = []; //订单统计数据源
orderCountData_type = []; //子维度订单统计
orderCountData_Form = []; //表单类型统计数据源
orderCountData_Form_sub = []; //子维度类型统计
diff_days1 = 0; //日期相差天数,用于计算日平均值
diff_days2 = 0; //日期相差天数,比较数据时使用
include_tickets = "1"; // 是否包含门票1是含有0不含
// diff_count_day = 0; //开始日期和结束日期的间隔,用于计算平均数
active_tab_key = "Form"; // 当前切换的标签页
active_tab_key_sub = "detail"; // 当前切换的子维度标签页
orderCountData = []; // 订单统计数据源
orderCountData_type = []; // 子维度订单统计
orderCountData_Form = []; // 表单类型统计数据源
orderCountData_Form_sub = []; // 子维度类型统计
diff_days1 = 0; // 日期相差天数,用于计算日平均值
diff_days2 = 0; // 日期相差天数,比较数据时使用
//选择事业部
// 选择事业部
group_handleChange(value) {
this.groups = value;
}
//计算两个时间段的有多少天
// 计算两个时间段的有多少天
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;
}
//下单日期、确认日期、出发日期
// 下单日期、确认日期、出发日期
onChange_datetype(value) {
this.date_type = value;
}
//选择来源网站
// 选择来源网站
handleChange_webcode = value => {
this.webcode = value;
};
//是否包含门票
// 是否包含门票
handleChange_include_tickets = value => {
this.include_tickets = value;
};
//切换标签页
// 切换标签页
onChange_Tabs_sub(ordertype, ordertype_sub, active_key) {
this.active_tab_key_sub = active_key;
this.getOrderCountByType_sub(ordertype, ordertype_sub, this.active_tab_key_sub);
}
//格式化一下数据
//映射时间做时间段对比的时候需要把对比时间段映射到开始时间上才能在同一个x轴显示
//比如2022-10-01~2022-10-30 vs 2021-10-01~2021-10-30 则需要在2021年的时间段加365天的时间映射成2022起始时间段
//相差的天数用a.diff(b, 'days')计算
// 格式化一下数据
// 映射时间做时间段对比的时候需要把对比时间段映射到开始时间上才能在同一个x轴显示
// 比如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 {
@ -80,13 +81,13 @@ 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
// 不能直接用diff计算因为日期是含有时间的会导致计算差一天先转成格式化的日期再比较
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 {
@ -101,7 +102,7 @@ class OrdersStore {
return comm.set_array_index(result);
}
//网站订单数量,根据类型
// 网站订单数量,根据类型
getOrderCount_type(ordertype, ordertype_sub) {
this.loading = true;
const date_picker_store = this.rootStore.date_picker_store;
@ -126,11 +127,11 @@ class OrdersStore {
});
}
//网站订单数量
// 网站订单数量
getOrderCount() {
this.loading = true;
const date_picker_store = this.rootStore.date_picker_store;
let url = "/service-web/QueryData/GetOrderCount"; //?WebCode=cht&COLI_ApplyDate1=2022-08-01&COLI_ApplyDate2=2022-08-31&COLI_ApplyDateold1=2021-08-01&COLI_ApplyDateold2=2021-08-31';
let url = "/service-web/QueryData/GetOrderCount"; // ?WebCode=cht&COLI_ApplyDate1=2022-08-01&COLI_ApplyDate2=2022-08-31&COLI_ApplyDateold1=2021-08-01&COLI_ApplyDateold2=2021-08-31';
url += "?WebCode=" + this.webcode + "&IncludeTickets=" + this.include_tickets;
url += "&COLI_ApplyDate1=" + date_picker_store.start_date.format(config.DATE_FORMAT) + "&COLI_ApplyDate2=" + date_picker_store.end_date.format(config.DATE_FORMAT) + "%2023:59:59";
url += `&DepartmentList=${this.groups.toString()}&DateType=${this.date_type}`;
@ -151,7 +152,7 @@ class OrdersStore {
});
}
//网站订单类型
// 网站订单类型
getOrderCountByType(order_type) {
const date_picker_store = this.rootStore.date_picker_store;
let url = "/service-web/QueryData/GetOrderCountByType";
@ -165,7 +166,7 @@ class OrdersStore {
.then(response => response.json())
.then(json => {
runInAction(() => {
//错误:[MOBX]由于启用了严格模式所以不允许改变观察到的在动作之外的值。如果此更改是有意的请将代码包在“Actudio”中。
// 错误:[MOBX]由于启用了严格模式所以不允许改变观察到的在动作之外的值。如果此更改是有意的请将代码包在“Actudio”中。
this.orderCountData_Form = json;
});
})
@ -174,12 +175,12 @@ class OrdersStore {
});
}
//子维度查询
// 子维度查询
getOrderCountByType_sub(ordertype, ordertype_sub, sub_type) {
const date_picker_store = this.rootStore.date_picker_store;
let url = "/service-web/QueryData/GetOrderCountByType_Sub";
if (sub_type == "page_cxstate1") {
//统计成行订单的路径
// 统计成行订单的路径
sub_type = "page&cxstate=1";
}
url += `?WebCode=${this.webcode}&OrderType=${ordertype}&OrderType_val=${ordertype_sub}&SubOrderType=${sub_type}` + "&IncludeTickets=" + this.include_tickets;
@ -192,7 +193,7 @@ class OrdersStore {
.then(response => response.json())
.then(json => {
runInAction(() => {
//错误:[MOBX]由于启用了严格模式所以不允许改变观察到的在动作之外的值。如果此更改是有意的请将代码包在“Actudio”中。
// 错误:[MOBX]由于启用了严格模式所以不允许改变观察到的在动作之外的值。如果此更改是有意的请将代码包在“Actudio”中。
this.orderCountData_Form_sub = json;
});
})
@ -201,7 +202,7 @@ class OrdersStore {
});
}
//切换标签页
// 切换标签页
onChange_Tabs(active_key) {
this.active_tab_key = active_key;
this.getOrderCountByType(this.active_tab_key);

@ -4,7 +4,7 @@ import * as config from "../config";
import * as comm from "../utils/commons";
import { NavLink } from "react-router-dom";
//销售数据
// 销售数据
class SaleStore {
constructor(rootStore) {
this.rootStore = rootStore;
@ -13,55 +13,57 @@ class SaleStore {
loading = false;
loading_table = false;
spinning = false; //加载状态
active_tab_key = "All"; //当前选择的标签
spinning = false; // 加载状态
active_tab_key = "All"; // 当前选择的标签
group_select_mode = false;
groups = ["1,2,28,7,33"]; //默认GH事业部
filter_country=[];//筛选国籍
filter_guest_type=[];//筛选客户关系
site_select_mode = false; //是否多选站点
include_tickets = "1"; //是否包含门票1是含有0不含
groups = ["1,2,28,7,33"]; // 默认GH事业部
filter_country=[];// 筛选国籍
filter_guest_type=[];// 筛选客户关系
site_select_mode = false; // 是否多选站点
include_tickets = "1"; // 是否包含门票1是含有0不含
webcode = "ALL";
date_type = "ConfirmDate";
ml_data = []; //毛利数据
type_data = []; //类型的数据
type_data_sub = []; //类型的子维度数据
date_title = "date_title"; //日期段,只用于显示,防止日期选择控件的变化导致页面刷新
ml_data = []; // 毛利数据
type_data = []; // 类型的数据
type_data_sub = []; // 类型的子维度数据
date_title = "date_title"; // 日期段,只用于显示,防止日期选择控件的变化导致页面刷新
//是否包含门票
// 是否包含门票
handleChange_include_tickets = value => {
this.include_tickets = value;
};
//选择事业部
// 选择事业部
group_handleChange(value) {
this.groups = value;
}
//选择站点
// 选择站点
handleChange_webcode = value => {
this.webcode = value;
};
//切换标签页
// 切换标签页
onChange_Tabs(active_key) {
this.active_tab_key = active_key;
}
//下单日期或者出发日期
// 下单日期或者出发日期
onChange_datetype(value) {
this.date_type = value;
}
//选择客源国
// 选择客源国
onChange_Country(value) {
this.filter_country = value;
}
//选择成员关系
// 选择成员关系
onChange_GuestGroupType(value) {
this.filter_guest_type = value;
}
//获取业绩信息
// 获取业绩信息
get_department_order_ml(date_moment) {
let result = [];
const date1_start = date_moment.start_date.format(config.DATE_FORMAT);
@ -103,9 +105,9 @@ 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);
@ -279,20 +281,20 @@ class SaleStore {
];
result.dataSource = json.result1;
} else {
//if (this.active_tab_key == "Country")
//获取类型的项目,去掉重复,作为列名
let type_name_arr = [];
// if (this.active_tab_key == "Country")
// 获取类型的项目,去掉重复,作为列名
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 }],
@ -335,10 +337,10 @@ 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);
@ -388,11 +390,11 @@ class SaleStore {
dataIndex: "COLI_Cycle",
},
];
//数据处理,把相同类型放入同一个数组
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';

@ -6,14 +6,14 @@ import moment from "moment";
if (!String.prototype.padStart) {
String.prototype.padStart = function padStart(targetLength, padString) {
targetLength = targetLength >> 0; //floor if number or convert non-number to 0;
targetLength = targetLength >> 0; // floor if number or convert non-number to 0;
padString = String(typeof padString !== "undefined" ? padString : " ");
if (this.length > targetLength) {
return String(this);
} else {
targetLength = targetLength - this.length;
if (targetLength > padString.length) {
padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed
padString += padString.repeat(targetLength / padString.length); // append to original to ensure we are longer than needed
}
return padString.slice(0, targetLength) + String(this);
}
@ -48,10 +48,10 @@ export function formatPrice(price) {
return Math.ceil(price).toLocaleString();
}
//千分符的金额转成数字默认为0
// 千分符的金额转成数字默认为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;
}
@ -155,12 +155,12 @@ export function isEmpty(val) {
}
export function empty(a) {
if (a === "") return true; //检验空字符串
if (a === "null") return true; //检验字符串类型的null
if (a === "undefined") return true; //检验字符串类型的 undefined
if (!a && a !== 0 && a !== "") return true; //检验 undefined 和 null
if (Array.prototype.isPrototypeOf(a) && a.length === 0) return true; //检验空数组
if (Object.prototype.isPrototypeOf(a) && Object.keys(a).length === 0) return true; //检验空对象
if (a === "") return true; // 检验空字符串
if (a === "null") return true; // 检验字符串类型的null
if (a === "undefined") return true; // 检验字符串类型的 undefined
if (!a && a !== 0 && a !== "") return true; // 检验 undefined 和 null
if (Array.prototype.isPrototypeOf(a) && a.length === 0) return true; // 检验空数组
if (Object.prototype.isPrototypeOf(a) && Object.keys(a).length === 0) return true; // 检验空对象
return false;
}
@ -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();
@ -226,15 +226,15 @@ 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 "周一";
@ -253,12 +253,12 @@ export function getWeek(date) {
}
}
//把非数字下标的数组设置下标因为非数字数组的length为0导致读取失败
// 把非数字下标的数组设置下标因为非数字数组的length为0导致读取失败
export function set_array_index(result) {
let result_array = [];
let result_keys = Object.keys(result);
result_keys.sort(); //必须做一次排序用for in循环会导致顺序错误
for (let key of result_keys) {
const result_array = [];
const result_keys = Object.keys(result);
result_keys.sort(); // 必须做一次排序用for in循环会导致顺序错误
for (const key of result_keys) {
result_array.push(result[key]);
}
return result_array;

@ -1,31 +1,28 @@
import React, {useContext, useEffect} from 'react';
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 { customerServicesStore } = useContext(stores_Context);
const agentList = customerServicesStore.agentList;
const agentGroupList = customerServicesStore.agentGroupList;
const agentGroupListColumns = customerServicesStore.agentGroupListColumns;
const {startDate, endDate, dateType, inProgress} = customerServicesStore;
const { startDate, endDate, dateType, inProgress } = customerServicesStore;
useEffect(() => {
customerServicesStore.fetchAllAgent();
}, []);
customerServicesStore.fetchAllAgent();
}, []);
const handleSearchClick = () => {
customerServicesStore.fetchAgentGroupCount();
}
};
const renderAgentItem = (agent) => {
return (
@ -33,16 +30,16 @@ const AgentGroupCount = () => {
{agent.VEI2_CompanyBN}
</Select.Option>
);
}
};
return (
<>
<Space direction="vertical" style={{ width: '100%' }}>
<Row gutter={{ md: 24 }} justify="end">
<Col span={4}>
<Select
value={customerServicesStore.selectedAgent}
style={{ width: "95%" }}
<Select
value={customerServicesStore.selectedAgent}
style={{ width: '95%' }}
showSearch
onSearch={(value) => {
console.log('search:', value);
@ -50,42 +47,87 @@ 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>
<Select.Option key="china" value="china">
国内
@ -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);
export default observer(AgentGroupCount);

Loading…
Cancel
Save