OWL ITS + 탐지시스템(인터넷 진흥원)
jhjang
2021-11-25 e50b78db2f5e74f88b7e5c736f1fca4ca3cbe29b
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
/**
 * Created by wisestone on 2018-05-08.
 */
'use strict';
 
define([
        'app',
        'angular'
    ],
    function (app, angular) {
        app.controller('workflowAddController', ['$scope', '$rootScope', '$log', '$resourceProvider', 'User', '$uibModalInstance', 'Workflow', 'SweetAlert', 'IssueStatus', '$filter', '$injector','$controller',
            function ($scope, $rootScope, $log, $resourceProvider, User, $uibModalInstance, Workflow, SweetAlert, IssueStatus, $filter) {
 
                $scope.fn = {
                    cancel : cancel,    //  팝업 창 닫기
                    formSubmit : formSubmit,    //  폼 전송
                    formCheck : formCheck,  //  폼 체크
                    getDepartments : getDepartments // 부서 목록 가져오기
                };
 
                $scope.vm = {
                    form : {
                        name : "",  //  워크플로우  명
                        issueStatusVos : [],    //  다이어그램에서 만들어진 이슈 상태 모음
                        WorkflowDepartmentVos : [
                            {
                                departmentVo : null
                            }
                        ]
                    },
                    issueStatusVos : [],    //  다이어그램 에디터에서 이 값을 감지하면서 조회가 시작된다.
                    step : "01",
                    isolationWorkflow : true,  //  워크플로우에 고립된 이슈 상태가 있는지 여부를 체크한다.
                    firstStatusExist : true,    //  워크플로우에 상태 속성 '대기'인 상태가 존재하는지 체크한다.
                    middleStatusExist : true,   //  워크플로우에 상태 속성 '진행'인 상태가 존재하는지 체크한다.
                    lastStatusExist : true,  //  워크플로우에 상태 속성 '종료'인 상태가 존재하는지 체크한다.
                    departments : []    // 부서 목록
                };
 
 
 
                //  폼 체크
                function formCheck(formInvalid) {
                    if (formInvalid) {
                        return true;
                    }
 
                    return false;
                }
 
                // 부서 목록 가져오기
                function getDepartments() {
                    var content = {
                        // 추후 변경을 위함
                    };
 
                    Workflow.findDepartments($resourceProvider.getContent(
                        content,
                        $resourceProvider.getPageContent(0, 1000))).then(function (result) {
 
                        if (result.data.message.status === "success") {
                            $scope.vm.departments = result.data.data;
                        }
                        else {
                            SweetAlert.error($filter("translate")("managementWorkflow.failedToSelectWorkspaceFullDepartmentList"), result.data.message.message); // 부서 목록 조회 실패
                        }
                    });
 
                }
 
                //  폼 전송
                function formSubmit() {
                    $rootScope.spinner = true;
 
                    var content = {
                        name : $rootScope.preventXss($scope.vm.form.name),
                        issueStatusVos : $scope.vm.form.issueStatusVos,
                        nodes : (function () {
                            var keys = Object.keys($scope.vm.form.nodes);
                            var nodes = [];
 
                            angular.forEach(keys, function (key) {
                                var node = $scope.vm.form.nodes[key];
 
                                if ($rootScope.isDefined(node)) {
                                    nodes.push(node);
                                }
                            });
 
                            return nodes;
                        })(),
                        links : $scope.vm.form.links
                    };
 
                    Workflow.add($resourceProvider.getContent(
                        content,
                        $resourceProvider.getPageContent(0, 0))).then(function (result) {
 
                        if (result.data.message.status === "success") {
                            $scope.fn.cancel();
                            //  목록 화면 갱신
                            $rootScope.$broadcast("getWorkflowList", {});
                        }
                        else {
                            SweetAlert.error($filter("translate")("managementWorkflow.failedCreateWorkflow"), result.data.message.message); // 워크플로우 생성 실패
                        }
 
                        $rootScope.spinner = false;
                    });
                }
 
                //  팝업 창 닫기
                function cancel() {
                    $rootScope.$broadcast("closeLayer");    //  팝업이 열리고 나서 js-multi, js-single 등에서 body 이벤트가 날아가는 현상 수정
                    $uibModalInstance.dismiss('cancel');
                    $(document).unbind("keydown");  //  단축키 이벤트 제거
                }
 
                $scope.fn.getDepartments();
            }]);
    });