|
@@ -52,10 +52,10 @@ $(document).ready(function() {
|
|
|
};
|
|
|
expensesPieChart.setOption(expensesPieOption);
|
|
|
|
|
|
- // 按create_time月份整理expensesList数据
|
|
|
+ // 按pay_time月份整理expensesPayList数据
|
|
|
const expensesBarDatas = [];
|
|
|
- for (const expenses of expensesList) {
|
|
|
- const yearMonth = moment(expenses.create_time).format('YYYY年MM月');
|
|
|
+ for (const expenses of expensesPayList) {
|
|
|
+ const yearMonth = moment(expenses.pay_time).format('YYYY年MM月');
|
|
|
const ymExpenses = _.find(expensesBarDatas, { yearMonth });
|
|
|
if (ymExpenses) {
|
|
|
ymExpenses.yf_price = ZhCalc.add(ymExpenses.yf_price, expenses.yf_price);
|
|
@@ -66,6 +66,9 @@ $(document).ready(function() {
|
|
|
for (const e of expensesBarDatas) {
|
|
|
e.rate = ZhCalc.round(ZhCalc.div(e.yf_price, prices.expenses_total_price) * 100, 2);
|
|
|
}
|
|
|
+ expensesBarDatas.sort((a, b) => {
|
|
|
+ return moment(a.yearMonth, 'YYYY年MM月').diff(moment(b.yearMonth, 'YYYY年MM月'));
|
|
|
+ });
|
|
|
console.log(expensesBarDatas);
|
|
|
|
|
|
const expensesBarChart = echarts.init(document.getElementById('expensesBarChart'));
|
|
@@ -183,8 +186,8 @@ $(document).ready(function() {
|
|
|
incomePieChart.setOption(incomePieOption);
|
|
|
|
|
|
const incomeBarDatas = [];
|
|
|
- for (const income of incomeList) {
|
|
|
- const yearMonth = moment(income.create_time).format('YYYY年MM月');
|
|
|
+ for (const income of incomePayList) {
|
|
|
+ const yearMonth = moment(income.pay_time).format('YYYY年MM月');
|
|
|
const ymIncome = _.find(incomeBarDatas, { yearMonth });
|
|
|
if (ymIncome) {
|
|
|
ymIncome.yf_price = ZhCalc.add(ymIncome.yf_price, income.yf_price);
|
|
@@ -195,6 +198,10 @@ $(document).ready(function() {
|
|
|
for (const i of incomeBarDatas) {
|
|
|
i.rate = ZhCalc.round(ZhCalc.div(i.yf_price, prices.income_total_price) * 100, 2);
|
|
|
}
|
|
|
+ // 按日期排序
|
|
|
+ incomeBarDatas.sort((a, b) => {
|
|
|
+ return moment(a.yearMonth, 'YYYY年MM月').diff(moment(b.yearMonth, 'YYYY年MM月'));
|
|
|
+ });
|
|
|
console.log(incomeBarDatas);
|
|
|
|
|
|
const incomeBarChart = echarts.init(document.getElementById('incomeBarChart'));
|