perf: 文旅局服务人数

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

@ -153,6 +153,12 @@ class FinancialStore {
this.servicePersonNum.curTab = v; 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; const url = this.serviceModelMapper[mkey].url;
this.servicePersonNum[this.servicePersonNum.curTab].loading = true; this.servicePersonNum[this.servicePersonNum.curTab].loading = true;
const json = await fetchJSON(url, {...queryData, DateType: 'confirmDate'}); const json = await fetchJSON(url, {...queryData, DateType: 'startDate'});
const totalRow = {...json.resultTotal, groupsKey: `total${mkey}`};
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: '单项服务人数', }; const IndividualServiceRow = {orgz: json.resultTotal.IndividualService, groupsKey: `individualService${mkey}`, groupsLabel: '单项服务人数', };
if (json.errcode === 0) { if (json.errcode === 0) {
runInAction(() => { runInAction(() => {

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

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

Loading…
Cancel
Save