Export Monthly Inventory
This commit is contained in:
@@ -3,10 +3,14 @@
|
||||
|
||||
window.app.controller('MovementReportController', MovementReportController);
|
||||
|
||||
MovementReportController.$inject = ['$scope', 'reportSvc'];
|
||||
function MovementReportController($scope, reportSvc) {
|
||||
MovementReportController.$inject = ['$scope', 'reportSvc', 'downloadSvc'];
|
||||
function MovementReportController($scope, reportSvc, downloadSvc) {
|
||||
var vm = this;
|
||||
vm.loadData = reportSvc.loadMovementData;
|
||||
vm.movementData = reportSvc.movementData;
|
||||
vm.export = function(month) {
|
||||
reportSvc.exportMovementData({month: month})
|
||||
.success(downloadSvc.success);
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -10,7 +10,8 @@
|
||||
distributionData: distributionData,
|
||||
loadDistributionReport: loadDistributionReport,
|
||||
movementData: movementData,
|
||||
loadMovementData: loadMovementData
|
||||
loadMovementData: loadMovementData,
|
||||
exportMovementData: exportMovementData
|
||||
};
|
||||
|
||||
return svc;
|
||||
@@ -28,5 +29,9 @@
|
||||
angular.copy(data, movementData);
|
||||
});
|
||||
}
|
||||
|
||||
function exportMovementData(query) {
|
||||
return $http.post('/Report/MovementExcel', query, { responseType: 'arraybuffer' });
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,17 @@
|
||||
(function () {
|
||||
window.app.factory('downloadSvc', downloadSvc);
|
||||
|
||||
downloadSvc.$inject = ['$http'];
|
||||
function downloadSvc($http) {
|
||||
|
||||
var svc = {
|
||||
success: function (data, status, headers, config) {
|
||||
var file = new Blob([data], { type: headers('Content-Type') });
|
||||
var match = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(headers('Content-Disposition'));
|
||||
saveAs(file, match[1]);
|
||||
}
|
||||
};
|
||||
|
||||
return svc;
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user