입고예정 리스트 하단 page 번호 추가

This commit is contained in:
김민구
2024-01-24 11:56:38 +09:00
parent 8e38a3f520
commit 2e29fcb969
4 changed files with 34 additions and 10 deletions

View File

@@ -33,10 +33,9 @@ public class PlanInController {
@GetMapping("/list")
public ModelAndView list(ModelAndView mav,@RequestParam(defaultValue = "0") int searchn, @RequestParam(defaultValue = "") String search, @RequestParam(defaultValue = "1") int page){
int perPage = 15;
int perPage = 10;
int startRow = (page - 1) * perPage;
int count = planinservice.count(searchn, search);
int count = planinservice.count(searchn, search, startRow, perPage);
int pageNum = 4;//보여질 페이지 번호 수

View File

@@ -20,11 +20,13 @@ public class PlanInService {
return mapper.selectAll(map);
}
int count(int searchn, String search){
int count(int searchn, String search, int start, int perPage){
System.out.printf("searchn : %d, search : %s, start : %d, perpage : %d", searchn, search, start, perPage);
HashMap<String, Object> m = new HashMap<>();
m.put("searchn", searchn);
m.put("search", search);
m.put("start", start);
m.put("perPage", perPage);
return mapper.count(m);
}
@@ -47,7 +49,4 @@ public class PlanInService {
return mapper.selectByQRHash(qrHash);
}
}

View File

@@ -127,9 +127,10 @@
<select id="count" parameterType="map" resultType="java.lang.Integer">
select count(*) from ( SELECT 1 from plan_In i join product p
<where>
<choose>
<choose>
<when test="searchn == 0"> i.product_id = p.id and i.activation = 1 and i.view_group_number like concat('%',#{search},'%') </when>
<when test="searchn == 1"> i.product_id = p.id and i.activation = 1 and p.name like concat('%',#{search},'%')</when>
<when test="searchn == 0"> i.product_id = p.id and i.activation = 1 and i.group_number like concat('%',#{search},'%') </when>
<when test="searchn == 2"> i.product_id = p.id and i.activation = 1 and i.quantity like concat(#{search})</when>
</choose>
</where>
) t

View File

@@ -31,6 +31,14 @@
$form.trigger("submit");
}
function onPaging(target){
const p = $(target).data("p");
$("#pPage").val(p);
const $form = $("#search_form");
$form.attr("action", "/plan_in/list");
$form.trigger("submit");
}
</script>
<div class="container">
@@ -77,6 +85,23 @@
</table>
</div>
</div>
<div class="row">
<div class="col-12">
<div id="page">
<ul class="pagination justify-content-center">
<c:if test="${begin > pageNum }">
<li class="page-item"><a class="page-link" data-p='${begin-1 }' href="#" onclick="onPaging(this)">[<]</a></li>
</c:if>
<c:forEach begin="${begin }" end="${end}" var="i" varStatus="status">
<li class="page-item <c:if test="${page eq status.count}">active</c:if> "><a class="page-link" data-p='${i}' href="#" onclick="onPaging(this)" >${i}</a></li>
</c:forEach>
<c:if test="${end < totalPages }">
<li class="page-item"><a class="page-link" data-p='${end+1}' href="#" onclick="onPaging(this)">[>]</a></li>
</c:if>
</ul>
</div>
</div>
</div>
</div>
<form id="form" action='/plan_in/read' method="post">
<input name="groupNumber" id="groupId" hidden>