import { useContext, useEffect, useState } from 'react';
import { observer } from 'mobx-react';
import { Row, Col, Spin, Space } from 'antd';
import { stores_Context } from '../config';
import { useNavigate } from 'react-router-dom';
import StatisticCard from '../components/StatisticCard';
import Bullet from '../components/BulletWithSort';
import Waterfall from '../components/Waterfall';
import DataFieldRadio from './../components/DateFieldRadio';
import SearchForm from './../components/search/SearchForm';
import { empty } from './../utils/commons';
import { dataFieldAlias } from './../libs/ht';
import './home.css';
export default observer(() => {
const navigate = useNavigate();
const { TradeStore } = useContext(stores_Context);
const { searchPayloadHome, sideData, summaryData, BuData, topData } = TradeStore;
const topSeries = [
{ key: 'country', label: '国籍' },
{ key: 'dept', label: '小组' },
{ key: 'operator', label: '顾问' },
{ key: 'destination', label: '目的地' },
// { key: 'GuestGroupType', label: '客群类别' },
];
useEffect(() => {
if (empty(summaryData.dataSource)) {
// pageRefresh();
}
return () => {};
}, []);
const pageRefresh = (queryData) => {
TradeStore.fetchSummaryData(queryData);
TradeStore.fetchTradeDataByBU(queryData);
TradeStore.fetchTradeDataByMonth(queryData);
for (const iterator of topSeries) {
TradeStore.fetchTradeDataByType(iterator.key, queryData);
}
};
const layoutProps = {
gutter: { xs: 8, sm: 8, lg: 16 },
lg: { span: 6 },
sm: { span: 12 },
xs: { span: 24 },
};
const layoutProps3 = {
gutter: { xs: 8, sm: 8, lg: 16 },
lg: { span: 8 },
sm: { span: 12 },
xs: { span: 24 },
};
const [valueKey, setValueKey] = useState('SumML');
const [BulletConfig, setBulletConfig] = useState({
measureField: 'SumML', //
rangeField: 'SumMLRange', //
targetField: 'MLKPIvalue', //
xField: 'groupsLabel',
});
const handleChangeValueKey = (key) => {
setValueKey(key);
setBulletConfig({
measureField: key,
rangeField: `${key}Range`,
// targetField: `${key}KPI`,
targetField: dataFieldAlias[key].nestkey.p,
xField: 'groupsLabel',
});
};
const WaterfallConfig = {
xField: 'groupDateVal',
yField: 'SumML',
seriesField: 'groupsLabel',
meta: {
groupDateVal: {
alias: '月份',
// type: 'cat',
},
},
label: {
formatter: (v) => summaryData.kpi.value === 0 ? (dataFieldAlias.SumML?.formatter(v.SumML) || v.SumML) : ((v.SumML / summaryData.kpi.value) * 100).toFixed(2) + '%',
},
};
const BUConfig = {
measureField: 'SumML', //
rangeField: 'SumMLRange', //
targetField: 'MLKPIvalue', //
xField: 'groupsLabel',
layout: 'vertical',
};
return (
<>
{/* style={{ margin: '-16px -8px', padding: 0 }} */}
{
TradeStore.setStateSearch(form);
pageRefresh(obj);
}}
/>
年度业绩
{summaryData.dataSource.map((item) => (
))}
市场进度
{Object.keys(sideData.dataSource).map((key) => (
{key}
))}
TOP
{topSeries.map((item) => (
{item.label}
))}
>
);
});