根据已有数据,对其进行重新组合,根据 tranDate 日期进行按月份分组,效果如下图所示。
// 重组缴费记录
.factory('pushRecord', function (getImgURL) {
var factory = {
};
factory.reorganization = function (details,length) {
var monthData = []; // 缴费记录月份存量
var item = angular.copy(details);
var detailsData = []; // 缴费记录月份数组
// 月份压入栈 -- 集合
for(var j=0;j<details.length;j++){
if (monthData.indexOf(item[j].tranDate.substr(0, 6)) < 0) {
monthData.push(item[j].tranDate.substr(0, 6));
}
}
// console.log(monthData);
// 月份下记录压入组合
for(var i=0;i<monthData.length;i++){
var combinationItem = {
'monthDataValue': '',
'yearMonth': '',
'detailsDataValue': []
};
combinationItem.monthDataValue = monthData[i];
combinationItem.yearMonth = monthData[i].substr(0, 4) + '年'
+ monthData[i].substr(4, 2) + '月';
combinationItem.showOrHide = true;
combinationItem.expenditure = 0;
combinationItem.income