|
|
|
@ -143,10 +143,10 @@ class FinancialStore {
|
|
|
|
|
'domestic': { url: '/service-Analyse2/domestic_person_num', keySort: true, dynamicsX: false },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
servicePersonNum = { curTab: 'inbound',
|
|
|
|
|
'inbound': { loading: false, dataSource: [], total: {} },
|
|
|
|
|
'outbound': { loading: false, dataSource: [], total: {} },
|
|
|
|
|
'domestic': { loading: false, dataSource: [], total: {} },
|
|
|
|
|
servicePersonNum = { curTab: 'inbound', loading: false,
|
|
|
|
|
'inbound': { loading: false, dataSource: [], rawData: [], NoEmptyData: [], },
|
|
|
|
|
'outbound': { loading: false, dataSource: [], rawData: [], NoEmptyData: [], },
|
|
|
|
|
'domestic': { loading: false, dataSource: [], rawData: [], NoEmptyData: [], },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
setCurTab(v) {
|
|
|
|
@ -154,9 +154,47 @@ class FinancialStore {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resetPersonNumData = () => {
|
|
|
|
|
this.servicePersonNum.inbound = { loading: false, dataSource: [], total: {} };
|
|
|
|
|
this.servicePersonNum.outbound = { loading: false, dataSource: [], total: {} };
|
|
|
|
|
this.servicePersonNum.domestic = { loading: false, dataSource: [], total: {} };
|
|
|
|
|
this.servicePersonNum.inbound = { loading: false, dataSource: [], rawData: [], NoEmptyData: [], };
|
|
|
|
|
this.servicePersonNum.outbound = { loading: false, dataSource: [], rawData: [], NoEmptyData: [], };
|
|
|
|
|
this.servicePersonNum.domestic = { loading: false, dataSource: [], rawData: [], NoEmptyData: [], };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
setPersonNumTableDataSource = (notnull) => {
|
|
|
|
|
const mkey = this.servicePersonNum.curTab;
|
|
|
|
|
if (comm.isEmpty(this.servicePersonNum[mkey].dataSource)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
this.servicePersonNum[mkey].dataSource = (notnull === false ? this.servicePersonNum[mkey].rawData : this.servicePersonNum[mkey].NoEmptyData);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
handleRows = (json) => {
|
|
|
|
|
const mkey = this.servicePersonNum.curTab;
|
|
|
|
|
const sumFun = (_data, key='sum') => ['orgz', 'orgzPDays', 'hosts', 'hostsPDays'].reduce((r, skey) => ({ ...r, [skey]: _data.reduce((a, c) => a + (c[skey] || 0), 0) }), {
|
|
|
|
|
groupsKey: key, // `sumResult`,
|
|
|
|
|
groupsLabel: '合计',
|
|
|
|
|
});
|
|
|
|
|
const percentRow = (row, sumResult) => {
|
|
|
|
|
return ['orgz', 'orgzPDays', 'hosts', 'hostsPDays'].reduce((r, skey) => ({ ...r, [`${skey}Percent`]: sumResult[skey] ? comm.fixTo4Decimals(row[skey] / sumResult[skey]) : 0 }), row);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const sumResult = sumFun(json.result, 'sumResult');
|
|
|
|
|
const emptyRows = json.result.filter(ele => ele.groupsLabel === '' || ele.groupsLabel === '未知');
|
|
|
|
|
const sumEmptyResult = sumFun(emptyRows, 'sumEmptyResult');
|
|
|
|
|
const NotEmptyRows = json.result.filter(ele => ele.groupsLabel !== '' && ele.groupsLabel !== '未知');
|
|
|
|
|
const sumNotEmptyRows = sumFun(NotEmptyRows, 'sumNotEmptyRows');
|
|
|
|
|
|
|
|
|
|
const result = NotEmptyRows.map((row) => ({...row, ...percentRow(row, sumNotEmptyRows)})).map((row) => {
|
|
|
|
|
const newData = ['orgz', 'orgzPDays', 'hosts', 'hostsPDays'].reduce(
|
|
|
|
|
(r, skey) => ({ ...r, [skey]: row[`${skey}Percent`] ? row[skey] + comm.fixToInt(sumEmptyResult[skey] * row[`${skey}Percent`]) : row[skey] }),
|
|
|
|
|
row
|
|
|
|
|
);
|
|
|
|
|
return newData;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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: '单项服务人数', };
|
|
|
|
|
|
|
|
|
|
return { sumResult, result, rawData: [].concat([IndividualServiceRow, totalRow], json.result), NoEmptyData: [].concat([IndividualServiceRow, totalRow], result) };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -166,21 +204,19 @@ class FinancialStore {
|
|
|
|
|
const mkey = this.servicePersonNum.curTab;
|
|
|
|
|
const url = this.serviceModelMapper[mkey].url;
|
|
|
|
|
|
|
|
|
|
this.servicePersonNum.loading = true;
|
|
|
|
|
this.servicePersonNum[this.servicePersonNum.curTab].loading = true;
|
|
|
|
|
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 { rawData, NoEmptyData } = this.handleRows(json);
|
|
|
|
|
|
|
|
|
|
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(() => {
|
|
|
|
|
this.servicePersonNum.loading = false;
|
|
|
|
|
this.servicePersonNum[this.servicePersonNum.curTab].loading = false;
|
|
|
|
|
this.servicePersonNum[this.servicePersonNum.curTab].dataSource = [].concat([IndividualServiceRow, totalRow], json.result);
|
|
|
|
|
this.servicePersonNum[this.servicePersonNum.curTab].total = json.resultTotal;
|
|
|
|
|
this.servicePersonNum[this.servicePersonNum.curTab].dataSource = rawData;
|
|
|
|
|
this.servicePersonNum[this.servicePersonNum.curTab].rawData = rawData;
|
|
|
|
|
this.servicePersonNum[this.servicePersonNum.curTab].NoEmptyData = NoEmptyData;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return json;
|
|
|
|
|