Displays value as filter AngularJS

0

ImadeapagetoqueryrecordsandIhavetwofieldssearchbynameandsearchbyinitialmonthandfinalmonth.Example:IwouldliketoselectthemonthsandadivtodisplaythetotalvalueoftheServiceOrdersforthatmonth(accordingtoexampleimage)...ifsomeonecanhelpwithanexample.

// Funcao que esta exibindo o valor Total de Ordem de servicos na div 
$scope.GetTotal = function() {
  var total = 0;
  for (var i = 0; i < $scope.ordens.length; i++) {
    var relatorio = $scope.ordens[i];
    total += parseFloat(relatorio.ordemValor);
  }
  return total;
};



/* Consulta OS por data - filtros */
angular.module("App").filter("betweenDate", function($filter) {
  return function(collection, column, startDate, endDate) {
    var new_collection = [];
    moment(startDate)
      .startOf("month")
      .format("YYYY-MM");
    moment(endDate)
      .startOf("month")
      .format("YYYY-MM");
    if (angular.isDefined(startDate) && angular.isDefined(endDate)) {
      if (startDate != "" && endDate != "") {
        if (angular.isDefined(startDate)) {
          startDate = $filter("date")(startDate, "yyyy-MM");
          //Date.parse($filter('date')(startDate, 'yyyy-MM'));
        }
        if (angular.isDefined(endDate)) {
          endDate = $filter("date")(endDate, "yyyy-MM");
          //Date.parse($filter('date')(endDate, 'yyyy-MM'));
        }
        angular.forEach(collection, function(value, index) {
          var obj = value[column];
          var currentDate = $filter("date")(obj, "yyyy-MM");
          //Date.parse($filter('date')(obj, 'yyyy-MM'));
          if (currentDate >= startDate && endDate >= currentDate) {
            new_collection.push(value);
          }
        });
      } else {
        new_collection = collection;
      }
      collection = new_collection;
    }
    return collection;
  };
});
<tr ng-repeat="ordem in ordens | filter: criterioDeBusca | orderBy:'-ordemData' | betweenDate:'ordemData':startDate:endDate | dateRange:'ordemData':startDate:endDate" ng-if="ordem.ordemStatus == 'ABERTO'"></tr>
    
asked by anonymous 09.10.2018 / 20:35

0 answers