| | |
| | | getStatusListCallBack : getStatusListCallBack, |
| | | addTel : addTel, |
| | | addMail : addMail, |
| | | addIpRange : addIpRange, |
| | | removeTelInput : removeTelInput, |
| | | removeMailInput : removeMailInput |
| | | removeMailInput : removeMailInput, |
| | | removeIpRangeInput : removeIpRangeInput |
| | | }; |
| | | |
| | | $scope.vm = { |
| | |
| | | statusId : "", |
| | | status : "", //상태 |
| | | inputTels : [0], //연락처 |
| | | tels : {}, |
| | | tels : [], |
| | | inputMails : [0], //이메일 |
| | | emails : {} |
| | | emails : [], |
| | | inputIpStarts : [0], //ip 시작점 |
| | | ipStarts : [], |
| | | inputIpEnds : [0], //ip 종료점 |
| | | ipEnds : [] |
| | | }, |
| | | typeCategory : { |
| | | companyType : "COMPANYTYPE", |
| | |
| | | } |
| | | return url; |
| | | })(), |
| | | ipStart : $scope.vm.form.ipStart, // ip시작주소 |
| | | ipEnd : $scope.vm.form.ipEnd, // ip종료주소 |
| | | 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; |
| | |
| | | statusName : $scope.vm.form.status |
| | | }; |
| | | |
| | | // ip 대역대 유효성 체크 |
| | | let result = ipRangeChk(content.ipStarts, content.ipEnds); |
| | | if (!result) { |
| | | $rootScope.spinner = false; |
| | | return; |
| | | } |
| | | |
| | | CompanyField.add($resourceProvider.getContent(content, |
| | | $resourceProvider.getPageContent(0, 10))).then(function (result) { |
| | | |
| | |
| | | $rootScope.$broadcast("getPageList", {}); |
| | | } |
| | | else { |
| | | SweetAlert.error($filter("translate")("companyField.failedCompanyFieldRegistration"), result.data.message.message); |
| | | SweetAlert.warning($filter("translate")("companyField.failedCompanyFieldRegistration"), result.data.message.message); |
| | | } |
| | | |
| | | $rootScope.spinner = false; |
| | | }); |
| | | } |
| | | |
| | | // ip 대역대 유효성 검사 |
| | | function ipRangeChk(ipStarts, ipEnds) { |
| | | let result = true; |
| | | |
| | | if ($rootScope.isDefined(ipStarts) && $rootScope.isDefined(ipEnds)) { |
| | | if (ipStarts.length !== ipEnds.length) { |
| | | SweetAlert.warning($filter("translate")("companyField.ipRangeError"), $filter("translate")("companyField.ipRangeNotEnter")); |
| | | result = false; |
| | | return; |
| | | } |
| | | |
| | | let ipStartArr = []; |
| | | let ipEndArr = []; |
| | | |
| | | for (let i=0; i<ipStarts.length; i++) { |
| | | let ipStart = ipToLong(ipStarts[i]); |
| | | let ipEnd = ipToLong(ipEnds[i]); |
| | | if (ipEnd < ipStart) { |
| | | SweetAlert.warning($filter("translate")("companyField.ipRangeError"), $filter("translate")("companyField.ipStartNotLargerThanEnd")); |
| | | result = false; |
| | | return; |
| | | } |
| | | ipStartArr.push(ipStart); |
| | | ipEndArr.push(ipEnd); |
| | | } |
| | | |
| | | for (let i=0; i<ipStartArr.length; i++) { |
| | | if ($rootScope.isDefined(ipStartArr[i+1])) { |
| | | if((ipStartArr[i] >= ipStartArr[i+1] && ipStartArr[i] <= ipEndArr[i+1]) |
| | | || (ipEndArr[i] >= ipStartArr[i+1] && ipEndArr[i] <= ipEndArr[i+1])) { |
| | | SweetAlert.warning($filter("translate")("companyField.ipRangeError"), $filter("translate")("companyField.ipRangeNotOverlap")); |
| | | result = false; |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | // ip 주소 숫자로 변환 |
| | | function ipToLong(ip) { |
| | | let result = 0; |
| | | let ipArr = ip.split("."); |
| | | |
| | | for (let i=0; i<ipArr.length; i++) { |
| | | result += parseInt(ipArr[i]) * Math.pow(256, 3-i); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | // 연락처 input 창 추가 버튼 |
| | |
| | | } |
| | | } |
| | | |
| | | // 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); |
| | | } |
| | | |
| | | // 팝업 창 닫기 |