Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.51 KB | None | 0 0
  1. (function () {
  2.  
  3. // 직위콤보
  4. var daCmb, dsCmb, dtPosi;
  5. var bErrorFlag = false;
  6.  
  7. dsCmb = new XgDataSet('dsCmb');
  8. dtPosi = new XgDataTable('dtPosi', {
  9. url: {select: '/adminUserInfo.bf?action=SelectDs02&divName=select_ma'} // ?
  10. });
  11. daCmb = new XgDataAdapter('daCmb');
  12.  
  13. daCmb.setSOCD('(O:dsCmb=dtPosi)'); //이것도 자주 ? , 서버의 DataTable 이름과 클라이언트의 DataTable 이름을 매칭
  14. daCmb.setDataType('JSON'); // XgDataAdapter의 데이터 형식을 설정
  15. daCmb.setAsyncStatus(false); //동기(false) 또는 비동기(true) 방식으로 설정
  16. dsCmb.setDataAdapter(daCmb); // 데이터 셋과 데이터 어댑터를 연결
  17. dsCmb.addDataTable(dtPosi); // 데이터 셋에 데이터 테이블을 추가
  18. dsCmb.select('dtPosi', function (result, errorMsg) {
  19. debugger;
  20. fn_IBKSsessionErrChk(errorMsg);
  21. if (result === false && fn_IBKSsessionErrChk(errorMsg) == false) {
  22. bErrorFlag = true;
  23. return;
  24. } else if (result === false && fn_IBKErrChk(result, errorMsg) == false) { // 시스템 에러 처리
  25. bErrorFlag = true;
  26. return;
  27. }
  28. });
  29. if (bErrorFlag) {
  30. return;
  31. }
  32.  
  33. //메뉴 조회
  34. var booleanColumn, dataSet, dataTable, selectURL, tr, updateURL, xgGridInit;
  35. selectURL = '/adminMenu.bf?action=SelectDs01';
  36. updateURL = '/adminMenu.bf?action=SaveTr01';
  37. booleanColumn = [{
  38. column: 'PROG_EXIS',
  39. trueValue: 1,
  40. falseValue: 0
  41. }];
  42.  
  43. dataSet = new XgDataSet('ds_menu', 'dt_menu').setDataAdapter(new XgDataAdapter('tr_menu'));
  44. tr = dataSet.getDataAdapter();
  45. tr.setSOCD('(O:ds_menu=dt_menu,I:ds_menu=dt_menu)');
  46. tr.setDataType('JSON');
  47. tr.setAsyncStatus(false);
  48. tr.setSrc(selectURL);
  49.  
  50. dataTable = dataSet.getDataTable('dt_menu');
  51. dataTable.setBooleanColumn(booleanColumn);
  52.  
  53. // 그리드 공통 컬럼 정보
  54. var createColumn = function (opt) {
  55. opt.align = 'center';
  56. opt.cellsalign = 'center';
  57. opt.menu = true;
  58.  
  59. return opt;
  60. };
  61.  
  62. // 그리드 컬럼 정보 메뉴ID, 레벨, 경로
  63. var columns = [
  64. createColumn({text: '*메뉴ID', datafield: 'MENU_IDEN', width: '10%', editable: false}),
  65. createColumn({text: '*메뉴명', datafield: 'MENU_NAME', width: 'auto'}),
  66. createColumn({text: '레벨', datafield: 'MENU_LEVL', width: 'auto', editable: false}),
  67. createColumn({text: '경로', datafield: 'MENU_PATH', width: '30%', editable: false}),
  68. createColumn({text: '메뉴등록여부', datafield: 'PROG_EXIS', width: '15%'}),
  69. createColumn({text: '정렬순서', datafield: 'SORT_SEQU', width: 'auto'}),
  70. //createColumn( {text: '이미지', datafield: 'IMGD', width: '60'} ),
  71. createColumn({text: '*직급', columntype: 'dropdownlist', datafield: 'POSI_CODE', width: 'auto'})
  72. ];
  73.  
  74. xgGridInit = function (result, errorMsg) {
  75. if (result === false && fn_IBKSsessionErrChk(errorMsg) == false) {
  76. bErrorFlag = true;
  77. return;
  78. }
  79. var getServerData;
  80.  
  81. var $xgGrid = $('.xg-grid').xgGrid({
  82. width: 926,
  83. height: 484,
  84. //theme: 'energyblue',
  85. editable: true,
  86. editmode: 'dblclick',
  87. /*pageable: true,
  88. pagesize: 15,
  89. pagermode: 'simple',*/
  90. keyboardnavigation: true,
  91. columnsmenu: true,
  92. columnsresize: true,
  93. columnsreorder: true,
  94. sortable: false,//true
  95. enablekeyboarddelete: true,
  96. selectionmode: 'multiplerowsextended',
  97. xgInitOption: {
  98. xgDataSet: dataSet,
  99. xgDataTable: dataTable,
  100. columns: columns
  101. },
  102. xgBindOption: {
  103. //template: 'view',
  104. cellEdit: true,
  105. cellValidation: true,
  106. useEditor: {
  107. 'PROG_EXIS': {
  108. columntype: 'checkbox',
  109. checkedAll: true
  110. },
  111. 'MENU_LEVL': {
  112. columntype: 'dropdownlist',
  113. source: [
  114. {text: '0', value: '0'},
  115. {text: '1', value: '1'},
  116. {text: '2', value: '2'},
  117. {text: '3', value: '3'},
  118. {text: '4', value: '4'}
  119. ]
  120. },
  121. 'IMGD': {
  122. columntype: 'dropdownlist',
  123. source: [
  124. {text: 'ImgC', value: 'ImgC'},
  125. {text: 'ImgD', value: 'ImgD'},
  126. {text: 'ImgO', value: 'ImgO'}
  127. ]
  128. },
  129. 'POSI_CODE': {
  130. columntype: 'dropdownlist',
  131. source: dsCmb.makeListTypeSource('dtPosi', 'DETA_CDNA', 'DETA_CODE')
  132. }
  133.  
  134. }
  135. }
  136. });
  137.  
  138. $('#bt_select').click(function () {
  139. getServerData();
  140. });
  141.  
  142. $('#bt_insert').click(function () {
  143. $xgGrid.xgGrid('addrow', null, [{
  144. MENU_LEVL: 1
  145. , PROG_EXIS: 1
  146. , IMGD: 'ImgC'
  147. }], 'top');
  148. $xgGrid.xgGrid('gotopage', 0);
  149. });
  150.  
  151. $('#bt_delete').click(function () {
  152. var rowPos = dataTable.getRowPos();
  153. $xgGrid.xgGrid('deleterow', rowPos);
  154. });
  155.  
  156. $('#bt_save').click(function () {
  157. for (var i = 0; i < dataTable.body.length; i++) {
  158. if (dataTable.getRowStatus(i) == 2 || dataTable.getRowStatus(i) == 3) {
  159. if (dataTable.getValue(i, 'MENU_IDEN') == null || dataTable.getValue(i, 'MENU_IDEN') == '') {
  160. alert("메뉴ID는 필수 입력 항목입니다.");
  161. return;
  162. }
  163. if (dataTable.getValue(i, 'MENU_NAME') == null || dataTable.getValue(i, 'MENU_NAME') == '') {
  164. alert("메뉴명은 필수 입력 항목입니다.");
  165. return;
  166. }
  167. if (dataTable.getValue(i, 'POSI_CODE') == null || dataTable.getValue(i, 'POSI_CODE') == '') {
  168. alert("직급은 필수 입력 항목입니다.");
  169. return;
  170. }
  171.  
  172. if (dataTable.getValue(i, 'MENU_PATH') == null) {
  173. dataTable.setValue(i, 'MENU_PATH', '');
  174. }
  175. if (dataTable.getValue(i, 'SORT_SEQU') == null) {
  176. dataTable.setValue(i, 'SORT_SEQU', '');
  177. }
  178. if (dataTable.getValue(i, 'INPU_EMNU') == null) {
  179. dataTable.setValue(i, 'INPU_EMNU', '');
  180. }
  181. if (dataTable.getValue(i, 'IMGC') == null) {
  182. dataTable.setValue(i, 'IMGC', '');
  183. }
  184. if (dataTable.getValue(i, 'IMGD') == null) {
  185. dataTable.setValue(i, 'IMGD', 'ImgC');
  186. }
  187. if (dataTable.getValue(i, 'IMGO') == null) {
  188. dataTable.setValue(i, 'IMGO', '');
  189. }
  190. }
  191. }
  192. tr.setSrc(updateURL);
  193. dataSet.update('dt_menu', function (result, errorMsg) {
  194. if (fn_IBKSsessionErrChk(errorMsg) == false) {
  195. bErrorFlag = true;
  196. return;
  197. } else if (fn_IBKErrChk(result, errorMsg) == false) { // 시스템 에러 처리
  198. bErrorFlag = true;
  199. return;
  200. }
  201. alert('메뉴가 저장되었습니다.');
  202. getServerData();
  203. });
  204. if (bErrorFlag) {
  205. return;
  206. }
  207. });
  208.  
  209. getParams = function () {
  210. var param;
  211. if ($('#mr_selId').is(":checked")) {
  212. param = '&menu_iden=' + $('#tx_menu').val();
  213. } else if ($('#mr_selName').is(":checked")) {
  214. param = '&menu_name=' + encodeURIComponent($('#tx_menu').val());
  215. }
  216. debugger;
  217. return param;
  218. }
  219. getServerData = function () {
  220. var param = getParams();
  221. tr.setSrc(selectURL + param);
  222. debugger;
  223. dataSet.select('dt_menu', function (result, errorMsg) {
  224. if (result === false && fn_IBKSsessionErrChk(errorMsg) == false) {
  225. bErrorFlag = true;
  226. return;
  227. } else if (result === false && fn_IBKErrChk(result, errorMsg) == false) { // 시스템 에러 처리
  228. bErrorFlag = true;
  229. return;
  230. }
  231. });
  232. };
  233.  
  234. // 2017/11/08 임대근 시작
  235. // 서버에서 엑셀다운로드하도록 변경
  236. $('#excel_format_export').click(
  237. function () {
  238. var params = getParams();
  239. window.open("/SmartGreenOFF/MDI/excel/menuAdminExcel.jsp?" + params);
  240. }
  241. );
  242. // edit by richardlim 2017-07-20
  243. // format excel export 추가
  244. // $('#excel_format_export').click(
  245. // function () {
  246. // $('.xg-grid').xgGrid('exportdata', 'xls',
  247. // '메뉴관리', true, null, false,
  248. // '/ix-export.xex?color=test',
  249. // 'UTF-8');
  250. // return false;
  251. // }
  252. // );
  253.  
  254. };
  255.  
  256. dataSet.select('dt_menu', function (result, errorMsg) {
  257. if (result === false && fn_IBKSsessionErrChk(errorMsg) == false) {
  258. bErrorFlag = true;
  259. return;
  260. } else if (result === false && fn_IBKErrChk(result, errorMsg) == false) { // 시스템 에러 처리
  261. bErrorFlag = true;
  262. return;
  263. }
  264. xgGridInit();
  265. });
  266.  
  267. if (bErrorFlag) {
  268. return;
  269. }
  270.  
  271. return this;
  272.  
  273. }).call(this);
  274.  
  275. $(document).ready(function () {
  276. $('.menu-export').addClass('btn-success').removeClass('jqx-rc-all');
  277. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement