Merge remote-tracking branch 'origin/master'

This commit is contained in:
Suh
2024-01-15 10:28:05 +09:00
19 changed files with 1122 additions and 172 deletions

View File

@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.no1.wms.excel.ExcelUtils;
@@ -193,4 +194,8 @@ public class CategoryController {
return "modal/categorysearch";
}
}

View File

@@ -5,13 +5,18 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.DeleteMapping;
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;
import org.springframework.web.servlet.ModelAndView;
import com.no1.wms.category.CategoryDto;
import com.no1.wms.product.ProductDto;
import com.no1.wms.product.ProductService;
@@ -21,18 +26,21 @@ public class PriceController {
@Autowired
PriceService priceService;
@Autowired
ProductService productService;
@GetMapping("/list")
public String list(@RequestParam(name = "searchn", defaultValue = "0") int searchn,
@RequestParam(name = "search", defaultValue = "") String search,
@RequestParam(name = "p", defaultValue = "1") int page, Model m) {
int count = priceService.count(searchn, search);
int count = priceService.count2(searchn, search);
int perPage = 15; // 한 페이지에 보일 글의 개수
int startRow = (page - 1) * perPage;
List<PriceDto> dto = priceService.priceList2(searchn, search, startRow ,perPage);
List<PriceDto> dto = priceService.priceList3(searchn, search, startRow ,perPage);
m.addAttribute("list", dto);
m.addAttribute("start", startRow + 1);
@@ -62,30 +70,100 @@ public class PriceController {
// 생성 - 폼
@PostMapping("/create")
public String create() {
return "price/create";
@PostMapping("/create")
public String create() {
return "price/create";
}
// 생성 - Ajax
@PostMapping("/create_process")
@ResponseBody
public boolean createProcess(PriceDto dto) {
int i = priceService.createProcess(dto);
if (i == 1) {
return true;
} else {
return false;
}
}
// 상세페이지
@PostMapping("/read")
public String read(String id, Model m) {
// 선택한 id를 바탕으로 원하는 상세정보 출력하는 메서드 작성
PriceDto dto = priceService.selectById(id);
m.addAttribute("dto", dto);
return "price/read";
}
// 수정 폼
@PostMapping("/update")
public String update(String id, Model m) {
PriceDto dto = priceService.selectById(id);
m.addAttribute("dto", dto);
return "price/update";
}
// 수정 - Ajax
@PutMapping("/update_process")
@ResponseBody
public boolean update_process(PriceDto dto) {
int i = priceService.updateById(dto);
if (i == 1) {
return true;
} else {
return false;
}
}
// 삭제
@DeleteMapping("/delete")
@ResponseBody
public boolean delete(String id) {
int i = priceService.deactivateById(id);
if(i == 1) {
return true;
}else {
return false;
}
}
//모달화면
@PostMapping("/show_modal")
public ModelAndView categoryShowModal(@RequestParam(name = "searchn", defaultValue = "0") int searchn,
@RequestParam(name = "search", defaultValue = "") String search,
@RequestParam(name = "p", defaultValue = "1") int page, ModelAndView m, String name) {
int count = productService.count(searchn, search);
int perPage = 10; // 한 페이지에 보일 글의 개수
int startRow = (page - 1) * perPage;
List<ProductDto> dto = productService.productList(searchn, search, startRow ,perPage);
m.addObject("list", dto);
m.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;
}
// 생성 - Ajax
@PostMapping("/price/create_process")
@ResponseBody
public boolean createProcess(PriceDto dto) {
int i = priceService.createProcess(dto);
if (i == 1) {
return true;
} else {
return false;
}
}
m.addObject("searchn",searchn);
m.addObject("search",search);
m.addObject("begin", begin);
m.addObject("end", end);
m.addObject("pageNum", pageNum);
m.addObject("totalPages", totalPages);
m.addObject("p" , page);
m.setViewName(name);
return m;
}
}

View File

@@ -14,4 +14,12 @@ public interface PriceMapper {
int count(Map<String, Object> m);//카운터
List<PriceDto> priceList2(Map<String, Object> m);//검색기능까지 포함
int createProcess(PriceDto dto);
List<PriceDto> priceList3(Map<String, Object> m);
int count2(Map<String, Object> m);//카운터
PriceDto selectById(String id);
int updateById(PriceDto dto);
int deactivateById(String id);
}

View File

@@ -48,9 +48,42 @@ public class PriceService {
return mapper.priceList2(m);
}
public List<PriceDto> priceList3(int searchn, String search, int start, int perPage){
Map<String, Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
m.put("search", search);
m.put("start", start);
m.put("perPage", perPage);
return mapper.priceList3(m);
}
public int createProcess(PriceDto dto) {
return mapper.createProcess(dto);
}
public int count2(int searchn, String search) {
Map<String,Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
m.put("search", search);
return mapper.count2(m);
};//카운터
public PriceDto selectById(String id) {
return mapper.selectById(id);
}
public int updateById(PriceDto dto) {
return mapper.updateById(dto);
}
public int deactivateById(String id) {
return mapper.deactivateById(id);
}
}

View File

@@ -12,9 +12,11 @@ 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;
import org.springframework.web.servlet.ModelAndView;
import com.no1.wms.category.CategoryDto;
import com.no1.wms.category.CategoryService;
import com.no1.wms.price.PriceDto;
@Controller
@RequestMapping("/product")
@@ -22,8 +24,10 @@ public class ProductController {
@Autowired
ProductService productService;
@Autowired
CategoryService categoryService;
/*
@GetMapping("list")
public String list(@RequestParam(name = "p", defaultValue = "1") int p, Model m) {
@@ -32,6 +36,44 @@ public class ProductController {
m.addAttribute("list", dto);
return "/product/list";
}
*/
@GetMapping("/list")
public String list(@RequestParam(name = "searchn", defaultValue = "0") int searchn,
@RequestParam(name = "search", defaultValue = "") String search,
@RequestParam(name = "p", defaultValue = "1") int page, Model m) {
int count = productService.count(searchn, search);
int perPage = 15; // 한 페이지에 보일 글의 개수
int startRow = (page - 1) * perPage;
List<ProductDto> dto = productService.productList(searchn, search, startRow ,perPage);
m.addAttribute("list", dto);
m.addAttribute("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;
}
m.addAttribute("searchn",searchn);
m.addAttribute("search",search);
m.addAttribute("begin", begin);
m.addAttribute("end", end);
m.addAttribute("pageNum", pageNum);
m.addAttribute("totalPages", totalPages);
m.addAttribute("p" , page);
return "/product/list";
}
// 생성 - 폼
@PostMapping("/create")
@@ -92,8 +134,39 @@ public class ProductController {
}
//모달화면
@PostMapping("/show_modal")
public ModelAndView categoryShowModal(@RequestParam(name = "searchn", defaultValue = "4") int searchn,
@RequestParam(name = "search", defaultValue = "") String search,
@RequestParam(name = "p", defaultValue = "1") int page, ModelAndView m, String name) {
int count = categoryService.count(searchn, search);
int perPage = 10; // 한 페이지에 보일 글의 개수
int startRow = (page - 1) * perPage;
List<CategoryDto> dto = categoryService.categoryList2(searchn, search, startRow ,perPage);
m.addObject("list", dto);
m.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;
}
m.addObject("searchn",searchn);
m.addObject("search",search);
m.addObject("begin", begin);
m.addObject("end", end);
m.addObject("pageNum", pageNum);
m.addObject("totalPages", totalPages);
m.addObject("p" , page);
m.setViewName(name);
return m;
}

View File

@@ -8,10 +8,10 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ProductMapper {
List<ProductDto> productList(Map<String, Object> m);
List<ProductDto> productList(Map<String, Object> m);//페이징 검색 적용 리스트
int createProcess(ProductDto dto);
ProductDto selectById(String id);
int updateById(ProductDto dto);
int deactivateById(String id);
int count(Map<String, Object> m);//카운터
}

View File

@@ -7,21 +7,19 @@ import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ProductService {
@Autowired
ProductMapper mapper;
public List<ProductDto> productList(int p){
//페이징 완료되면 수정해야함.
int start = 0;
int count = 10;
Map m = new HashMap<String, Object>();
public List<ProductDto> productList(int searchn, String search, int start, int perPage){
Map<String, Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
m.put("search", search);
m.put("start", start);
m.put("count", count);
m.put("perPage", perPage);
return mapper.productList(m);
}
@@ -42,4 +40,11 @@ public class ProductService {
return mapper.deactivateById(id);
}
public int count(int searchn, String search) {
Map<String,Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
m.put("search", search);
return mapper.count(m);
};//카운터
}

View File

@@ -22,12 +22,27 @@
</resultMap>
<!-- insert -->
<insert id="createProcess" parameterType="priceDto">
<insert id="createProcess" parameterType="PriceDto">
INSERT INTO prices (id, price, registration_date, manager_id, product_id, activation)
VALUES (UUID(), #{price}, curdate(), #{manager_id}, #{product_id}, 1)
</insert>
<!-- update -->
<update id="updateById" parameterType="PriceDto">
UPDATE prices
SET price = #{price}, registration_date = CURDATE()
WHERE id = #{id}
</update>
<update id="deactivateById" parameterType="String">
UPDATE prices
SET activation = 0
WHERE id = #{id}
</update>
<!-- delete -->
@@ -86,10 +101,66 @@
order by p.registration_date limit #{start} , #{perPage}
</select>
<select id="priceList3" parameterType="map" resultMap="priceResultMap">
SELECT
p.id, p.price, p.registration_date, p.manager_id, p.product_id, p.activation,
p.manager_id, p.activation,
pro.name as product_name,
a.name as account_name
FROM prices as p
LEFT JOIN product as pro ON p.product_id = pro.id
LEFT JOIN account as a ON p.manager_id = a.id
<where>
<choose>
<when test="searchn == 0">
p.activation = 1 AND pro.id IN (SELECT id FROM product WHERE name LIKE CONCAT('%',#{search},'%'))
</when>
<when test="searchn == 1">
p.activation = 1 AND p.price LIKE CONCAT('%',#{search},'%')
</when>
<when test="searchn == 2">
p.activation = 1 AND p.registration_date LIKE CONCAT('%',#{search},'%')
</when>
</choose>
</where>
ORDER BY p.registration_date LIMIT #{start} , #{perPage}
</select>
<select id="count2" parameterType="map" resultType="int">
SELECT COUNT(*)
FROM prices as p
LEFT JOIN product as pro ON p.product_id = pro.id
LEFT JOIN account as a ON p.manager_id = a.id
<where>
<choose>
<when test="searchn == 0">
p.activation = 1 AND pro.id IN (SELECT id FROM product WHERE name LIKE CONCAT('%',#{search},'%'))
</when>
<when test="searchn == 1">
p.activation = 1 AND p.price LIKE CONCAT('%',#{search},'%')
</when>
<when test="searchn == 2">
p.activation = 1 AND p.registration_date LIKE CONCAT('%',#{search},'%')
</when>
</choose>
</where>
</select>
<select id="selectById" resultMap="priceResultMap" parameterType="String" >
SELECT
p.id, p.price, p.registration_date, p.manager_id, p.product_id, p.activation,
p.manager_id, p.activation,
pro.name as product_name,
a.name as account_name
FROM prices as p
left join product as pro on p.product_id = pro.id
left join account as a on p.manager_id = a.id
WHERE p.id = #{id}
</select>
</mapper>

View File

@@ -58,6 +58,7 @@
<!-- select -->
<!--
<select id="productList" resultMap="productResultMap" parameterType="map" >
SELECT
p.id, p.name, p.company_name, p.kan_code, p.vendor_id, p.registration_date,
@@ -72,7 +73,7 @@
WHERE p.activation != 0
ORDER BY p.registration_date limit #{start} , #{count}
</select>
-->
<select id="selectById" parameterType="String" resultMap="productResultMap">
SELECT
@@ -89,7 +90,64 @@
</select>
<select id="count" parameterType="map" resultType="int">
SELECT COUNT(*)
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>
<choose>
<when test="searchn == 0">
p.activation = 1 AND p.name LIKE CONCAT('%',#{search},'%')
</when>
<when test="searchn == 1">
p.activation = 1 AND p.company_name LIKE CONCAT('%',#{search},'%')
</when>
<when test="searchn == 2">
p.activation = 1 AND p.manager_id IN (SELECT id FROM account WHERE name LIKE CONCAT('%',#{search},'%'))
</when>
<when test="searchn == 3">
p.activation = 1 AND p.kan_code LIKE CONCAT('%',#{search},'%')
</when>
</choose>
</where>
</select>
<select id="productList" parameterType="map" 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>
<choose>
<when test="searchn == 0">
p.activation = 1 AND p.name LIKE CONCAT('%',#{search},'%')
</when>
<when test="searchn == 1">
p.activation = 1 AND p.company_name LIKE CONCAT('%',#{search},'%')
</when>
<when test="searchn == 2">
p.activation = 1 AND p.kan_code IN (SELECT kan_code FROM product_category WHERE cls_nm_4 LIKE CONCAT('%',#{search},'%'))
</when>
<when test="searchn == 3">
p.activation = 1 AND p.manager_id IN (SELECT id FROM account WHERE name LIKE CONCAT('%',#{search},'%'))
</when>
</choose>
</where>
ORDER BY p.registration_date LIMIT #{start} , #{perPage}
</select>
</mapper>

View File

@@ -0,0 +1,69 @@
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script>
function onSearch(){
//
//
}
function onSelectAuth(tag){
const $tag = $(tag);
const tid = $tag.data('tid');
const name = $tag.data('tname');
$("#cls_nm_4").val(name);
$("#kan_code").val(tid);
hideSearchModal();
}
</script>
<div class="container">
<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="4">세분류</option>
<option value="1">대분류</option>
<option value="2">중분류</option>
<option value="3">소분류</option>
<option value="0">KAN코드</option>
</select>
</div>
<input type="text" id="search" name="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">
<table class="table">
<thead class="table-dark">
<tr>
<th>대분류</th>
<th>중분류</th>
<th>소분류</th>
<th>세분류</th>
<th>KAN코드</th>
<th>선택</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>
<td><button data-tid="${dto.kan_code}" data-tname="${dto.cls_nm_4}" class="btn btn-primary" onclick="onSelectAuth(this)">선택</button></td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div>
</div>

View File

@@ -0,0 +1,72 @@
<%@ 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"%>
<script>
function onSearch(){
//
//
}
function onSelectAuth(tag){
const $tag = $(tag);
const tid = $tag.data('tid');
const name = $tag.data('tname');
$("#productName").val(name);
$("#product_id").val(tid);
hideSearchModal();
}
</script>
<div class="container">
<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">제품명</option>
<option value="1">회사명</option>
<option value="2">분류</option>
<option value="3">담당자명</option>
</select>
</div>
<input type="text" id="search" name="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">
<table class="table">
<thead class="table-dark">
<tr>
<th>제품명</th>
<th>회사명</th>
<th>분류</th>
<th>거래처</th>
<th>등록날짜</th>
<th>담당자</th>
<th>선택</th>
</tr>
</thead>
<tbody>
<c:forEach items="${list }" var="dto">
<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.vendorDto.name }</td>
<td><fmt:formatDate value="${dto.registration_date }"
dateStyle="short" /></td>
<td>${dto.accountDto.name }</td>
<td><button data-tid="${dto.id}" data-tname="${dto.name}" class="btn btn-primary" onclick="onSelectAuth(this)">선택</button></td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div>
</div>

View File

@@ -26,44 +26,30 @@
<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="productDto.name" id="productDto.name" class="form-control"
<input type="text" name="productName" id="productName" class="form-control"
placeholder="제품명을 검색하세요" aria-label="제품명" value="${dto.productDto.name }"
aria-describedby="basic-addon1">
aria-describedby="basic-addon1" readonly>
<button class="btn btn-outline-secondary rounded-end" id="searchProductName"
style="background-color:#FF5E5E;" type="button" >검색</button>
<input type='hidden' id='searchProductName' value='0'>
style="background-color:#FF5E5E;" type="button" onclick="showSearchModal('제품 검색','product')" >검색</button>
<input type='hidden' id="product_id" value="">
</div>
<!-- 설명만 있는 입력 -->
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon2">중분류</span>
<input type="text" name="cls_nm_2" id="cls_nm_2" class="form-control"
placeholder="중분류를 입력하세요" aria-label="중분류" value="${dto.cls_nm_2 }"
<span class="input-group-text" id="basic-addon2">가격</span>
<input type="number" name="price" id="price" class="form-control"
placeholder="가격을 입력하세요" aria-label="가격" value="${dto.price }"
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="text" name="cls_nm_3" id="cls_nm_3" class="form-control"
placeholder="소분류를 입력하세요" aria-label="소분류" value="${dto.cls_nm_3 }"
aria-describedby="basic-addon1">
</div>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon4">세분류</span>
<input type="text" name="cls_nm_4" id="cls_nm_4" class="form-control"
placeholder="세분류를 입력하세요" aria-label="세분류" value="${dto.cls_nm_4 }"
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 }"
aria-describedby="button-addon2">
<button class="btn btn-outline-secondary rounded-end" id="checkKan"
style="background-color:#FF5E5E;" type="button" >중복확인</button>
<input type='hidden' id='kan_chack' value='0'>
</div>
<!-- 추후 수정 -->
<input type='hidden' id="manager_id" value="83bdda69-ae95-11ee-935d-0242ac110006">
<!-- 추후 수정 -->
</div>
</div>
</div>
@@ -72,17 +58,101 @@
<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>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$("#cancelBtn").on("click", function(){
$(location).attr("href", "/product/list");
})
$("#submitBtn").on("click", function(){
var price = $("#price").val();
var manager_id = $("#manager_id").val();// 수정해야함.
var product_id = $("#product_id").val();// 수정해야함.
if(!price){
alert("가격을 입력해야 합니다.");
$("#price").focus();
return false;
}
if(!product_id){
alert("제품을 선택해야합니다.");
return false;
}
</script>
$.ajax({
url: "/price/create_process",
type: "post",
data: {
"price": price,
"manager_id": manager_id, // 추후 수정해야함.
"product_id": product_id, // 추후 수정해야함.
"activation": true
},
datatype:"json"
}).done(function(data) {
if (data == true) {
alert("제품 가격을 추가했습니다.");
$(location).attr("href", "/price/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() {
//
});
});
});//ready
function showSearchModal(title, val){
$("#searchModalLabel").text(title);
const data = { name : val};
$.ajax({
type : 'post', // 타입 (get, post, put 등등)
url : '/price/show_modal', // 요청할 서버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)
}
});
}
</script>

View File

@@ -109,7 +109,94 @@
document.body.appendChild(form);
form.submit();
});//createButton
//상세페이지
$("body").on("click", ".detailTr", function(){
var id = $(this).data("id");
var form = document.createElement("form");
form.action = "/price/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();
});
$("#searchBtn").on("click",function(){
var searchn = $("#searchn").val();
var search = $("#search").val();
var form = document.createElement("form");
form.action = "/price/list";
form.method = "get";
var input1 = document.createElement("input");
input1.type = "hidden";
input1.name = "searchn";
input1.value = searchn;
form.appendChild(input1);
var input2 = document.createElement("input");
input2.type = "hidden";
input2.name = "search";
input2.value = search;
form.appendChild(input2);
var input3 = document.createElement("input");
input3.type = "hidden";
input3.name = "p";
input3.value = 1;
form.appendChild(input3);
document.body.appendChild(form);
form.submit();
});
});//ready
function pagingFunction(clickedId){
var searchn1 = $("#searchn1").val();
var search1 = $("#search1").val();
var form = document.createElement("form");
form.action = "/price/list";
form.method = "get";
var input1 = document.createElement("input");
input1.type = "hidden";
input1.name = "searchn";
input1.value = searchn1;
form.appendChild(input1);
var input2 = document.createElement("input");
input2.type = "hidden";
input2.name = "search";
input2.value = search1;
form.appendChild(input2);
var input3 = document.createElement("input");
input3.type = "hidden";
input3.name = "p";
input3.value = clickedId;
form.appendChild(input3);
document.body.appendChild(form);
form.submit();
}
</script>
</body>

View File

@@ -0,0 +1,123 @@
<%@ 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.productDto.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.price }" 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.registration_date }" 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.accountDto.name }" 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", "/price/list");
})//checkBtn click
$("#modifyBtn").on("click", function() {
var id = $("#id").val();
var form = document.createElement("form");
form.action = "/price/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
yesNoModal.yesFunction = deletePriceFunction;
});//ready
function deletePriceFunction(){
var id = $("#id").val();
$.ajax({
url: "/price/delete",
type: "delete",
data: {
"id": id
},
datatype:"json"
}).done(function(data) {
if (data == true) {
alert("삭제되었습니다.");
$(location).attr("href", "/price/list");
} else {
alert("정상적으로 삭제되지 않았습니다..");
}
}).fail(function() {
alert("오류가 발생했습니다.");
}).always(function() {
//
});
}//deletePriceFunction
</script>
</body>
</html>

View File

@@ -0,0 +1,125 @@
<%@ page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<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" placeholder="제품명" id="name"
aria-label="제품명" value="${dto.productDto.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="가격" id="price"
aria-label="가격" value="${dto.price }">
</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.registration_date }" 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.accountDto.name }" 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="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() {
$("#submitBtn").on("click", function() {
var id = $("#id").val();
var price = $("#price").val();
if (!price || isNaN(price)) {
alert("올바른 가격을 입력하세요.");
$("#price").focus();
return;
}
$.ajax({
url: "/price/update_process",
type: "put",
data: {
"id": id,
"price": price
},
datatype: "json"
}).done(function(data) {
if (data == true) {
alert("제품 가격을 수정했습니다.");
var form = document.createElement("form");
form.action = "/price/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
$("#cancelBtn").on("click", function() {
var id = $("#id").val();
var form = document.createElement("form");
form.action = "/price/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
});
</script>
</body>
</html>

View File

@@ -44,12 +44,13 @@
<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">
<input type="text" name="cls_nm_4" id="cls_nm_4" class="form-control"
placeholder="분류를 검색하세요" aria-label="분류"
aria-describedby="button-addon2" readonly>
<button class="btn btn-outline-secondary rounded-end" id="searchKan"
style="background-color:#FF5E5E;" type="button" >검색</button>
<input type='hidden' id='searchKanChack' value='0'>
style="background-color:#FF5E5E;" type="button" onclick="showSearchModal('분류 검색','category')" >검색</button>
<input type='hidden' id="kan_code" value="">
</div>
<div class="input-group mb-3 w-40 col-centered">
@@ -58,14 +59,14 @@
placeholder="거래처를 입력하세요" aria-label="거래처"
aria-describedby="button-addon2">
<button class="btn btn-outline-secondary rounded-end" id="searchVendor"
style="background-color:#FF5E5E;" type="button" >검색</button>
style="background-color:#FF5E5E;" type="button" onclick="showSearchModal2('거래처 검색','vendor')">검색</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="">
<input type='hidden' id="vendor_id" value="52f16bb8-aeb9-11ee-935d-0242ac110006">
<!-- 추후 수정 -->
@@ -92,8 +93,8 @@
$("#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 kan_code = $("#kan_code").val();
var vendor = $("#vendor_id").val();// 수정해야함.
var manager_id = $("#manager_id").val();
if(!name){
alert("제품명을 입력해야 합니다.");
@@ -104,8 +105,7 @@
company_name = "미지정";
}
if(!kan_code){
alert("KAN 분류코드를 입력해야 합니다.");
$("#kan_code").focus();
alert("분류를 검색해야 합니다.");
return false;
}
if(!vendor){
@@ -165,35 +165,44 @@
})
$("#searchKan").on("click", function(){
searchKanCode();
});//searchKan
$("#searchVendor").on("click", function(){
searchModalBootStrap.show();
});//searcVendor
function searchKanCode(){
$.ajax({
url:"/category/categorysearch",
type:"get",
datatype:"html"
}).done(function(data){
$("body").append(data);
$("#searchKanModal").modal("show");
}).fail(function() {
alert("오류가 발생했습니다.");
}).always(function() {
//alert("항상뜨는 창입니다.");
});
}
function searchVendor(){
}
});//ready
function showSearchModal(title, val){
$("#searchModalLabel").text(title);
const data = { name : val};
$.ajax({
type : 'post', // 타입 (get, post, put 등등)
url : '/product/show_modal', // 요청할 서버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)
}
});
}
function showSearchModal2(title, val){
$("#searchModalLabel").text(title);
const data = { name : val};
$.ajax({
type : 'post', // 타입 (get, post, put 등등)
url : '/category/show_modal', // 요청할 서버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)
}
});
}
</script>
</body>
</html>

View File

@@ -18,16 +18,20 @@
<form action="productSearch">
<div class="input-group mb-3 w-30 col-centered">
<div class="w-25">
<select class="form-select">
<option selected="selected" value="name">제품명</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 class="form-select" name="searchn" id="searchn">
<option selected="selected" value="0">제품명</option>
<option value="1">회사명</option>
<option value="2">분류</option>
<option value="3">담당자명</option>
</select>
</div>
<input type="text" name="productSearch" class="form-control" aria-label="Text input with dropdown button" placeholder="검색어를 입력하세요">
<button class="btn btn-info" type="button" id="button-addon2 searchBtn">검색</button>
<input type="text" id="search" name="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>
</form>
</div>
@@ -73,31 +77,23 @@
<div class="col-6 d-flex justify-content-center">
<nav>
<ul class="pagination">
<li class="page-item">
<a class="page-link" href="#">&lt;</a>
</li>
<li class="page-item active">
<a class="page-link" href="#">1</a>
</li>
<li class="page-item">
<a class="page-link" href="#">2</a>
</li>
<li class="page-item">
<a class="page-link" href="#">3</a>
</li>
<li class="page-item">
<a class="page-link" href="#">4</a>
</li>
<li class="page-item">
<a class="page-link" href="#">5</a>
</li>
<li class="page-item">
<a class="page-link" href="#">6</a>
</li>
<li class="page-item">
<a class="page-link" href="#">&gt;</a>
</li>
</ul>
<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="col-3 text-end">
@@ -137,6 +133,37 @@
form.submit();
});//body detailTr
$("#searchBtn").on("click",function(){
var searchn = $("#searchn").val();
var search = $("#search").val();
var form = document.createElement("form");
form.action = "/product/list";
form.method = "get";
var input1 = document.createElement("input");
input1.type = "hidden";
input1.name = "searchn";
input1.value = searchn;
form.appendChild(input1);
var input2 = document.createElement("input");
input2.type = "hidden";
input2.name = "search";
input2.value = search;
form.appendChild(input2);
var input3 = document.createElement("input");
input3.type = "hidden";
input3.name = "p";
input3.value = 1;
form.appendChild(input3);
document.body.appendChild(form);
form.submit();
});
@@ -144,9 +171,38 @@
});//ready
function pagingFunction(clickedId){
var searchn1 = $("#searchn1").val();
var search1 = $("#search1").val();
var form = document.createElement("form");
form.action = "/product/list";
form.method = "get";
var input1 = document.createElement("input");
input1.type = "hidden";
input1.name = "searchn";
input1.value = searchn1;
form.appendChild(input1);
var input2 = document.createElement("input");
input2.type = "hidden";
input2.name = "search";
input2.value = search1;
form.appendChild(input2);
var input3 = document.createElement("input");
input3.type = "hidden";
input3.name = "p";
input3.value = clickedId;
form.appendChild(input3);
document.body.appendChild(form);
form.submit();
}
</script>

View File

@@ -127,7 +127,7 @@
//
});
}//deleteCategoryFunction
}//deleteProductFunction
</script>
</body>

View File

@@ -31,15 +31,16 @@
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 }">
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon3">분류</span>
<input type="text" name="cls_nm_4" id="cls_nm_4" class="form-control"
placeholder="분류를 검색하세요" aria-label="분류" value="${dto.categoryDto.cls_nm_4 }"
aria-describedby="button-addon2" readonly>
<button class="btn btn-outline-secondary rounded-end" id="searchKan"
style="background-color:#FF5E5E;" type="button" onclick="showSearchModal('분류 검색','category')" >검색</button>
<input type='hidden' id="kan_code" value="${dto.kan_code }">
<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>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon4">거래처</span>
@@ -61,7 +62,7 @@
<!-- 추후 수정 -->
<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 }">
<!-- 추후 수정 -->
@@ -117,8 +118,7 @@
company_name = "미지정";
}
if(!kan_code){
alert("KAN 분류코드를 입력해야 합니다.");
//$("#kan_code").focus();
alert("분류를 검색해야 합니다.");
return false;
}
if(!vendor_id){
@@ -127,14 +127,6 @@
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",
@@ -180,7 +172,23 @@
});//ready
function showSearchModal(title, val){
$("#searchModalLabel").text(title);
const data = { name : val};
$.ajax({
type : 'post', // 타입 (get, post, put 등등)
url : '/product/show_modal', // 요청할 서버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)
}
});
}
</script>