OWL ITS + 탐지시스템(인터넷 진흥원)
src/main/webapp/scripts/app/companyField/companyFieldModify.controller.js
@@ -25,8 +25,10 @@
                    getStatusListCallBack : getStatusListCallBack,
                    addTel : addTel,
                    addMail : addMail,
                    addIpRange : addIpRange,
                    removeTelInput : removeTelInput,
                    removeMailInput : removeMailInput
                    removeMailInput : removeMailInput,
                    removeIpRangeInput : removeIpRangeInput
                };
                $scope.vm = {
@@ -41,6 +43,8 @@
                        tel : "",  //전화번호
                        email : "",  //이메일
                        url : "", // url
                        ipStart : "", //ip시작주소
                        ipEnd : "", //ip종료주소
                        memo : "",  //메모(비고)
                        companyTypeId : "",
                        companyType : "", //기업구분
@@ -53,9 +57,13 @@
                        statusId : "",
                        status : "", //상태
                        inputTels : [0],
                        tels : {},
                        tels : [],
                        inputMails : [0],
                        emails : {}
                        emails : [],
                        inputIpStarts : [0], //ip 시작점
                        ipStarts : [],
                        inputIpEnds : [0], //ip 종료점
                        ipEnds : []
                    },
                    typeCategory : {
                        companyType : "COMPANYTYPE",
@@ -115,7 +123,16 @@
                }
                // 업체 카테고리 autocomplete page 업데이트
                function getParentSectorListCallBack(result) {
                function getParentSectorListCallBack(result, value) {
                    if (value === "") {
                        $scope.vm.form.parentSectorId = "";
                        if ($rootScope.isDefined($scope.vm.form.parentSectors) && $rootScope.isDefined($scope.vm.form.parentSectors[0])) {
                            $scope.vm.form.parentSectors[0].id = "";
                        }
                        $scope.vm.form.childSectorId = "";
                        $scope.vm.form.childSector = "";
                        $scope.vm.form.childSectors = [];
                    }
                    $scope.vm.autoCompletePage.parentSector.totalPage = result.data.page.totalPage;
                }
@@ -250,8 +267,40 @@
                            }
                            return emailList;
                        })(),
                        url : $rootScope.preventXss($scope.vm.form.url), // url
                        memo : $rootScope.preventXss($scope.vm.form.memo),
                        url : (function () {
                            //  모든 공백 제거
                            var regex = / /gi;
                            let url = $scope.vm.form.url;
                            if ($rootScope.isDefined(url) && url.indexOf(" ") !== -1) {
                                url = url.replace(regex, "");
                            }
                            return url;
                        })(),
                        ipStarts : (function () {
                            var ipStarts = [];
                            if ($scope.vm.form.ipStarts != null) {
                                angular.forEach($scope.vm.form.ipStarts, function (ipS) {
                                    ipStarts.push(ipS);
                                });
                                ipStarts  = ipStarts.filter(function(item) { //쓰레기 데이터 필터링
                                    return item !== null && item !== undefined && item !== '';
                                });
                            }
                            return ipStarts;
                        })(),
                        ipEnds : (function () {
                            var ipEnds = [];
                            if ($scope.vm.form.ipEnds != null) {
                                angular.forEach($scope.vm.form.ipEnds, function (ipE) {
                                    ipEnds.push(ipE);
                                });
                                ipEnds  = ipEnds.filter(function(item) { //쓰레기 데이터 필터링
                                    return item !== null && item !== undefined && item !== '';
                                });
                            }
                            return ipEnds;
                        })(),
                        memo : $scope.vm.form.memo,
                        companyTypeId : (function () {
                            var companyTypeId = null;
                            if ($scope.vm.form.companyTypes != null && $scope.vm.form.companyTypes.length > 0) {
@@ -356,14 +405,53 @@
                    }
                }
                // IPRange input 창 추가 버튼
                function addIpRange() {
                    var arrayFull = true;      // 배열이 가득 차 있는지 여부
                    var startIdx = 0;
                    var endIdx = 0;
                    $scope.vm.form.inputIpStarts.forEach(function (start) {
                        if (!$rootScope.isDefined($scope.vm.form.ipStarts[startIdx])) {
                            arrayFull = false;
                        }
                        startIdx++;
                    });
                    $scope.vm.form.inputIpEnds.forEach(function (start) {
                        if (!$rootScope.isDefined($scope.vm.form.ipEnds[endIdx])) {
                            arrayFull = false;
                        }
                        endIdx++;
                    });
                    if (arrayFull) {
                        $scope.vm.form.inputIpStarts.push(startIdx);
                        $scope.vm.form.ipStarts[startIdx] = "";
                        $scope.vm.form.inputIpEnds.push(endIdx);
                        $scope.vm.form.ipEnds[endIdx] = "";
                    } else {
                        SweetAlert.warning($filter("translate")("companyField.writeCompanyIpRange"), $filter("translate")("companyField.writeIpRange")); // 추가버튼 경고
                    }
                }
                // 연락처 input 삭제
                function removeTelInput(index) {
                    $scope.vm.form.inputTels.splice(index, 1);
                    $scope.vm.form.tels.splice(index, 1);
                }
                // 이메일 주소 input 삭제
                function removeMailInput(index) {
                    $scope.vm.form.inputMails.splice(index, 1);
                    $scope.vm.form.emails.splice(index, 1);
                }
                // ipRange input 삭제
                function removeIpRangeInput(index) {
                    $scope.vm.form.inputIpStarts.splice(index, 1);
                    $scope.vm.form.ipStarts.splice(index, 1);
                    $scope.vm.form.inputIpEnds.splice(index, 1);
                    $scope.vm.form.ipEnds.splice(index, 1);
                }
                //  팝업 창 닫기
@@ -432,7 +520,51 @@
                                    $scope.vm.form.emails = angular.copy(inputMails);
                                }
                                if (result.data.content.ipStart != null) {
                                    var inputIpStarts = $scope.vm.form.inputIpStarts;
                                    var ipStarts = result.data.content.ipStart
                                    if (result.data.content.ipStart.indexOf("[") !== -1){
                                        ipStarts = result.data.content.ipStart.substr(1, result.data.content.ipStart.indexOf("]")-1);
                                    }
                                    var ipStartArr = ipStarts.split(",");
                                    angular.forEach(ipStartArr, function (ipS) {
                                        var ipStart = ipS.trim();
                                        inputIpStarts.push(ipStart);
                                    });
                                    inputIpStarts = inputIpStarts.filter(function(item) {
                                        return item !== null && item !== undefined && item !== '';
                                    });
                                    if(inputIpStarts[0] === 0 || inputIpStarts[0] === "") { // 첫번째 배열은 공백으로
                                        inputIpStarts.shift();
                                    }
                                    inputIpStarts.push("");
                                    $scope.vm.form.ipStarts = angular.copy(inputIpStarts);
                                }
                                if (result.data.content.ipEnd != null) {
                                    var inputIpEnds = $scope.vm.form.inputIpEnds;
                                    var ipEnds = result.data.content.ipEnd
                                    if (result.data.content.ipEnd.indexOf("[") !== -1){
                                        ipEnds = result.data.content.ipEnd.substr(1, result.data.content.ipEnd.indexOf("]")-1);
                                    }
                                    var ipEndArr = ipEnds.split(",");
                                    angular.forEach(ipEndArr, function (ipS) {
                                        var ipEnd = ipS.trim();
                                        inputIpEnds.push(ipEnd);
                                    });
                                    inputIpEnds = inputIpEnds.filter(function(item) {
                                        return item !== null && item !== undefined && item !== '';
                                    });
                                    if(inputIpEnds[0] === 0 || inputIpEnds[0] === "") { // 첫번째 배열은 공백으로
                                        inputIpEnds.shift();
                                    }
                                    inputIpEnds.push("");
                                    $scope.vm.form.ipEnds = angular.copy(inputIpEnds);
                                }
                                $scope.vm.form.url = result.data.content.url;
                                $scope.vm.form.ipStart = result.data.content.ipStart;
                                $scope.vm.form.ipEnd = result.data.content.ipEnd;
                                $scope.vm.form.memo = result.data.content.memo;
                                $scope.vm.form.companyTypeId = result.data.content.companyTypeId;
                                $scope.vm.form.companyType = result.data.content.companyTypeName;