This commit is contained in:
Suh
2024-01-05 18:56:09 +09:00
14 changed files with 399 additions and 144 deletions

View File

@@ -37,7 +37,7 @@ public class CategoryController {
return "category/test"; return "category/test";
} }
// 카테고리 리스트 출력 // 카테고리 리스트 출력
@GetMapping("/category/list") @GetMapping("/category/list")
public String list(@RequestParam(name = "p", defaultValue = "1") int p, Model m) { public String list(@RequestParam(name = "p", defaultValue = "1") int p, Model m) {
@@ -66,14 +66,14 @@ public class CategoryController {
// 생성 - Ajax // 생성 - Ajax
@PostMapping("/category/create_process") @PostMapping("/category/create_process")
@ResponseBody @ResponseBody
public int createProcess(CategoryDto dto, Model m) { public boolean createProcess(CategoryDto dto, Model m) {
int i = categoryService.createProcess(dto); int i = categoryService.createProcess(dto);
if (i == 1) { if (i == 1) {
return i; return true;
} else { } else {
// ajax테스트후 결정 // ajax테스트후 결정
// m.addAttribute("dto", dto); m.addAttribute("dto", dto);
return 0; return false;
} }
} }
@@ -126,13 +126,11 @@ public class CategoryController {
} }
// KAN코드 중복확인 메서드 // KAN코드 중복확인 메서드
@PostMapping("/category/checkKancode")
@PostMapping("/category/chackKancode")
@ResponseBody @ResponseBody
public int chackKancode(String kan_code) { public String chackKancode(String kan_code) {
int chack = categoryService.checkKan(kan_code); String checkkan = categoryService.kanCheck(kan_code);
System.out.println(chack); return checkkan;
return chack;
} }

View File

@@ -16,5 +16,4 @@ public class CategoryDto {
private String cls_nm_3; private String cls_nm_3;
private String cls_nm_4; private String cls_nm_4;
private boolean activation; private boolean activation;
} }

View File

@@ -14,4 +14,5 @@ public interface CategoryMapper {
int updateByKanCode(CategoryDto dto); int updateByKanCode(CategoryDto dto);
int deactivateByKanCode(String kan_code); int deactivateByKanCode(String kan_code);
int activateByKanCode(String kan_code); int activateByKanCode(String kan_code);
String kanCheck(String kan_code);
} }

View File

@@ -52,14 +52,8 @@ public class CategoryService {
return mapper.activateByKanCode(kan_code); return mapper.activateByKanCode(kan_code);
} }
public int checkKan(String kan_code) { public String kanCheck(String kan_code) {
CategoryDto dto = mapper.selectByKanCode(kan_code); return mapper.kanCheck(kan_code);
String kancode = dto.getKan_code();
if(kancode == null) {
return 0;
}else {
return 1;
}
} }

View File

@@ -1,20 +1,12 @@
package com.no1.wms.stock; package com.no1.wms.stock;
import java.util.List;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.no1.wms.stock.StockDto; import java.util.List;
@Controller @Controller
@Slf4j @Slf4j
@@ -34,7 +26,7 @@ public class StockController {
int startRow = (page - 1) * perPage; int startRow = (page - 1) * perPage;
//스톡서비스로 재고 리스트 출력 메서트 작성 //스톡서비스로 재고 리스트 출력 메서트 작성
List<StockDto> dto = service.stockList(searchn, search, perPage); List<StockDto> dto = service.list(searchn, search, perPage);
m.addAttribute("list", dto); m.addAttribute("list", dto);
int pageNum = 4;//보여질 페이지 번호 수 int pageNum = 4;//보여질 페이지 번호 수
@@ -56,7 +48,7 @@ public class StockController {
// 재고 상세페이지 // 재고 상세페이지
@PostMapping("stock/read/{id}") @PostMapping("stock/read/{id}")
public String read(@PathVariable UUID id, Model m) { public String read(@PathVariable String id, Model m) {
//스톡서비스로 재고 상세페이지 출력 메서드 작성 //스톡서비스로 재고 상세페이지 출력 메서드 작성
StockDto dto = service.stockOne(id); StockDto dto = service.stockOne(id);
m.addAttribute("dto", dto); m.addAttribute("dto", dto);
@@ -66,10 +58,44 @@ public class StockController {
// 수정 - 폼 // 수정 - 폼
@GetMapping("/stock/update/{id}") @GetMapping("/stock/update/{id}")
public String update(@PathVariable UUID id, Model m) { public String update(@PathVariable String id, Model m) {
// StockDto dto = service.updateStock(); StockDto dto = service.stockOne(id);
// m.addAttribute("dto", dto); m.addAttribute("dto", dto);
return "stock/update"; return "stock/update";
} }
// 수정 프로세스
@PutMapping("/board/update_process")
@ResponseBody
public String updateProcess(StockDto dto) {
service.updateStock(dto);
return "redirect:list";
}
// 생성 폼
@PostMapping("/stock/create")
public String create()
{
return "stock/create";
}
// 생성 프로세스
@PostMapping("/stock/create_process")
@ResponseBody
public String createProcess(StockDto dto) {
service.createStock(dto);
return "redirect:list";// 글목록
}
// 삭제
@DeleteMapping("/stock/delete")
@ResponseBody
public int delete(String id) {
int i = service.deleteBoard(id);
return i;
}
} }

View File

@@ -1,13 +1,11 @@
package com.no1.wms.stock; package com.no1.wms.stock;
import java.util.UUID;
import lombok.Data; import lombok.Data;
@Data @Data
public class StockDto { public class StockDto {
private UUID id; private String id;
private int warehouse_id; private int warehouse_id;
private int product_id; private int product_id;
private int quantity; private int quantity;

View File

@@ -1,10 +1,9 @@
package com.no1.wms.stock; package com.no1.wms.stock;
import org.apache.ibatis.annotations.Mapper;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
@@ -18,7 +17,10 @@ public interface StockMapper {
int createStock(StockDto dto); int createStock(StockDto dto);
StockDto stockOne(UUID id); StockDto stockOne(String id);
int deleteStock(String id);
} }

View File

@@ -1,14 +1,12 @@
package com.no1.wms.stock; package com.no1.wms.stock;
import java.io.Console;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service @Service
public class StockService { public class StockService {
@Autowired @Autowired
@@ -25,7 +23,7 @@ public class StockService {
} }
public List<StockDto> stockList(int searchn, String search, int start){ public List<StockDto> list(int searchn, String search, int start){
System.out.println(searchn+search); System.out.println(searchn+search);
@@ -40,7 +38,7 @@ public class StockService {
} }
public StockDto stockOne(UUID id) { public StockDto stockOne(String id) {
return mapper.stockOne(id); return mapper.stockOne(id);
} }
@@ -53,4 +51,9 @@ public class StockService {
public int updateStock(StockDto dto) { public int updateStock(StockDto dto) {
return mapper.updateStock(dto); return mapper.updateStock(dto);
} }
public int deleteBoard(String id) {
return mapper.deleteStock(id);
}
} }

View File

@@ -7,9 +7,9 @@
<insert id="createProcess" parameterType="CategoryDto"> <insert id="createProcess" parameterType="CategoryDto">
INSERT INTO product_category (kan_code, cls_nm_1, cls_nm_2, cls_nm_3, cls_nm_4, activation) INSERT INTO product_category (kan_code, cls_nm_1, cls_nm_2, cls_nm_3, cls_nm_4, activation)
VALUES (#{dto.kan_code}, #{dto.cls_nm_1},#{dto.cls_nm_2},#{dto.cls_nm_3},#{dto.cls_nm_4},1) VALUES (#{kan_code}, #{cls_nm_1},#{cls_nm_2},#{cls_nm_3},#{cls_nm_4},1)
</insert> </insert>
<!-- update --> <!-- update -->
<update id="updateByKanCode" parameterType="CategoryDto"> <update id="updateByKanCode" parameterType="CategoryDto">
@@ -51,7 +51,9 @@
select * from product_category select * from product_category
</select> </select>
<select id="kanCheck" parameterType="String" resultType="String">
select kan_code from product_category where kan_code = #{kan_code}
</select>

View File

@@ -2,32 +2,32 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTO Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTO Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.no1.wms.stock.StockMapper"> <mapper namespace="com.no1.wms.authority.StockMapper">
<!-- select --> <!-- select -->
<select id="count" parameterType="map" resultType="com.no1.wms.stock.StockDto"> <select id="count" parameterType="map" resultType="com.no1.wms.stock.StockDto">
select count(*) from wms.stock left join wms.warehouse on wms.stock.warehouse_id = wms.warehouse.id left join wms.product on wms.stock.product_id = wms.product.id select count(*) from wms.stock left join wms.warehouse on wms.stock.warehouse_id = wms.warehouse.id left join wms.product on wms.stock.product_id = wms.product.id
<where> <where>
<choose> <choose>
<when test="searchn == 0"> activation = 1 and warehouse.name like concat('%',#{search},'%')</when> <when test="searchn == 0"> wms.stock.activation = 1 and wms.warehouse.name like concat('%',#{search},'%')</when>
<when test="searchn == 1"> activation = 1 and product.name like concat('%',#{search},'%') </when> <when test="searchn == 1"> wms.stock.activation = 1 and wms.product.name like concat('%',#{search},'%') </when>
</choose> </choose>
</where> </where>
order by id desc limit #{start}, #{perPage} order by id desc limit #{start}, #{perPage}
</select> </select>
<select id="stockList" parameterType="map" resultType="com.no1.wms.stock.StockDto"> <select id="list" parameterType="map" resultType="com.no1.wms.stock.StockDto">
select * from wms.stock left join wms.warehouse on wms.stock.warehouse_id = wms.warehouse.id left join wms.product on wms.stock.product_id = wms.product.id select * from wms.stock left join wms.warehouse on wms.stock.warehouse_id = wms.warehouse.id left join wms.product on wms.stock.product_id = wms.product.id
<where> <where>
<choose> <choose>
<when test="searchn == 0"> activation = 1 and warehouse.name like concat('%',#{search},'%')</when> <when test="searchn == 0"> wms.stock.activation = 1 and wms.warehouse.name like concat('%',#{search},'%')</when>
<when test="searchn == 1"> activation = 1 and product.name like concat('%',#{search},'%') </when> <when test="searchn == 1"> wms.stock.activation = 1 and wms.product.name like concat('%',#{search},'%') </when>
</choose> </choose>
</where> </where>
order by id desc limit #{start}, #{perPage} order by id desc limit #{start}, #{perPage}
</select> </select>
<select id="stockOne" parameterType="java.util.UUID" resultType="com.no1.wms.stock.StockDto"> <select id="stockOne" parameterType="String" resultType="com.no1.wms.stock.StockDto">
selct * from stock where id = #{id} selct * from stock where id = #{id}
</select> </select>
<!-- select --> <!-- select -->
@@ -44,8 +44,14 @@
<!-- insert --> <!-- insert -->
<insert id="createStock" parameterType="com.no1.wms.stock.StockDto"> <insert id="createStock" parameterType="com.no1.wms.stock.StockDto">
insert into stock (id, quantity, activation) insert into stock (id, warehouse_id, product_id, quantity, activation)
values (#{dto.id}, #{dto.quantity}, 1) values (#{dto.id}, #{dto.warehouse_id}, #{dto.product_id}, #{dto.quantity}, 1)
</insert> </insert>
<!-- insert --> <!-- insert -->
<!-- delete -->
<delete id="deleteStock" parameterType="String">
delete from stock where no = #{id}
</delete>
<!-- delete -->
</mapper> </mapper>

View File

@@ -6,25 +6,28 @@
<title>카테고리 생성</title> <title>카테고리 생성</title>
<style> <style>
input {
display: inline-block;
}
#checkKan { .header-white {
margin-left: 10px; /* .checkKan 버튼과 옆의 input 사이 간격 조절 */
}
.header {
text-align: center; text-align: center;
color: white; color: white;
} }
.body{ .body{
text-align: center; text-align: center;
} }
.col-centered{
margin: 0 auto;
float: none;
}
.col-margin-left-32{
margin-left: 32%;
}
</style> </style>
</head> </head>
<body> <body>
<div class="header"> <div class="header-white">
<h1><b>제품 카테고리 생성</b></h1> <h1><b>제품 카테고리 생성</b></h1>
</div> </div>
<hr> <hr>
@@ -32,51 +35,46 @@ input {
<form id="createForm"> <form id="createForm">
<div class="ulTag"> <div class="ulTag">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12" style="text-align: center;">
<div class="input-group mb-3"> <div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon1">대분류</span> <span class="input-group-text" id="basic-addon1">대분류</span>
<input type="text" name="cls_nm_1" class="form-control" placeholder="대분류를 입력하세요" aria-label="대분류" aria-describedby="basic-addon1"> <input type="text" name="cls_nm_1" id="cls_nm_1" class="form-control"
placeholder="대분류를 입력하세요" aria-label="대분류" value="${dto.cls_nm_1 }"
aria-describedby="basic-addon1">
</div> </div>
<!-- 설명만 있는 입력 --> <!-- 설명만 있는 입력 -->
<div class="input-group mb-3"> <div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon1">중분류</span> <span class="input-group-text" id="basic-addon1">중분류</span>
<input type="text" name="cls_nm_2" class="form-control" placeholder="중분류를 입력하세요" aria-label="중분류" aria-describedby="basic-addon1"> <input type="text" name="cls_nm_2" id="cls_nm_2" class="form-control"
placeholder="중분류를 입력하세요" aria-label="중분류" value="${dto.cls_nm_2 }"
aria-describedby="basic-addon1">
</div> </div>
<div class="input-group mb-3"> <div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon1">소분류</span> <span class="input-group-text" id="basic-addon1">소분류</span>
<input type="text" name="cls_nm_3" class="form-control" placeholder="소분류를 입력하세요" aria-label="소분류" aria-describedby="basic-addon1"> <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>
<div class="input-group mb-3"> <div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon1">분류</span> <span class="input-group-text" id="basic-addon1">분류</span>
<input type="text" name="cls_nm_4" class="form-control" placeholder="세분류를 입력하세요" aria-label="세분류" aria-describedby="basic-addon1"> <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>
<div class="input-group mb-3"> <div class="input-group mb-3 w-40 col-centered">
<input type="text" name="kan_code" class="form-control" placeholder="KAN 분류코드" aria-label="KAN 분류코드" aria-describedby="button-addon2"> <input type="number" name="kan_code" id="kan_code" class="form-control"
<button class="btn btn-outline-secondary" style="background-color:#FF5E5E;" type="button" id="button-addon2">중복확인</button> placeholder="KAN 분류코드" aria-label="KAN 분류코드" value="${dto.kan_code }"
aria-describedby="button-addon2">
<button class="btn btn-outline-secondary" id="checkKan"
style="background-color:#FF5E5E;" type="button"
id="button-addon2">중복확인</button>
</div> </div>
</div> </div>
</div> </div>
대분류
<input type="text" name="cls_nm_1">
중분류
<input type="text" name="cls_nm_2">
소분류
<input type="text" name="cls_nm_3">
세분류
<input type="text" name="cls_nm_4">
KAN 분류코드
<input type="text" name="kan_code" id="kan_code">
<input type="button" id="checkKan" value="중복확인">
<span id="chackDiv"></span>
</div> </div>
<div class="Btn"> <div class="col-margin-left-32">
<button id="commit">생성</button> <button class="btn btn-success" id="submit">생성</button>
<button id="cancel">취소</button> <button class="btn btn-secondary" id="cancel">취소</button>
</div> </div>
</form> </form>
@@ -87,29 +85,31 @@ input {
// 중복 클릭 방지를 위해 버튼을 비활성화 // 중복 클릭 방지를 위해 버튼을 비활성화
$("#checkKan").prop("disabled", true); $("#checkKan").prop("disabled", true);
// 이전 결과 및 메시지 초기화
$("#chackDiv").html("");
var kanCode = $("#kan_code").val(); var kanCode = $("#kan_code").val();
if (!kanCode) { if (!kanCode) {
$("#chackDiv").html("KAN 분류코드를 입력하세요."); alert("KAN 분류코드를 입력하세요.");
$("#kan_code").focus();
// 버튼 다시 활성화 // 버튼 다시 활성화
$("#checkKan").prop("disabled", false); $("#checkKan").prop("disabled", false);
return false; return false;
} }
$.ajax({ $.ajax({
url: "/category/checkKancode",
type: "post", type: "post",
url: "/category/chackKancode", data: {"kan_code": kanCode},
data: { kan_code: kanCode }, datatype:"text"
dataType: text
}).done(function(data) { }).done(function(data) {
if (data == 0) { if (data == "") {
$("#chackDiv").html("사용가능합니다"); $("#checkKan").css("background-color", "#4CAF50"); // 파란색 배경으로 변경
$("#chackDiv").append("<input type='hidden' id='kan_chack' value='1'>"); $("#checkKan").text("사용가능"); // 버튼 텍스트 변경
$("#checkKan").append("<input type='hidden' id='kan_chack' value='1'>");
} else { } else {
$("#chackDiv").html("이미 사용중인 KAN 분류코드입니다."); $("#checkKan").css("background-color", "#FF5E5E"); // 원래의 빨간색 배경으로 변경
$("#checkKan").text("사용불가"); // 버튼 텍스트 변경
$("#kan_chack").val('0');
//여기
} }
}).fail(function() { }).fail(function() {
alert("오류가 발생했습니다."); alert("오류가 발생했습니다.");
@@ -117,12 +117,71 @@ input {
// Ajax 요청 완료 후 버튼 다시 활성화 // Ajax 요청 완료 후 버튼 다시 활성화
$("#checkKan").prop("disabled", false); $("#checkKan").prop("disabled", false);
}); });
}); });//kan중복체크 기능
// 포커스를 잃었을 때 KAN 분류코드 입력 안내 메시지를 초기화
$("#kan_code").on("blur", function() {
$("#chackDiv").html(""); $("#submit").on("click", function(){
}); var clsnm1 = $("#cls_nm_1").val();
var clsnm2 = $("#cls_nm_2").val();
var clsnm3 = $("#cls_nm_3").val();
var clsnm4 = $("#cls_nm_4").val();
var kanCode = $("#kan_code").val();
if(!clsnm1){
alert("대분류를 입력해야 합니다.");
return false;
}
if(!clsnm2){
alert("중분류를 입력해야 합니다.");
return false;
}
if(!clsnm3){
alert("소분류를 입력해야 합니다.");
return false;
}
if(!clsnm4){
alert("세분류를 입력해야 합니다.");
return false;
}
if( $("#kan_chack").val() != 1){
alert("KAN코드를 입력후 중복체크를 해야합니다.");
return false;
}
$.ajax({
url: "/category/create_process",
type: "post",
data: {
"cls_nm_1": clsnm1,
"cls_nm_2": clsnm2,
"cls_nm_3": clsnm3,
"cls_nm_4": clsnm4,
"kan_code": kanCode,
"activation": true
},
datatype:"json"
}).done(function(data) {
if (data == true) {
alert("카테고리가 생성되었습니다.");
$(location).attr("href", "/category/list")
} else {
alert("카테고리 생성에 실패하였습니다.");
}
}).fail(function() {
alert("오류가 발생했습니다.");
}).always(function() {
// Ajax 요청 완료 후 버튼 다시 활성화
});
})
}); });
</script> </script>

View File

@@ -6,37 +6,38 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>제품 카테고리</title> <title>제품 카테고리</title>
<style type="text/css"> <style type="text/css">
.header { .header-white {
text-align: center; text-align: center;
color: white;
} }
</style> </style>
</head> </head>
<body> <body>
<div class="header"> <div class="header-white">
<h1>제품 카테고리 관리</h1> <h1><b>제품 카테고리 관리</b></h1>
</div> </div>
<hr> <hr>
<div class="body"> <div class="body">
<div class="search12"> <div class="search12">
<form action="categorysearch"> <form action="categorySearch">
<div class="searchDropdown" id="searchDropdown"> <div class="input-group mb-3 w-30">
<select> <div class="w-25">
<option value="0"></option> <select class="form-select">
<option value="1"></option> <option selected="selected" value="cls_nm_4">세분류</option>
<option value="2"></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> </select>
</div>
<input type="text" name="categorySearch" class="form-control" aria-label="Text input with dropdown button" placeholder="검색어를 입력하세요">
<button class="btn btn-outline-secondary" style="background-color:aqua;" type="button" id="button-addon2 searchBtn">검색</button>
</div> </div>
<div class="searchInput"> </form>
<input type="text" name="searchInput" id="searchInput"
placeholder="검색어를 입력하세요" />
</div>
<div class="searchButton">
<button id="searchButton">검색</button>
</div>
</div> </div>
</form>
<div class="table12"> <div class="table12">
<table> <table>
<tr> <tr>

View File

@@ -1,18 +1,81 @@
<%@ page contentType="text/html; charset=UTF-8"%> <%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>test상세페이지</title> <title>test상세페이지</title>
<style type="text/css">
.col-centered{
margin: 0 auto;
float: none;
}
.col-margin-left-32{
margin-left: 32%;
}
</style>
</head> </head>
<body> <body>
test success<br> test success
<hr> <br>
<c:forEach items="${dto }" var="item"> <hr>
<c:forEach items="${dto }" var="item">
${item.kan_code} : ${item.cls_nm_1} > ${item.cls_nm_2} > ${item.cls_nm_3} > ${item.cls_nm_4}<br> ${item.kan_code} : ${item.cls_nm_1} > ${item.cls_nm_2} > ${item.cls_nm_3} > ${item.cls_nm_4}<br>
활성화 : ${item.activation}<br> 활성화 : ${item.activation}<br>
<hr> <hr>
</c:forEach> </c:forEach>
코드테스트 버튼 :
<div class="input-group mb-3 w-40 col-centered">
<input type="text" name="kan_code" id="kan_code" class="form-control"
placeholder="KAN 분류코드" aria-label="KAN 분류코드"
aria-describedby="button-addon2">
<button class="btn btn-outline-secondary" id="checkKan"
style="background-color: #FF5E5E;" type="button" id="button-addon2">중복확인</button>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$("#checkKan").on("click", function() {
// 중복 클릭 방지를 위해 버튼을 비활성화
$("#checkKan").prop("disabled", true);
let kanCode = $("#kan_code").val();
if (!kanCode) {
alert("KAN 분류코드를 입력하세요.");
$("#kan_code").focus();
// 버튼 다시 활성화
$("#checkKan").prop("disabled", false);
return false;
}
$.ajax({
url: "/category/checkKancode",
type: "post",
data: {"kan_code": kanCode},
datatype:"text"
}).done(function(data) {
if (data == "") {
$("#checkKan").css("background-color", "#4CAF50"); // 파란색 배경으로 변경
$("#checkKan").text("사용가능"); // 버튼 텍스트 변경
$("#checkKan").append("<input type='hidden' id='kan_chack' value='1'>");
} else {
$("#checkKan").css("background-color", "#FF5E5E"); // 원래의 빨간색 배경으로 변경
$("#checkKan").text("사용불가"); // 버튼 텍스트 변경
}
}).fail(function() {
alert("오류가 발생했습니다.");
}).always(function() {
// Ajax 요청 완료 후 버튼 다시 활성화
$("#checkKan").prop("disabled", false);
});
});
});
</script>
</body> </body>
</html> </html>

View File

@@ -0,0 +1,103 @@
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>재고 리스트</title>
<style type="text/css">
.header {
text-align: center;
}
</style>
</head>
<body>
<div class="header">
<h1>재고 리스트</h1>
</div>
<hr>
<script>
/*
yes no 모달의 확인 버튼을 누를때 재정의할 function
yesNoModal.yesFunction = myYesFunction;
function myYesFunction(){
alert("재정의 됨");
}
*/
$(function(){
$('.tabcontent > div').hide();
$('.tabnav a').click(function () {
$('.tabcontent > div').hide().filter(this.hash).fadeIn();
$('.tabnav a').removeClass('active');
$(this).addClass('active');
return false;
}).filter(':eq(0)').click();
});
</script>
여기다가 화면 만들기
<!--탭키명 -->
<div class="tab">
<ul class="tabnav">
<li><a href="#tab01">재고</a></li>
<li><a href="#tab02">부족한재고</a></li>
</ul>
<!--탭키 내용-->
<div class="tabcontent">
<!--재고 탭 내용-->
<div id="tab01">
<div id="search" align="center">
<form action="search">
<select name="searchn">
<option value="0">창고명</option>
<option value="1">제품명</option>
</select>
<input type="text" name="search" maxlength="50"/>
<input type="submit" class="btn btn-primary" value="검색" />
</form>
</div>
<!--재고 리스트 -->
<c:if test="${count != 0 }">
<table>
<tr>
<th>번호</th>
<th>제품명</th>
<th>창고명</th>
</tr>
<c:forEach items="${list}" var="stock">
<tr>
<td><a href ="read/${stock.id}">${stock.stock.id}</a></td>
<td>${stock.product.name }</td>
<td>${stock.warehouse.name }</td>
</tr>
</c:forEach>
</table>
<div id="page">
<c:if test="${begin > pageNum }">
<a href="list?p=${begin-1 }">[이전]</a>
</c:if>
<c:forEach begin="${begin }" end="${end}" var="i">
<a href="list?p=${i}">${i}</a>
</c:forEach>
<c:if test="${end < totalPages }">
<a href="list?p=${end+1}">[다음]</a>
</c:if>
</div>
</c:if>
</div>
<!--부족한재고 탭 내용-->
<div id="tab02">
tab2 content
</div>
</div>
</div>
</body>
</html>