|
@@ -29,7 +29,7 @@ app.controller('scoreConfigurationPerformanceCtrl', ["$rootScope", "$scope", "$s
|
29
|
29
|
}
|
30
|
30
|
var defaultFilterData = {
|
31
|
31
|
"idx": 0,
|
32
|
|
- "sum": 9999
|
|
32
|
+ "sum": 10
|
33
|
33
|
};
|
34
|
34
|
|
35
|
35
|
$scope.gridOptions = {};
|
|
@@ -66,38 +66,35 @@ app.controller('scoreConfigurationPerformanceCtrl', ["$rootScope", "$scope", "$s
|
66
|
66
|
},
|
67
|
67
|
|
68
|
68
|
{
|
69
|
|
- name: 'incidentCategory.parent.parent.category',
|
|
69
|
+ name: 'parent.parent.category',
|
70
|
70
|
displayName: '一级分类',
|
71
|
71
|
width: '10%',
|
72
|
72
|
enableFiltering: false
|
73
|
73
|
},
|
74
|
74
|
{
|
75
|
|
- name: 'incidentCategory.parent.category',
|
|
75
|
+ name: 'parent.category',
|
76
|
76
|
displayName: '二级分类',
|
77
|
77
|
width: '10%',
|
78
|
78
|
enableFiltering: false
|
79
|
79
|
},
|
80
|
80
|
{
|
81
|
|
- name: 'incidentCategory.category',
|
|
81
|
+ name: 'category',
|
82
|
82
|
displayName: '三级分类',
|
83
|
83
|
width: '10%',
|
84
|
84
|
enableFiltering: false
|
85
|
85
|
},
|
86
|
86
|
{
|
87
|
|
- name: 'incidentCategory.complexity',
|
|
87
|
+ name: 'complexity.value',
|
88
|
88
|
displayName: '默认积分',
|
89
|
89
|
width: '5%',
|
90
|
|
- enableFiltering: false,
|
91
|
|
- cellTemplate: '<div style="line-height:34px;">' +
|
92
|
|
- '<span>{{row.entity.incidentCategory.complexity?row.entity.incidentCategory.complexity.value:0}}</span>' +
|
93
|
|
- '</div>'
|
|
90
|
+ enableFiltering: false
|
94
|
91
|
},
|
95
|
92
|
{
|
96
|
93
|
name: 'five',
|
97
|
94
|
displayName: '积分规则',
|
98
|
95
|
width: '50%',
|
99
|
96
|
enableFiltering: false,
|
100
|
|
- cellTemplate: '<div style="line-height:34px;">' +
|
|
97
|
+ cellTemplate: '<div class="ui-grid-cell-contents">' +
|
101
|
98
|
'<span ng-repeat="item in row.entity.rules">【{{item.startCount}}-{{item.endCount}}单】获得积分{{item.score}};</span>' +
|
102
|
99
|
'</div>'
|
103
|
100
|
},
|
|
@@ -116,6 +113,18 @@ app.controller('scoreConfigurationPerformanceCtrl', ["$rootScope", "$scope", "$s
|
116
|
113
|
//导入gridApi对象
|
117
|
114
|
$scope.gridApi = gridApi;
|
118
|
115
|
|
|
116
|
+ //分页选项
|
|
117
|
+ gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
|
|
118
|
+ var filtersData = {};
|
|
119
|
+ filtersData.idx = newPage - 1;
|
|
120
|
+ filtersData.sum = pageSize;
|
|
121
|
+ $scope.pageNum = $scope.gridApi.pagination.getPage() - 1;
|
|
122
|
+ $scope.fileData.idx = newPage - 1;
|
|
123
|
+ $scope.fileData.sum = pageSize;
|
|
124
|
+ $scope.refreshData('expand-right', $scope.fileData);
|
|
125
|
+
|
|
126
|
+ });
|
|
127
|
+
|
119
|
128
|
//勾选行事件
|
120
|
129
|
gridApi.selection.on.rowSelectionChanged($scope, function (data) {
|
121
|
130
|
if (data.isSelected) {
|
|
@@ -149,43 +158,110 @@ app.controller('scoreConfigurationPerformanceCtrl', ["$rootScope", "$scope", "$s
|
149
|
158
|
|
150
|
159
|
|
151
|
160
|
// 批量修改积分
|
152
|
|
- $scope.edits = function (data) {
|
153
|
|
- console.log(data);
|
|
161
|
+ $scope.edits = function () {
|
154
|
162
|
var modalInstance = $modal.open({
|
155
|
163
|
templateUrl: 'assets/views/scoreConfigurationPerformance-edit.html',
|
156
|
164
|
size: "sm",
|
157
|
|
- controller: function ($scope, $modalInstance) {
|
|
165
|
+ controller: function ($scope, scope, $modalInstance, SweetAlert) {
|
|
166
|
+ console.log(scope.selected.items);
|
|
167
|
+ $scope.incidentComplexity = scope.incidentComplexity;
|
158
|
168
|
$scope.configs = {
|
159
|
|
- defaultScore:0,
|
160
|
|
- configs: []
|
|
169
|
+ defaultScore:null,
|
|
170
|
+ configs: [],
|
|
171
|
+ selectedItems: scope.selected.items,
|
|
172
|
+ refreshData: scope.refreshData,
|
|
173
|
+ fileData: scope.fileData
|
161
|
174
|
};
|
162
|
175
|
// 增加配置
|
163
|
176
|
$scope.addConfig = function(){
|
164
|
|
- $scope.configs.configs.push({startNum: 0, endNum: 0, score: 0});
|
|
177
|
+ $scope.configs.configs.push({startCount: 1, endCount: 1, score: 1});
|
165
|
178
|
}
|
166
|
179
|
// 移除配置
|
167
|
180
|
$scope.removeConfig = function(index){
|
168
|
181
|
$scope.configs.configs.splice(index, 1);
|
169
|
182
|
}
|
170
|
183
|
$scope.ok = function () {
|
171
|
|
- $modalInstance.close(data);
|
|
184
|
+ // 校验
|
|
185
|
+ var flag = true;
|
|
186
|
+ if($scope.configs.configs.length){
|
|
187
|
+ //是否是大于1的正整数
|
|
188
|
+ var isNumberReg = /^[1-9][0-9]*$/;
|
|
189
|
+ $scope.configs.configs.forEach(v => {
|
|
190
|
+ if(!isNumberReg.test(v.startCount) || !isNumberReg.test(v.endCount) || !isNumberReg.test(v.score)){
|
|
191
|
+ flag = false;
|
|
192
|
+ }
|
|
193
|
+ })
|
|
194
|
+ //是否起始 < 终值
|
|
195
|
+ if(flag){
|
|
196
|
+ $scope.configs.configs.forEach(v => {
|
|
197
|
+ if(v.startCount > v.endCount){
|
|
198
|
+ flag = false;
|
|
199
|
+ }
|
|
200
|
+ })
|
|
201
|
+ }
|
|
202
|
+ // 是否有区间交叉
|
|
203
|
+ if(flag){
|
|
204
|
+ let startArr = $scope.configs.configs.map(v => v.startCount);
|
|
205
|
+ let endArr = $scope.configs.configs.map(v => v.endCount);
|
|
206
|
+ for(let i=1;i<startArr.length;i++){
|
|
207
|
+ if (startArr[i] <= endArr[i-1]){
|
|
208
|
+ flag = false;
|
|
209
|
+ break;
|
|
210
|
+ }
|
|
211
|
+ }
|
|
212
|
+ }
|
|
213
|
+ }
|
|
214
|
+ if(!flag){
|
|
215
|
+ SweetAlert.swal({
|
|
216
|
+ title: "提示",
|
|
217
|
+ text: "请正确填写选项!",
|
|
218
|
+ type: "error"
|
|
219
|
+ });
|
|
220
|
+ return;
|
|
221
|
+ }
|
|
222
|
+ $modalInstance.close($scope.configs);
|
172
|
223
|
};
|
173
|
224
|
|
174
|
225
|
$scope.cancel = function () {
|
175
|
226
|
$modalInstance.dismiss('cancel');
|
176
|
227
|
};
|
177
|
228
|
},
|
|
229
|
+ resolve: {
|
|
230
|
+ scope: function(){
|
|
231
|
+ return $scope;
|
|
232
|
+ }
|
|
233
|
+ }
|
178
|
234
|
})
|
179
|
235
|
|
180
|
236
|
modalInstance.result.then(function (result) {
|
181
|
237
|
console.log(result);
|
|
238
|
+ var postData = {
|
|
239
|
+ ids: result.selectedItems.map(v => v.id).toString(),
|
|
240
|
+ removeComplexity: 1,
|
|
241
|
+ removeRules: 1
|
|
242
|
+ }
|
182
|
243
|
if (result) {
|
183
|
|
- api_bpm_data.executeOnce({inspection:data}).then(function (response) {
|
|
244
|
+ api_bpm_data.setScoreRule(postData).then(function (response) {
|
184
|
245
|
if(response.status == 200){
|
185
|
|
- SweetAlert.swal({
|
186
|
|
- title: "操作成功!",
|
187
|
|
- type: "success",
|
188
|
|
- });
|
|
246
|
+ var postData = {
|
|
247
|
+ ids: result.selectedItems.map(v => v.id).toString(),
|
|
248
|
+ complexity: result.defaultScore?result.defaultScore.id:undefined,
|
|
249
|
+ rules: result.configs.length?result.configs:undefined
|
|
250
|
+ }
|
|
251
|
+ api_bpm_data.setScoreRule(postData).then(function (response) {
|
|
252
|
+ if(response.status == 200){
|
|
253
|
+ SweetAlert.swal({
|
|
254
|
+ title: "操作成功!",
|
|
255
|
+ type: "success",
|
|
256
|
+ });
|
|
257
|
+ result.refreshData('expand-right', result.fileData);
|
|
258
|
+ }else{
|
|
259
|
+ SweetAlert.swal({
|
|
260
|
+ title: "操作失败!",
|
|
261
|
+ type: "error",
|
|
262
|
+ });
|
|
263
|
+ }
|
|
264
|
+ })
|
189
|
265
|
}else{
|
190
|
266
|
SweetAlert.swal({
|
191
|
267
|
title: "操作失败!",
|
|
@@ -202,38 +278,106 @@ app.controller('scoreConfigurationPerformanceCtrl', ["$rootScope", "$scope", "$s
|
202
|
278
|
var modalInstance = $modal.open({
|
203
|
279
|
templateUrl: 'assets/views/scoreConfigurationPerformance-edit.html',
|
204
|
280
|
size: "sm",
|
205
|
|
- controller: function ($scope, $modalInstance) {
|
|
281
|
+ controller: function ($scope, scope, $modalInstance, SweetAlert) {
|
|
282
|
+ console.log(scope.selected.items);
|
|
283
|
+ $scope.incidentComplexity = scope.incidentComplexity;
|
206
|
284
|
$scope.configs = {
|
207
|
|
- defaultScore:0,
|
208
|
|
- configs: []
|
|
285
|
+ defaultScore:data.complexity || null,
|
|
286
|
+ configs: data.rules ? data.rules.map(v=>({startCount:v.startCount,endCount:v.endCount,score:v.score})) : [],
|
|
287
|
+ selectedItems: [data],
|
|
288
|
+ refreshData: scope.refreshData,
|
|
289
|
+ fileData: scope.fileData
|
209
|
290
|
};
|
210
|
291
|
// 增加配置
|
211
|
292
|
$scope.addConfig = function(){
|
212
|
|
- $scope.configs.configs.push({startNum: 0, endNum: 0, score: 0});
|
|
293
|
+ $scope.configs.configs.push({startCount: 1, endCount: 1, score: 1});
|
213
|
294
|
}
|
214
|
295
|
// 移除配置
|
215
|
296
|
$scope.removeConfig = function(index){
|
216
|
297
|
$scope.configs.configs.splice(index, 1);
|
217
|
298
|
}
|
218
|
299
|
$scope.ok = function () {
|
219
|
|
- $modalInstance.close(data);
|
|
300
|
+ // 校验
|
|
301
|
+ var flag = true;
|
|
302
|
+ if($scope.configs.configs.length){
|
|
303
|
+ //是否是大于1的正整数
|
|
304
|
+ var isNumberReg = /^[1-9][0-9]*$/;
|
|
305
|
+ $scope.configs.configs.forEach(v => {
|
|
306
|
+ if(!isNumberReg.test(v.startCount) || !isNumberReg.test(v.endCount) || !isNumberReg.test(v.score)){
|
|
307
|
+ flag = false;
|
|
308
|
+ }
|
|
309
|
+ })
|
|
310
|
+ //是否起始 < 终值
|
|
311
|
+ if(flag){
|
|
312
|
+ $scope.configs.configs.forEach(v => {
|
|
313
|
+ if(v.startCount > v.endCount){
|
|
314
|
+ flag = false;
|
|
315
|
+ }
|
|
316
|
+ })
|
|
317
|
+ }
|
|
318
|
+ // 是否有区间交叉
|
|
319
|
+ if(flag){
|
|
320
|
+ let startArr = $scope.configs.configs.map(v => v.startCount);
|
|
321
|
+ let endArr = $scope.configs.configs.map(v => v.endCount);
|
|
322
|
+ for(let i=1;i<startArr.length;i++){
|
|
323
|
+ if (startArr[i] <= endArr[i-1]){
|
|
324
|
+ flag = false;
|
|
325
|
+ break;
|
|
326
|
+ }
|
|
327
|
+ }
|
|
328
|
+ }
|
|
329
|
+ }
|
|
330
|
+ if(!flag){
|
|
331
|
+ SweetAlert.swal({
|
|
332
|
+ title: "提示",
|
|
333
|
+ text: "请正确填写选项!",
|
|
334
|
+ type: "error"
|
|
335
|
+ });
|
|
336
|
+ return;
|
|
337
|
+ }
|
|
338
|
+ $modalInstance.close($scope.configs);
|
220
|
339
|
};
|
221
|
340
|
|
222
|
341
|
$scope.cancel = function () {
|
223
|
342
|
$modalInstance.dismiss('cancel');
|
224
|
343
|
};
|
225
|
344
|
},
|
|
345
|
+ resolve: {
|
|
346
|
+ scope: function(){
|
|
347
|
+ return $scope;
|
|
348
|
+ }
|
|
349
|
+ }
|
226
|
350
|
})
|
227
|
351
|
|
228
|
352
|
modalInstance.result.then(function (result) {
|
229
|
353
|
console.log(result);
|
|
354
|
+ var postData = {
|
|
355
|
+ ids: result.selectedItems.map(v => v.id).toString(),
|
|
356
|
+ removeComplexity: 1,
|
|
357
|
+ removeRules: 1
|
|
358
|
+ }
|
230
|
359
|
if (result) {
|
231
|
|
- api_bpm_data.executeOnce({inspection:data}).then(function (response) {
|
|
360
|
+ api_bpm_data.setScoreRule(postData).then(function (response) {
|
232
|
361
|
if(response.status == 200){
|
233
|
|
- SweetAlert.swal({
|
234
|
|
- title: "操作成功!",
|
235
|
|
- type: "success",
|
236
|
|
- });
|
|
362
|
+ var postData = {
|
|
363
|
+ ids: result.selectedItems.map(v => v.id).toString(),
|
|
364
|
+ complexity: result.defaultScore?result.defaultScore.id:undefined,
|
|
365
|
+ rules: result.configs.length?result.configs:undefined
|
|
366
|
+ }
|
|
367
|
+ api_bpm_data.setScoreRule(postData).then(function (response) {
|
|
368
|
+ if(response.status == 200){
|
|
369
|
+ SweetAlert.swal({
|
|
370
|
+ title: "操作成功!",
|
|
371
|
+ type: "success",
|
|
372
|
+ });
|
|
373
|
+ result.refreshData('expand-right', result.fileData);
|
|
374
|
+ }else{
|
|
375
|
+ SweetAlert.swal({
|
|
376
|
+ title: "操作失败!",
|
|
377
|
+ type: "error",
|
|
378
|
+ });
|
|
379
|
+ }
|
|
380
|
+ })
|
237
|
381
|
}else{
|
238
|
382
|
SweetAlert.swal({
|
239
|
383
|
title: "操作失败!",
|
|
@@ -251,7 +395,6 @@ app.controller('scoreConfigurationPerformanceCtrl', ["$rootScope", "$scope", "$s
|
251
|
395
|
|
252
|
396
|
//重置按钮
|
253
|
397
|
$scope.reload = function () {
|
254
|
|
- this.one_cates = [];
|
255
|
398
|
this.two_cates = [];
|
256
|
399
|
delete $scope.fileData.incidentcategory.oneCate;
|
257
|
400
|
delete $scope.fileData.incidentcategory.twoCate;
|
|
@@ -270,34 +413,23 @@ app.controller('scoreConfigurationPerformanceCtrl', ["$rootScope", "$scope", "$s
|
270
|
413
|
|
271
|
414
|
var postData = angular.copy(filterData);
|
272
|
415
|
if(postData.incidentcategory.twoCate){
|
273
|
|
- postData.incidentcategory.categoryid = postData.incidentcategory.twoCate.id;
|
|
416
|
+ postData.incidentcategory.id = postData.incidentcategory.twoCate.id;
|
|
417
|
+ postData.incidentcategory.cascade = true;
|
274
|
418
|
delete postData.incidentcategory.oneCate;
|
275
|
419
|
delete postData.incidentcategory.twoCate;
|
276
|
420
|
}else if(postData.incidentcategory.oneCate){
|
277
|
|
- postData.incidentcategory.categoryid = postData.incidentcategory.oneCate.id;
|
|
421
|
+ postData.incidentcategory.id = postData.incidentcategory.oneCate.id;
|
|
422
|
+ postData.incidentcategory.cascade = true;
|
278
|
423
|
delete postData.incidentcategory.oneCate;
|
279
|
424
|
}
|
|
425
|
+ postData.incidentcategory.selectType = 'three';
|
|
426
|
+ postData.incidentcategory.rules = [];
|
280
|
427
|
|
281
|
428
|
api_bpm_data.fetchDataList('incidentcategory', postData).then(function (data) {
|
282
|
429
|
var myData = Restangular.stripRestangular(data);
|
283
|
430
|
$scope.gridOptions.totalItems = myData.totalNum;
|
284
|
431
|
if (angular.isArray(myData.list)) {
|
285
|
432
|
$scope.myData = myData.list;
|
286
|
|
- var arr = [];
|
287
|
|
- $scope.myData.forEach(v => {
|
288
|
|
- // 判断arr数组里是否有该事件分类
|
289
|
|
- let index = arr.findIndex(vv => vv.id == v.categoryid);
|
290
|
|
- if(index > -1){
|
291
|
|
- arr[index].rules.push(v);
|
292
|
|
- }else{
|
293
|
|
- arr.push({
|
294
|
|
- id: v.categoryid,
|
295
|
|
- incidentCategory: v.incidentCategory,
|
296
|
|
- rules: [v]
|
297
|
|
- })
|
298
|
|
- }
|
299
|
|
- })
|
300
|
|
- $scope.myData = arr;
|
301
|
433
|
for (var i = 0; i < $scope.myData.length; i++) {
|
302
|
434
|
$scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
|
303
|
435
|
}
|
|
@@ -323,34 +455,23 @@ app.controller('scoreConfigurationPerformanceCtrl', ["$rootScope", "$scope", "$s
|
323
|
455
|
|
324
|
456
|
var postData = angular.copy(filterData);
|
325
|
457
|
if(postData.incidentcategory.twoCate){
|
326
|
|
- postData.incidentcategory.categoryid = postData.incidentcategory.twoCate.id;
|
|
458
|
+ postData.incidentcategory.id = postData.incidentcategory.twoCate.id;
|
|
459
|
+ postData.incidentcategory.cascade = true;
|
327
|
460
|
delete postData.incidentcategory.oneCate;
|
328
|
461
|
delete postData.incidentcategory.twoCate;
|
329
|
462
|
}else if(postData.incidentcategory.oneCate){
|
330
|
|
- postData.incidentcategory.categoryid = postData.incidentcategory.oneCate.id;
|
|
463
|
+ postData.incidentcategory.id = postData.incidentcategory.oneCate.id;
|
|
464
|
+ postData.incidentcategory.cascade = true;
|
331
|
465
|
delete postData.incidentcategory.oneCate;
|
332
|
466
|
}
|
|
467
|
+ postData.incidentcategory.selectType = 'three';
|
|
468
|
+ postData.incidentcategory.rules = [];
|
333
|
469
|
|
334
|
470
|
api_bpm_data.fetchDataList('incidentcategory', postData).then(function (data) {
|
335
|
471
|
var myData = Restangular.stripRestangular(data);
|
336
|
472
|
$scope.gridOptions.totalItems = myData.totalNum;
|
337
|
473
|
if (angular.isArray(myData.list)) {
|
338
|
474
|
$scope.myData = myData.list;
|
339
|
|
- var arr = [];
|
340
|
|
- $scope.myData.forEach(v => {
|
341
|
|
- // 判断arr数组里是否有该事件分类
|
342
|
|
- let index = arr.findIndex(vv => vv.id == v.categoryid);
|
343
|
|
- if(index > -1){
|
344
|
|
- arr[index].rules.push(v);
|
345
|
|
- }else{
|
346
|
|
- arr.push({
|
347
|
|
- id: v.categoryid,
|
348
|
|
- incidentCategory: v.incidentCategory,
|
349
|
|
- rules: [v]
|
350
|
|
- })
|
351
|
|
- }
|
352
|
|
- })
|
353
|
|
- $scope.myData = arr;
|
354
|
475
|
for (var i = 0; i < $scope.myData.length; i++) {
|
355
|
476
|
$scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
|
356
|
477
|
}
|
|
@@ -371,12 +492,23 @@ app.controller('scoreConfigurationPerformanceCtrl', ["$rootScope", "$scope", "$s
|
371
|
492
|
$scope.ldloading = {};
|
372
|
493
|
$scope.fileData = {
|
373
|
494
|
"idx": 0,
|
374
|
|
- "sum": 9999,
|
|
495
|
+ "sum": 10,
|
375
|
496
|
"incidentcategory": {}
|
376
|
497
|
}
|
377
|
498
|
$scope.searchinspe = function () {
|
378
|
499
|
$scope.refreshData('expand-right', $scope.fileData);
|
379
|
500
|
}
|
|
501
|
+ // 获取默认积分
|
|
502
|
+ $scope.incidentComplexity = [];
|
|
503
|
+ $scope.getIncidentComplexity = function () {
|
|
504
|
+ api_wechatfile.getDictionary({
|
|
505
|
+ key: "incident_complexity",
|
|
506
|
+ type: "list"
|
|
507
|
+ }).then(function (res) {
|
|
508
|
+ $scope.incidentComplexity = res;
|
|
509
|
+ })
|
|
510
|
+ }
|
|
511
|
+ $scope.getIncidentComplexity();
|
380
|
512
|
// 获取一级分类
|
381
|
513
|
$scope.getOneCates = function (keyword='') {
|
382
|
514
|
$scope.one_cates = [];
|