Browse Source

상품상세 공지

eskim 5 năm trước cách đây
mục cha
commit
345c557103

+ 15 - 1
style24.admin/src/main/java/com/style24/admin/biz/service/TsaGoodsService.java

@@ -1603,6 +1603,20 @@ public class TsaGoodsService {
 	 */
 	@Transactional("shopTxnManager")
 	public void deleteNoticeGoods(NoticeGoods noticeGoods) {
-		goodsDao.deleteNoticeGoods(noticeGoods);
+
+		if (noticeGoods == null || (noticeGoods.getArrGoodsCd() == null && noticeGoods.getArrGoodsCd().length <= 0)) {
+			throw new IllegalStateException(message.getMessage("FAIL_1001"));
+		}
+
+		if (noticeGoods.getArrGoodsCd().length > 0) {
+			for (String goodsCd : noticeGoods.getArrGoodsCd()) {
+				noticeGoods.setGoodsCd(goodsCd);
+				noticeGoods.setRegNo(TsaSession.getInfo().getUserNo());
+				noticeGoods.setUpdNo(TsaSession.getInfo().getUserNo());
+
+				goodsDao.deleteNoticeGoods(noticeGoods);
+			}
+		}
+
 	}
 }

+ 14 - 0
style24.admin/src/main/java/com/style24/admin/biz/web/TsaGoodsController.java

@@ -1328,6 +1328,20 @@ public class TsaGoodsController extends TsaBaseController {
 		return super.ok(message.getMessage("SUCC_0001"));
 	}
 
+	/**
+	 * 상품 상세공지상품 삭제
+	 *
+	 * @param
+	 * @return
+	 * @author eskim
+	 * @since 2020. 11. 09
+	 */
+	@PostMapping("/notice/goods/delete")
+	@ResponseBody
+	public GagaResponse deleteNoticeGoods(@RequestBody NoticeGoods noticeGoods) {
+		goodsService.deleteNoticeGoods(noticeGoods);
+		return super.ok(message.getMessage("SUCC_0001"));
+	}
 
 	/**
 	 * 상품조회 팝업

+ 5 - 0
style24.admin/src/main/java/com/style24/persistence/domain/NoticeGoods.java

@@ -1,5 +1,6 @@
 package com.style24.persistence.domain;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.style24.persistence.TscBaseDomain;
 
 import lombok.Data;
@@ -19,4 +20,8 @@ public class NoticeGoods extends TscBaseDomain {
 	private String goodsNm;
 	private String crud;
 
+	@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+	private String[] arrGoodsCd;
+
+
 }

+ 1 - 1
style24.admin/src/main/java/com/style24/persistence/mybatis/shop/TsaGoods.xml

@@ -2074,7 +2074,7 @@
 	<delete id="deleteNoticeGoods" parameterType="NoticeGoods">
 		/* TsaGoods.deleteNoticeGoods */
 		DELETE FROM TB_NOTICE_GOODS 
-		WHERE NOICE_SQ =  #{noiceSq}
+		WHERE NOTICE_SQ =  #{noticeSq}
 		AND GOODS_CD = #{goodsCd}
 	</delete>
 	

+ 137 - 6
style24.admin/src/main/webapp/WEB-INF/views/goods/GoodsDetailNoticeForm.html

@@ -27,9 +27,15 @@
 		
 		<!-- 검색조건 영역 -->
 		<div class="panelStyle">
+			<!-- TITLE -->
+			<div class="panelTitle">
+				<h3><i class="fa fa-info-circle"></i>아래 검색조건 중 하나를 꼭 입력해 주세요.</h3>
+			</div>
+			<!-- //TITLE -->
 			<form id="searchForm" name="searchForm" action="#" th:action="@{'/goods/notice/list'}" >
 				<input type="hidden" name="noticeType" value="G047_30"/>
 				<input type="hidden" id="searchGb" name="searchGb" />
+			<div class="panelContent">	
 				<table class="frmStyle" aria-describedby="검색조건">
 					<colgroup>
 						<col width="10%"/>
@@ -85,6 +91,7 @@
 						<button type="button" class="btn btn-base btn-lg" id="btnSearch">조회</button>
 					</li>
 				</ul>
+			</div>	
 			</form>
 		</div>
 		<!-- 검색조건 영역 -->
@@ -210,12 +217,15 @@
 		{headerName: 'No', width: 60, cellClass: 'text-center', valueGetter: function(params) { return params.node.rowIndex + 1 }},
 		{headerName: "CRUD", field: "crud", width: 75, minWidth: 75, hide: true},
 		{headerName: "상품코드", field: "goodsCd", width: 140, cellClass: 'text-center'},
-		{headerName: "상품명", field: "goodsNm", width: 250, cellClass: 'text-left'}
+		{headerName: "상품명", field: "goodsNm", width: 260, cellClass: 'text-left'}
 	];
 
 	var gridNoticeOptions = gagaAgGrid.getGridOptions(columnNoticeDefs);
 	var gridNoticeGoodsOptions = gagaAgGrid.getGridOptions(columnNoticeGoodsDefs);
 
+	gridNoticeGoodsOptions.rowSelection = 'multiple';
+	gridNoticeGoodsOptions.suppressRowClickSelection = true;
+	
 	// Cell click
 	gridNoticeOptions.onCellClicked = function(event) {
 		if (event.colDef.field != 'noticeTitle')
@@ -224,8 +234,10 @@
 		$('#goodsNoticeForm input[name=noticeSq]').val(event.data.noticeSq);
 		if (event.data.useYn == 'Y') {
 			$('#goodsNoticeForm input:checkbox[name=chkUseYn]').prop('checked', true);
+			$('#goodsNoticeForm input:checkbox[name=chkUseYn]').parent("label").addClass("checked");
 		} else {
 			$('#goodsNoticeForm input:checkbox[name=chkUseYn]').prop('checked', false);
+			$('#goodsNoticeForm input:checkbox[name=chkUseYn]').parent("label").removeClass("checked");
 		}
 		
 		$('#goodsNoticeForm input[name=noticeStdt]').val(event.data.noticeStdt);
@@ -241,9 +253,66 @@
 
 	// 검색
 	$('#btnSearch').on('click', function() {
+		if(!fnConditionCheck()) return;
 		gagaAgGrid.fetch($('#searchForm').prop('action'), gridNoticeOptions, '#searchForm');
 	});
 	
+	//검색 조건 확인
+	var fnConditionCheck = function(){
+		var formId = '#searchForm';
+		var form = document.searchForm;
+
+		//if($("#goodsNoticeForm input[name=searchGb]").val() == "EXCEL") return true;
+		
+		var searchFlag = false;
+		var cnt = 0;
+
+		for (i = 0; i < form.elements.length; i++ ) {
+			var el = form.elements[i];
+
+			if ($(el).prop("type") == "text" || ($(el).prop("type") == "select-one" && el.name != "search" && el.name != "pageSize")) {
+				if (!(el.value == null || el.value == "")) {
+					cnt++;
+				}
+			}
+		}
+			
+		if(cnt > 0) searchFlag = true;
+
+		if(searchFlag == false){
+			mcxDialog.alert("검색조건을 입력하세요.");
+			return false;
+		}
+		
+		var fromDate = $('#searchForm input[name=stDate]').val();
+		var toDate = $('#searchForm input[name=edDate]').val();
+		
+		if (!gagajf.isNull(fromDate) || !gagajf.isNull(toDate)) {
+			
+			if (gagajf.isNull(fromDate) || gagajf.isNull(toDate)) {
+				mcxDialog.alertC("공지기간 조회시 시작일자와 종료일자를 입력하세요.", {
+					sureBtnText: "확인",
+					sureBtnClick: function(){
+						$('#searchForm input[name=stDate]').focus();
+					}
+				});
+				return false;
+			}
+
+			if (fromDate > toDate) {
+				mcxDialog.alertC("공지기간 시작일자는 종료일자 보다 클 수 없습니다.", {
+					sureBtnText: "확인",
+					sureBtnClick: function(){
+						$('#goodsNoticeForm input[name=stDate]').focus();
+					}
+				});
+				return false;
+			} 
+		}
+
+		return true;
+	}
+	
 	// 상품 목록 조회
 	var fnGetNoticeGoodsList = function(noticeSq) {
 		var actionUrl = '/goods/notice/goods/list/' + noticeSq;
@@ -279,16 +348,38 @@
 		gagajf.ajaxJsonSubmit('/goods/excel/upload/goods/list', '', fnExcelSearchCallBack);
 	}
 	
+	// 상품 엑셀 조회 콜백함수
+	var fnExcelSearchCallBack = function(result) {
+		if (result.goodsExcelList.length < 1) return;
+		var oldData = gagaAgGrid.getAllRowData(gridNoticeGoodsOptions);
+		$.each(result.goodsExcelList, function(idx, item) {
+			var isInvalid = false;
+			if (oldData != null && oldData.length != 0){
+				oldData.forEach(function(oneData){
+					if(oneData.goodsCd == item.goodsCd){
+						isInvalid = true;
+						return true;
+					}
+				});
+				if(isInvalid){
+					return isInvalid;
+				}
+			}
+			gagaAgGrid.addRowData(gridNoticeGoodsOptions, {"goodsCd" : item.goodsCd, "goodsNm" : item.goodsNm, "crud" : "C"});
+		});
+		return;
+	};
+	
 	// 상품 조회 클릭 시
 	$('#btnSearchGoods').on('click', function() {
-		cfnOpenGoodsPopup('fnExcelSearchCallBack');
+		cfnOpenGoodsPopup('fnSearchCallBack');
 	});
 
 	// 상품 조회 콜백함수
-	var fnExcelSearchCallBack = function(result) {
-		if (result.goodsExcelList.length < 1) return;
+	var fnSearchCallBack = function(result) {
+		if (result.length < 1) return;
 		var oldData = gagaAgGrid.getAllRowData(gridNoticeGoodsOptions);
-		$.each(result.goodsExcelList, function(idx, item) {
+		$.each(result, function(idx, item) {
 			var isInvalid = false;
 			if (oldData != null && oldData.length != 0){
 				oldData.forEach(function(oneData){
@@ -305,12 +396,52 @@
 		});
 		return;
 	};
-
+	
+	// 상품 삭제
+	$('#btnDeleteNoticeGoods').on('click', function() {
+		
+		var selectedData = gridNoticeGoodsOptions.api.getSelectedRows();
+		if (selectedData.length == 0) {
+			mcxDialog.alert('선택된 행이 없습니다.');
+			return;
+		}
+		
+		var removedData = gagaAgGrid.removeRowData(gridNoticeGoodsOptions, false);
+		debugger;
+		// 신규 상세 공지일경우 화면에서만 삭제
+		if (gagajf.isNull($('#goodsNoticeForm input[name=noticeSq]').val())){
+			return;
+		}
+		
+		var arrGoodsCd = [];
+		$.each(selectedData, function(idx, item) {
+			arrGoodsCd.push(item.goodsCd);
+		});
+		
+		mcxDialog.confirm('삭제하시겠습니까?',  {
+			cancelBtnText: "취소",
+			sureBtnText: "확인",
+			sureBtnClick: function(){
+				var data = {arrGoodsCd : arrGoodsCd
+							,noticeSq : $('#goodsNoticeForm input[name=noticeSq]').val()
+			};
+			
+			var jsonData = JSON.stringify(data);
+			gagajf.ajaxJsonSubmit('/goods/notice/goods/delete', jsonData);
+			}
+		});
+	});
 	
 	// 신규 버튼 클릭
 	$("#btnNew").on("click", function(){
 		$('#goodsNoticeForm')[0].reset();
+		
+		// 공지내용. Summernote에 값 세팅
+		gagaSn.setContents('#noticeContent', "");
 
+		// 그리드 초기화
+		gridNoticeGoodsOptions.api.setRowData(null);
+		 
 		$('#goodsNoticeForm input[name=noticeSq]').val('');
 		$('#goodsNoticeForm input[name=noticeStdt]').val(_today);
 		$('#goodsNoticeForm input[name=noticeEddt]').val(_today);