CommoncodeForm.html 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <!DOCTYPE html>
  2. <html lang="ko"
  3. xmlns:th="http://www.thymeleaf.org">
  4. <!--
  5. *******************************************************************************
  6. * @source : CommoncodeForm.html
  7. * @desc : 공통코드관리 Page
  8. *============================================================================
  9. * STYLE24
  10. * Copyright(C) 2020 TSIT, All rights reserved.
  11. *============================================================================
  12. * VER DATE AUTHOR DESCRIPTION
  13. * === =========== ========== =============================================
  14. * 1.0 2020.10.08 gagamel 최초 작성
  15. *******************************************************************************
  16. -->
  17. <div id="main">
  18. <!-- 메인타이틀 영역 -->
  19. <div class="main-title">
  20. </div>
  21. <!-- //메인타이틀 영역 -->
  22. <!-- 메뉴 설명 -->
  23. <div class="infoBox menu-desc">
  24. </div>
  25. <!-- //메뉴 설명 -->
  26. <!-- 검색조건 영역 -->
  27. <div class="panelStyle">
  28. <!-- Search -->
  29. <form id="searchForm" name="searchForm" action="#" th:action="@{'/system/commoncode/list'}" onsubmit="$('#btnSearch').trigger('click'); return false;">
  30. <input type="hidden" name="cdGb" value="ROOT"/>
  31. <ul class="panelBar">
  32. <li class="center">
  33. <button type="button" class="btn btn-base btn-lg" id="btnSearch">조회</button>
  34. </li>
  35. </ul>
  36. </form>
  37. </div>
  38. <!-- //검색조건 영역 -->
  39. <div class="panelStyle">
  40. <!-- 다중 TABLE 배치 -->
  41. <ul class="division">
  42. <li style="width: 20%">
  43. <div class="panelBar">
  44. <h4>코드구분</h4>
  45. </div>
  46. <div id="gridList1" style="width: 100%; height: 570px" class="ag-theme-balham"></div>
  47. </li>
  48. <li style="width: 50%">
  49. <div class="panelBar">
  50. <h4>상세코드</h4>
  51. </div>
  52. <div id="gridList2" style="width: 100%; height: 570px" class="ag-theme-balham"></div>
  53. </li>
  54. <li style="width: 30%">
  55. <div class="panelBar">
  56. <h4>코드정보</h4>
  57. </div>
  58. <form id="detailForm" name="detailForm" action="#" th:action="@{'/system/commoncode/save'}">
  59. <table class="frmStyle" aria-describedby="등록/상세">
  60. <colgroup>
  61. <col style="width:30%;"/>
  62. <col/>
  63. </colgroup>
  64. <tr>
  65. <th>코드구분<i class="required" title="필수" aria-hidden="true"></i></th>
  66. <td>
  67. <input type="text" name="cdGb" class="w200" placeholder="" maxlength="4" required="required" data-valid-type="alphaNumeric" data-valid-name="코드구분" onkeyup="$(this).val($(this).val().toUpperCase());"/>
  68. </td>
  69. </tr>
  70. <tr>
  71. <th>코드<i class="required" title="필수" aria-hidden="true"></i></th>
  72. <td>
  73. <input type="text" name="cd" class="w200" placeholder="" maxlength="20" required="required" data-valid-name="코드"/>
  74. </td>
  75. </tr>
  76. <tr>
  77. <th>코드명<i class="required" title="필수" aria-hidden="true"></i></th>
  78. <td>
  79. <input type="text" name="cdNm" class="w200" placeholder="" maxlength="50" required="required" data-valid-name="코드명"/>
  80. </td>
  81. </tr>
  82. <tr>
  83. <th>코드설명</th>
  84. <td>
  85. <textarea class="textareaR4" name="cdDesc"></textarea>
  86. </td>
  87. </tr>
  88. <tr>
  89. <th>표시순서<i class="required" title="필수" aria-hidden="true"></i></th>
  90. <td>
  91. <input type="text" class="w100 text-right" name="dispOrd" placeholder="" maxlength="5" required="required" data-valid-type="numeric" data-valid-name="표시순서" />
  92. </td>
  93. </tr>
  94. <tr>
  95. <th>사용여부<i class="required" title="필수" aria-hidden="true"></i></th>
  96. <td>
  97. <input type="hidden" name="useYn"/>
  98. <label class="chkBox"><input type="checkbox" name="chkUseYn" value="Y"/>사용</label>
  99. </td>
  100. </tr>
  101. </table>
  102. </form>
  103. <!-- 버튼 배치 영역 -->
  104. <ul class="panelBar">
  105. <li class="right">
  106. <button type="button" class="btn btn-info btn-lg" id="btnNew">신규</button>
  107. <input type="button" value="저장" class="btn btn-base btn-lg" id="btnSave"/>
  108. </li>
  109. </ul>
  110. <!-- //버튼 배치 영역 -->
  111. </li>
  112. </ul>
  113. <!--//다중 TABLE 배치 -->
  114. </div>
  115. </div>
  116. <script th:inline="javascript">
  117. /*<![CDATA[*/
  118. // specify the columns
  119. let columnDefs1 = [
  120. // {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  121. // {headerName: "CRUD", field: "crud", width: 75, minWidth: 75, hide: true},
  122. {
  123. headerName: "코드구분", field: "cd", width: 80, cellClass: 'text-center',
  124. cellRenderer: function(params) {
  125. return '<a href="javascript:void(0);">' + params.value + '</button>';
  126. }
  127. },
  128. {headerName: "코드구분명", field: "cdNm", width: 150},
  129. // {headerName: "코드설명", field: "cdDesc", width: 300},
  130. // {headerName: "표시순서", field: "dispOrd", width: 80, cellClass: 'text-right'},
  131. // {headerName: "사용여부", field: "useYn", width: 80, cellClass: 'text-center'}
  132. ];
  133. let columnDefs2 = [
  134. // {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
  135. // {headerName: "CRUD", field: "crud", width: 75, minWidth: 75, hide: true},
  136. {headerName: "코드구분", field: "cdGb", width: 80, cellClass: 'text-center'},
  137. {
  138. headerName: "코드", field: "cd", width: 80, cellClass: 'text-center',
  139. cellRenderer: function(params) {
  140. return '<a href="javascript:void(0);">' + params.value + '</button>';
  141. }
  142. },
  143. {headerName: "코드명", field: "cdNm", width: 150},
  144. {headerName: "코드설명", field: "cdDesc", width: 250},
  145. {headerName: "표시순서", field: "dispOrd", width: 80, cellClass: 'text-right'},
  146. {headerName: "사용여부", field: "useYn", width: 80, cellClass: 'text-center'}
  147. ];
  148. // Get GridOptions
  149. let gridOptions1 = gagaAgGrid.getGridOptions(columnDefs1);
  150. let gridOptions2 = gagaAgGrid.getGridOptions(columnDefs2);
  151. // 중복 선택 가능
  152. // gridOptions1.rowSelection = 'multiple';
  153. // gridOptions2.rowSelection = 'multiple';
  154. // Cell Click
  155. gridOptions1.onCellClicked = function(event) {
  156. if (event.colDef.field != 'cd')
  157. return;
  158. fnBindDetail(event.data, 1);
  159. }
  160. gridOptions2.onCellClicked = function(event) {
  161. if (event.colDef.field != 'cd')
  162. return;
  163. fnBindDetail(event.data, 2);
  164. }
  165. // 목록 > row 클릭 시
  166. let lvl = 1;
  167. let fnBindDetail = function(rowData, flag) {
  168. lvl = flag;
  169. $('#detailForm input[name=cdGb]').val(rowData.cdGb);
  170. $('#detailForm input[name=cd]').val(rowData.cd);
  171. $('#detailForm input[name=cdNm]').val(rowData.cdNm);
  172. $('#detailForm input[name=dispOrd]').val(rowData.dispOrd);
  173. $('#detailForm textarea[name=cdDesc]').val(rowData.cdDesc);
  174. $("#detailForm input[name=useYn]").val(rowData.useYn);
  175. if (rowData.useYn == 'Y') {
  176. $("#detailForm input:checkbox[name=chkUseYn]").prop('checked', true);
  177. $("#detailForm input:checkbox[name=chkUseYn]").parent().addClass('checked');
  178. } else {
  179. $("#detailForm input:checkbox[name=chkUseYn]").prop('checked', false);
  180. $("#detailForm input:checkbox[name=chkUseYn]").parent().removeClass('checked');
  181. }
  182. if (flag == 1) {
  183. fnGetDetailCode(rowData.cd);
  184. }
  185. }
  186. // 코드구분 조회
  187. $('#btnSearch').on('click', function() {
  188. let actionUrl = $('#searchForm').prop('action') + '?' + $('#searchForm').serialize();
  189. // Fetch data
  190. gagaAgGrid.fetch(actionUrl, gridOptions1);
  191. });
  192. // 상세코드 조회
  193. let gCd = '';
  194. let fnGetDetailCode = function(cd) {
  195. gCd = cd;
  196. let actionUrl = $('#searchForm').prop('action') + '?cdGb=' + cd;
  197. gagaAgGrid.fetch(actionUrl, gridOptions2);
  198. }
  199. // 신규
  200. $('#btnNew').on('click', function() {
  201. $('#detailForm')[0].reset();
  202. $('#detailForm input:checkbox[name=chkUseYn]').attr('checked', true);
  203. $('#detailForm input:checkbox[name=chkUseYn]').attr('disabled', true);
  204. $('#detailForm input[name=cdGb]').focus();
  205. });
  206. // 저장
  207. $('#btnSave').on('click', function() {
  208. // 입력 값 체크
  209. if (!gagajf.validation('#detailForm'))
  210. return false;
  211. $('#detailForm input[name=useYn]').val($('#detailForm input:checkbox[name=chkUseYn]').is(":checked") ? 'Y' : 'N');
  212. gagajf.ajaxFormSubmit('/system/commoncode/save', '#detailForm', function(result) {
  213. if (lvl == 1) {
  214. $('#btnSearch').trigger('click');
  215. } else {
  216. fnGetDetailCode(gCd);
  217. }
  218. });
  219. });
  220. $(document).ready(function() {
  221. // Create a agGrid
  222. gagaAgGrid.createGrid('gridList1', gridOptions1);
  223. gagaAgGrid.createGrid('gridList2', gridOptions2);
  224. });
  225. /*]]>*/
  226. </script>
  227. </html>