|
@@ -8,8 +8,9 @@
|
|
|
};
|
|
|
$scope.op = $stateParams.op;
|
|
|
$scope.yearList = []
|
|
|
- $scope.sumScore = 0;
|
|
|
- $scope.sumItemScore = 0;
|
|
|
+ $scope.totalScore = 0;
|
|
|
+ $scope.totalItemScore = 0;
|
|
|
+ $scope.templateElementList = []
|
|
|
|
|
|
//选择党委
|
|
|
$scope.partyConfig = {
|
|
@@ -27,10 +28,23 @@
|
|
|
$scope.dataModel.dzzmc = $scope.partyConfig.selectedText;
|
|
|
}
|
|
|
}, true);
|
|
|
+
|
|
|
$scope.selectParty = function () {
|
|
|
$partySelect.showModal();
|
|
|
};
|
|
|
|
|
|
+ $scope.getYearList = function () {
|
|
|
+ $http({
|
|
|
+ method: 'get',
|
|
|
+ url: '../../api/jcdzzpb/assestemplate/getYearList',
|
|
|
+ params: {}
|
|
|
+ }).then(function (result) {
|
|
|
+ $scope.yearList = result.data.item;
|
|
|
+ }, function (resp) {
|
|
|
+
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
//获取数据
|
|
|
$scope.getById = function () {
|
|
|
$http.get("../../api/jcdzzpb/assesconfirm/get", {
|
|
@@ -44,33 +58,15 @@
|
|
|
}
|
|
|
|
|
|
$scope.dataModel = result.data.item;
|
|
|
- $scope.getSumScore();
|
|
|
+ $scope.mergenRow($scope.dataModel.itemScoreList);
|
|
|
+ $scope.totalItemScore = $scope.sumScore($scope.dataModel.itemScoreList, function (x){
|
|
|
+ return isNaN(x.itemScore) ? 0 : x.itemScore;
|
|
|
+ })
|
|
|
}, function () {
|
|
|
$scope.showMsg('错误', '服务器错误');
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- $scope.getYearList = function () {
|
|
|
- $http({
|
|
|
- method: 'get',
|
|
|
- url: '../../api/jcdzzpb/assestemplate/getYearList',
|
|
|
- params: {}
|
|
|
- }).then(function (result) {
|
|
|
- $scope.yearList = result.data.item;
|
|
|
- }, function (resp) {
|
|
|
-
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- $scope.getSumScore = function (){
|
|
|
- $scope.sumScore = 0;
|
|
|
- $scope.sumItemScore = 0;
|
|
|
- $scope.dataModel.itemScoreList.forEach(x=>{
|
|
|
- $scope.sumScore += x.score;
|
|
|
- $scope.sumItemScore += x.itemScore;
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
$scope.checkYear = function () {
|
|
|
let id = $scope.yearList.find(x=>x.year == $scope.dataModel.year).id;
|
|
|
$http.get("../../api/jcdzzpb/assestemplate/get", {
|
|
@@ -90,12 +86,60 @@
|
|
|
x.assesTemplateItemId=x.id;
|
|
|
x.id='';
|
|
|
})
|
|
|
- $scope.getSumScore();
|
|
|
+ $scope.mergenRow($scope.dataModel.itemScoreList);
|
|
|
+ $scope.totalItemScore = $scope.sumScore($scope.dataModel.itemScoreList, function (x){
|
|
|
+ return isNaN(x.itemScore) ? 0 : x.itemScore;
|
|
|
+ })
|
|
|
}, function () {
|
|
|
$scope.showMsg('错误', '服务器错误');
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ $scope.mergenRow = function (sourceData) {
|
|
|
+ var list = [];
|
|
|
+ angular.forEach(sourceData, function (item) {
|
|
|
+ var filterData = list.filter(function (x) {
|
|
|
+ return x.itemName == item.itemName;
|
|
|
+ });
|
|
|
+ if (filterData.length == 0) {
|
|
|
+ list.push({
|
|
|
+ itemName: item.itemName,
|
|
|
+ itemList: [item]
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ filterData[0].itemList.push(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ angular.forEach(list, function (item) {
|
|
|
+ item.subTotalItemScore = $scope.sumScore(item.itemList, function (x) {
|
|
|
+ return isNaN(x.itemScore) ? 0 : x.itemScore;
|
|
|
+ })
|
|
|
+ item.itemListLength = item.itemList.length;
|
|
|
+ })
|
|
|
+ $scope.templateElementList = list;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.$watch("templateElementList", function (p1, p2) {
|
|
|
+ if (p1 != undefined && p1.length > 0) {
|
|
|
+ let resultData = [];
|
|
|
+ p1.forEach(function (item) {
|
|
|
+ resultData = resultData.concat(item.itemList);
|
|
|
+ });
|
|
|
+ $scope.totalScore = $scope.sumScore(resultData, function (x) {
|
|
|
+ return isNaN(x.score) ? 0 : x.score;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }, true);
|
|
|
+
|
|
|
+ $scope.sumScore = function (list, func) {
|
|
|
+ if (list != undefined && list.length > 0) {
|
|
|
+ return list.map(func).reduce(function (x, y) {
|
|
|
+ return x + y;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$scope.submitData = function (isflag) {
|
|
|
if (!isflag) {
|
|
|
$scope.showMsg('提示', '请填写相关信息');
|
|
@@ -103,11 +147,27 @@
|
|
|
}
|
|
|
|
|
|
//数据验证
|
|
|
- if ($scope.dataModel.itemScoreList.length <= 0) {
|
|
|
+ if ($scope.templateElementList.length <= 0) {
|
|
|
$scope.showMsg('错误', '请添加考核项目');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ let resultData = [];
|
|
|
+ $scope.templateElementList.forEach(function (item) {
|
|
|
+ resultData = resultData.concat(item.itemList);
|
|
|
+ });
|
|
|
+
|
|
|
+ let filterDate = resultData.filter(function (item) {
|
|
|
+ return item.score < 0 || item.score > item.itemScore;
|
|
|
+ });
|
|
|
+
|
|
|
+ if (filterDate.length > 0) {
|
|
|
+ $scope.showMsg('提示', "评分不能大于分值");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.dataModel.itemScoreList = resultData;
|
|
|
+
|
|
|
//保存
|
|
|
if (confirm("确定提交?")) {
|
|
|
$loading.show();
|