From 398a4927e195755bd6a46be99337efd8dacc3dc2 Mon Sep 17 00:00:00 2001
From: 박지현 <jhpark@maprex.co.kr>
Date: 월, 07 3월 2022 18:08:13 +0900
Subject: [PATCH] Merge branch 'master' of http://maprex.iptime.org:9001/r/owl-kisa

---
 src/main/webapp/scripts/app/companyField/companyFieldModify.controller.js |  456 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 419 insertions(+), 37 deletions(-)

diff --git a/src/main/webapp/scripts/app/companyField/companyFieldModify.controller.js b/src/main/webapp/scripts/app/companyField/companyFieldModify.controller.js
index eca409e..de4a45f 100644
--- a/src/main/webapp/scripts/app/companyField/companyFieldModify.controller.js
+++ b/src/main/webapp/scripts/app/companyField/companyFieldModify.controller.js
@@ -8,58 +8,144 @@
         'angular'
     ],
     function (app, angular) {
-        app.controller('companyFieldModifyController', ['$scope', '$rootScope', '$log', '$resourceProvider', '$uibModalInstance', 'CompanyField', 'parameter', 'SweetAlert', '$filter',
-            function ($scope, $rootScope, $log, $resourceProvider, $uibModalInstance, CompanyField, parameter, SweetAlert, $filter) {
+        app.controller('companyFieldModifyController', ['$scope', '$rootScope', '$log', '$resourceProvider', '$uibModalInstance', 'CompanyField', 'parameter', 'SweetAlert', '$filter', '$q', '$injector','$controller',
+            function ($scope, $rootScope, $log, $resourceProvider, $uibModalInstance, CompanyField, parameter, SweetAlert, $filter, $q, $injector, $controller) {
 
                 $scope.fn = {
                     detail : detail,  //  �긽�꽭 議고쉶
                     cancel : cancel,    //  �뙘�뾽 李� �떕湲�
                     formSubmit : formSubmit,    //  �뤌 �쟾�넚
                     formCheck : formCheck,  //  �뤌 泥댄겕
+                    getIssueIspFieldListCallBack : getIssueIspFieldListCallBack,
+                    getIssueHostingFieldListCallBack : getIssueHostingFieldListCallBack,
+                    getCompanyTypeListCallBack : getCompanyTypeListCallBack,
+                    getParentSectorListCallBack : getParentSectorListCallBack,
+                    getChildSectorListCallBack : getChildSectorListCallBack,
+                    getRegionListCallBack : getRegionListCallBack,
+                    getStatusListCallBack : getStatusListCallBack,
+                    addTel : addTel,
+                    addMail : addMail,
+                    removeTelInput : removeTelInput,
+                    removeMailInput : removeMailInput
                 };
 
                 $scope.vm = {
                     id : parameter.id,
                     form : {
                         name : "",  //�뾽泥대챸
-                        companyType : "", //�뾽泥대텇瑜�
-                        profitYN : "",  //�쁺由�/鍮꾩쁺由�
-                        industry : "",  //�궛�뾽遺꾨쪟
-                        domain : "",  //�룄硫붿씤
-                        email : "",  //�씠硫붿씪
+                        ispId : "",
+                        ispName : "",
+                        hostingName : "",
+                        hostingId : "",
+                        manager : "",   //�떞�떦�옄
                         tel : "",  //�쟾�솕踰덊샇
-                        desc : ""  //硫붾え(鍮꾧퀬)
+                        email : "",  //�씠硫붿씪
+                        url : "", // url
+                        ipStart : "", //ip�떆�옉二쇱냼
+                        ipEnd : "", //ip醫낅즺二쇱냼
+                        memo : "",  //硫붾え(鍮꾧퀬)
+                        companyTypeId : "",
+                        companyType : "", //湲곗뾽援щ텇
+                        parentSectorId : "",
+                        parentSector : "", //�뾽醫�(��遺꾨쪟)
+                        childSectorId : "",
+                        childSector : "", //�뾽醫�(以묐텇瑜�)
+                        regionId : "",
+                        region : "", //吏��뿭
+                        statusId : "",
+                        status : "", //�긽�깭
+                        inputTels : [0],
+                        tels : {},
+                        inputMails : [0],
+                        emails : {}
+                    },
+                    typeCategory : {
+                        companyType : "COMPANYTYPE",
+                        parentSector : "PARENTSECTOR",
+                        childSector : "CHILDSECTOR",
+                        region : "REGION",
+                        status : "STATUS"
+                    },
+                    autoCompletePage : {
+                        ispField : {
+                            page : 0,
+                            totalPage : 0
+                        },
+                        hostingField : {
+                            page : 0,
+                            totalPage : 0
+                        },
+                        companyType : {
+                            page : 0,
+                            totalPage : 0
+                        },
+                        parentSector : {
+                            page : 0,
+                            totalPage : 0
+                        },
+                        childSector : {
+                            page : 0,
+                            totalPage : 0
+                        },
+                        region : {
+                            page : 0,
+                            totalPage : 0
+                        },
+                        status : {
+                            page : 0,
+                            totalPage : 0
+                        }
                     }
                 };
 
-                //  �긽�꽭 �젙蹂�
-                function detail() {
-                    var conditions = {
-                        id : parameter.id
-                    }
+                angular.extend(this, $controller('autoCompleteController', {$scope : $scope, $injector : $injector}));
 
-                    CompanyField.detail($resourceProvider.getContent(
-                        conditions,
-                        $resourceProvider.getPageContent(0, 1))).then(function (result) {
 
-                        if (result.data.message.status === "success") {
-                            if (angular.isDefined(result.data.data)) {
-                                $scope.vm.form.name = result.data.data.name;
-                                $scope.vm.form.companyType = result.data.data.companyType;
-                                $scope.vm.form.profitYN = result.data.data.profitYN;
-                                $scope.vm.form.industry = result.data.data.industry;
-                                $scope.vm.form.domain = result.data.data.domain;
-                                $scope.vm.form.email = result.data.data.email;
-                                $scope.vm.form.tel = result.data.data.tel;
-                                $scope.vm.form.desc = result.data.data.desc;
-                            }
-                        }
-                        else {
-                            SweetAlert.swal($filter("translate")("customField.failedToDetailCompanyFieldModify"), result.data.message.message, "error"); // "�뾽泥� �긽�꽭 �젙蹂� 議고쉶 �떎�뙣"
-                        }
-                    });
+                // ISP�젙蹂� autocomplete page �뾽�뜲�씠�듃
+                function getIssueIspFieldListCallBack(result) {
+                    $scope.vm.autoCompletePage.ispField.totalPage = result.data.page.totalPage;
                 }
 
+                // �샇�뒪�똿�젙蹂� autocomplete page �뾽�뜲�씠�듃
+                function getIssueHostingFieldListCallBack(result) {
+                    $scope.vm.autoCompletePage.hostingField.totalPage = result.data.page.totalPage;
+                }
+
+                // �뾽泥� 移댄뀒怨좊━ autocomplete page �뾽�뜲�씠�듃
+                function getCompanyTypeListCallBack(result) {
+                    $scope.vm.autoCompletePage.companyType.totalPage = result.data.page.totalPage;
+                }
+
+                // �뾽泥� 移댄뀒怨좊━ autocomplete page �뾽�뜲�씠�듃
+                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;
+                }
+
+                // �뾽泥� 移댄뀒怨좊━ autocomplete page �뾽�뜲�씠�듃
+                function getChildSectorListCallBack(result) {
+                    $scope.vm.autoCompletePage.childSector.totalPage = result.data.page.totalPage;
+                }
+
+                // �뾽泥� 移댄뀒怨좊━ autocomplete page �뾽�뜲�씠�듃
+                function getRegionListCallBack(result) {
+                    $scope.vm.autoCompletePage.region.totalPage = result.data.page.totalPage;
+                }
+
+                // �뾽泥� 移댄뀒怨좊━ autocomplete page �뾽�뜲�씠�듃
+                function getStatusListCallBack(result) {
+                    $scope.vm.autoCompletePage.status.totalPage = result.data.page.totalPage;
+                }
+
+                // �뤌 泥댄겕
                 function formCheck(formInvalid) {
                     if (formInvalid) {
                         return true;
@@ -68,25 +154,181 @@
                     return false;
                 }
 
+                $scope.$on("ispFieldEvent", function (event, result) {
+                    if ($rootScope.isDefined(result) && $rootScope.isDefined(result[0])) {
+                        $scope.vm.form.ispId = result[0].id;
+                    }
+                });
+
+                $scope.$on("hostingFieldEvent", function (event, result) {
+                    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;
+                    }  else {
+                        $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.$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;
+                    }
+                });
+
                 //  �뤌 �쟾�넚
                 function formSubmit() {
                     $rootScope.spinner = true;
+                    $scope.vm.form.tel = $scope.vm.form.tel.replace(/\-/g,'');  // �쟾�솕踰덊샇瑜� 蹂대궪�븧 �븯�씠�뵂�쓣 �젣嫄고빐�꽌 DB�뿉 ���옣
 
                     var content = {
                         id : parameter.id,
-                        departmentName : $rootScope.preventXss($scope.vm.form.departmentName),
-                        departmentDescription : $rootScope.preventXss($scope.vm.form.departmentDescription)
+                        name : $rootScope.preventXss($scope.vm.form.name),
+                        ispId : (function () {  // ISP �븘�씠�뵒
+                            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 && $scope.vm.form.issueIspFields.length > 0) {
+                                ispId = $scope.vm.form.issueIspFields[0].id;
+                            }
+                            return ispId;
+                        })(),
+                        hostingId : (function () {  // Hosting �븘�씠�뵒
+                            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 && $scope.vm.form.issueHostingFields.length > 0) {
+                                hostingId = $scope.vm.form.issueHostingFields[0].id;
+                            }
+                            return hostingId;
+                        })(),
+                        manager : $rootScope.preventXss($scope.vm.form.manager),
+                        tels : (function () {
+                            var telList = [];
+                            if ($scope.vm.form.tels != null) {
+                                angular.forEach($scope.vm.form.tels, function (tel) {
+                                    telList.push(tel);
+                                });
+                                telList  = telList.filter(function(item) { //�벐�젅湲� �뜲�씠�꽣 �븘�꽣留�
+                                    return item !== null && item !== undefined && item !== '';
+                                });
+                                telList  = telList.filter(function(item, idx){
+                                    return telList.findIndex(function(item2, idx2){
+                                        return item === item2
+                                    }) == idx;
+                                });
+                            }
+                            return telList;
+                        })(),
+                        emails : (function () {
+                            var emailList = [];
+                            if ($scope.vm.form.emails != null) {
+                                angular.forEach($scope.vm.form.emails, function (email) {
+                                    emailList.push(email);
+                                });
+                                emailList  = emailList.filter(function(item) { //�벐�젅湲� �뜲�씠�꽣 �븘�꽣留�
+                                    return item !== null && item !== undefined && item !== '';
+                                });
+                                emailList  = emailList.filter(function(item, idx){
+                                    return emailList.findIndex(function(item2, idx2){
+                                        return item === item2
+                                    }) == idx;
+                                });
+                            }
+                            return emailList;
+                        })(),
+                        url : (function () {
+                            //  紐⑤뱺 怨듬갚 �젣嫄�
+                            var regex = / /gi;
+                            let url = $scope.vm.form.url;
+                            if ($rootScope.isDefined(url) && url.indexOf(" ") !== -1) {
+                                url = url.replace(regex, "");
+                            }
+                            return url;
+                        })(),
+                        ipStart : $scope.vm.form.ipStart, // ip�떆�옉二쇱냼
+                        ipEnd : $scope.vm.form.ipEnd, // ip醫낅즺二쇱냼
+                        memo : $scope.vm.form.memo,
+                        companyTypeId : (function () {
+                            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 = 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 = 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 = 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 = 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;
+                        })(),
+                        statusName : $scope.vm.form.status
                     };
 
-                    UserWorkspace.departmentModify($resourceProvider.getContent(
+                    CompanyField.modify($resourceProvider.getContent(
                         content,
                         $resourceProvider.getPageContent(0, 0))).then(function (result) {
 
                         if (result.data.message.status === "success") {
                             $scope.fn.cancel();
-
                             //  紐⑸줉 �솕硫� 媛깆떊
-                            $rootScope.$broadcast("getDepartmentList", {});
+                            $rootScope.$broadcast("getPageList", {});
                         }
                         else {
                             SweetAlert.error($filter("translate")("companyField.failedCompanyFieldRegistration"), result.data.message.message); //�뾽泥� �벑濡� �떎�뙣
@@ -97,6 +339,54 @@
 
                 }
 
+                // 硫붿씪 二쇱냼 input 李� 異붽� 踰꾪듉
+                function addTel() {
+                    var arrayFull = true;      // 諛곗뿴�씠 媛��뱷 李� �엳�뒗吏� �뿬遺�
+                    var index = 0;
+                    $scope.vm.form.inputTels.forEach(function (tel) {
+                        if (!$rootScope.isDefined($scope.vm.form.tels[index])) {
+                            arrayFull = false;
+                        }
+                        index++;
+                    });
+
+                    if (arrayFull) {
+                        $scope.vm.form.inputTels.push(index);
+                        $scope.vm.form.tels[index] = "";
+                    } else {
+                        SweetAlert.warning($filter("translate")("companyField.writeCompanyTel"), $filter("translate")("companyField.writeTel")); // 異붽�踰꾪듉 寃쎄퀬
+                    }
+                }
+
+                // 硫붿씪 二쇱냼 input 李� 異붽� 踰꾪듉
+                function addMail() {
+                    var arrayFull = true;      // 諛곗뿴�씠 媛��뱷 李� �엳�뒗吏� �뿬遺�
+                    var index = 0;
+                    $scope.vm.form.inputMails.forEach(function (email) {
+                        if (!$rootScope.isDefined($scope.vm.form.emails[index])) {
+                            arrayFull = false;
+                        }
+                        index++;
+                    });
+
+                    if (arrayFull) {
+                        $scope.vm.form.inputMails.push(index);
+                        $scope.vm.form.emails[index] = ""
+                    } else {
+                        SweetAlert.warning($filter("translate")("issue.writeIssueMail"), $filter("translate")("issue.writeMail")); // 異붽�踰꾪듉 寃쎄퀬
+                    }
+                }
+
+                // �뿰�씫泥� input �궘�젣
+                function removeTelInput(index) {
+                    $scope.vm.form.inputTels.splice(index, 1);
+                }
+
+                // �씠硫붿씪 二쇱냼 input �궘�젣
+                function removeMailInput(index) {
+                    $scope.vm.form.inputMails.splice(index, 1);
+                }
+
                 //  �뙘�뾽 李� �떕湲�
                 function cancel() {
                     $rootScope.$broadcast("closeLayer");    //  �뙘�뾽�씠 �뿴由ш퀬 �굹�꽌 js-multi, js-single �벑�뿉�꽌 body �씠踰ㅽ듃媛� �궇�븘媛��뒗 �쁽�긽 �닔�젙
@@ -104,6 +394,98 @@
                     $(document).unbind("keydown");  //  �떒異뺥궎 �씠踰ㅽ듃 �젣嫄�
                 }
 
+                //  �긽�꽭 �젙蹂�
+                function detail() {
+                    var deferred = $q.defer();
+
+                    var conditions = {
+                        id : parameter.id
+                    }
+
+                    CompanyField.detail($resourceProvider.getContent(
+                        conditions,
+                        $resourceProvider.getPageContent(0, 1))).then(function (result) {
+
+                        if (result.data.message.status === "success") {
+                            if (result.data.content != null) {
+                                $scope.vm.form.name = result.data.content.name;
+                                $scope.vm.form.manager = result.data.content.manager;
+
+                                if (result.data.content.tel != null) {
+                                    var inputTels = $scope.vm.form.inputTels;
+                                    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) {
+                                        var tell = tel.trim();
+                                        inputTels.push(tell);
+                                    });
+                                    inputTels  = inputTels.filter(function(item) {
+                                        return item !== null && item !== undefined && item !== '';
+                                    });
+                                    if (inputTels[0] === 0 || inputTels[0] === "") {
+                                        inputTels.shift();
+                                    }
+                                    inputTels.push("");
+                                    $scope.vm.form.tels = angular.copy(inputTels);
+                                }
+
+                                if (result.data.content.email != null) {
+                                    var inputMails = $scope.vm.form.inputMails;
+                                    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) {
+                                        var mail = email.trim();
+                                        inputMails.push(mail);
+                                    });
+                                    inputMails  = inputMails.filter(function(item) {
+                                        return item !== null && item !== undefined && item !== '';
+                                    });
+                                    if(inputMails[0] === 0 || inputMails[0] === "") { // 泥ル쾲吏� 諛곗뿴�� 怨듬갚�쑝濡�
+                                        inputMails.shift();
+                                    }
+                                    inputMails.push("");
+                                    $scope.vm.form.emails = angular.copy(inputMails);
+                                }
+
+                                $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;
+                                $scope.vm.form.parentSectorId = result.data.content.parentSectorId;
+                                $scope.vm.form.parentSector = result.data.content.parentSectorName;
+                                $scope.vm.form.childSectorId = result.data.content.childSectorId;
+                                $scope.vm.form.childSector = result.data.content.childSectorName;
+                                $scope.vm.form.regionId = result.data.content.regionId;
+                                $scope.vm.form.region = result.data.content.regionName;
+                                $scope.vm.form.statusId = result.data.content.statusId;
+                                $scope.vm.form.status = result.data.content.statusName;
+
+                                if (result.data.content.ispFieldVo != null) {
+                                    $scope.vm.form.ispId = result.data.content.ispFieldVo.id;
+                                    $scope.vm.form.ispName = result.data.content.ispFieldVo.name;
+                                }
+                                if (result.data.content.hostingFieldVo != null) {
+                                    $scope.vm.form.hostingId = result.data.content.hostingFieldVo.id;
+                                    $scope.vm.form.hostingName = result.data.content.hostingFieldVo.name;
+                                }
+                            }
+                        }
+                        else {
+                            SweetAlert.swal($filter("translate")("customField.failedToDetailCompanyFieldModify"), result.data.message.message, "error"); // "�뾽泥� �긽�꽭 �젙蹂� 議고쉶 �떎�뙣"
+                        }
+                        deferred.resolve(result.data.data);
+                    });
+                    return deferred.promise;
+                }
+
                 $scope.fn.detail();
 
             }]);

--
Gitblit v1.8.0