|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import { makeAutoObservable, runInAction } from "mobx";
|
|
|
|
|
import { makeAutoObservable, runInAction, toJS } from "mobx";
|
|
|
|
|
import { CaretUpOutlined, CaretDownOutlined } from "@ant-design/icons";
|
|
|
|
|
import { Tag } from "antd";
|
|
|
|
|
import * as config from "../config";
|
|
|
|
@ -121,16 +121,46 @@ class OrdersStore {
|
|
|
|
|
(r[v.ApplyDate] || (r[v.ApplyDate] = [])).push(v);
|
|
|
|
|
return r;
|
|
|
|
|
}, {});
|
|
|
|
|
this.orderCountData = Object.keys(groupByDate)
|
|
|
|
|
const _data = Object.keys(groupByDate)
|
|
|
|
|
.reduce((r, _d) => {
|
|
|
|
|
const summaryVal = groupByDate[_d].reduce((rows, row) => rows + row.orderCount, 0);
|
|
|
|
|
r.push({ ...groupByDate[_d][0], orderCount: summaryVal });
|
|
|
|
|
const xAxisGroup = groupByDate[_d].reduce((a, v) => {
|
|
|
|
|
(a[v.groups] || (a[v.groups] = [])).push(v);
|
|
|
|
|
return a;
|
|
|
|
|
}, {});
|
|
|
|
|
Object.keys(xAxisGroup).map((_group) => {
|
|
|
|
|
const summaryVal = xAxisGroup[_group].reduce((rows, row) => rows + row.orderCount, 0);
|
|
|
|
|
r.push({ ...xAxisGroup[_group][0], orderCount: summaryVal });
|
|
|
|
|
return _group;
|
|
|
|
|
});
|
|
|
|
|
return r;
|
|
|
|
|
}, [])
|
|
|
|
|
.map((row) => ({ xField: row.ApplyDate, yField: row.orderCount, seriesField: row.groups }));
|
|
|
|
|
this.orderCountData = _data;
|
|
|
|
|
this.avgLine1 = avg1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
summaryAllWebcode = (json) => {
|
|
|
|
|
const groupByDate1 = json.ordercount1.reduce((r, v) => {
|
|
|
|
|
(r[v.ApplyDate] || (r[v.ApplyDate] = [])).push(v);
|
|
|
|
|
return r;
|
|
|
|
|
}, {});
|
|
|
|
|
const ordercount1 = Object.keys(groupByDate1).reduce((r, _date) => {
|
|
|
|
|
const summaryVal = groupByDate1[_date].reduce((rows, row) => rows + row.orderCount, 0);
|
|
|
|
|
r.push({ ...groupByDate1[_date][0], orderCount: summaryVal });
|
|
|
|
|
return r;
|
|
|
|
|
}, []);
|
|
|
|
|
const groupByDate2 = json.ordercount2.reduce((r, v) => {
|
|
|
|
|
(r[v.ApplyDate] || (r[v.ApplyDate] = [])).push(v);
|
|
|
|
|
return r;
|
|
|
|
|
}, {});
|
|
|
|
|
const ordercount2 = Object.keys(groupByDate2).reduce((r, _date) => {
|
|
|
|
|
const summaryVal = groupByDate2[_date].reduce((rows, row) => rows + row.orderCount, 0);
|
|
|
|
|
r.push({ ...groupByDate2[_date][0], orderCount: summaryVal });
|
|
|
|
|
return r;
|
|
|
|
|
}, []);
|
|
|
|
|
return { ...json, ordercount1, ordercount2 };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
parseOrderCount = (orderCountData, dateGroup) => {
|
|
|
|
|
resultDataCb(orderCountData, dateGroup, this.orderCountDataMapper, this.orderCountDataFieldMapper, this.onChangeDateGroup);
|
|
|
|
|
};
|
|
|
|
@ -175,9 +205,10 @@ class OrdersStore {
|
|
|
|
|
.then(response => response.json())
|
|
|
|
|
.then(json => {
|
|
|
|
|
runInAction(() => {
|
|
|
|
|
this.orderCountDataRaw = json;
|
|
|
|
|
const data = this.summaryAllWebcode(json);
|
|
|
|
|
this.orderCountDataRaw = data;
|
|
|
|
|
// 第一次得到数据
|
|
|
|
|
this.parseOrderCount(json, 'day');
|
|
|
|
|
this.parseOrderCount(data, 'day');
|
|
|
|
|
this.loading = false;
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|