ITP_OPER02010.js 27 KB

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