Bladeren bron

샘플양식관리 추가

gagamel 5 jaren geleden
bovenliggende
commit
4df71b4470

+ 10 - 2
style24.admin/src/main/java/com/style24/admin/biz/dao/TsaSystemDao.java

@@ -219,12 +219,20 @@ public interface TsaSystemDao {
 	Collection<SampleFile> getSampleFileList();
 
 	/**
-	 * 샘플파일 등록/수정
+	 * 샘플파일 등록
 	 * @param sampleFile - 샘플파일 정보
 	 * @author gagamel
 	 * @since 2020. 11. 3
 	 */
-	void saveSampleFile(SampleFile sampleFile);
+	void createSampleFile(SampleFile sampleFile);
+
+	/**
+	 * 샘플파일 수정
+	 * @param sampleFile - 샘플파일 정보
+	 * @author gagamel
+	 * @since 2020. 11. 3
+	 */
+	void updateSampleFile(SampleFile sampleFile);
 
 	/**
 	 * 샘플파일 시스템파일명 조회

+ 5 - 1
style24.admin/src/main/java/com/style24/admin/biz/service/TsaSystemService.java

@@ -407,7 +407,11 @@ public class TsaSystemService {
 	 */
 	@Transactional("shopTxnManager")
 	public void saveSampleFile(SampleFile sampleFile) {
-		systemDao.saveSampleFile(sampleFile);
+		if (sampleFile.getMode().equals("N")) {
+			systemDao.createSampleFile(sampleFile);
+		} else {
+			systemDao.updateSampleFile(sampleFile);
+		}
 	}
 
 	/**

+ 1 - 1
style24.admin/src/main/java/com/style24/admin/biz/web/TsaSystemController.java

@@ -397,7 +397,7 @@ public class TsaSystemController extends TsaBaseController {
 	}
 
 	/**
-	 * 샘플파일 화면
+	 * 샘플양식관리 화면
 	 * @return
 	 * @author gagamel
 	 * @since 2020. 11. 3

+ 11 - 5
style24.admin/src/main/java/com/style24/persistence/mybatis/shop/TsaSystem.xml

@@ -579,8 +579,8 @@
 	</select>
 
 	<!-- 샘플파일 등록/수정 -->
-	<insert id="saveSampleFile" parameterType="SampleFile">
-		/* TsaSystem.saveSampleFile */
+	<insert id="createSampleFile" parameterType="SampleFile">
+		/* TsaSystem.createSampleFile */
 		INSERT INTO TB_SAMPLE_FILE (
 		       SAMPLE_FILE_ID
 		     , SAMPLE_FILE_NM
@@ -605,14 +605,20 @@
 		     , #{updNo}
 		     , NOW()
 		)
-		ON DUPLICATE KEY UPDATE
-		       SAMPLE_FILE_NM = #{sampleFileNm}
+	</insert>
+	
+	<!-- 샘플파일 등록/수정 -->
+	<update id="updateSampleFile" parameterType="SampleFile">
+		/* TsaSystem.updateSampleFile */
+		UPDATE TB_SAMPLE_FILE
+		SET    SAMPLE_FILE_NM = #{sampleFileNm}
 		     , ORG_FILE_NM = #{orgFileNm}
 		     , SYS_FILE_NM = #{sysFileNm}
 		     , USE_YN = #{useYn}
 		     , UPD_NO = #{updNo}
 		     , UPD_DT = NOW()
-	</insert>
+		WHERE  SAMPLE_FILE_ID = #{sampleFileId}
+	</update>
 	
 	<!-- 샘플파일 시스템파일명 조회 -->
 	<select id="getSampleFileSystemFilename" parameterType="String" resultType="String">

+ 52 - 30
style24.admin/src/main/webapp/WEB-INF/views/system/SampleFileForm.html

@@ -27,7 +27,27 @@
 
 		<!-- 검색조건 영역 -->
 		<div class="panelStyle">
-			<form id="registerForm" name="registerForm" action="#" th:action="@{'/system/sample/file/save'}">
+			<!-- Search -->
+			<form id="searchForm" name="searchForm" action="#" th:action="@{'/system/sample/file/list'}" onsubmit="$('#btnSearch').trigger('click'); return false;">
+				<ul class="panelBar">
+					<li class="center">
+						<button type="button" class="btn btn-base btn-lg" id="btnSearch">조회</button>
+					</li>
+				</ul>
+			</form>
+		</div>
+		
+		<!-- 리스트 영역 -->
+		<div class="panelStyle">
+			<div id="gridList" style="width: 100%; height: 470px" class="ag-theme-balham"></div>
+		</div>
+		<!-- //리스트 영역 -->
+		
+		<!-- 등록/수정 영역 -->
+		<div class="panelStyle">
+			<form id="detailForm" name="detailForm" action="#" th:action="@{'/system/sample/file/save'}">
+				<input type="hidden" name="mode" value="N"/>
+				
 				<table class="frmStyle" aria-describedby="신규">
 					<colgroup>
 						<col style="width:10%;"/>
@@ -69,20 +89,14 @@
 				</table>
 
 				<ul class="panelBar">
-					<li class="center">
+					<li class="right">
 						<button type="button" class="btn btn-info btn-lg" id="btnNew">신규</button>
 						<button type="button" class="btn btn-success btn-lg" id="btnSave">저장</button>
 					</li>
 				</ul>
 			</form>
 		</div>
-		<!-- //검색조건 영역 -->
-		
-		<!-- 리스트 영역 -->
-		<div class="panelStyle">
-			<div id="gridList" style="width: 100%; height: 570px" class="ag-theme-balham"></div>
-		</div>
-		<!-- //리스트 영역 -->
+		<!-- //등록/수정 영역 -->
 	</div>
 
 <script th:inline="javascript">
@@ -108,31 +122,39 @@
 		if (event.colDef.field != 'sampleFileNm')
 			return;
 
-		$('#registerForm input[name=sampleFileId]').val(event.data.sampleFileId);
-		$('#registerForm input[name=sampleFileNm]').val(event.data.sampleFileNm);
-		$('#registerForm input[name=orgFileNm]').val(event.data.orgFileNm);
-		$('#registerForm input[name=sysFileNm]').val(event.data.sysFileNm);
+		$('#detailForm input[name=mode]').val('U');
+		$('#detailForm input[name=sampleFileId]').val(event.data.sampleFileId);
+		$('#detailForm input[name=sampleFileNm]').val(event.data.sampleFileNm);
+		$('#detailForm input[name=orgFileNm]').val(event.data.orgFileNm);
+		$('#detailForm input[name=sysFileNm]').val(event.data.sysFileNm);
 		$('#sampleFileList').html('<a href="javascript:void(0);" onclick="cfnDownloadSampleFile(\'' + event.data.sampleFileId + '\');">' + event.data.sysFileNm + '</a>');
 		$('#sampleFileList').show();
 
 		if (event.data.useYn == 'Y') {
-			$("#registerForm input:checkbox[name=chkUseYn]").prop('checked', true);
+			$("#detailForm input:checkbox[name=chkUseYn]").prop('checked', true);
 		} else {
-			$("#registerForm input:checkbox[name=chkUseYn]").prop('checked', false);
+			$("#detailForm input:checkbox[name=chkUseYn]").prop('checked', false);
 		}
+		
+		$('#detailForm input:checkbox[name=chkUseYn]').attr('readonly', false);
 	}
 
 	// 조회
-	$('#searchForm').on('click', function() {
-		gagaAgGrid.fetch('/system/sample/file/list', gridOptions);
+	$('#btnSearch').on('click', function() {
+		let actionUrl = $('#searchForm').prop('action') + '?' + $('#searchForm').serialize();
+		
+		// Fetch data
+		gagaAgGrid.fetch(actionUrl, gridOptions);
 	});
 
 	// 신규
 	$('#btnNew').on('click', function() {
-		$('#registerForm')[0].reset();
-		$('#registerForm input[name=sampleFileId]').val('자동생성');
-		$('#registerForm input[name=file]').val('');
-		$('#registerForm input:checkbox[name=chkUseYn]').prop('checked', true);
+		$('#detailForm')[0].reset();
+		$('#detailForm input[name=mode]').val('N');
+		$('#detailForm input[name=sampleFileId]').val('자동생성');
+		$('#detailForm input[name=file]').val('');
+		$('#detailForm input:checkbox[name=chkUseYn]').prop('checked', true);
+		$('#detailForm input:checkbox[name=chkUseYn]').attr('readonly', true);
 		$('#sampleFileList').html('');
 		$('#sampleFileList').hide();
 	});
@@ -140,25 +162,25 @@
 	// 저장 처리
 	$('#btnSave').on('click', function() {
 		// 입력 값 체크
-		if (!gagajf.validation('#registerForm'))
+		if (!gagajf.validation('#detailForm'))
 			return;
 
-		if (gagajf.isNull($('#registerForm input[name=sysFileNm]').val())) {
+		if (gagajf.isNull($('#detailForm input[name=sysFileNm]').val())) {
 			mcxDialog.alert('샘플파일을 선택해 주세요.');
 			return;
 		}
 
-		$('#registerForm input[name=useYn]').val($('#registerForm input:checkbox[name=chkUseYn]').is(":checked") ? 'Y' : 'N');
+		$('#detailForm input[name=useYn]').val($('#detailForm input:checkbox[name=chkUseYn]').is(":checked") ? 'Y' : 'N');
 
 		mcxDialog.confirm("저장하시겠습니까?", {
 			cancelBtnText: "취소",
 			sureBtnText: "확인",
 			sureBtnClick: function() {
-				gagajf.ajaxFormSubmit($('#registerForm').prop('action')
-						, $('#registerForm')
+				gagajf.ajaxFormSubmit($('#detailForm').prop('action')
+						, $('#detailForm')
 						, function() {
 							$('#btnNew').trigger('click');
-							fnSearch();
+							$('#btnSearch').trigger('click');
 						}
 				);
 			}
@@ -166,7 +188,7 @@
 	});
 
 	// 파일첨부 선택 시
-	$('#registerForm input[name=file]').on('change', function() {
+	$('#detailForm input[name=file]').on('change', function() {
 		// multiple 속성이 있으면 files에는 다수의 객체가 할당됨
 		var file = this.files[0];
 
@@ -175,8 +197,8 @@
 				, file
 				, function(result) {
 					// 업로드한 파일명 설정
-					$('#registerForm input[name=orgFileNm]').val(result.oldFileName);
-					$('#registerForm input[name=sysFileNm]').val(result.newFileName);
+					$('#detailForm input[name=orgFileNm]').val(result.oldFileName);
+					$('#detailForm input[name=sysFileNm]').val(result.newFileName);
 				}
 		);
 	});