ITP_OPER02010.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. require(['config'], function() {
  2. require([
  3. 'jquery.bootstrap.fileUpload' //파일 업로드가 있는 페이지에서 로딩
  4. ], function($) {
  5. pageObj.init();
  6. });
  7. });
  8. const OPER02010_GRID_ID = '#ITP_OPER02010_jqGrid';
  9. const OPER02010_GRID_LIST = '#ITP_OPER02010_jqGrid_list';
  10. const OPER02010_GRID_PAGER = '#ITP_OPER02010_jqGridPager';
  11. const OPER02010_GRID_EMPTY = '#ITP_OPER02010_jqGridEmpty';
  12. // const OPER02010_VIEW_GRID_ID = '#ITP_OPER02010_VIEW_jqGrid';
  13. // const OPER02010_VIEW_GRID_LIST = '#ITP_OPER02010_VIEW_jqGrid_list';
  14. // const OPER02010_VIEW_GRID_PAGER = '#ITP_OPER02010_VIEW_jqGridPager';
  15. // const OPER02010_VIEW_GRID_EMPTY = '#ITP_OPER02010_VIEW_jqGridEmpty';
  16. //
  17. // const OPER02010_DETAIL_GRID_ID = '#ITP_OPER02010_DETAIL_jqGrid';
  18. // const OPER02010_DETAIL_GRID_LIST = '#ITP_OPER02010_DETAIL_jqGrid_list';
  19. // const OPER02010_DETAIL_GRID_PAGER = '#ITP_OPER02010_DETAIL_jqGridPager';
  20. // const OPER02010_DETAIL_GRID_EMPTY = '#ITP_OPER02010_DETAIL_jqGridEmpty';
  21. let ITP_FORM_OPER02010_DETAIL_IS_WRITING = false;
  22. let NTICE_SAVE_NTICE = '/api/ntice/save-ntice';
  23. let NTICE_DETAIL_GRID_LIST = '/api/ntice/detail-grid-list';
  24. let NTICE_INFO_NTICE = '/api/ntice/info-ntice';
  25. let NTICE_TARGET_GRID_LIST = '/api/ntice/target-grid-list';
  26. let BRAND_POP_GRID_LIST = '/api/brand/pop-grid-list';
  27. // Grid Column Model
  28. const gridColModel = {
  29. // 목록
  30. list: [
  31. {
  32. index: 'NTICE_NO', name: 'nticeNo',
  33. label: ITP_MSG_LOCALE.label.notiNo, //공지번호
  34. width: '10', fixed: false, align: 'center',
  35. sortable: false, hidden: false
  36. },
  37. {
  38. index: 'AFFL_SHOP_NM', name: 'afflShopNm',
  39. label: ITP_MSG_LOCALE.label.afflShopNm, //가맹점
  40. width: '10', fixed: false, align: 'center',
  41. sortable: false, hidden: false
  42. },
  43. {
  44. index: 'BRAND_NM', name: 'brandNm',
  45. label: ITP_MSG_LOCALE.label.brandNm, //브랜드
  46. width: '13', fixed: false, align: 'center',
  47. sortable: false, hidden: false
  48. },
  49. {
  50. index: 'NTICE_TITL', name: 'nticeTitl',
  51. label: ITP_MSG_LOCALE.label.titlet, //공지제목
  52. width: '15', fixed: false, align: 'center',
  53. sortable: false, hidden: false
  54. },
  55. {
  56. index: 'TARGET_NM', name: 'targetNm',
  57. label: ITP_MSG_LOCALE.label.targetNm, //공지대상
  58. width: '8', fixed: false, align: 'center',
  59. sortable: false, hidden: false
  60. },
  61. {
  62. index: 'NTICE_STAT_NM', name: 'nticeStatNm',
  63. label: ITP_MSG_LOCALE.label.status, //상태
  64. width: '6', fixed: false, align: 'center',
  65. sortable: false, hidden: false
  66. },
  67. {
  68. index: 'NOTI_ST_DAY', name: 'notiStDay',
  69. label: ITP_MSG_LOCALE.label.viewDt, //노출일
  70. width: '12', fixed: false, align: 'center',
  71. sortable: false, hidden: false
  72. },
  73. {
  74. index: 'ADD_DT', name: 'addDt',
  75. label: ITP_MSG_LOCALE.label.regDt, //등록일
  76. width: '10', fixed: false, align: 'center',
  77. sortable: false, hidden: false
  78. }
  79. ]/*,
  80. detail: [
  81. {
  82. index: 'VIEW_CD', name: 'viewCd',
  83. label: ITP_MSG_LOCALE.label.viewCd,
  84. width: '10', fixed: false, align: 'center',
  85. sortable: false, hidden: true
  86. },
  87. {
  88. index: 'NTICE_NO', name: 'nticeNo',
  89. label: ITP_MSG_LOCALE.label.notiNo,
  90. width: '10', fixed: false, align: 'center',
  91. sortable: false, hidden: true
  92. },
  93. {
  94. index: 'BRAND_ID', name: 'brandId',
  95. label: ITP_MSG_LOCALE.label.brandId,
  96. width: '20', fixed: false, align: 'center',
  97. sortable: false, editable: false, edittype: 'text'
  98. },
  99. {
  100. index: 'BRAND_NM', name: 'brandNm',
  101. label: ITP_MSG_LOCALE.label.brandNm,
  102. width: '30', fixed: false, align: 'center',
  103. sortable: false, editable: false, edittype: 'text'
  104. }
  105. ],
  106. brand: [
  107. {
  108. index: 'VIEW_CD', name: 'viewCd',
  109. label: ITP_MSG_LOCALE.label.viewCd,
  110. width: '10', fixed: false, align: 'center',
  111. sortable: false, hidden: true
  112. },
  113. {
  114. index: 'BRAND_ID', name: 'brandId',
  115. label: ITP_MSG_LOCALE.table.brandId,
  116. width: '20', fixed: false, align: 'center',
  117. sortable: false, editable: false, edittype: 'text'
  118. },
  119. {
  120. index: 'BRAND_NM', name: 'brandNm',
  121. label: ITP_MSG_LOCALE.table.brandNm,
  122. width: '30', fixed: false, align: 'center',
  123. sortable: false, editable: false, edittype: 'text'
  124. }
  125. ]*/
  126. };
  127. /********************************************************
  128. --------------------------------------------------------
  129. - Object 목록 -
  130. --------------------------------------------------------
  131. * let pageObj = {} : 화면공통 Object *
  132. * let listObj = {} : 목록화면 Object *
  133. * let viewObj = {} : 상세화면 Object *
  134. * let modifyObj = {} : 수정화면 Object *
  135. * let createObj = {} : 신규화면 Object *
  136. *******************************************************/
  137. /*화면공통 Object*/
  138. let pageObj = {
  139. init: function () {
  140. this.ui.init();
  141. this.event.init();
  142. },
  143. pageMode: '',
  144. ui: {
  145. init: function () {
  146. this.view();
  147. this.view();
  148. this.ready();
  149. },
  150. view: function () {
  151. // 버튼 권한설정
  152. fn_proc_btn_auth('OPER02010');
  153. // 공통코드 표시
  154. $('select').each(function() {
  155. if($(this).data('select-code')) {
  156. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  157. }
  158. });
  159. // 조회일자 지정
  160. var now = new Date();
  161. $('#ITP_TAB_OPER02010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  162. $('#ITP_FORM_OPER02010_SEARCH_FROM_DT').datepicker('setDate', new Date());
  163. },
  164. afflInfo: {
  165. init: function() {
  166. this.authTpCd = fn_make_user_info.get('authTpCd');
  167. if(this.authTpCd === '30' || this.authTpCd === '40' || this.authTpCd === '50') {
  168. this.afflShopId = fn_make_user_info.get('afflShopId');
  169. this.afflShopNm = fn_make_user_info.get('afflShopNm');
  170. this.brandId = fn_make_user_info.get('brandId');
  171. this.brandNm = fn_make_user_info.get('brandNm');
  172. this.setAffl();
  173. }
  174. },
  175. setAffl: function() {
  176. var _this = this;
  177. var afflShopId = '#ITP_FORM_OPER02010_' + (pageObj.pageMode === 'LIST' ? 'SEARCH' : 'DETAIL') + '_AFFL_SHOP_ID';
  178. var afflShopNm = '#ITP_FORM_OPER02010_' + (pageObj.pageMode === 'LIST' ? 'SEARCH' : 'DETAIL') + '_AFFL_SHOP_NM';
  179. // var afflShopId = '#ITP_FORM_OPER02010_' + (pageObj.pageMode === 'ADD' ? 'DETAIL' : 'SEARCH') + '_AFFL_SHOP_ID';
  180. // var afflShopNm = '#ITP_FORM_OPER02010_' + (pageObj.pageMode === 'ADD' ? 'DETAIL' : 'SEARCH') + '_AFFL_SHOP_NM';
  181. $(afflShopId).val(_this.afflShopId);
  182. $(afflShopNm).val(_this.afflShopNm);
  183. $(afflShopNm).attr('readonly', true);
  184. if(_this.authTpCd === '30') {
  185. var callbackFn = (result) => {
  186. var brandList = [];
  187. $.each(result.gridRows, function(i, item) {
  188. brandList.push({'brandId': item.brandId, 'brandNm': item.brandNm});
  189. });
  190. _this.setBrand(brandList);
  191. };
  192. var param = {
  193. 'afflShopId': _this.afflShopId
  194. };
  195. fn_ajax_call(BRAND_POP_GRID_LIST, JSON.stringify(param), callbackFn, 'POST');
  196. } else {
  197. var brandList = [{'brandId': _this.brandId, 'brandNm': _this.brandNm}];
  198. this.setBrand(brandList);
  199. }
  200. },
  201. setBrand: function(AFFL_BRAND) {
  202. var _this = this;
  203. if(AFFL_BRAND.length > 0) {
  204. var brandId = 'ITP_FORM_OPER02010_' + (pageObj.pageMode === 'LIST' ? 'SEARCH' : 'DETAIL') + '_BRAND_ID';
  205. console.log(brandId);
  206. (_this.authTpCd === '30') ? fn_make_select_brand(AFFL_BRAND, brandId, true, '선택') : fn_make_select_brand(AFFL_BRAND, brandId, false);
  207. } else {
  208. }
  209. }
  210. },
  211. ready: function () {
  212. listObj.init();
  213. // 가맹점 조회
  214. afflShopObj.init();
  215. }
  216. },
  217. event: {
  218. init: function () {
  219. this.button();
  220. },
  221. button: function () {
  222. // 버튼 클릭 이벤트
  223. $('button').each(function() {
  224. var id = $(this).attr('id');
  225. $(this).on('click', function() {
  226. switch (id) {
  227. case 'ITP_BTN_OPER02010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  228. case 'ITP_BTN_OPER02010_NEWREG' : listObj.button.create(); break; // 신규등록 버튼
  229. case 'ITP_BTN_OPER02010_MODIFY' : modifyObj.button.modify(); break; // 수정 버튼
  230. case 'ITP_BTN_OPER02010_CANCELLIST' : createObj.button.cancel(); break; // 취소/목록 버튼
  231. case 'ITP_BTN_OPER00210_DELETE' : break; // 삭제 버튼
  232. case 'ITP_BTN_OPER02010_SAVE' : createObj.button.save(); break; // 저장 버튼
  233. // case 'ITP_BTN_OPER02010_DETAIL_ADDROW' : pageObj.grid.button.addRow(); break; // 상세:추가버튼
  234. // case 'ITP_BTN_OPER02010_DETAIL_DELROW' : pageObj.grid.button.delRow(); break; // 상세:삭제버튼
  235. }
  236. });
  237. });
  238. },
  239. notiTarget: function(isDisabled) {
  240. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_TARGET_CD').attr('disabled', isDisabled);
  241. }
  242. },
  243. fileUpload: function() {
  244. //파일업로드(등록/수정화면)
  245. var id = 'OPER02010';
  246. $('#ITP_' + id + '_DETAIL_UPLOAD').empty();
  247. $('#ITP_' + id + '_DETAIL_LOGO_FILE').empty();
  248. var removeFn = (param) => {
  249. $('#ITP_' + id + '_DETAIL_LOGO_FILE').empty();
  250. };
  251. const fileArgs = {
  252. 'fileNo': $('#ITP_FORM_' + id + '_DETAIL_FILE_NO').val(),
  253. 'viewCd': $('#ITP_FORM_' + id + '_DETAIL_VIEW_CD').val(),
  254. 'showYn': $('#ITP_' + id + '_DETAIL_UPLOAD').attr('data-show-yn'),
  255. 'fileId': '#ITP_FORM_' + id + '_DETAIL_FILE_NO' //파일번호를 서버에서 받아서 넣을 파일번호 인풋박스 아이디
  256. };
  257. itp_fn_set_file_upload('ITP_' + id + '_DETAIL_UPLOAD', 'notice', true, false, id, fileArgs, removeFn);
  258. },
  259. switchScreen: function(mode) {
  260. pageObj.pageMode = mode;
  261. $('.itp_det_head').find('button[id^="ITP_BTN_OPER02010_"]').each(function(i) {
  262. $(this).hide();
  263. });
  264. $('#ITP_TAB_OPER02010').find('div[id$="_CONTAINER"]').each(function(i) {
  265. $(this).hide();
  266. });
  267. if(mode === 'LIST') { // 목록
  268. $('#ITP_AJAX_OPER02010_LIST_CONTAINER').show();
  269. fn_show_btn_auth_array(['#ITP_BTN_OPER02010_SRH', '#ITP_BTN_OPER02010_NEWREG']);
  270. pageObj.ui.afflInfo.init();
  271. } else if(mode == 'ADD') { // 등록
  272. $('#ITP_AJAX_OPER02010_DETAIL_CONTAINER').show();
  273. fn_show_btn_auth_array(['#ITP_BTN_OPER02010_CANCELLIST', '#ITP_BTN_OPER02010_SAVE']);
  274. $('#ITP_FORM_OPER02010_DETAIL').find('input, textarea, select, checkbox').each(function(i, elem) {
  275. $(this).attr('id') === 'ITP_FORM_OPER02010_DETAIL_VIEW_CD' ? $(this).val('C') : $(this).val('');
  276. if(elem.type === 'select') {
  277. $(this).val('').prop('selected', true);
  278. }
  279. });
  280. $('#ITP_FORM_OPER02010_FROM_DT').datepicker('setDate', new Date());
  281. $('#ITP_FORM_OPER02010_TO_DT').datepicker('setDate', new Date());
  282. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_AFFL_SHOP_ID').val('');
  283. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_AFFL_SHOP_NM').val('').prop('readonly', true);
  284. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_SEARCH_BRAND_ID option').remove();
  285. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_FILE_NO').val('');
  286. pageObj.ui.afflInfo.init();
  287. pageObj.event.notiTarget(fn_make_user_info.get('authTpCd') === '10');
  288. } else if(mode === 'MODIFY') { // 수정
  289. $('#ITP_AJAX_OPER02010_DETAIL_CONTAINER').show();
  290. fn_show_btn_auth_array(['#ITP_BTN_OPER02010_CANCELLIST', '#ITP_BTN_OPER02010_SAVE', '#ITP_BTN_OPER02010_RESET_PW']);
  291. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_AFFL_SHOP_NM').prop('readonly', true);
  292. if(fn_make_user_info.get('authTpCd') === '30') {
  293. pageObj.ui.afflInfo.init();
  294. }
  295. } else if(mode === 'VIEW') { // 보기
  296. $('#ITP_AJAX_OPER02010_VIEW_CONTAINER').show();
  297. }
  298. }/*,
  299. grid: {
  300. init: function(mode) {
  301. this.mode = mode;
  302. this.gridId = (mode === 'VIEW') ? OPER02010_VIEW_GRID_ID : OPER02010_DETAIL_GRID_ID;
  303. this.unload();
  304. this.load(mode);
  305. },
  306. mode: 'DETAIL',
  307. gridId: '',
  308. button: {
  309. addRow: function() {
  310. // 팝업
  311. var popFn = function(rowDataPop) {
  312. console.log(rowDataPop);
  313. // 기존등록 사용자ID
  314. var exists = '';
  315. const rowData = $(OPER02010_DETAIL_GRID_ID).getRowData();
  316. $.each(rowData, function(key, value) {
  317. exists = exists + value.brandId + ';';
  318. });
  319. $.each(rowDataPop, function(key, value) {
  320. // console.log(JSON.stringify(value));
  321. if(exists.indexOf(value.brandId) < 0) {
  322. value['viewCd'] = "C";
  323. $(OPER02010_DETAIL_GRID_ID).jqGrid('addRowData', value.brandId, value, 'last');
  324. }
  325. });
  326. $(OPER02010_DETAIL_GRID_EMPTY).hide();
  327. };
  328. var agrs = {'afflShopId': $('#ITP_FORM_OPER02010_DETAIL_SEARCH_AFFL_SHOP_ID').val()};
  329. fn_call_popup('biz', 'BIZPOP_AFFL_BRAND', '#ITP_ASIDE', popFn, agrs, 'S');
  330. },
  331. delRow: function() {
  332. itp_fn_grid_del_row(OPER02010_DETAIL_GRID_ID);
  333. }
  334. },
  335. load : function() {
  336. let param = $('#ITP_FORM_OPER02010_' + this.mode).serializeObject();
  337. param.gridSize = $.jgrid.defaults.rowNum;
  338. param.pagingYn = false; // 페이지안함
  339. var _gridId = this.gridId;
  340. var option = {
  341. gridId: _gridId,
  342. colModel: gridColModel.detail,
  343. param: param,
  344. url: DOMAIN + NTICE_TARGET_GRID_LIST,
  345. multiselect: (this.mode !== 'VIEW'),
  346. loadComplete: function(data) {
  347. console.log(data);
  348. itp_fn_grid_load_complete(data, _gridId, true, undefined, 'OPER02010_' + this.mode);
  349. },
  350. onSortCol: function(index, columnIndex, sortOrder) {
  351. var sortingFn = {
  352. callBack: function(args) {
  353. $(args).trigger('reloadGrid');
  354. }
  355. };
  356. if (itp_fn_check_grid_is_writing(_gridId)) {
  357. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, sortingFn, _gridId);
  358. return 'stop';
  359. } else {
  360. itp_fn_grid_sorting(_gridId, index, sortOrder);
  361. }
  362. }
  363. };
  364. itp_fn_grid_make_not_paging(option);
  365. },
  366. unload : function() {
  367. $.jgrid.gridUnload(this.gridId);
  368. }
  369. }*/
  370. };
  371. /*목록화면 Object*/
  372. let listObj = {
  373. init: function () {
  374. // Grid
  375. this.grid.init();
  376. },
  377. button: {
  378. search: function () {
  379. listObj.grid.itp_OPER02010_search = true;
  380. let param = $('#ITP_FORM_OPER02010_SEARCH').serializeObject();
  381. param.gridSize = $.jgrid.defaults.rowNum;
  382. param.gridPage = $.jgrid.defaults.page;
  383. $(OPER02010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  384. },
  385. create: function () {
  386. pageObj.switchScreen('ADD');
  387. itp_fn_form_clear_validate(null, '#ITP_FORM_OPER02010_DETAIL');
  388. createObj.init();
  389. }
  390. },
  391. grid: {
  392. init: function() {
  393. // 데이터 없을때
  394. this.itp_fn_OPER02010_empty.push();
  395. itp_fn_jqgrid_resize(OPER02010_GRID_ID, OPER02010_GRID_LIST, 'lg');
  396. itp_fn_fire_window_resize();
  397. this.search();
  398. },
  399. itp_OPER02010_param: {},
  400. itp_OPER02010_search: false,
  401. colModel: gridColModel.list,
  402. search: function() {
  403. pageObj.switchScreen('LIST');
  404. this.unload();
  405. this.load();
  406. },
  407. load: function() {
  408. var _this = this;
  409. let param = $('#ITP_FORM_OPER02010_SEARCH').serializeObject();
  410. param.gridSize = $.jgrid.defaults.rowNum;
  411. var option = {
  412. gridId: OPER02010_GRID_ID,
  413. colModel: this.colModel,
  414. param: param,
  415. autowidth:true,
  416. shrinkToFit:false,
  417. url: DOMAIN + NTICE_DETAIL_GRID_LIST,
  418. pager: OPER02010_GRID_PAGER,
  419. onCellSelect: function(rowId, cellIdx, cellValue) {
  420. var cm = $(this).jqGrid('getGridParam', 'colModel');
  421. var colNm = cm[cellIdx].name;
  422. if (colNm == 'nticeTitl') {
  423. const nticeNoVal = $(this).jqGrid('getCell', rowId, 'nticeNo');
  424. const key = {nticeNo: nticeNoVal, viewCd: 'R'};
  425. var param = $.param(key);
  426. viewObj.init(param);
  427. }
  428. },
  429. loadComplete: function(data) {
  430. $("tr.jqgrow:odd").css("background", "#f5f5f5"); //2번째 마다 색변경
  431. console.log(data);
  432. itp_fn_grid_load_complete(data, OPER02010_GRID_ID, true, 'number', 'OPER02010', listObj.grid.itp_OPER02010_search, _this.itp_fn_OPER02010_empty, true, data.gridRecords, true);
  433. var ids = $(OPER02010_GRID_ID).getDataIDs();
  434. $.each(ids, function(idx, rowId) {
  435. $(OPER02010_GRID_ID).jqGrid('setCell', rowId, 'nticeTitl', '', ITP_GRID_COL_STYLE.link);
  436. // $(OPER02010_GRID_ID).jqGrid('setCell', rowId, 'afflShopNm', '', ITP_GRID_COL_STYLE.link);
  437. });
  438. if ($('#ITP_CONTAINER').data('openYn') == 'Y') {
  439. $('#ITP_CONTAINER').data('openYn', 'N');
  440. const keyNew = {nticeNo: $('#ITP_CONTAINER').data('nticeNo'), viewCd: 'R'};
  441. var paramNew = $.param(keyNew);
  442. viewObj.init(paramNew);
  443. }
  444. }
  445. };
  446. itp_fn_grid_make_remote(option);
  447. },
  448. itp_fn_OPER02010_empty: {
  449. push: function() {
  450. let param = $('#ITP_FORM_OPER02010_SEARCH').serializeObject();
  451. listObj.grid.itp_OPER02010_param = param;
  452. },
  453. back: function() {
  454. var _this = listObj.grid;
  455. $('#ITP_FORM_OPER02010_DEVI_TP_CD').val(_this.itp_OPER02010_param.safflShopId);
  456. $('#ITP_FORM_OPER02010_ORDER_YN').val(_this.itp_OPER02010_param.safflShopNm);
  457. $('#ITP_FORM_OPER02010_ADT_AUTH_CD').val(_this.itp_OPER02010_param.sbrandId);
  458. $('#ITP_FORM_OPER02010_EMAIL_RCV_YN').val(_this.itp_OPER02010_param.snticeTitl);
  459. $('#ITP_FORM_OPER02010_FROM_DT').val(_this.itp_OPER02010_param.fromDt);
  460. $('#ITP_FORM_OPER02010_TO_DT').val(_this.itp_OPER02010_param.toDt);
  461. }
  462. },
  463. reload : function() {
  464. var _this = this;
  465. $(OPER02010_GRID_EMPTY).off('click').on('click', function() {
  466. _this.itp_fn_OPER02010_empty.back();
  467. _this.itp_OPER02010_param.gridSize = $.jgrid.defaults.rowNum;
  468. $(OPER02010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_OPER02010_param)}).trigger('reloadGrid');
  469. });
  470. },
  471. clearData : function() {
  472. $(OPER02010_GRID_ID).jqGrid('clearGridData', true);
  473. $(OPER02010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  474. $(OPER02010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  475. $(OPER02010_GRID_EMPTY).show();
  476. },
  477. unload : function() {
  478. $.jgrid.gridUnload(OPER02010_GRID_ID);
  479. }
  480. }
  481. };
  482. /*상세화면 Object*/
  483. let viewObj = {
  484. init: function (param) {
  485. this.load(param);
  486. },
  487. button: {
  488. },
  489. load: function(param) {
  490. fn_ajax_call(NTICE_INFO_NTICE, param, this.callback, 'GET');
  491. },
  492. callback: function (result) {
  493. console.log(result);
  494. pageObj.switchScreen('VIEW');
  495. $('#ITP_FORM_OPER02010_VIEW #ITP_FORM_OPER02010_VIEW_USER_ID').val(result.nticeNo);
  496. $('#ITP_FORM_OPER02010_VIEW .fnNticeTitl').text(result.nticeTitl);
  497. $('#ITP_FORM_OPER02010_VIEW .fnNotiDay').text(result.notiStDay+' ~ '+result.notiEdDay);
  498. $('#ITP_FORM_OPER02010_VIEW .fnDelYn').text(result.delYn);
  499. $('#ITP_FORM_OPER02010_VIEW .fnNticeDesc').html(result.nticeDesc.replace(/(\n|\r\n)/g, '<br>'));
  500. $('#ITP_FORM_OPER02010_VIEW .fnTargetNm').text(result.targetNm);
  501. $('#ITP_FORM_OPER02010_VIEW_FILE_NO').val(result.fileNo); //파일번호 셋팅
  502. $('#ITP_FORM_OPER02010_VIEW .fnAddId').text(result.addId);
  503. $('#ITP_FORM_OPER02010_VIEW .fnAddNm').text(result.addNm);
  504. itp_fn_attach_file.view('ITP_OPER02010_VIEW_UPLOAD', result.fileNoList
  505. , 'form-control itp_input', 'border:none; top:0px; left:12px; height:100px; width:125px; position:absolute;');
  506. // if(result.addId === fn_make_user_info.get('userId')) {
  507. if(fn_make_user_info.get('authTpCd') === '10' || result.addId === fn_make_user_info.get('userId')) {
  508. fn_show_btn_auth_array(['#ITP_BTN_OPER02010_MODIFY', '#ITP_BTN_OPER02010_CANCELLIST']);
  509. } else {
  510. fn_show_btn_auth_array(['#ITP_BTN_OPER02010_CANCELLIST']);
  511. }
  512. // 권한정보 리스트 조회
  513. // pageObj.grid.init('VIEW');
  514. }
  515. };
  516. /*수정화면 Object*/
  517. let modifyObj = {
  518. init: function (param) {
  519. },
  520. button: {
  521. modify: function () {
  522. itp_fn_form_clear_validate(null, '#ITP_FORM_OPER02010_DETAIL');
  523. const nticeNoVal = $('#ITP_FORM_OPER02010_VIEW_USER_ID').val();
  524. const key = {nticeNo: nticeNoVal, viewCd: 'R'};
  525. var param = $.param(key);
  526. modifyObj.load(param);
  527. }
  528. },
  529. load: function(param) {
  530. fn_ajax_call(NTICE_INFO_NTICE, param, this.callback, 'GET');
  531. },
  532. callback: function (result) {
  533. console.log(result);
  534. pageObj.switchScreen('MODIFY');
  535. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_VIEW_CD').val('U');
  536. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_NTICE_NO').val(result.nticeNo);
  537. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_NTICE_TITL').val(result.nticeTitl);
  538. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_FROM_DT').val(result.notiStDay);
  539. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_TO_DT').val(result.notiEdDay);
  540. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DEL_YN').val(result.delYn);
  541. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_NTICE_DESC').val(result.nticeDesc);
  542. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_TARGET_CD').val(result.targetCd);
  543. // $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_BRAND').prop('checked', result.brandChk === 'Y');
  544. // $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_STORE').prop('checked', result.shopChk === 'Y');
  545. // $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_SPPLY').prop('checked', result.supplyChk === 'Y');
  546. // $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_BRAND_CHK').val(result.brandChk);
  547. // $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_STORE_CHK').val(result.shopChk);
  548. // $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_SPPLY_CHK').val(result.supplyChk);
  549. $('#ITP_FORM_OPER02010_DETAIL_FILE_NO').val(result.fileNo); //파일번호 셋팅
  550. // 가맹점 셋팅
  551. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_AFFL_SHOP_ID').val(result.afflShopId);
  552. $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_AFFL_SHOP_NM').val(result.afflShopNm);
  553. // $('#ITP_FORM_OPER02010_DETAIL_SEARCH_AFFL_SHOP').attr('disabled', true);
  554. // $('#ITP_FORM_OPER02010_DETAIL_DELETE_AFFL_SHOP').attr('disabled', true);
  555. // $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_SEARCH_AFFL_SHOP_NM').attr('readonly', true);
  556. // $('#ITP_FORM_OPER02010_DETAIL #ITP_FORM_OPER02010_DETAIL_SEARCH_BRAND_ID').attr('readonly', true);
  557. pageObj.ui.afflInfo.init();
  558. if(result.brandId && result.brandId !== '') {
  559. var brandList = [{'brandId':result.brandId, 'brandNm':result.brandNm}];
  560. fn_make_select_brand(brandList, 'ITP_FORM_OPER02010_DETAIL_SEARCH_BRAND_ID');
  561. }
  562. pageObj.event.notiTarget(result.afflShopId === '');
  563. // if(result.targetCd && result.targetCd != '') {
  564. // $('#ITP_BTN_OPER02010_DETAIL_ADDROW').attr('disabled', false);
  565. // $('#ITP_BTN_OPER02010_DETAIL_DELROW').attr('disabled', false);
  566. // }
  567. //파일업로드(수정화면)
  568. pageObj.fileUpload();
  569. // 리스트 조회
  570. // createObj.form.init();
  571. // pageObj.grid.init('DETAIL');
  572. }
  573. };
  574. /*신규화면 Object*/
  575. let createObj = {
  576. init: function () {
  577. pageObj.fileUpload();
  578. // this.form.init();
  579. },
  580. /*form: {
  581. init: function () {
  582. this.selectbox();
  583. this.checkbox();
  584. },
  585. selectbox: function () {
  586. // 브랜드 selectbox 선택
  587. $('#ITP_FORM_OPER02010_DETAIL_BRAND_ID').one('change', function() {
  588. if(this.selectedIndex > 0) {
  589. $('#ITP_FORM_OPER02010_DETAIL_TARGET_CD option:eq(0)').prop('selected', true);
  590. $('#ITP_FORM_OPER02010_DETAIL_TARGET_CD').prop('disabled', true).trigger('change');
  591. } else {
  592. $('#ITP_FORM_OPER02010_DETAIL_TARGET_CD').prop('disabled', false);
  593. }
  594. });
  595. // 공지대상 selectbox 선택
  596. $('#ITP_FORM_OPER02010_DETAIL_TARGET_CD').one('change', function() {
  597. if(this.selectedIndex > 0) {
  598. $('#ITP_BTN_OPER02010_DETAIL_ADDROW').prop('disabled', false);
  599. $('#ITP_BTN_OPER02010_DETAIL_DELROW').prop('disabled', false);
  600. } else {
  601. $('#ITP_BTN_OPER02010_DETAIL_ADDROW').prop('disabled', true);
  602. $('#ITP_BTN_OPER02010_DETAIL_DELROW').prop('disabled', true);
  603. $(OPER02010_DETAIL_GRID_ID).jqGrid('clearGridData');
  604. }
  605. });
  606. },
  607. checkbox: function () {
  608. // 공지대상 checkbox 선택
  609. $('#ITP_FORM_OPER02010_TARGET').find('input:checkbox').one('change', function() {
  610. $(this).next().val($(this).is(':checked') ? 'Y' : '');
  611. });
  612. }
  613. },*/
  614. button: {
  615. save: function() {
  616. const formId = '#ITP_FORM_OPER02010_DETAIL';
  617. itp_fn_form_clear_validate(null, formId);
  618. $('#ITP_FORM_OPER02010_DETAIL_TARGET_CD').attr('disabled', false);
  619. if(fn_make_user_info.get('authTpCd') === '30') {
  620. $('#ITP_FORM_OPER02010_DETAIL_TARGET_CD').val('A');
  621. }
  622. if (itp_fn_form_event.isValid(formId)) {
  623. // let gridInsertData = [];
  624. // let gridUpdateData = [];
  625. // let gridDeleteData = [];
  626. // const rowData = $(OPER02010_DETAIL_GRID_ID).getRowData();
  627. // const keyValue = $(formId + '_USER_ID').val();
  628. // $.each(rowData, function(key, value) {
  629. // if (value.viewCd != 'R') {
  630. // value.nticeNo = keyValue;
  631. // if (value.viewCd == 'C') {
  632. // gridInsertData.push(value);
  633. // } else if (value.viewCd == 'U') {
  634. // gridUpdateData.push(value);
  635. // } else if (value.viewCd == 'D') {
  636. // gridDeleteData.push(value);
  637. // }
  638. // }
  639. // });
  640. let param = $(formId).serializeObject();
  641. // param.gridInsertData = gridInsertData;
  642. // param.gridUpdateData = gridUpdateData;
  643. // param.gridDeleteData = gridDeleteData;
  644. // console.log(JSON.stringify(param));
  645. var searhFn = function() {
  646. ITP_FORM_OPER02010_DETAIL_IS_WRITING = false;
  647. listObj.grid.search();
  648. };
  649. fn_ajax_call(NTICE_SAVE_NTICE, JSON.stringify(param), searhFn, 'POST');
  650. }
  651. },
  652. cancel: function() {
  653. listObj.grid.search();
  654. }
  655. }
  656. };
  657. /*가맹점 조회 Object*/
  658. let afflShopObj = {
  659. init: function() {
  660. this.action();
  661. },
  662. button: function() {
  663. var _this = this;
  664. // 가맹점 조회 버튼 클릭
  665. $('#ITP_FORM_OPER02010_SEARCH_AFFL_SHOP_BTN').on('click', function() {
  666. _this.popup('L');
  667. });
  668. // 가맹점 텍스트 삭제 버튼 클릭
  669. $('#ITP_FORM_OPER02010_DELETE_AFFL_SHOP_BTN').on('click', function() {
  670. $('#ITP_FORM_OPER02010_SEARCH_AFFL_SHOP_ID').val('');
  671. $('#ITP_FORM_OPER02010_SEARCH_AFFL_SHOP_NM').val('');
  672. $('select#ITP_FORM_OPER02010_SEARCH_BRAND_ID option').remove();
  673. });
  674. // 신규등록 가맹점 조회 버튼 클릭
  675. $('#ITP_FORM_OPER02010_DETAIL_SEARCH_AFFL_SHOP').on('click', function() {
  676. _this.popup('C');
  677. });
  678. // 신규등록 가맹점 텍스트 삭제 버튼 클릭
  679. $('#ITP_FORM_OPER02010_DETAIL_DELETE_AFFL_SHOP').on('click', function() {
  680. $('#ITP_FORM_OPER02010_DETAIL_AFFL_SHOP_ID').val('');
  681. $('#ITP_FORM_OPER02010_DETAIL_AFFL_SHOP_NM').val('');
  682. $('select#ITP_FORM_OPER02010_DETAIL_BRAND_ID option').remove();
  683. $('#ITP_FORM_OPER02010_DETAIL_TARGET_CD option:eq(0)').prop('selected', true);
  684. // $('#ITP_FORM_OPER02010_DETAIL_TARGET_CD').trigger('change');
  685. pageObj.event.notiTarget(true);
  686. });
  687. },
  688. action: function() {
  689. this.button();
  690. },
  691. popup: function (view) {
  692. // 팝업
  693. var popFn = function(rowDataPop) {
  694. console.log(rowDataPop);
  695. var id = (view === 'C') ? 'ITP_FORM_OPER02010_DETAIL' : 'ITP_FORM_OPER02010_SEARCH';
  696. console.log(id);
  697. if(rowDataPop.AFFL_SHOP) {
  698. $('#'+ id + '_AFFL_SHOP_ID').val(rowDataPop.AFFL_SHOP.afflShopId);
  699. $('#'+ id + '_AFFL_SHOP_NM').val(rowDataPop.AFFL_SHOP.afflShopNm);
  700. if(view === 'C') pageObj.event.notiTarget(false);
  701. }
  702. if(rowDataPop.AFFL_BRAND) {
  703. fn_make_select_brand(rowDataPop.AFFL_BRAND, id + '_BRAND_ID', true, '선택');
  704. }
  705. };
  706. fn_call_popup('biz', 'BIZPOP_AFFL_SHOP', '#ITP_ASIDE', popFn, null, 'S');
  707. }
  708. };