perf: 文旅局服务人数

feature/hotel-cruise
Lei OT 2 years ago
parent 43780b5fc2
commit d80ecf398b

@ -153,6 +153,12 @@ class FinancialStore {
this.servicePersonNum.curTab = v;
}
resetPersonNumData = () => {
this.servicePersonNum.inbound = { loading: false, dataSource: [], total: {} };
this.servicePersonNum.outbound = { loading: false, dataSource: [], total: {} };
this.servicePersonNum.domestic = { loading: false, dataSource: [], total: {} };
};
/**
* 获取服务人数
*/
@ -161,8 +167,14 @@ class FinancialStore {
const url = this.serviceModelMapper[mkey].url;
this.servicePersonNum[this.servicePersonNum.curTab].loading = true;
const json = await fetchJSON(url, {...queryData, DateType: 'confirmDate'});
const totalRow = {...json.resultTotal, groupsKey: `total${mkey}`};
const json = await fetchJSON(url, {...queryData, DateType: 'startDate'});
const sumResult = ['orgz', 'orgzPDays', 'hosts', 'hostsPDays'].reduce((r, skey) => ({ ...r, [skey]: json.result.reduce((a, c) => a + (c[skey] || 0), 0) }), {
groupsKey: `sumResult`,
groupsLabel: '合计',
});
const totalRow = Object.keys(json.resultTotal).length > 1 ? { ...json.resultTotal, groupsKey: `total${mkey}` } : (mkey === 'domestic' ? sumResult : { groupsKey: 'empty'});
const IndividualServiceRow = {orgz: json.resultTotal.IndividualService, groupsKey: `individualService${mkey}`, groupsLabel: '单项服务人数', };
if (json.errcode === 0) {
runInAction(() => {

@ -43,12 +43,6 @@ export default observer(() => {
});
};
useEffect(() => {
if (empty(DistributionStore[curTab].dataSource)) {
pageRefresh();
}
}, [curTab]);
useEffect(() => {
DistributionStore.setFormDates(formValuesToSub);
DistributionStore.resetData();
@ -57,6 +51,9 @@ export default observer(() => {
const onTabsChange = (tab) => {
DistributionStore.setCurTab(tab);
if (empty(DistributionStore[tab].dataSource)) {
pageRefresh();
}
};
const RingProgressConfig = {
height: 60,

@ -1,9 +1,10 @@
import { useContext } from 'react';
import { useContext, useEffect } from 'react';
import { observer } from 'mobx-react';
import { stores_Context } from '../config';
import { Spin, Table, Row, Col, Tabs } from 'antd';
import SearchForm from './../components/search/SearchForm';
import { TableExportBtn } from './../components/Data';
import { empty } from '../utils/commons';
import './kpi.css';
const apartOptions = [
@ -11,6 +12,7 @@ const apartOptions = [
{ key: 'outbound', value: 'outbound', label: '出境' },
{ key: 'domestic', value: 'domestic', label: '国内' },
];
const apartOptionsMapped = apartOptions.reduce((r, v) => ({...r, [v.value]: v}), {});
export default observer((props) => {
const { financial_store: financialStore, date_picker_store: searchFormStore } = useContext(stores_Context);
@ -18,26 +20,26 @@ export default observer((props) => {
const { servicePersonNum } = financialStore;
const { curTab } = servicePersonNum;
useEffect(() => {
// DistributionStore.setFormDates(formValuesToSub);
financialStore.resetPersonNumData();
return () => {};
}, [formValuesToSub]);
const pageRefresh = (queryData = formValuesToSub) => {
// console.log(queryData, 'qqqq');
financialStore.getPersonNum(queryData);
};
const columns = [
{ title: '名称', dataIndex: 'groupsLabel' },
{ title: apartOptionsMapped[curTab].label, dataIndex: 'groupsLabel', children: [{ title: `${formValuesToSub.Date1}~${formValuesToSub.Date2.substring(0, 10)}`, dataIndex: 'groupsLabel' }] },
{
title: '人次数',
children: [
{ title: '外联', dataIndex: 'orgz' },
{ title: '接待', dataIndex: 'hosts' },
],
children: [{ title: '组织', dataIndex: 'orgz' }, ...(['inbound', 'domestic'].includes(curTab) ? [{ title: '接待', dataIndex: 'hosts' }] : [])],
},
{
title: '人天',
children: [
{ title: '外联', dataIndex: 'orgzPDays' },
{ title: '接待', dataIndex: 'hostsPDays' },
],
children: [{ title: '组织', dataIndex: 'orgzPDays' }, ...(['inbound', 'domestic'].includes(curTab) ? [{ title: '接待', dataIndex: 'hostsPDays' }] : [])],
},
];
@ -68,7 +70,9 @@ export default observer((props) => {
activeKey={curTab}
onChange={(v) => {
financialStore.setCurTab(v);
pageRefresh();
if (empty(servicePersonNum[v].dataSource)) {
pageRefresh();
}
}}
tabBarExtraContent={{
right: <TableExportBtn label={'服务人数'} {...{ columns, dataSource: servicePersonNum[curTab].dataSource }} />,

Loading…
Cancel
Save