mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-04 19:54:00 +09:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -8,7 +8,6 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Alias("CategoryDto")
|
||||
public class CategoryDto {
|
||||
|
||||
|
||||
@@ -6,39 +6,73 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/product")
|
||||
public class ProductController {
|
||||
|
||||
@Autowired
|
||||
ProductService productservice;
|
||||
|
||||
@GetMapping("/product/list")
|
||||
public void list(@RequestParam(name = "p", defaultValue = "1") int p, Model m) {
|
||||
@GetMapping("list")
|
||||
public String list(@RequestParam(name = "p", defaultValue = "1") int p, Model m) {
|
||||
|
||||
// 서비스로 카테고리 목록 불러오는 메서드 작성
|
||||
List<ProductDto> dto = productservice.productList(p);
|
||||
m.addAttribute("list", dto);
|
||||
return "/product/list";
|
||||
}
|
||||
|
||||
System.out.println(dto.get(0).getId());
|
||||
System.out.println(dto.get(0).getName());
|
||||
System.out.println(dto.get(0).getCompany_name());
|
||||
System.out.println(dto.get(0).getKan_code());
|
||||
System.out.println(dto.get(0).getVendor_id());
|
||||
System.out.println(dto.get(0).getRegistration_date());
|
||||
System.out.println(dto.get(0).getManager_id());
|
||||
System.out.println(dto.get(0).getAccountDto());
|
||||
System.out.println(dto.get(0).getVendorDto().getName());
|
||||
System.out.println(dto.get(0).getVendorDto().getPresident_name());
|
||||
System.out.println(dto.get(0).getAccountDto().getName());
|
||||
System.out.println(dto.get(0).getCategoryDto().getCls_nm_1());
|
||||
System.out.println(dto.get(0).getCategoryDto().getCls_nm_2());
|
||||
System.out.println(dto.get(0).getCategoryDto().getCls_nm_3());
|
||||
System.out.println(dto.get(0).getCategoryDto().getCls_nm_4());
|
||||
// 생성 - 폼
|
||||
@PostMapping("/create")
|
||||
public String create() {
|
||||
return "/product/create";
|
||||
}
|
||||
|
||||
// 생성 - Ajax
|
||||
@PostMapping("/create_process")
|
||||
@ResponseBody
|
||||
public boolean createProcess(ProductDto dto) {
|
||||
int i = productservice.createProcess(dto);
|
||||
if (i == 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//m.addAttribute("list", dto);
|
||||
//return "/";
|
||||
// 상세페이지
|
||||
@PostMapping("/read")
|
||||
public String read(String id, Model m) {
|
||||
ProductDto dto = productservice.selectById(id);
|
||||
m.addAttribute("dto", dto);
|
||||
return "product/read";
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public String update(String id, Model m) {
|
||||
ProductDto dto = productservice.selectById(id);
|
||||
m.addAttribute("dto", dto);
|
||||
return "product/update";
|
||||
}
|
||||
|
||||
// 수정 - Ajax
|
||||
@PutMapping("update_process")
|
||||
@ResponseBody
|
||||
public boolean update_process(ProductDto dto) {
|
||||
System.out.println(dto.getId());
|
||||
|
||||
int i = productservice.updateById(dto);
|
||||
if (i == 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,14 +5,17 @@ import java.util.Date;
|
||||
import org.apache.ibatis.type.Alias;
|
||||
|
||||
import com.no1.wms.account.AccountDto;
|
||||
import com.no1.wms.authority.AuthorityDto;
|
||||
import com.no1.wms.category.CategoryDto;
|
||||
import com.no1.wms.vendor.VendorDto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Alias("ProductDto")
|
||||
@@ -20,7 +23,8 @@ public class ProductDto {
|
||||
|
||||
private String id;//id
|
||||
private String name;//제품명
|
||||
private String company_name;//회사명
|
||||
@Builder.Default
|
||||
private String company_name = "미지정";//회사명
|
||||
private String kan_code;//분류코드
|
||||
private String vendor_id;//거래처 id
|
||||
private Date registration_date;//등록날짜
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
public interface ProductMapper {
|
||||
|
||||
List<ProductDto> productList(Map<String, Object> m);
|
||||
|
||||
|
||||
|
||||
int createProcess(ProductDto dto);
|
||||
ProductDto selectById(String id);
|
||||
int updateById(ProductDto dto);
|
||||
}
|
||||
|
||||
@@ -26,4 +26,16 @@ public class ProductService {
|
||||
return mapper.productList(m);
|
||||
}
|
||||
|
||||
public int createProcess(ProductDto dto) {
|
||||
return mapper.createProcess(dto);
|
||||
}
|
||||
|
||||
public ProductDto selectById(String id) {
|
||||
return mapper.selectById(id);
|
||||
}
|
||||
|
||||
public int updateById(ProductDto dto) {
|
||||
return mapper.updateById(dto);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,12 +30,23 @@
|
||||
</association>
|
||||
</resultMap>
|
||||
|
||||
<!-- 설명한번 드릴게요 이거 원래 jsp를 부르려고했는데 오류가 자꾸 나서 원인을 찾아보다가
|
||||
결국 dto에 안담긴다는 것을 알고 컨트롤러코드를 수정했습니다ㅣ.mapper sql문이 아래 있는거?네 -->
|
||||
<!-- insert -->
|
||||
<insert id="createProcess" parameterType="ProductDto">
|
||||
INSERT INTO product (id, name, company_name, kan_code, vendor_id, registration_date, manager_id, activation)
|
||||
VALUES (UUID(), #{name}, #{company_name}, #{kan_code}, #{vendor_id}, CURDATE(), #{manager_id}, 1)
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- update -->
|
||||
|
||||
<update id="updateById" parameterType="ProductDto">
|
||||
UPDATE product
|
||||
SET name = #{name}, company_name = #{company_name},kan_code = #{kan_code},
|
||||
vendor_id = #{vendor_id}, manager_id = #{manager_id}, registration_date = CURDATE()
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- delete -->
|
||||
|
||||
@@ -57,4 +68,22 @@
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectById" parameterType="String" resultMap="productResultMap">
|
||||
SELECT
|
||||
p.id, p.name, p.company_name, p.kan_code, p.vendor_id, p.registration_date,
|
||||
p.manager_id, p.activation,
|
||||
v.name as vendor_name, v.president_name,
|
||||
a.name as account_name,
|
||||
pc.cls_nm_1, pc.cls_nm_2, pc.cls_nm_3, pc.cls_nm_4
|
||||
FROM product as p
|
||||
left join vendor as v on p.vendor_id = v.id
|
||||
left join account as a on p.manager_id = a.id
|
||||
left join product_category as pc on p.kan_code = pc.kan_code
|
||||
WHERE p.id = #{id}
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -5,9 +5,6 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>카테고리 생성</title>
|
||||
<style>
|
||||
.body{
|
||||
text-align: center;
|
||||
}
|
||||
.col-centered{
|
||||
margin: 0 auto;
|
||||
float: none;
|
||||
@@ -56,8 +53,9 @@
|
||||
aria-describedby="basic-addon1">
|
||||
</div>
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon5">KAN 분류코드</span>
|
||||
<input type="number" min="1" name="kan_code" id="kan_code" class="form-control"
|
||||
placeholder="KAN 분류코드" aria-label="KAN 분류코드" value="${dto.kan_code }"
|
||||
placeholder="KAN 분류코드를 입력하세요" aria-label="KAN 분류코드" value="${dto.kan_code }"
|
||||
aria-describedby="button-addon2">
|
||||
<button class="btn btn-outline-secondary rounded-end" id="checkKan"
|
||||
style="background-color:#FF5E5E;" type="button" >중복확인</button>
|
||||
|
||||
259
src/main/webapp/WEB-INF/views/product/create.jsp
Normal file
259
src/main/webapp/WEB-INF/views/product/create.jsp
Normal file
@@ -0,0 +1,259 @@
|
||||
<%@ page contentType="text/html; charset=UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>제품 추가</title>
|
||||
<style>
|
||||
|
||||
.col-centered{
|
||||
margin: 0 auto;
|
||||
float: none;
|
||||
}
|
||||
.col-margin-left-32{
|
||||
margin-left: 32%;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="mt-5 mb-5 text-center">
|
||||
<h1>제품 추가</h1>
|
||||
</div>
|
||||
<hr>
|
||||
<div style="text-align: center">
|
||||
<form id="createForm">
|
||||
<div class="ulTag">
|
||||
<div class="row">
|
||||
<div class="col-12" style="text-align: center;">
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon1">제품명</span>
|
||||
<input type="text" name="name" id="name" class="form-control"
|
||||
placeholder="제품명을 입력하세요" aria-label="제품명" value="${dto.name }"
|
||||
aria-describedby="basic-addon1">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon2">회사명</span>
|
||||
<input type="text" name="company_name" id="company_name" class="form-control"
|
||||
placeholder="회사명을 입력하세요(선택)" aria-label="회사명" value="${dto.company_name }"
|
||||
aria-describedby="basic-addon1">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon3">분류</span>
|
||||
<input type="number" min="1" name="cls_nm_4" id="cls_nm_4" class="form-control"
|
||||
placeholder="KAN 분류코드를 입력하세요(모달이 만들어지면 분류로 바꿀예정)" aria-label="분류"
|
||||
aria-describedby="button-addon2">
|
||||
<button class="btn btn-outline-secondary rounded-end" id="searchKan"
|
||||
style="background-color:#FF5E5E;" type="button" >검색</button>
|
||||
<input type='hidden' id='searchKanChack' value='0'>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon4">거래처</span>
|
||||
<input type="text" name="vendor" id="vendor" class="form-control"
|
||||
placeholder="거래처를 입력하세요" aria-label="거래처"
|
||||
aria-describedby="button-addon2">
|
||||
<button class="btn btn-outline-secondary rounded-end" id="searchVendor"
|
||||
style="background-color:#FF5E5E;" type="button" >검색</button>
|
||||
<input type='hidden' id='searchVendorChack' value='0'>
|
||||
</div>
|
||||
|
||||
<!-- 추후 수정 -->
|
||||
<input type='hidden' id="manager_id" value="83bdda69-ae95-11ee-935d-0242ac110006">
|
||||
<input type='hidden' id="vendor_id" value="">
|
||||
<input type='hidden' id="kan_code" value="">
|
||||
|
||||
<!-- 추후 수정 -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 ">
|
||||
<div class="w-40 col-centered" style="text-align: right">
|
||||
<button type="button" class="btn btn-success" id="submitBtn">추가</button>
|
||||
<button type="button" class="btn btn-secondary" id="cancelBtn">취소</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
<!-- 모달화면 -->
|
||||
<div class="modal fade" id="searchKanModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl" >
|
||||
<div class="modal-content" id="search_modal_content">
|
||||
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" id="searchModalLabel">KAN 분류코드 검색</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body" id="search_modal_body">
|
||||
<form action="categorySearch">
|
||||
<div class="input-group mb-3 w-50 col-centered">
|
||||
<div class="w-25">
|
||||
<select class="form-select">
|
||||
<option selected="selected" value="cls_nm_4">세분류</option>
|
||||
<option value="cls_nm_1">대분류</option>
|
||||
<option value="cls_nm_2">중분류</option>
|
||||
<option value="cls_nm_3">세분류</option>
|
||||
<option value="kan_code">KAN코드</option>
|
||||
</select>
|
||||
</div>
|
||||
<input type="text" name="categorySearch" class="form-control" aria-label="Text input with dropdown button" placeholder="검색어를 입력하세요">
|
||||
<button class="btn btn-info" type="button" id="button-addon2 searchBtn">검색</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="row row-table">
|
||||
<div class="col-12">
|
||||
<table class="table">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>대분류</th>
|
||||
<th>중분류</th>
|
||||
<th>소분류</th>
|
||||
<th>세분류</th>
|
||||
<th>KAN코드</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${list }" var="dto">
|
||||
<tr class="detailTr" data-kan_code="${dto.kan_code}" >
|
||||
<td>${dto.cls_nm_1 }</td>
|
||||
<td>${dto.cls_nm_2 }</td>
|
||||
<td>${dto.cls_nm_3 }</td>
|
||||
<td>${dto.cls_nm_4 }</td>
|
||||
<td>${dto.kan_code }</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button id="modal_yes_button" type="button" class="modal_yes btn btn-primary">확인</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 스크립트 -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
const searchKanModalBootStrap = new bootstrap.Modal("#searchKanModal");
|
||||
$("#searchKan").on("click", function(){
|
||||
searchKanModalBootStrap.show();
|
||||
});//searchKan
|
||||
|
||||
$("#searchVendor").on("click", function(){
|
||||
searchModalBootStrap.show();
|
||||
});//searcVendor
|
||||
|
||||
$("#submitBtn").on("click", function(){
|
||||
var name = $("#name").val();
|
||||
var company_name = $("#company_name").val();
|
||||
var kan_code = $("#cls_nm_4").val();// 수정해야함.
|
||||
var vendor = $("#vendor").val();
|
||||
var manager_id = $("#manager_id").val();
|
||||
if(!name){
|
||||
alert("제품명을 입력해야 합니다.");
|
||||
$("#name").focus();
|
||||
return false;
|
||||
}
|
||||
if(!company_name){
|
||||
company_name = "미지정";
|
||||
}
|
||||
if(!kan_code){
|
||||
alert("KAN 분류코드를 입력해야 합니다.");
|
||||
$("#kan_code").focus();
|
||||
return false;
|
||||
}
|
||||
if(!vendor){
|
||||
alert("거래처를 입력해야 합니다.");
|
||||
$("#vendor").focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: "/product/create_process",
|
||||
type: "post",
|
||||
data: {
|
||||
"name": name,
|
||||
"company_name": company_name,
|
||||
"kan_code": kan_code,
|
||||
"vendor_id": vendor, // 추후 수정해야함.
|
||||
"manager_id": manager_id,
|
||||
"activation": true
|
||||
},
|
||||
datatype:"json"
|
||||
}).done(function(data) {
|
||||
if (data == true) {
|
||||
alert("제품을 추가했습니다.");
|
||||
$(location).attr("href", "/product/list");
|
||||
|
||||
|
||||
//생각해서 바꿔야함.
|
||||
// 조건 : DB에서 생성되는 uuid를 어떻게 자바스크립트에서 가져올것인지 궁리.
|
||||
/*
|
||||
var form = document.createElement("form");
|
||||
form.action = "/product/read";
|
||||
form.method = "POST";
|
||||
document.body.appendChild(form);
|
||||
|
||||
var input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = "id";
|
||||
input.value = data.id;
|
||||
form.appendChild(input);
|
||||
|
||||
form.submit();
|
||||
*/
|
||||
} else {
|
||||
alert("제품 추가에 실패하였습니다.");
|
||||
}
|
||||
}).fail(function() {
|
||||
alert("오류가 발생했습니다.");
|
||||
}).always(function() {
|
||||
//
|
||||
});
|
||||
});
|
||||
|
||||
$("#cancelBtn").on("click", function(){
|
||||
$(location).attr("href", "/product/list");
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});//ready
|
||||
function searchKanCode(){
|
||||
|
||||
}
|
||||
|
||||
function searchVendor(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,4 +1,6 @@
|
||||
<%@ page contentType="text/html; charset=UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@@ -39,7 +41,7 @@
|
||||
<tr>
|
||||
<th>제품명</th>
|
||||
<th>회사명</th>
|
||||
<th>소분류</th>
|
||||
<th>분류</th>
|
||||
<th>거래처</th>
|
||||
<th>등록날짜</th>
|
||||
<th>담당자</th>
|
||||
@@ -47,17 +49,14 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${list }" var="dto">
|
||||
<tr class="detailTr" data-productId="${dto.id}" >
|
||||
<tr class="detailTr" data-product_id="${dto.id}" >
|
||||
<td>${dto.name }</td>
|
||||
<td>${dto.company_name }</td>
|
||||
<!-- <td>${dto.categoryDto.cls_nm_4 }</td>
|
||||
<td>${dto.categoryDto.cls_nm_4 }</td>
|
||||
<td>${dto.vendorDto.name }</td>
|
||||
<td>${dto.registration_date }</td>
|
||||
<td>${dto.accountDto.name }</td>-->
|
||||
<td>3</td>
|
||||
<td>4</td>
|
||||
<td>5</td>
|
||||
<td>6</td>
|
||||
<td><fmt:formatDate value="${dto.registration_date }"
|
||||
dateStyle="short" /></td>
|
||||
<td>${dto.accountDto.name }</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
@@ -66,11 +65,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row row-buttons">
|
||||
<div class="col-3 text-start">
|
||||
<img alt="엑셀이미지" src="엑셀이미지">
|
||||
<button type="button" class="btn btn-success" id="uploadExcel">업로드</button>
|
||||
</div>
|
||||
<div class="col-6 d-flex justify-content-center">
|
||||
<nav>
|
||||
@@ -78,10 +76,10 @@
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#"><</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<li class="page-item active">
|
||||
<a class="page-link" href="#">1</a>
|
||||
</li>
|
||||
<li class="page-item active">
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#">2</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
@@ -103,13 +101,54 @@
|
||||
</nav>
|
||||
</div>
|
||||
<div class="col-3 text-end">
|
||||
<button type="button" class="btn btn-primary" id="createButton">생성</button>
|
||||
<button type="button" class="btn btn-primary" id="createButton">추가</button>
|
||||
</div>
|
||||
</div><!-- row row-buttons -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
//POST방식으로 create폼화면 출력
|
||||
$("#createButton").on("click",function(){
|
||||
var form = document.createElement("form");
|
||||
form.action = "/product/create";
|
||||
form.method = "POST";
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
});//createButton
|
||||
|
||||
$("body").on("click", ".detailTr", function(){
|
||||
var product_id = $(this).data("product_id");
|
||||
|
||||
//console.log(product_id);
|
||||
|
||||
var form = document.createElement("form");
|
||||
form.action = "/product/read";
|
||||
form.method = "POST";
|
||||
document.body.appendChild(form);
|
||||
|
||||
var input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = "id";
|
||||
input.value = product_id;
|
||||
form.appendChild(input);
|
||||
|
||||
form.submit();
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});//ready
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
109
src/main/webapp/WEB-INF/views/product/read.jsp
Normal file
109
src/main/webapp/WEB-INF/views/product/read.jsp
Normal file
@@ -0,0 +1,109 @@
|
||||
<%@ page contentType="text/html; charset=UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>제품 상세페이지</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="mt-5 mb-5 text-center">
|
||||
|
||||
<div class="row">
|
||||
<h1>제품 상세페이지</h1>
|
||||
<div class="col-10" style="text-align: right;">
|
||||
<button type="button" class="btn btn-danger" id="yes_no_modal_show_button">삭제</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<div style="text-align: center">
|
||||
<form>
|
||||
<div class="ulTag">
|
||||
<div class="row">
|
||||
<div class="col-12" style="text-align: center;">
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon1">제품명</span> <input
|
||||
type="text" class="form-control" placeholder="제품명"
|
||||
aria-label="제품명" value="${dto.name }" readonly>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon2">회사명</span> <input
|
||||
type="text" class="form-control" placeholder="회사명"
|
||||
aria-label="회사명" value="${dto.company_name }" readonly>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon3">분류</span> <input
|
||||
type="text" class="form-control" placeholder="분류"
|
||||
aria-label="분류" value="${dto.categoryDto.cls_nm_4 }" readonly>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon4">거래처</span> <input
|
||||
type="text" class="form-control" placeholder="거래처"
|
||||
aria-label="거래처" value="${dto.vendorDto.name }" readonly>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon5">등록날짜</span> <input
|
||||
type="text" class="form-control" placeholder="등록날짜"
|
||||
aria-label="KAN 코드" value="${dto.registration_date }" readonly>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon6">담당자</span> <input
|
||||
type="text" class="form-control" placeholder="담당자"
|
||||
aria-label="담당자" value="${dto.accountDto.name }" id="kan_code" readonly>
|
||||
</div>
|
||||
<input type='hidden' id="id" value="${dto.id }">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 ">
|
||||
<div class="w-40 col-centered" style="text-align: right">
|
||||
<button type="button" class="btn btn-primary" id="checkBtn">확인</button>
|
||||
<button type="button" class="btn btn-warning" id="modifyBtn">수정</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#checkBtn").on("click", function() {
|
||||
$(location).attr("href", "/product/list");
|
||||
})//checkBtn click
|
||||
|
||||
|
||||
$("#modifyBtn").on("click", function() {
|
||||
var id = $("#id").val();
|
||||
|
||||
|
||||
var form = document.createElement("form");
|
||||
form.action = "/product/update";
|
||||
form.method = "POST";
|
||||
document.body.appendChild(form);
|
||||
|
||||
var input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = "id";
|
||||
input.value = id;
|
||||
form.appendChild(input);
|
||||
|
||||
form.submit();
|
||||
|
||||
|
||||
})//modifyBtn click
|
||||
|
||||
|
||||
});//ready
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
189
src/main/webapp/WEB-INF/views/product/update.jsp
Normal file
189
src/main/webapp/WEB-INF/views/product/update.jsp
Normal file
@@ -0,0 +1,189 @@
|
||||
<%@ page contentType="text/html; charset=UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Insert title here</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="mt-5 mb-5 text-center">
|
||||
<div class="row">
|
||||
<h1>제품 수정</h1>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<div style="text-align: center">
|
||||
<form>
|
||||
<div class="ulTag">
|
||||
<div class="row">
|
||||
<div class="col-12" style="text-align: center;">
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon1">제품명</span>
|
||||
<input type="text" class="form-control" name="newProductName" placeholder="제품명을 입력하세요"
|
||||
aria-label="제품명" id="name" value="${dto.name }">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon2">회사명</span>
|
||||
<input type="text" class="form-control" name="newCompanyName" placeholder="회사명을 입력하세요(선택)"
|
||||
aria-label="회사명" id="company_name" value="${dto.company_name }">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon3">분류</span>
|
||||
<input type="text" class="form-control" name="newCategory" placeholder="분류를 입력해도 바뀌는건 없습니다 ㅎㅎ(수정예정)"
|
||||
aria-label="분류" id="cls_nm_4" value="${dto.categoryDto.cls_nm_4 }">
|
||||
|
||||
<button class="btn btn-outline-secondary rounded-end" id="searchKan"
|
||||
style="background-color:#FF5E5E;" type="button" >검색</button>
|
||||
<input type='hidden' id='searchKanChack' value='0'>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon4">거래처</span>
|
||||
<input type="text" class="form-control" name="newVendor" placeholder="거래처를 입력해도 바뀌는 건 없습니다."
|
||||
aria-label="거래처" id="vendor" value="${dto.vendorDto.name }">
|
||||
|
||||
<button class="btn btn-outline-secondary rounded-end" id="searchVendor"
|
||||
style="background-color:#FF5E5E;" type="button" >검색</button>
|
||||
<input type='hidden' id='searchVendorChack' value='0'>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon5">등록날짜</span>
|
||||
<input type="text" class="form-control" name="newRegistrationDate"
|
||||
aria-label="등록날짜" readonly id="registration_date" value="${dto.registration_date } (자동)">
|
||||
</div>
|
||||
|
||||
<input type='hidden' id="id" value="${dto.id }">
|
||||
<!-- 추후 수정 -->
|
||||
<input type='hidden' id="manager_id" value="83bdda69-ae95-11ee-935d-0242ac110006">
|
||||
<input type='hidden' id="vendor_id" value="${dto.vendor_id }">
|
||||
<input type='hidden' id="kan_code" value="${dto.kan_code }">
|
||||
|
||||
<!-- 추후 수정 -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="w-40 col-centered" style="text-align: right">
|
||||
<button type="button" class="btn btn-primary" id="submitBtn">수정 완료</button>
|
||||
<button type="button" class="btn btn-secondary" id="cancelBtn">취소</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#cancelBtn").on("click", function(){
|
||||
var id = $("#id").val();
|
||||
|
||||
var form = document.createElement("form");
|
||||
form.action = "/product/read";
|
||||
form.method = "POST";
|
||||
document.body.appendChild(form);
|
||||
|
||||
var input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = "id";
|
||||
input.value = id;
|
||||
form.appendChild(input);
|
||||
|
||||
form.submit();
|
||||
|
||||
})//cancelBtn
|
||||
|
||||
$("#submitBtn").on("click", function(){
|
||||
var name = $("#name").val();
|
||||
var company_name = $("#company_name").val();
|
||||
var kan_code = $("#kan_code").val();
|
||||
var vendor_id = $("#vendor_id").val();
|
||||
var manager_id = $("#manager_id").val();
|
||||
var id = $("#id").val();
|
||||
|
||||
if(!name){
|
||||
alert("제품명을 입력해야 합니다.");
|
||||
$("#name").focus();
|
||||
return false;
|
||||
}
|
||||
if(!company_name){
|
||||
company_name = "미지정";
|
||||
}
|
||||
if(!kan_code){
|
||||
alert("KAN 분류코드를 입력해야 합니다.");
|
||||
//$("#kan_code").focus();
|
||||
return false;
|
||||
}
|
||||
if(!vendor_id){
|
||||
alert("거래처를 입력해야 합니다.");
|
||||
//$("#vendor").focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log(name);
|
||||
console.log(company_name);
|
||||
console.log(kan_code);
|
||||
console.log(vendor_id);
|
||||
console.log(manager_id);
|
||||
console.log(id);
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: "/product/update_process",
|
||||
type: "put",
|
||||
data: {
|
||||
"id":id,
|
||||
"name": name,
|
||||
"company_name": company_name,
|
||||
"kan_code": kan_code,
|
||||
"vendor_id": vendor_id,
|
||||
"manager_id": manager_id,
|
||||
"activation": true
|
||||
},
|
||||
datatype:"json"
|
||||
}).done(function(data) {
|
||||
if (data == true) {
|
||||
alert("제품을 수정했습니다.");
|
||||
//$(location).attr("href", "/product/list");
|
||||
|
||||
var form = document.createElement("form");
|
||||
form.action = "/product/read";
|
||||
form.method = "POST";
|
||||
document.body.appendChild(form);
|
||||
|
||||
var input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = "id";
|
||||
input.value = id;
|
||||
form.appendChild(input);
|
||||
|
||||
form.submit();
|
||||
|
||||
} else {
|
||||
alert("제품 수정에 실패하였습니다.");
|
||||
}
|
||||
}).fail(function() {
|
||||
alert("오류가 발생했습니다.");
|
||||
}).always(function() {
|
||||
//
|
||||
});
|
||||
|
||||
|
||||
});//submitBtn
|
||||
|
||||
|
||||
});//ready
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user