change planin

This commit is contained in:
Kana
2024-01-24 16:59:33 +09:00
parent 8d4eac2b77
commit 02f31c224e
2 changed files with 131 additions and 3 deletions

View File

@@ -122,15 +122,49 @@ public class PlanInController {
// 입고예정추가 // 입고예정추가
@PostMapping("/planin_add") @PostMapping("/planin_add")
public ModelAndView add(ModelAndView mav, ProductDto dto) public ModelAndView add(@RequestParam(name = "searchn", defaultValue = "0") int searchn,
@RequestParam(name = "search", defaultValue = "") String search,
@RequestParam(name = "p", defaultValue = "1") int page, ModelAndView mav)
{ {
int count = productservice.count(searchn, search);
int perPage = 3; // 한 페이지에 보일 글의 개수
int startRow = (page - 1) * perPage;
List<ProductDto> dto = productservice.productList(searchn, search, startRow ,perPage);
mav.addObject("list", dto);
mav.addObject("start", startRow + 1);
int pageNum = 5;//보여질 페이지 번호 수
int totalPages = count / perPage + (count % perPage > 0 ? 1 : 0); // 전체 페이지 수
int begin = (page - 1) / pageNum * pageNum + 1;
int end = begin + pageNum - 1;
if (end > totalPages) {
end = totalPages;
}
mav.addObject("searchn",searchn);
mav.addObject("search",search);
mav.addObject("begin", begin);
mav.addObject("end", end);
mav.addObject("pageNum", pageNum);
mav.addObject("totalPages", totalPages);
mav.addObject("p" , page);
/*
List<ProductDto> list = productservice.productList(0, "", 0, 10000); List<ProductDto> list = productservice.productList(0, "", 0, 10000);
//list //list
//ProductDto (0) //ProductDto (0)
//ProductDto (1) //ProductDto (1)
//ProductDto (2) //ProductDto (2)
mav.addObject("list", list); mav.addObject("list", list);
*/
mav.setViewName("planin_add"); mav.setViewName("planin_add");
return mav; return mav;
} }

View File

@@ -37,11 +37,84 @@ function goTable(){
hideSearchModal(); hideSearchModal();
} }
function pagingFunction(clickedId){
var title = "입고 예정 추가";
var searchn = $("#searchn1").val();
var search = $("#search1").val();
$("#searchModalLabel").text(title);
const data = {
searchn : searchn,
search : search,
p : parseInt(clickedId)
};
$.ajax({
type : 'post', // 타입 (get, post, put 등등)
url : '/plan_in/planin_add', // 요청할 서버url
dataType : 'html', // 데이터 타입 (html, xml, json, text 등등)
data : data,
success : function(result) { // 결과 성공 콜백함수
$("#search_modal_body").html(result);
searchModalBootStrap.show();
},
error : function(request, status, error) {
alert(error)
}
});
}//pagingFunction
$(document).ready(function() {
$("#searchBtn").on("click", function(){
var title = "입고 예정 추가";
var searchn = $("#searchn").val();
var search = $("#search").val();
$("#searchModalLabel").text(title);
const data = {
searchn : searchn,
search : search,
p : 1
};
$.ajax({
type : 'post', // 타입 (get, post, put 등등)
url : '/plan_in/planin_add', // 요청할 서버url
dataType : 'html', // 데이터 타입 (html, xml, json, text 등등)
data : data,
success : function(result) { // 결과 성공 콜백함수
$("#search_modal_body").html(result);
searchModalBootStrap.show();
},
error : function(request, status, error) {
alert(error)
}
});
})//searchBtn
});//ready
</script> </script>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-12">
<div id="div_auth_search" class="text-end">
<div class="input-group mb-3 w-50 col-centered">
<div class="w-30">
<select class="form-select" name="searchn" id="searchn">
<option selected="selected" value="0" <c:if test="${searchn == 0}">selected="selected"</c:if> >제품명</option>
<option value="1" <c:if test="${searchn == 1}">selected="selected"</c:if>>회사명</option>
<option value="2" <c:if test="${searchn == 2}">selected="selected"</c:if>>분류</option>
<option value="3" <c:if test="${searchn == 3}">selected="selected"</c:if>>담당자명</option>
</select>
</div>
<input type="text" id="search" name="search" value="${search}" class="form-control" aria-label="Text input with dropdown button" placeholder="검색어를 입력하세요">
<button class="btn btn-info" type="button" id="searchBtn">검색</button>
<!-- 페이징작업용 -->
<input type="hidden" id="searchn1" value="${searchn}">
<input type="hidden" id="search1" value="${search}">
<!-- 페이징작업용 -->
</div>
</div>
</div>
<div class="col-12"> <div class="col-12">
<table class="table"> <table class="table">
<thead class="table-dark"> <thead class="table-dark">
@@ -73,6 +146,27 @@ function goTable(){
</table> </table>
</div> </div>
</div> </div>
<div class="col-12 d-flex justify-content-center">
<nav>
<ul class="pagination">
<c:if test="${begin > pageNum }">
<li class="page-item">
<a href="javascript:void(0);" class="page-link" onclick="pagingFunction(this.id)" id="${begin - 1 }">&lt;</a>
</li>
</c:if>
<c:forEach begin="${begin }" end="${end }" var="i">
<li class="page-item <c:if test="${p == i}"> active </c:if>">
<a href="javascript:void(0);" class="page-link " onclick="pagingFunction(this.id); return false;" id="${i }">${i }</a>
</li>
</c:forEach>
<c:if test="${end < totalPages }">
<li class="page-item">
<a href="javascript:void(0);" class="page-link" onclick="pagingFunction(this.id)" id="${end + 1 }">&gt;</a>
</li>
</c:if>
</ul>
</nav>
</div>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<hr> <hr>