(function () { "use strict"; angular .module('codeAPLEBOX.client.user.employee.customer.monthlystatus.detailmonthlystatus') .controller('detailmonthlystatusController', detailmonthlystatusController); /* @ngInject */ function detailmonthlystatusController($state, $stateParams, appConfig, $log, Auth, $cookies, WEB_API_EMPLOYEE) { var vm = this; // ======================================================================= // 초기데이터 // ======================================================================= if($stateParams.selectedCustomerInfo != null){ $cookies.putObject('selectedCustomerInfo', $stateParams.selectedCustomerInfo) } vm.selectedCustomerInfo = $cookies.getObject('selectedCustomerInfo'); iniData(); // ======================================================================= // Angularjs Function // ======================================================================= /* start dialog */ vm.clickChangeDialog = function(index){ vm.checkDialogRentStatus = false; // 대여 현황 vm.checkDialogReleaseStatus = false; // 출고 내역 vm.checkDialogStoredStatus = false; // 입고 내역 vm.checkDialogOverStoredStatus = false; // 오버입고 내역 switch (index) { case 1: vm.tmpTxt = "출고"; vm.checkDialogRentStatus = true; // 대여 현황 vm.type = 0; vm.resetBoard(); break; case 2: vm.tmpTxt = "출고"; vm.checkDialogReleaseStatus = true; // 출고 내역 vm.type = 1; vm.resetBoard(); break; case 3: vm.tmpTxt = "입고"; vm.checkDialogStoredStatus = true; // 입고 내역 vm.type = 2; vm.resetBoard(); break; case 4: vm.tmpTxt = "입고"; vm.type = 3; vm.checkDialogOverStoredStatus = true; // 오버입고 내역 vm.resetBoard(); break; default: break; } } vm.closeDialog = function(){ vm.tmpTxt = "출고"; /* start dialog */ vm.checkDialogRentStatus = true; // 대여 현황 vm.checkDialogReleaseStatus = false; // 출고 내역 vm.checkDialogStoredStatus = false; // 입고 내역 vm.checkDialogOverStoredStatus = false; // 오버입고 내역 /* end dialog */ } /* end dialog */ vm.resetBoard = function () { vm.checkChangeDate = false; // 날짜변경 // board 초기화 vm.flag = true; vm.curPage = 1; // 현재 페이지 vm.startRange = 1; // 시작 페이지 번호 vm.endRange = 1; // 마지막 페이지 번호 vm.searchInfo = { customerId: vm.selectedCustomerInfo.id, searchDate: { startDate: null, endDate: null, }, searchReleaseStatus: null, searchReceiptStatus: null, searchReturnNameOrEmployeeName: null } vm.startDate = null; vm.endDate = null; vm.searchReleaseStatus = null; vm.searchReceiptStatus = null; vm.searchReturnNameOrEmployeeName = null; vm.orderInfo = null; getMonthlyPersonalList(); } vm.iniBoard = function(){ vm.flag = true; vm.curPage = 1; // 현재 페이지 vm.startRange = 1; // 시작 페이지 번호 vm.endRange = 1; // 마지막 페이지 번호 } vm.searchForBoard = function(){ if(vm.searchReturnNameOrEmployeeName == null || vm.searchReturnNameOrEmployeeName == ''){ vm.searchReturnNameOrEmployeeName = null; } vm.searchInfo = { customerId: vm.selectedCustomerInfo.id, searchDate: { startDate: vm.startDate, endDate: vm.endDate, }, searchReleaseStatus: vm.searchReleaseStatus, searchReceiptStatus: vm.searchReceiptStatus, searchReturnNameOrEmployeeName: vm.searchReturnNameOrEmployeeName } vm.iniBoard(); getMonthlyPersonalList(); } vm.checkDuring = function(check){ if(check == 1){ // 오늘 vm.checkChangeDate = false; }else{ vm.checkChangeDate = true; } } vm.searchForDate = function(check){ if(check){ vm.checkChangeDate = false; vm.startDate = null; vm.endDate = null; }else{ vm.startDate = $("#startDate").val(); vm.endDate = $("#endDate").val(); } vm.searchForBoard(); } vm.searchForReleaseStatus = function(check){ // check 0:일반, 1: 상차, 2: 경매, 3: 수관 if(check == null){ vm.searchReleaseStatus = null; }else{ vm.searchReleaseStatus = check; } vm.searchForBoard(); } vm.searchForReceiptStatus = function(check){ // check 0:일반, 1: 점포, 2: 비회원 if(check == null){ vm.searchReceiptStatus = null; }else{ vm.searchReceiptStatus = check; } vm.searchForBoard(); } vm.searchForReturnNameOrEmployeeName = function(check){ if(check == 0){ vm.searchReturnNameOrEmployeeName = null; } vm.searchForBoard(); } vm.selectBoardCnt = function(number){ vm.boardCnt = number; vm.iniBoard(); getMonthlyPersonalList(); } // ======================================================================= // Common Function // ======================================================================= function iniData(){ vm.checkSearchResult = true; vm.tmpTxt = "출고"; vm.checkChangeDate = false; // 날짜변경 /* start dialog */ vm.checkDialogRentStatus = true; // 대여 현황 vm.checkDialogReleaseStatus = false; // 출고 내역 vm.checkDialogStoredStatus = false; // 입고 내역 vm.checkDialogOverStoredStatus = false; // 오버입고 내역 /* end dialog */ // board 초기화 vm.flag = true; vm.curPage = 1; // 현재 페이지 vm.boardCnt = 15; // 한페이지에 보여지는 콘텐츠 개수 vm.arrowPageCnt = 5; vm.maxShownPageCnt = 5; // 보여지는 최대 페이지 개수 vm.startRange = 1; // 시작 페이지 번호 vm.endRange = 1; // 마지막 페이지 번호 vm.searchInfo = { customerId: vm.selectedCustomerInfo.id, searchDate: { startDate: null, endDate: null, }, searchReleaseStatus: null, searchReceiptStatus: null, searchReturnNameOrEmployeeName: null } vm.startDate = null; vm.endDate = null; vm.searchReleaseStatus = null; vm.searchReceiptStatus = null; vm.searchReturnNameOrEmployeeName = null; vm.type = 0; // 0: 대여현황, 1: 출고내역, 2: 입고내역: 3:오버입고내역 getMonthlyPersonalList(); } /*start: getMonthlyPersonalList*/ function getMonthlyPersonalList() { if( vm.searchInfo.searchDate.startDate == null && vm.searchInfo.searchDate.endDate == null && vm.searchInfo.searchReleaseStatus == null && vm.searchInfo.searchReceiptStatus== null && vm.searchInfo.searchReturnNameOrEmployeeName== null ){ vm.checkSearchResult = false; }else{ vm.checkSearchResult = true; } WEB_API_EMPLOYEE.getMonthlyPersonalList({ curPage: vm.curPage, boardCnt: vm.boardCnt, searchInfo: vm.searchInfo, orderInfo: vm.orderInfo, type: vm.type }).then(function (result) { vm.getMonthlyPersonalList = result.data.rows; console.log(vm.getMonthlyPersonalList); vm.totalBoardLen = result.data.count; vm.pageCnt = Math.ceil(vm.totalBoardLen / vm.boardCnt); if (vm.flag) { if (vm.pageCnt <= vm.maxShownPageCnt) { vm.endRange = vm.pageCnt; } else { vm.endRange = vm.maxShownPageCnt; } } vm.flag = false; }).catch(function (err) { $log.error(err); }); } // ======================================================================= // 페이지 범위 계산 // ======================================================================= vm.pageRange = function (min, max) { var input = []; for (var i = min; i <= max; i += 1) { input.push(i); } return input; }; // ======================================================================= // 버튼클릭 이벤트 // ======================================================================= // clickFirstArrow 클릭 vm.clickFirstArrow = function () { vm.curPage = 1; vm.startRange = 1; if (vm.pageCnt <= vm.maxShownPageCnt) { vm.endRange = vm.pageCnt; } else { vm.endRange = vm.maxShownPageCnt; } getMonthlyPersonalList(); }; // clickLastArrow 클릭 vm.clickLastArrow = function () { vm.curPage = vm.pageCnt; vm.endRange = vm.pageCnt; if (vm.pageCnt <= vm.maxShownPageCnt) { vm.startRange = 1; } else { var remainderValue = vm.pageCnt % vm.maxShownPageCnt; var value = vm.maxShownPageCnt - remainderValue; if (remainderValue != 0) { vm.startRange = vm.pageCnt - remainderValue + 1; } else { vm.startRange = vm.endRange; } } getMonthlyPersonalList(); }; // leftArrow 클릭 vm.clickLeftArrow = function () { if (vm.curPage > 1) { vm.curPage -= vm.arrowPageCnt; } if (vm.curPage < vm.startRange) { if ((vm.endRange % vm.maxShownPageCnt) != 0) { vm.endRange += (vm.maxShownPageCnt - (vm.endRange % vm.maxShownPageCnt)); } vm.startRange -= vm.arrowPageCnt; vm.endRange = vm.startRange + (vm.arrowPageCnt - 1); } vm.curPage = vm.endRange; getMonthlyPersonalList(); }; // rightArrow 클릭 vm.clickRightArrow = function () { if (vm.curPage < vm.pageCnt) { vm.curPage += vm.arrowPageCnt; } if (vm.curPage > vm.endRange) { vm.startRange += vm.arrowPageCnt; vm.endRange += vm.arrowPageCnt; if (vm.endRange >= vm.pageCnt) { vm.endRange = vm.pageCnt; } } vm.curPage = vm.startRange; getMonthlyPersonalList(); }; // 페이지 직접 클릭 vm.clickPage = function (index) { vm.curPage = index; getMonthlyPersonalList(); }; /* end: getMonthlyPersonalList*/ } })();