mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-05 19:53:26 +09:00
planin 작업중
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
|
||||
<script>
|
||||
|
||||
let modalData = {};
|
||||
let $selectedTr;
|
||||
|
||||
function showSearchModal(title){
|
||||
$("#searchModalLabel").text(title);
|
||||
const data = { };
|
||||
@@ -21,6 +23,111 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
function showSearchModalEdit(title, target){
|
||||
$selectedTr = $($(target).parent('td').parent("tr"));
|
||||
$("#searchModalLabel").text(title);
|
||||
const data = { };
|
||||
$.ajax({
|
||||
type : 'post', // 타입 (get, post, put 등등)
|
||||
url : '/plan_in/planin_edit', // 요청할 서버url
|
||||
dataType : 'html', // 데이터 타입 (html, xml, json, text 등등)
|
||||
data : data,
|
||||
success : function(result) { // 결과 성공 콜백함수
|
||||
$("#search_modal_body").html(result);
|
||||
const tds = $selectedTr.find("td");
|
||||
|
||||
modalData.name = $(tds[0]).text();
|
||||
modalData.category = $(tds[1]).text();
|
||||
modalData.id = $selectedTr.data("productid");
|
||||
modalData.vendor = $(tds[3]).text();
|
||||
modalData.date = $(tds[4]).text();
|
||||
modalData.num = $(tds[2]).text();
|
||||
|
||||
editData();
|
||||
searchModalBootStrap.show();
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
alert(error)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addToTable(data){
|
||||
const $addTr = $("#id_add_tr");
|
||||
|
||||
const $newTr = $($("#id_table_body tr")[0]).clone();
|
||||
|
||||
//데이터 세팅 부분
|
||||
$newTr.data("productid", data.id);
|
||||
const tds = $newTr.find("td");
|
||||
$(tds[0]).text(data.name);
|
||||
$(tds[1]).text(data.category);
|
||||
$(tds[2]).text(data.num);
|
||||
$(tds[3]).text(data.vendor);
|
||||
$(tds[4]).text(data.date);
|
||||
|
||||
|
||||
$addTr.detach().appendTo("#form");
|
||||
|
||||
$("#id_table_body").append($newTr);
|
||||
|
||||
$addTr.detach().appendTo("#id_table_body");
|
||||
}
|
||||
|
||||
function editToTable(data){
|
||||
|
||||
const $newTr = $selectedTr;
|
||||
|
||||
//데이터 세팅 부분
|
||||
$newTr.data("productid", data.id);
|
||||
const tds = $newTr.find("td");
|
||||
$(tds[0]).text(data.name);
|
||||
$(tds[1]).text(data.category);
|
||||
$(tds[2]).text(data.num);
|
||||
$(tds[3]).text(data.vendor);
|
||||
$(tds[4]).text(data.date);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function deleteTable(target){
|
||||
$($(target).parent('td').parent("tr")).remove();
|
||||
}
|
||||
|
||||
function goSave(){
|
||||
const list = [];
|
||||
|
||||
const $trs = $(".group_tr");
|
||||
|
||||
$trs.each(function(index, item){
|
||||
let data = {};
|
||||
const $tr = $(item);
|
||||
const tds = $tr.find("td");
|
||||
data.groupNumber = $tr.data("groupn");
|
||||
data.productId = $tr.data("productid");
|
||||
data.date = $(tds[4]).text();
|
||||
data.quantity = $(tds[2]).text();
|
||||
list.push(data);
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type : 'post', // 타입 (get, post, put 등등)
|
||||
url : '/plan_in/planin_update_process', // 요청할 서버url
|
||||
data : JSON.stringify(list),
|
||||
dataType : 'json',
|
||||
contentType: "application/json; charset=utf-8",
|
||||
success : function(result) { // 결과 성공 콜백함수
|
||||
console.log(result);
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
alert(error)
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
@@ -43,7 +150,7 @@
|
||||
<thead class="table-dark">
|
||||
<tr><th>제품 카테고리</th><th>제품명</th><th>수량</th><th>공급업체</th><th>날짜</th><th>수정/삭제</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody id="id_table_body">
|
||||
<c:forEach items="${list }" var="dto" varStatus="status">
|
||||
<tr class="group_tr" data-groupn="${dto.groupNumber}" data-productid="${dto.productId}">
|
||||
<td>${dto.caName}</td>
|
||||
@@ -51,10 +158,11 @@
|
||||
<td>${dto.quantity}</td>
|
||||
<td>${dto.vendorDto.name}</td>
|
||||
<td><fmt:formatDate value="${dto.date}" pattern="yyyy-MM-dd" type="date"/></td>
|
||||
<td><button type="submit" class="btn btn-warning" >수정</button><button type="submit" class="btn btn-danger" >삭제</button><td>
|
||||
<td><button type="button" class="btn btn-warning" onclick="showSearchModalEdit('입고 예정 추가', this)">수정</button>
|
||||
<button type="button" class="btn btn-danger" onclick="deleteTable(this)" >삭제</button><td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
<tr>
|
||||
<tr id="id_add_tr">
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
@@ -66,6 +174,14 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<button class="btn-primary btn" onclick="goSave()">저장</button>
|
||||
<form method="get" class="d-inline" action="/plan_in/list">
|
||||
<button class="btn-primary btn" type="submit">취소</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form id="form" action='/plan_in/read' method="post">
|
||||
<input name="groupNumber" id="groupId" hidden>
|
||||
|
||||
Reference in New Issue
Block a user