Pārlūkot izejas kodu

绩效积分配置

seimin 2 gadi atpakaļ
vecāks
revīzija
ed35f8f306

+ 200 - 68
assets/js/controllers/performance/scoreConfigurationPerformanceCtrl.js

@@ -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 = [];

+ 4 - 0
assets/js/main.js

@@ -947,6 +947,10 @@ app.factory('api_bpm_data', ['BpmRestangular', function (BpmRestangular) {
947 947
     var inspectionProcessActual = BpmRestangular.all("InspectionProcessActual");
948 948
     var solutionService = BpmRestangular.all("solution");
949 949
     return {
950
+        // 设置服务台积分规则
951
+        setScoreRule: function (data) {
952
+            return dataService.customPOST(data, 'setScoreRule');
953
+        },
950 954
         // 服务台绩效
951 955
         serviceCount: function (data) {
952 956
             return dataService.customPOST(data, 'serviceCount');

+ 1 - 1
assets/views/performance/scoreConfigurationPerformance.html

@@ -71,7 +71,7 @@
71 71
     </div>
72 72
     <div class="tableList" ui-i18n="{{lang}}">
73 73
         <div>
74
-            <div id="grid1 " ui-grid="gridOptions" external-scopes="$scope" ui-grid-resize-columns ui-grid-selection ui-grid-auto-resize class="grid">
74
+            <div id="grid1 " ui-grid="gridOptions" ui-grid-pagination external-scopes="$scope" ui-grid-resize-columns ui-grid-selection ui-grid-auto-resize class="grid">
75 75
             </div>
76 76
         </div>
77 77
     </div>

+ 12 - 5
assets/views/scoreConfigurationPerformance-edit.html

@@ -6,12 +6,19 @@
6 6
 </div>
7 7
 <div class="modal-body center">
8 8
     <div class="col-xs-12 padding-top-15 padding-bottom-15 padding-left-5 padding-right-5">
9
-        <div class="col-xs-6 no-padding text-left">
9
+        <div class="col-xs-6 no-padding text-left" style="display: flex;align-items:center;">
10 10
             <div class="col-xs-5 no-padding">
11 11
                 默认积分:
12 12
             </div>
13 13
             <div class="col-xs-7 no-padding">
14
-                <input type="number" min="0" max="999" style="width: 100%;" ng-model="configs.defaultScore">
14
+                <ui-select style="width: 100%;" ng-model="configs.defaultScore" theme="bootstrap">
15
+                    <ui-select-match placeholder="" allow-clear>
16
+                        {{$select.selected.value}}
17
+                    </ui-select-match>
18
+                    <ui-select-choices repeat="item in incidentComplexity">
19
+                        <div ng-bind-html="item.value | highlight: $select.search"></div>
20
+                    </ui-select-choices>
21
+                </ui-select>
15 22
             </div>
16 23
         </div>
17 24
         <div class="col-xs-6 no-padding text-right">
@@ -24,7 +31,7 @@
24 31
                 起值:
25 32
             </div>
26 33
             <div class="col-xs-7 no-padding">
27
-                <input type="number" min="0" max="{{config.endNum}}" style="width: 100%;" ng-model="config.startNum">
34
+                <input type="number" min="1" max="999" step="1" style="width: 100%;" ng-model="config.startCount">
28 35
             </div>
29 36
         </div>
30 37
         <div class="col-xs-3 no-padding">
@@ -32,7 +39,7 @@
32 39
                 终值:
33 40
             </div>
34 41
             <div class="col-xs-7 no-padding">
35
-                <input type="number" min="{{config.startNum}}" max="999" style="width: 100%;" ng-model="config.endNum">
42
+                <input type="number" min="1" max="999" step="1" style="width: 100%;" ng-model="config.endCount">
36 43
             </div>
37 44
         </div>
38 45
         <div class="col-xs-3 no-padding">
@@ -40,7 +47,7 @@
40 47
                 积分:
41 48
             </div>
42 49
             <div class="col-xs-7 no-padding">
43
-                <input type="number" min="0" max="999" style="width: 100%;" ng-model="config.score">
50
+                <input type="number" min="1" max="999" step="1" style="width: 100%;" ng-model="config.score">
44 51
             </div>
45 52
         </div>
46 53
         <div class="col-xs-3 no-padding text-right">