| | |
| | | '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 |
| | | }; |
| | | |
| | | $scope.vm = { |
| | | id : parameter.id, |
| | | form : { |
| | | name : "", //업체명 |
| | | companyType : "", //업체분류 |
| | | profitYN : "", //영리/비영리 |
| | | industry : "", //산업분류 |
| | | domain : "", //도메인 |
| | | email : "", //이메일 |
| | | ispId : "", |
| | | ispName : "", |
| | | hostingName : "", |
| | | hostingId : "", |
| | | manager : "", //담당자 |
| | | tel : "", //전화번호 |
| | | desc : "" //메모(비고) |
| | | email : "", //이메일 |
| | | url : "", // url |
| | | memo : "" //메모(비고) |
| | | }, |
| | | autoCompletePage : { |
| | | ispField : { |
| | | page : 0, |
| | | totalPage : 0 |
| | | }, |
| | | hostingField : { |
| | | 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; |
| | | } |
| | | |
| | | // 폼 체크 |
| | | function formCheck(formInvalid) { |
| | | if (formInvalid) { |
| | | return true; |
| | |
| | | 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 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 = -1; |
| | | if ($scope.vm.form.issueIspFields != null && $scope.vm.form.issueIspFields.length > 0) { |
| | | ispId = $scope.vm.form.ispId; |
| | | } |
| | | return ispId; |
| | | })(), |
| | | hostingId : (function () { // Hosting 아이디 |
| | | var hostingId = -1; |
| | | if ($scope.vm.form.issueHostingFields != null && $scope.vm.form.issueHostingFields.length > 0) { |
| | | hostingId = $scope.vm.form.hostingId; |
| | | } |
| | | return hostingId; |
| | | })(), |
| | | manager : $rootScope.preventXss($scope.vm.form.manager), |
| | | tel : $rootScope.preventXss($scope.vm.form.tel), |
| | | email : $rootScope.preventXss($scope.vm.form.email), |
| | | url : $rootScope.preventXss($scope.vm.form.url), // url |
| | | memo : $rootScope.preventXss($scope.vm.form.memo) |
| | | }; |
| | | |
| | | UserWorkspace.departmentModify($resourceProvider.getContent( |
| | | CompanyField.modify($resourceProvider.getContent( |
| | | content, |
| | | $resourceProvider.getPageContent(0, 0))).then(function (result) { |
| | | |
| | |
| | | $scope.fn.cancel(); |
| | | |
| | | // 목록 화면 갱신 |
| | | $rootScope.$broadcast("getDepartmentList", {}); |
| | | $rootScope.$broadcast("getPageList", {}); |
| | | } |
| | | else { |
| | | SweetAlert.error($filter("translate")("companyField.failedCompanyFieldRegistration"), result.data.message.message); //업체 등록 실패 |
| | |
| | | $(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 (angular.isDefined(result.data.content)) { |
| | | $scope.vm.form.name = result.data.content.name; |
| | | $scope.vm.form.manager = result.data.content.manager; |
| | | $scope.vm.form.email = result.data.content.email; |
| | | $scope.vm.form.tel = result.data.content.tel; |
| | | $scope.vm.form.url = result.data.content.url; |
| | | $scope.vm.form.memo = result.data.content.memo; |
| | | |
| | | if (result.data.content.ispFieldVo != null) { |
| | | $scope.vm.form.ispName = result.data.content.ispFieldVo.name; |
| | | } |
| | | if (result.data.content.hostingFieldVo != null) { |
| | | $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(); |
| | | |
| | | }]); |