From 911e65ca7d4f47ec18212375b4eb479c1c40acbe Mon Sep 17 00:00:00 2001 From: wyu <kknd09321@nate.com> Date: 금, 07 1월 2022 10:03:18 +0900 Subject: [PATCH] 연락처 입력시 하이픈 자동 입력 (지역, 핸드폰 번호) --- src/main/webapp/scripts/app/companyField/companyFieldAdd.controller.js | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 107 insertions(+), 12 deletions(-) diff --git a/src/main/webapp/scripts/app/companyField/companyFieldAdd.controller.js b/src/main/webapp/scripts/app/companyField/companyFieldAdd.controller.js index bca5967..1457b34 100644 --- a/src/main/webapp/scripts/app/companyField/companyFieldAdd.controller.js +++ b/src/main/webapp/scripts/app/companyField/companyFieldAdd.controller.js @@ -7,28 +7,55 @@ 'app' ], function (app) { - app.controller('companyFieldAddController', ['$scope', '$rootScope', '$log', '$resourceProvider', 'SweetAlert', '$uibModal', '$uibModalInstance', '$state', 'CompanyField', '$filter', - function ($scope, $rootScope, $log, $resourceProvider, SweetAlert, $uibModal, $uibModalInstance, $state, CompanyField, $filter) { + app.controller('companyFieldAddController', ['$scope', '$rootScope', '$log', '$resourceProvider', 'SweetAlert', '$uibModal', '$uibModalInstance', '$state', 'CompanyField', '$filter', '$injector','$controller', + function ($scope, $rootScope, $log, $resourceProvider, SweetAlert, $uibModal, $uibModalInstance, $state, CompanyField, $filter, $injector, $controller) { $scope.fn = { cancel : cancel, // �뙘�뾽 李� �떕湲� formSubmit : formSubmit, // �뤌 �쟾�넚 formCheck : formCheck, // �뤌 泥댄겕 + getIssueIspFieldListCallBack : getIssueIspFieldListCallBack, + getIssueHostingFieldListCallBack : getIssueHostingFieldListCallBack, + autoHyphenPhone : autoHyphenPhone // �뿰�씫泥� �엯�젰�떆 �븯�씠�뵂 �옄�룞 �엯�젰 }; $scope.vm = { form : { name : "", //�뾽泥대챸 - //companyType : "", //�뾽泥대텇瑜� - //profitYN : "", //�쁺由�/鍮꾩쁺由� - //industry : "", //�궛�뾽遺꾨쪟 - //domain : "", //�룄硫붿씤 + ispId : "", + ispName : "", + hostingName : "", + hostingId : "", manager : "", //�떞�떦�옄 tel : "", //�쟾�솕踰덊샇 email : "", //�씠硫붿씪 + url : "", // url memo : "" //鍮꾧퀬 + }, + autoCompletePage : { + ispField : { + page : 0, + totalPage : 0 + }, + hostingField : { + page : 0, + totalPage : 0 + } } }; + + angular.extend(this, $controller('autoCompleteController', {$scope : $scope, $injector : $injector})); + + + // 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; + } // �뤌 泥댄겕 function formCheck(formInvalid) { @@ -38,19 +65,89 @@ return false; } + $scope.$on("ispFieldEvent", function (event, result) { + $scope.vm.form.ispId = result[0].id; + }); + + $scope.$on("hostingFieldEvent", function (event, result) { + $scope.vm.form.hostingId = result[0].id; + }); + + // �뿰�씫泥� �엯�젰�떆 �븯�씠�뵂 �옄�룞 �엯�젰 + function autoHyphenPhone() { + let phone = $scope.vm.form.tel + let seoul = $scope.vm.form.tel + + // �빖�뱶�룿 諛� 吏�諛� 吏��뿭踰덊샇 議곌굔 + phone.replace(/^[0-9]/g, ''); + // �꽌�슱 吏��뿭踰덊샇 議곌굔 + seoul.replace(/^[0-9]/g, ''); + var tmp = ''; + + if (phone.length < 4) { + return phone; + } else if (phone.length < 7) { + tmp += phone.substr(0, 3); + tmp += '-'; + tmp += phone.substr(3); + $scope.vm.form.tel = tmp; + } else if (seoul.substring(0, 2) == "02" && seoul.length == 9) { // �꽌�슱 吏��뿭踰덊샇 議곌굔 + tmp += seoul.substring(0, 2); + tmp += '-'; + tmp += seoul.substring(2, 5); + tmp += '-'; + tmp += seoul.substr(5); + $scope.vm.form.tel = tmp; + } else if (seoul.substring(0, 2) == "02" && seoul.length == 10) { // �꽌�슱 吏��뿭踰덊샇 議곌굔 + tmp += seoul.substring(0, 2); + tmp += '-'; + tmp += seoul.substring(2, 6); + tmp += '-'; + tmp += seoul.substr(6); + $scope.vm.form.tel = tmp; + } else if (phone.length < 11) { // �빖�뱶�룿 諛� 吏�諛� 吏��뿭踰덊샇 議곌굔 + tmp += phone.substr(0, 3); + tmp += '-'; + tmp += phone.substr(3, 3); + tmp += '-'; + tmp += phone.substr(6); + $scope.vm.form.tel = tmp; + } else { // �빖�뱶�룿 諛� 吏�諛� 吏��뿭踰덊샇 議곌굔 + tmp += phone.substr(0, 3); + tmp += '-'; + tmp += phone.substr(3, 4); + tmp += '-'; + tmp += phone.substr(7); + $scope.vm.form.tel = tmp; + } + return phone; + } + // �뤌 �쟾�넚 function formSubmit(condition) { $rootScope.spinner = true; + $scope.vm.form.tel = $scope.vm.form.tel.replace(/\-/g,''); // �쟾�솕踰덊샇瑜� 蹂대궪�븧 �븯�씠�뵂�쓣 �젣嫄고빐�꽌 DB�뿉 ���옣 var content = { name : $rootScope.preventXss($scope.vm.form.name), // �뾽泥대챸 - //companyType : $scope.vm.form.companyType, //�뾽泥대텇瑜� - //profitYN : $scope.vm.form.profitYN, //�쁺由�/鍮꾩쁺由� - //industry : $scope.vm.form.industry, //�궛�뾽遺꾨쪟 - //domain : $scope.vm.form.domain, //�룄硫붿씤 + ispId : (function () { // ISP �븘�씠�뵒 + var ispId = -1; + if ($scope.vm.form.issueIspFields != null) { + ispId = $scope.vm.form.ispId; + } + return ispId; + })(), + hostingId : (function () { // Hosting �븘�씠�뵒 + var hostingId = -1; + if ($scope.vm.form.issueHostingFields != null) { + hostingId = $scope.vm.form.hostingId; + } + return hostingId; + })(), manager : $scope.vm.form.manager, //�떞�떦�옄 tel : $scope.vm.form.tel, //�쟾�솕踰덊샇 email : $scope.vm.form.email, //�씠硫붿씪 + url : $scope.vm.form.url, // url memo : $scope.vm.form.memo //鍮꾧퀬 }; @@ -77,9 +174,7 @@ $uibModalInstance.dismiss('cancel'); $(document).unbind("keydown"); // �떒異뺥궎 �씠踰ㅽ듃 �젣嫄� } - } - ]); } ); \ No newline at end of file -- Gitblit v1.8.0