From 8e62d47c7210854b570db5e9164a6a9da6351c12 Mon Sep 17 00:00:00 2001
From: 이민희 <mhlee@maprex.co.kr>
Date: 수, 09 2월 2022 17:59:06 +0900
Subject: [PATCH] - 이슈 추가,수정 시 파트너 정보 null 체크 추가

---
 src/main/webapp/scripts/app/companyField/companyFieldModify.controller.js |  105 ++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 73 insertions(+), 32 deletions(-)

diff --git a/src/main/webapp/scripts/app/companyField/companyFieldModify.controller.js b/src/main/webapp/scripts/app/companyField/companyFieldModify.controller.js
index 6042b36..d866e76 100644
--- a/src/main/webapp/scripts/app/companyField/companyFieldModify.controller.js
+++ b/src/main/webapp/scripts/app/companyField/companyFieldModify.controller.js
@@ -144,11 +144,44 @@
                 }
 
                 $scope.$on("ispFieldEvent", function (event, result) {
-                    $scope.vm.form.ispId = result[0].id;
+                    if ($rootScope.isDefined(result) && $rootScope.isDefined(result[0])) {
+                        $scope.vm.form.ispId = result[0].id;
+                    }
                 });
 
                 $scope.$on("hostingFieldEvent", function (event, result) {
-                    $scope.vm.form.hostingId = result[0].id;
+                    if ($rootScope.isDefined(result) && $rootScope.isDefined(result[0])) {
+                        $scope.vm.form.hostingId = result[0].id;
+                    }
+                });
+
+                $scope.$on("companyTypeEvent", function (event, result) {
+                    if ($rootScope.isDefined(result) && $rootScope.isDefined(result[0])) {
+                        $scope.vm.form.companyTypeId = result[0].id;
+                    }
+                });
+                $scope.$on("parentSectorEvent", function (event, result) {
+                    if ($rootScope.isDefined(result) && $rootScope.isDefined(result[0])) {
+                        $scope.vm.form.parentSectorId = result[0].id;
+                    }
+                    $scope.vm.form.childSectorId = "";
+                    $scope.vm.form.childSector = "";
+                    $scope.vm.form.childSectors = [];
+                });
+                $scope.$on("childSectorEvent", function (event, result) {
+                    if ($rootScope.isDefined(result) && $rootScope.isDefined(result[0])) {
+                        $scope.vm.form.childSectorId = result[0].id;
+                    }
+                });
+                $scope.$on("regionEvent", function (event, result) {
+                    if ($rootScope.isDefined(result) && $rootScope.isDefined(result[0])) {
+                        $scope.vm.form.regionId = result[0].id;
+                    }
+                });
+                $scope.$on("statusEvent", function (event, result) {
+                    if ($rootScope.isDefined(result) && $rootScope.isDefined(result[0])) {
+                        $scope.vm.form.statusId = result[0].id;
+                    }
                 });
 
                 //  �뤌 �쟾�넚
@@ -160,19 +193,19 @@
                         id : parameter.id,
                         name : $rootScope.preventXss($scope.vm.form.name),
                         ispId : (function () {  // ISP �븘�씠�뵒
-                            var ispId = -1;
+                            var ispId = null;
                             if ($scope.vm.form.ispName !== "" && $scope.vm.form.ispId !== null && $scope.vm.form.ispId !== -1) {
                                 ispId = $scope.vm.form.ispId;
-                            }else if ($scope.vm.form.issueIspFields != null) {
+                            }else if ($scope.vm.form.issueIspFields != null && $scope.vm.form.issueIspFields.length > 0) {
                                 ispId = $scope.vm.form.issueIspFields[0].id;
                             }
                             return ispId;
                         })(),
                         hostingId : (function () {  // Hosting �븘�씠�뵒
-                            var hostingId = -1;
+                            var hostingId = null;
                             if ($scope.vm.form.hostingName !== "" && $scope.vm.form.hostingId !== null && $scope.vm.form.hostingId !== -1) {
                                 hostingId = $scope.vm.form.hostingId;
-                            }else if ($scope.vm.form.issueHostingFields != null) {
+                            }else if ($scope.vm.form.issueHostingFields != null && $scope.vm.form.issueHostingFields.length > 0) {
                                 hostingId = $scope.vm.form.issueHostingFields[0].id;
                             }
                             return hostingId;
@@ -215,47 +248,47 @@
                         url : $rootScope.preventXss($scope.vm.form.url), // url
                         memo : $rootScope.preventXss($scope.vm.form.memo),
                         companyTypeId : (function () {
-                            var companyTypeId = -1;
-                            if ($scope.vm.form.companyType !== "" && $scope.vm.form.companyTypeId !== "" && $scope.vm.form.companyTypeId !== -1) {
-                                companyTypeId = $scope.vm.form.companyTypeId;
-                            }else if ($scope.vm.form.companyTypes != null) {
+                            var companyTypeId = null;
+                            if ($scope.vm.form.companyTypes != null && $scope.vm.form.companyTypes.length > 0) {
                                 companyTypeId = $scope.vm.form.companyTypes[0].id;
+                            } else {
+                                companyTypeId = $scope.vm.form.companyTypeId;
                             }
                             return companyTypeId;
                         })(),
                         parentSectorId : (function () {
-                            var parentSectorId = -1;
-                            if ($scope.vm.form.parentSector !== "" && $scope.vm.form.parentSectorId !== "" && $scope.vm.form.parentSectorId !== -1) {
-                                parentSectorId = $scope.vm.form.parentSectorId;
-                            }else if ($scope.vm.form.parentSectors != null) {
+                            var parentSectorId = null;
+                            if ($scope.vm.form.parentSectors != null && $scope.vm.form.parentSectors.length > 0) {
                                 parentSectorId = $scope.vm.form.parentSectors[0].id;
+                            } else {
+                                parentSectorId = $scope.vm.form.parentSectorId;
                             }
                             return parentSectorId;
                         })(),
                         childSectorId : (function () {
-                            var childSectorId = -1;
-                            if ($scope.vm.form.childSector !== "" && $scope.vm.form.childSectorId !== "" && $scope.vm.form.childSectorId !== -1) {
-                                childSectorId = $scope.vm.form.childSectorId;
-                            }else if ($scope.vm.form.childSectors != null) {
+                            var childSectorId = null;
+                            if ($scope.vm.form.childSectors != null && $scope.vm.form.childSectors.length > 0) {
                                 childSectorId = $scope.vm.form.childSectors[0].id;
+                            } else {
+                                childSectorId = $scope.vm.form.childSectorId;
                             }
                             return childSectorId;
                         })(),
                         regionId : (function () {
-                            var regionId = -1;
-                            if ($scope.vm.form.region !== "" && $scope.vm.form.regionId !== "" && $scope.vm.form.regionId !== -1) {
-                                regionId = $scope.vm.form.regionId;
-                            }else if ($scope.vm.form.regions != null) {
+                            var regionId = null;
+                            if ($scope.vm.form.regions != null && $scope.vm.form.regions.length > 0) {
                                 regionId = $scope.vm.form.regions[0].id;
+                            } else {
+                                regionId = $scope.vm.form.regionId;
                             }
                             return regionId;
                         })(),
                         statusId : (function () {
-                            var statusId = -1;
-                            if ($scope.vm.form.status !== "" && $scope.vm.form.statusId !== "" && $scope.vm.form.statusId !== -1) {
-                                statusId = $scope.vm.form.statusId;
-                            }else if ($scope.vm.form.statuses != null) {
+                            var statusId = null;
+                            if ($scope.vm.form.statuses != null && $scope.vm.form.statuses.length > 0) {
                                 statusId = $scope.vm.form.statuses[0].id;
+                            } else {
+                                statusId = $scope.vm.form.statusId;
                             }
                             return statusId;
                         })(),
@@ -354,10 +387,14 @@
 
                                 if (result.data.content.tel != null) {
                                     var inputTels = $scope.vm.form.inputTels;
-                                    var tels = result.data.content.tel.substr(1, result.data.content.tel.indexOf("]")-1);
-                                    var telArr = tels.split(", ");
+                                    var tels = result.data.content.tel;
+                                    if (result.data.content.tel.indexOf("[") !== -1){
+                                        tels = result.data.content.tel.substr(1, result.data.content.tel.indexOf("]")-1);
+                                    }
+                                    var telArr = tels.split(",");
                                     angular.forEach(telArr, function (tel) {
-                                        inputTels.push(tel);
+                                        var tell = tel.trim();
+                                        inputTels.push(tell);
                                     });
                                     inputTels  = inputTels.filter(function(item) {
                                         return item !== null && item !== undefined && item !== '';
@@ -371,10 +408,14 @@
 
                                 if (result.data.content.email != null) {
                                     var inputMails = $scope.vm.form.inputMails;
-                                    var emails = result.data.content.email.substr(1, result.data.content.email.indexOf("]")-1);
-                                    var emailArr = emails.split(", ");
+                                    var emails = result.data.content.email
+                                    if (result.data.content.email.indexOf("[") !== -1){
+                                        emails = result.data.content.email.substr(1, result.data.content.email.indexOf("]")-1);
+                                    }
+                                    var emailArr = emails.split(",");
                                     angular.forEach(emailArr, function (email) {
-                                        inputMails.push(email);
+                                        var mail = email.trim();
+                                        inputMails.push(mail);
                                     });
                                     inputMails  = inputMails.filter(function(item) {
                                         return item !== null && item !== undefined && item !== '';

--
Gitblit v1.8.0