main.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. const MAIN_NOTICE_GRID_ID = '#ITP_MAIN_NOTICE_jqGrid';
  2. const MAIN_NOTICE_GRID_LIST = '#ITP_MAIN_NOTICE_jqGrid_list';
  3. const MAIN_NOTICE_GRID_PAGER = '#ITP_MAIN_NOTICE_jqGridPager';
  4. const MAIN_NOTICE_GRID_EMPTY = '#ITP_MAIN_NOTICE_jqGridEmpty';
  5. let NTICE_DETAIL_GRID_LIST = '/api/ntice/detail-grid-list';
  6. require(['config'], function() {
  7. require([
  8. 'jquery',
  9. 'jquery.bootstrap.fileUpload' //파일 업로드가 있는 페이지에서 로딩
  10. ], function($) {
  11. setTimeout(function() {
  12. // 시간지정
  13. $('#ITP_FORM_MAIN_NOTICE_SEARCH_SCH_DT').val(itp_fn_date_format(new Date(), 2));
  14. $('#ITP_FORM_MAIN_NOTICE_SEARCH_USER_ID').val(USER_ID);
  15. // 그리드
  16. itp_fn_jqgrid_resize(MAIN_NOTICE_GRID_ID, MAIN_NOTICE_GRID_LIST, 'lg');
  17. itp_fn_MAIN_NOTICE_grid.init();
  18. itp_fn_fire_window_resize();
  19. // 조회
  20. itp_fn_MAIN_NOTICE_search();
  21. }, 100);
  22. });
  23. });
  24. var itp_fn_MAIN_NOTICE_grid = {
  25. init: function() {
  26. // 데이터 없을때
  27. itp_fn_MAIN_NOTICE_empty.push();
  28. $(MAIN_NOTICE_GRID_EMPTY).on('click', function() {
  29. itp_fn_MAIN_NOTICE_empty.back();
  30. itp_MAIN_NOTICE_param.gridSize = $.jgrid.defaults.rowNum;
  31. $(MAIN_NOTICE_GRID_ID).setGridParam({'postData': JSON.stringify(itp_MAIN_NOTICE_param)}).trigger('reloadGrid');
  32. });
  33. },
  34. callBack: function() {
  35. let param = $('#ITP_FORM_MAIN_NOTICE_SEARCH').serializeObject();
  36. param.gridSize = $.jgrid.defaults.rowNum;
  37. $(MAIN_NOTICE_GRID_ID).jqGrid({
  38. colModel: [
  39. {
  40. index: 'NTICE_NO', name: 'nticeNo',
  41. label: ITP_MSG_LOCALE.label.notiNo, //공지번호
  42. width: '10', fixed: false, align: 'center',
  43. sortable: false, hidden: false
  44. },
  45. {
  46. index: 'NTICE_TITL', name: 'nticeTitl',
  47. label: '공지사항', //공지제목
  48. width: '15', fixed: false, align: 'center',
  49. sortable: false, hidden: false
  50. },
  51. {
  52. index: 'ADD_DT', name: 'addDt',
  53. label: ITP_MSG_LOCALE.label.regDt, //등록일
  54. width: '10', fixed: false, align: 'center',
  55. sortable: false, hidden: false
  56. }
  57. ],
  58. loadBeforeSend: function(jqXHR) {
  59. jqXHR.setRequestHeader('X-AUTH-TOKEN', CONN_KEY);
  60. },
  61. postData: JSON.stringify(param),
  62. url: DOMAIN + NTICE_DETAIL_GRID_LIST,
  63. pager: MAIN_NOTICE_GRID_PAGER,
  64. multiselect: false,
  65. rownumbers: true,
  66. onCellSelect: function(rowId, cellIdx, cellValue) {
  67. var cm = $(this).jqGrid('getGridParam', 'colModel');
  68. var colNm = cm[cellIdx].name;
  69. if (colNm == 'nticeTitl') {
  70. const nticeNoVal = $(this).jqGrid('getCell', rowId, 'nticeNo');
  71. const key = {nticeNo: nticeNoVal, viewCd: 'R'};
  72. var param = $.param(key);
  73. // itp_fn_MAIN_NOTICE_view(param);
  74. fn_call_popup('comm', 'NOTICE_INFO_POPUP', '#ITP_ASIDE', function() {
  75. }, param, 'S');
  76. $('#ITP_NOTICE_INFO_POPUP > div.modal-dialog').width('500px');
  77. }
  78. },
  79. loadComplete: function(data) {
  80. //console.log(JSON.stringify(data));
  81. itp_fn_grid_load_complete(data, MAIN_NOTICE_GRID_ID, true, 'number', 'MAIN_NOTICE', itp_MAIN_NOTICE_search, itp_fn_MAIN_NOTICE_empty, false, data.gridRecords, false);
  82. var ids = $(MAIN_NOTICE_GRID_ID).getDataIDs();
  83. $.each(ids, function(idx, rowId) {
  84. $(MAIN_NOTICE_GRID_ID).jqGrid('setCell', rowId, 'nticeTitl', '', ITP_GRID_COL_STYLE.link);
  85. });
  86. if ($('#ITP_CONTAINER').data('openYn') == 'Y') {
  87. $('#ITP_CONTAINER').data('openYn', 'N');
  88. const keyNew = {nticeNo: $('#ITP_CONTAINER').data('nticeNo'), viewCd: 'R'};
  89. var paramNew = $.param(keyNew);
  90. itp_fn_MAIN_NOTICE_view(paramNew);
  91. }
  92. },
  93. loadError: function(jqXHR, textStatus, errorThrown) {
  94. itp_fn_grid_load_error(jqXHR, textStatus, errorThrown);
  95. },
  96. onPaging: function(action) {
  97. itp_fn_grid_paging(MAIN_NOTICE_GRID_ID, action, param);
  98. }
  99. }).navGrid(MAIN_NOTICE_GRID_PAGER, ITP_GRID_NAV_DEFAULTS.navGrid);
  100. },
  101. clearData : function() {
  102. $(MAIN_NOTICE_GRID_ID).jqGrid('clearGridData', true);
  103. $(MAIN_NOTICE_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  104. $(MAIN_NOTICE_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  105. $(MAIN_NOTICE_GRID_EMPTY).show();
  106. },
  107. unload : function() {
  108. $.jgrid.gridUnload(MAIN_NOTICE_GRID_ID);
  109. }
  110. };
  111. var itp_fn_MAIN_NOTICE_search = function() {
  112. itp_fn_MAIN_NOTICE_grid.unload();
  113. itp_fn_MAIN_NOTICE_grid.callBack();
  114. };
  115. let itp_MAIN_NOTICE_param = {};
  116. let itp_MAIN_NOTICE_search = false;
  117. var itp_fn_MAIN_NOTICE_empty = {
  118. push: function() {
  119. let param = $('#ITP_FORM_MAIN_NOTICE_SEARCH').serializeObject();
  120. itp_MAIN_NOTICE_param = param;
  121. },
  122. back: function() {
  123. }
  124. };