zhuguifei
2025-04-28 0218ec09998552d392b7ff622eb3a76795b11c32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
/*
 * Activiti Modeler component part of the Activiti project
 * Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
/*
 * Assignment
 */
 
 
var KisBpmAssignmentCtrl = ['$scope', '$modal', '$http', function ($scope, $modal, $http) {
 
    // Config for the modal window
    var opts = {
        template: 'editor-app/configuration/properties/assignment-popup.html?version=' + Date.now(),
        scope: $scope
    };
 
    // Open the dialog
    $modal(opts);
}];
 
var KisBpmAssignmentPopupCtrl = ['$scope', '$modal', '$http', function ($scope, $modal, $http) {
 
 
    // Put json representing assignment on scope
    if ($scope.property.value !== undefined && $scope.property.value !== null
        && $scope.property.value.assignment !== undefined
        && $scope.property.value.assignment !== null) {
        $scope.assignment = $scope.property.value.assignment;
    } else {
        $scope.assignment = {};
    }
 
    if ($scope.assignment.candidateUsers == undefined || $scope.assignment.candidateUsers.length == 0) {
        $scope.assignment.candidateUsers = [{value: ''}];
    }
 
 
    if ($scope.assignment.assignee == undefined || $scope.assignment.assignee == '') {
        $scope.assignment.assignee = '';
    }
 
    // Click handler for + button after enum value
    var userValueIndex = 1;
    $scope.addCandidateUserValue = function (index) {
        $scope.assignment.candidateUsers.splice(index + 1, 0, {value: 'value ' + userValueIndex++});
    };
 
    // Click handler for - button after enum value
    $scope.removeCandidateUserValue = function (index) {
        $scope.assignment.candidateUsers.splice(index, 1);
    };
 
    if ($scope.assignment.candidateGroups == undefined || $scope.assignment.candidateGroups.length == 0) {
        $scope.assignment.candidateGroups = [{value: ''}];
    }
 
    var groupValueIndex = 1;
    $scope.addCandidateGroupValue = function (index) {
        $scope.assignment.candidateGroups.splice(index + 1, 0, {value: 'value ' + groupValueIndex++});
    };
 
    // Click handler for - button after enum value
    $scope.removeCandidateGroupValue = function (index) {
        $scope.assignment.candidateGroups.splice(index, 1);
    };
 
    //Open the dialog to select users
    $scope.choseAssignment = function (flag) {
        var opts = {
            template: 'editor-app/configuration/properties/assignment-popup-popup.html?version=' + Date.now(),
            scope: $scope
        };
        $scope.choseAssignmentFlag = flag;
        // Open the dialog
        $modal(opts);
    };
 
    //Open the dialog to select candidateGroups
    $scope.choseCandidateGroups = function () {
        var opts = {
            template: 'editor-app/configuration/properties/assignment-candidateGroup.html?version=' + Date.now(),
            scope: $scope
        };
        // Open the dialog
        $modal(opts);
    };
 
    $scope.dynCandidateUser = function (position) {
        $scope.assignment.assignee = "${" + position.code + "}";
        $scope.assignment.assigneeshowname = position.name;
        if (typeof $scope.property.value === 'string') {
            $scope.property.value = {};
        }
        $scope.property.value.assignment = $scope.assignment;
        $scope.updatePropertyInModel($scope.property);
        $scope.close();
    };
 
    $scope.save = function () {
        $scope.property.value = {};
        handleAssignmentInput($scope);
        $scope.property.value.assignment = $scope.assignment;
        $scope.updatePropertyInModel($scope.property);
        $scope.close();
    };
 
    // Close button handler
    $scope.close = function () {
        handleAssignmentInput($scope);
        $scope.property.mode = 'read';
        $scope.$hide();
    };
 
    var handleAssignmentInput = function ($scope) {
        if ($scope.assignment.candidateUsers) {
            var emptyUsers = true;
            var toRemoveIndexes = [];
            for (var i = 0; i < $scope.assignment.candidateUsers.length; i++) {
                if ($scope.assignment.candidateUsers[i].value != '') {
                    emptyUsers = false;
                } else {
                    toRemoveIndexes[toRemoveIndexes.length] = i;
                }
            }
 
            for (var i = 0; i < toRemoveIndexes.length; i++) {
                $scope.assignment.candidateUsers.splice(toRemoveIndexes[i], 1);
            }
 
            if (emptyUsers) {
                $scope.assignment.candidateUsers = undefined;
            }
        }
 
        if ($scope.assignment.candidateGroups) {
            var emptyGroups = true;
            var toRemoveIndexes = [];
            for (var i = 0; i < $scope.assignment.candidateGroups.length; i++) {
                if ($scope.assignment.candidateGroups[i].value != '') {
                    emptyGroups = false;
                } else {
                    toRemoveIndexes[toRemoveIndexes.length] = i;
                }
            }
 
            for (var i = 0; i < toRemoveIndexes.length; i++) {
                $scope.assignment.candidateGroups.splice(toRemoveIndexes[i], 1);
            }
 
            if (emptyGroups) {
                $scope.assignment.candidateGroups = undefined;
            }
        }
    };
 
    //因新打开的界面上选定的数据要传输到当前modal中,所以使用此方式,这是angular.js中不同控制器之间传输数据的方式
    $scope.$on('choseAssigneesStr', function (event, data, nameData) {
        var infos = data.split(",");
        var nameInfos = nameData.split(",");
        // $scope.assignment.candidateUsers= [];
        for (var i = 0; i < infos.length; i++) {
            $scope.assignment.candidateUsers.push({value: infos[i], nameValue: nameInfos[i]});
            // $scope.assignment.candidateUsers[i].value = infos[i];
        }
        //清空第一个
        if ((!$scope.assignment.candidateUsers[0].value) || $scope.assignment.candidateUsers[0] == '') {
            //清空第一个元素
            $scope.assignment.candidateUsers.splice(0, 1);
        }
    });
    $scope.$on('choseAssigneeStr', function (event, data) {
    
        $scope.assignment.assignee = data;
    });
    $scope.$on('choseAssigneeNameStr', function (event, data) {
        $scope.assignment.assigneeshowname = data;
    });
    $scope.$on('choseCandidateGroupsStr', function (event, data, nameData) {
        // $scope.assignment.candidateGroups[0].value = data;
        var infos = data.split(",");
        var nameInfos = nameData.split(",");
 
        for (var i = 0; i < infos.length; i++) {
            // $scope.assignment.candidateGroups[i].value = infos[i];
            $scope.assignment.candidateGroups.push({value: infos[i], nameValue: nameInfos[i]});
        }
 
        //清空第一个
        if ((!$scope.assignment.candidateGroups[0].value) || $scope.assignment.candidateGroups[0] == '') {
            //清空第一个元素
            $scope.assignment.candidateGroups.splice(0, 1);
        }
 
    });
}];
 
  // 用户列表
 
var KisBpmChoseAssignmentCtrl = ['$scope', '$http', function ($scope, $http) {
 
    $scope.keyword = '';
    $scope.reload = true;
    $scope.paginationConf = {
        currentPage: 1,
        totalItems: 100,
        itemsPerPage: 10,
        pagesLength: 5,
        perPageOptions: [10, 20, 30, 40, 50],
        onChange: function () {
            if (!$scope.reload) {
                return;
            }
            $scope.reloadList();//重新加载  这个方法会重复调用两次  
            $scope.reload = false;
            setTimeout(function () { 
                $scope.reload = true; 
            }, 200); 
        }
    };
 
    // 刷新列表方法
    $scope.reloadList = function () {
        $scope.findPage($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
    }
 
    // 分页方法,请求数据
    $scope.findPage = function (page, limit) {
      let accounts = [];
        $http({
            method: 'get',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
               
            },
            url: ACTIVITI.CONFIG.baseUrl + '/sys/user/actUserList/'+ page + '/' + limit + "?keyword=" + $scope.keyword
        })
            .success(function (data, status, headers, config) {
             
                //封装数据
                let obj = data.result;
                
                if (data != null && data.code == 0) {
                  
                    obj.records.forEach(function (e, i) {
                        accounts.push({id: e.id, code: e.username, name: e.realname, index: i});
                    })
                }
                $scope.accounts = accounts;
                $scope.paginationConf.totalItems = obj.total;
            })
           .error(function (data, status, headers, config) {
            });
    }
 
    //模态框左侧组的点击事件:根据所点击的组获取当前组的所有用户
    $scope.queryByRole = function (value) {
        //初始化表格
        $scope.keyword = '';
        $scope.paginationConf.currentPage = 1;
        $scope.reloadList();
    };
 
    $scope.queryByKeyword = function () {
        
        $scope.paginationConf.currentPage = 1;
        $scope.reloadList();
    }
 
    $scope.reset = function () {
        $scope.keyword = "";
        $scope.paginationConf.currentPage = 1;
        $scope.reloadList();
    }
 
    //初始化左边菜单栏数据,并触发第一个菜单的点击事件
    let roles = [];
    $scope.getAllRoles = function (successCallback) {
        $http({
            method: 'get',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
                'X-Access-Token': ACTIVITI.CONFIG.token
            },
            url: ACTIVITI.CONFIG.baseUrl + '/sys/role/getRoleList'
        })
 
            .success(function (data, status, headers, config) {
                let obj = data.result;
                for (var i = 0; i < obj.length; i++) {
                    roles.push({id: obj[i].id, name: obj[i].roleName});
                }
                $scope.roles = roles;
            })
            .error(function (data, status, headers, config) {
            });
    };
    $scope.getAllRoles(function () {
    });
 
 
    // Close button handler
    $scope.close = function () {
        $scope.$hide();
    };
    $scope.formData = {};
    $scope.candidateUser = {};
 
    //Save Data
    $scope.save = function () {
 
        if ($scope.choseAssignmentFlag == "assignee") {
 
            var choseAssignees = $scope.accounts;
            var choseAssigneesStr = "";
            var choseAssigneesNameStr = "";
            for (var i = 0; i < choseAssignees.length; i++) {
                if (choseAssignees[i].checked) {
                    choseAssigneesStr = choseAssignees[i].id;
                    choseAssigneesNameStr = choseAssignees[i].name;
                    break;
                }
            }
            $scope.$emit('choseAssigneeStr', choseAssigneesStr);
            $scope.$emit('choseAssigneeNameStr', choseAssigneesNameStr);
        } else if ($scope.choseAssignmentFlag == "assignees") {
            var choseAssignees = $scope.accounts;
            var choseAssigneesStr = "";
            var choseAssigneesNameStr = "";
            for (var i = 0; i < choseAssignees.length; i++) {
                if (choseAssignees[i].selected) {
                    choseAssigneesStr += choseAssignees[i].id + ",";
                    choseAssigneesNameStr += choseAssignees[i].name + ",";
                }
            }
            choseAssigneesStr = choseAssigneesStr.substring(0, choseAssigneesStr.length - 1);
            choseAssigneesNameStr = choseAssigneesNameStr.substring(0, choseAssigneesNameStr.length - 1);
            $scope.$emit('choseAssigneesStr', choseAssigneesStr, choseAssigneesNameStr);
        }
        $scope.close();
    };
    $scope.selectAll = function () {
        var choseAssignees = $scope.accounts;
        for (var i = 0; i < choseAssignees.length; i++) {
            choseAssignees[i].selected = true;
        }
        $scope.accounts = choseAssignees;
    };
    $scope.rowClick = function (id) {
      
        var type = $scope.choseAssignmentFlag;
        var choseAssignees = $scope.accounts;
        for (var i = 0; i < choseAssignees.length; i++) {
            if (type == "assignee") {
                if (choseAssignees[i].id == id) {
                    choseAssignees[i].checked = true;
                } else {
                    choseAssignees[i].checked = false;
                }
            } else if (type == "assignees") {
                if (choseAssignees[i].id == id) {
                    choseAssignees[i].selected = choseAssignees[i].selected ? false : true;
                }
            }
        }
        $scope.accounts = choseAssignees;
    }
}];
 
 
var KisBpmChoseCandidateGroupsCtrl = ['$scope', '$http', function ($scope, $http) {
 
    var candidateGroups = [];
    $scope.getAllRoles = function (successCallback) {
        $http({
            method: 'get',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
            },
            url: ACTIVITI.CONFIG.baseUrl + '/sys/role/getRoleList'
        })
            .success(function (data, status, headers, config) {
                let obj = data.result;
                for (let i = 0; i < obj.length; i++) {
                    candidateGroups.push({id: obj[i].id, name: obj[i].roleName, description: obj[i].description});
                }
                $scope.candidateGroups = candidateGroups;
            })
            .error(function (data, status, headers, config) {
            });
    };
    $scope.getAllRoles(function () {
    });
 
    // Close button handler
    $scope.close = function () {
        $scope.$hide();
    };
 
    $scope.save = function () {
        var choseCandidateGroups = $scope.candidateGroups;
        var choseCandidateGroupsStr = "";
        var choseAssigneesNameStr = "";
        for (var i = 0; i < choseCandidateGroups.length; i++) {
            if (choseCandidateGroups[i].selected) {
                choseCandidateGroupsStr += choseCandidateGroups[i].id + ",";
                choseAssigneesNameStr += choseCandidateGroups[i].description + ",";
            }
        }
        choseCandidateGroupsStr = choseCandidateGroupsStr.substring(0, choseCandidateGroupsStr.length - 1);
        choseAssigneesNameStr = choseAssigneesNameStr.substring(0, choseAssigneesNameStr.length - 1);
        $scope.$emit('choseCandidateGroupsStr', choseCandidateGroupsStr, choseAssigneesNameStr);
        $scope.close();
    }
 
    $scope.selectAll = function () {
        var candidateGroups = $scope.candidateGroups;
        for (var i = 0; i < candidateGroups.length; i++) {
            candidateGroups[i].selected = true;
        }
        $scope.candidateGroups = candidateGroups;
    };
    $scope.rowClick = function (id) {
        var candidateGroups = $scope.candidateGroups;
        for (var i = 0; i < candidateGroups.length; i++) {
            if (candidateGroups[i].id == id) {
                candidateGroups[i].selected = candidateGroups[i].selected ? false : true;
            }
        }
        $scope.candidateGroups = candidateGroups;
    }
}];