68 lines
2.1 KiB
JavaScript
68 lines
2.1 KiB
JavaScript
|
|
|
|
app.controller('SamplingTabCtrl', ['$scope', 'YPJBXXGL', 'wyCYDData', function ($scope, YPJBXXGL, wyCYDData) {
|
|
// $scope.data = "这是采样点覆盖页面";
|
|
$scope.myData = [];
|
|
wyCYDData.getData().then(function (data) {
|
|
$scope.myData = data
|
|
})
|
|
//增加日志20211109
|
|
addlog("采样点覆盖", "查询[采样点覆盖]")
|
|
}])
|
|
|
|
|
|
|
|
//这个service是用于获取当前年份的计划件数和采样件数完成件数的接口数据
|
|
app.service('wyCYDData', function ($http, $q, $timeout) {
|
|
this.getData = function () {
|
|
var deferred = $q.defer();
|
|
var Year = ["2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016"];//表格年份
|
|
var mydata = [];
|
|
angular.forEach(Year, function (data2) {
|
|
|
|
var aa = {
|
|
YEAR: "",
|
|
LT:0,
|
|
SC: 0,
|
|
CY: 0,
|
|
HJ: 0
|
|
}
|
|
var jcddata = pubserver + "YPJBXXGL_DB?$filter=" + "RWNF eq '" + data2 + "' &$select=CYDD";
|
|
$http.get(jcddata, {}).success(function (data3) {
|
|
if (data3.value.length > 0) {
|
|
var dd = Enumerable.From(data3.value);
|
|
aa.YEAR = data2;
|
|
aa.LT = dd.Where(function (x) { return x.CYDD == "流通环节" }).Count();
|
|
aa.SC = dd.Where(function (x) { return x.CYDD == "生产环节" }).Count();
|
|
aa.CY = dd.Where(function (x) { return x.CYDD == "餐饮环节" }).Count();
|
|
aa.HJ = aa.LT + aa.SC + aa.CY;
|
|
}
|
|
else {
|
|
aa.YEAR = data2;
|
|
aa.LT = 0;
|
|
aa.SC = 0;
|
|
aa.CY = 0
|
|
aa.HJ = 0;
|
|
}
|
|
})
|
|
mydata.push(aa);
|
|
})
|
|
|
|
|
|
|
|
$timeout(function () {
|
|
|
|
deferred.resolve(mydata);
|
|
}, 2000)
|
|
|
|
return deferred.promise;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|