import { clone } from "lodash";

export default (datas, columns, vm) => {
	let subTotal = {
		_subTotal_row: true
	};
	for (let dataIndex in Object.keys(datas)) {
		for (let [index, column] of columns.entries()) {
			//小计
			if (column.cellRendererParams && column.cellRendererParams.subTotal) {
				if (!subTotal[column.field]) {
					subTotal[column.field] = 0;
				}
				if (typeof column.cellRendererParams.subTotal === 'string') {
					subTotal[column.field] = column.cellRendererParams.subTotal;
				} else {
					subTotal[column.field] += datas[dataIndex][column.field];
				}
			}
		}
	}
	return { subTotal };
};
