|
|
@ -47,7 +47,7 @@ class SaleStore {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
salesTrade = {
|
|
|
|
salesTrade = {
|
|
|
|
groupType: 'dept', loading: false,
|
|
|
|
groupType: 'dept', loading: false, tableDataSource: [],
|
|
|
|
operator: [], dept: [], overview: [],
|
|
|
|
operator: [], dept: [], overview: [],
|
|
|
|
operatorMapped: {}, pickSales: [], pickSalesData: [],
|
|
|
|
operatorMapped: {}, pickSales: [], pickSalesData: [],
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -529,15 +529,36 @@ class SaleStore {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTableDataSource = (merge = false) => {
|
|
|
|
|
|
|
|
if (comm.isEmpty(this.salesTrade[this.salesTrade.groupType]) || comm.isEmpty(this.salesTrade.operator)) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.salesTrade.tableDataSource = [].concat(this.salesTrade[this.salesTrade.groupType], merge === false ? this.salesTrade.operator : this.salesTrade.operatorAccount);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
async fetchOperatorTradeData(groupType, queryData) {
|
|
|
|
async fetchOperatorTradeData(groupType, queryData) {
|
|
|
|
this.salesTrade.loading = true;
|
|
|
|
this.salesTrade.loading = true;
|
|
|
|
const param1 = Object.assign({}, queryData, {groupType, groupDateType: 'year' });
|
|
|
|
const param1 = Object.assign({}, queryData, {groupType, groupDateType: 'year' });
|
|
|
|
const yearData = await this.fetchTradeDataAll(param1);
|
|
|
|
const yearData = await this.fetchTradeDataAll(param1);
|
|
|
|
const { mergeRows: yearMergeRows } = yearData.result1;
|
|
|
|
|
|
|
|
const yData = parseSaleData(yearMergeRows, ['groupsKey', 'groupDateType']);
|
|
|
|
|
|
|
|
const param2 = Object.assign({}, queryData, {groupType, groupDateType: 'month' });
|
|
|
|
const param2 = Object.assign({}, queryData, {groupType, groupDateType: 'month' });
|
|
|
|
const monthData = await this.fetchTradeDataAll(param2);
|
|
|
|
const monthData = await this.fetchTradeDataAll(param2);
|
|
|
|
const { mergeRows: monthMergeRows } = monthData.result1;
|
|
|
|
|
|
|
|
|
|
|
|
const { salesTradeDataMapped, accountMergeYearMonth } = await this.handleYearMonthData(groupType, queryData, yearData, monthData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
runInAction(() => {
|
|
|
|
|
|
|
|
this.salesTrade.loading = false;
|
|
|
|
|
|
|
|
this.salesTrade[groupType] = Object.values(salesTradeDataMapped).sort(comm.sortBy('yearML')).reverse();
|
|
|
|
|
|
|
|
this.salesTrade[`${groupType}Account`] = accountMergeYearMonth.sort(comm.sortBy('yearML')).reverse();
|
|
|
|
|
|
|
|
this.salesTrade[`${groupType}Mapped`] = Object.values(salesTradeDataMapped).reduce((r, v) => ({...r, [v.groupsKey]: Object.values(v.mData)}), {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleYearMonthData = async (groupType, queryData, yearData, monthData) => {
|
|
|
|
|
|
|
|
const { mergeRows: yearMergeRows, mergeLabelsRows: yearMergeLabelsRows } = yearData.result1;
|
|
|
|
|
|
|
|
const { mergeRows: monthMergeRows, mergeLabelsRows: monthMergeLabelsRows } = monthData.result1;
|
|
|
|
|
|
|
|
const yData = parseSaleData(yearMergeRows, ['groupsKey', 'groupDateType']);
|
|
|
|
const mData = parseSaleData(monthMergeRows, ['groupsKey', 'groupDateType']);
|
|
|
|
const mData = parseSaleData(monthMergeRows, ['groupsKey', 'groupDateType']);
|
|
|
|
const mergeYearMonth = Object.keys(yData).map(ykey => ({
|
|
|
|
const mergeYearMonth = Object.keys(yData).map(ykey => ({
|
|
|
|
...yData[ykey],
|
|
|
|
...yData[ykey],
|
|
|
@ -547,6 +568,17 @@ class SaleStore {
|
|
|
|
yearML: Object.values(yData[ykey].data)[0]?.SumML || 0, // 整理排序用
|
|
|
|
yearML: Object.values(yData[ykey].data)[0]?.SumML || 0, // 整理排序用
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const accountYData = parseSaleData(yearMergeLabelsRows, ['groupsKey', 'groupDateType']);
|
|
|
|
|
|
|
|
const accountMData = parseSaleData(monthMergeLabelsRows, ['groupsKey', 'groupDateType']);
|
|
|
|
|
|
|
|
const accountMergeYearMonth = Object.keys(accountYData).map(ykey => ({
|
|
|
|
|
|
|
|
...accountYData[ykey],
|
|
|
|
|
|
|
|
mData: accountMData[ykey].data,
|
|
|
|
|
|
|
|
yData: Object.values(accountYData[ykey].data)[0],
|
|
|
|
|
|
|
|
data: undefined,
|
|
|
|
|
|
|
|
yearML: Object.values(accountYData[ykey].data)[0]?.SumML || 0, // 整理排序用
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
const accountSalesTradeDataMapped = accountMergeYearMonth.reduce((ro, vo) => ({...ro, [vo.groupsKey]: vo}), {});
|
|
|
|
|
|
|
|
|
|
|
|
const kpiObjects = mergeYearMonth.map(v => ({ key: v.groupsKey, value: v.groupsKey, label: v.groupsLabel }));
|
|
|
|
const kpiObjects = mergeYearMonth.map(v => ({ key: v.groupsKey, value: v.groupsKey, label: v.groupsLabel }));
|
|
|
|
const kpiData = await this.getKPISettings(groupType, queryData, kpiObjects);
|
|
|
|
const kpiData = await this.getKPISettings(groupType, queryData, kpiObjects);
|
|
|
|
const salesTradeDataMapped = mergeYearMonth.reduce((ro, vo) => ({...ro, [vo.groupsKey]: vo}), {});
|
|
|
|
const salesTradeDataMapped = mergeYearMonth.reduce((ro, vo) => ({...ro, [vo.groupsKey]: vo}), {});
|
|
|
@ -560,18 +592,16 @@ class SaleStore {
|
|
|
|
if (comm.isEmpty(salesTradeDataMapped[ele.object_id].mData[`month_${padM}`])) {
|
|
|
|
if (comm.isEmpty(salesTradeDataMapped[ele.object_id].mData[`month_${padM}`])) {
|
|
|
|
salesTradeDataMapped[ele.object_id].mData[`month_${padM}`] = {};
|
|
|
|
salesTradeDataMapped[ele.object_id].mData[`month_${padM}`] = {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// set
|
|
|
|
Object.assign(salesTradeDataMapped[ele.object_id].mData[`month_${padM}`], _monthMLKPI);
|
|
|
|
Object.assign(salesTradeDataMapped[ele.object_id].mData[`month_${padM}`], _monthMLKPI);
|
|
|
|
return km;
|
|
|
|
return km;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return ele;
|
|
|
|
return ele;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
runInAction(() => {
|
|
|
|
return { salesTradeDataMapped, accountSalesTradeDataMapped, accountMergeYearMonth };
|
|
|
|
this.salesTrade.loading = false;
|
|
|
|
|
|
|
|
this.salesTrade[groupType] = Object.values(salesTradeDataMapped).sort(comm.sortBy('yearML')).reverse();
|
|
|
|
};
|
|
|
|
this.salesTrade[`${groupType}Mapped`] = Object.values(salesTradeDataMapped).reduce((r, v) => ({...r, [v.groupsKey]: Object.values(v.mData)}), {});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async getKPISettings(curObject, queryData, objects) {
|
|
|
|
async getKPISettings(curObject, queryData, objects) {
|
|
|
|
const getkpiParam = comm.objectMapper(queryData, {
|
|
|
|
const getkpiParam = comm.objectMapper(queryData, {
|
|
|
|