ITP_OPER01010.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. pageObj.init();
  5. });
  6. });
  7. /********************************************************
  8. --------------------------------------------------------
  9. - Object 목록 -
  10. --------------------------------------------------------
  11. * const gridColModel = {} : 화면 Grid Object *
  12. * let pageObj = {} : 화면공통 Object *
  13. * let listObj = {} : 목록화면 Object *
  14. * let viewObj = {} : 상세화면 Object *
  15. * let modifyObj = {} : 수정화면 Object *
  16. * let createObj = {} : 신규화면 Object *
  17. * let afflShopObj = {} : 가맹점 Object *
  18. *******************************************************/
  19. /*화면 변수*/
  20. const OPER01010_GRID_ID = '#ITP_OPER01010_jqGrid';
  21. const OPER01010_GRID_LIST = '#ITP_OPER01010_jqGrid_list';
  22. const OPER01010_GRID_PAGER = '#ITP_OPER01010_jqGridPager';
  23. const OPER01010_GRID_EMPTY = '#ITP_OPER01010_jqGridEmpty';
  24. const OPER01010_VIEW_GRID_ID = '#ITP_OPER01010_VIEW_jqGrid';
  25. const OPER01010_VIEW_GRID_LIST = '#ITP_OPER01010_VIEW_jqGrid_list';
  26. const OPER01010_VIEW_GRID_PAGER = '#ITP_OPER01010_VIEW_jqGridPager';
  27. const OPER01010_VIEW_GRID_EMPTY = '#ITP_OPER01010_VIEW_jqGridEmpty';
  28. const OPER01010_DETAIL_GRID_ID = '#ITP_OPER01010_DETAIL_jqGrid';
  29. const OPER01010_DETAIL_GRID_LIST = '#ITP_OPER01010_DETAIL_jqGrid_list';
  30. const OPER01010_DETAIL_GRID_PAGER = '#ITP_OPER01010_DETAIL_jqGridPager';
  31. const OPER01010_DETAIL_GRID_EMPTY = '#ITP_OPER01010_DETAIL_jqGridEmpty';
  32. let ITP_FORM_OPER01010_DETAIL_IS_DUPLICATE = false;
  33. let ITP_FORM_OPER01010_DETAIL_IS_WRITING = false;
  34. /*API URL*/
  35. let USER_DETAIL_GRID_LIST = '/api/user/detail-grid-list';
  36. let USER_USERAUTH_GRID_LIST = '/api/user/userauth-grid-list';
  37. let USER_INFO_USER = '/api/user/info-user';
  38. let USER_SAVE_USER = '/api/user/save-user';
  39. let USER_CHECK_DUPLICATE = '/api/user/check-duplicate';
  40. let USER_INTI_USERPW = '/api/user/inti-userpw';
  41. /*화면 Grid ColModel*/
  42. const gridColModel = {
  43. list: [
  44. {
  45. index: 'AFFL_SHOP_NM', name: 'afflShopNm',
  46. label: ITP_MSG_LOCALE.label.afflShopNm, //가맹점
  47. width: '10', fixed: false, align: 'center',
  48. sortable: false, hidden: false
  49. },
  50. {
  51. index: 'BRAND_NM', name: 'brandNm',
  52. label: ITP_MSG_LOCALE.label.brandNm, //브랜드
  53. width: '13', fixed: false, align: 'center',
  54. sortable: false, hidden: false
  55. },
  56. {
  57. index: 'USER_ID', name: 'userId',
  58. label: ITP_MSG_LOCALE.label.userId, //사용자ID
  59. width: '10', fixed: false, align: 'center',
  60. sortable: false, hidden: false
  61. },
  62. {
  63. index: 'USER_NM', name: 'userNm',
  64. label: ITP_MSG_LOCALE.label.userName, //닉네임
  65. width: '13', fixed: false, align: 'center',
  66. sortable: false, hidden: false
  67. },
  68. {
  69. index: 'EMAIL', name: 'email',
  70. label: ITP_MSG_LOCALE.label.idEmail, //아이디(이메일)
  71. width: '15', fixed: false, align: 'center',
  72. sortable: false, hidden: false
  73. },
  74. {
  75. index: 'TEL_NO', name: 'telNo',
  76. label: ITP_MSG_LOCALE.label.telNo, //휴대폰 번호
  77. width: '10', fixed: false, align: 'center',
  78. sortable: false, hidden: false
  79. },
  80. {
  81. index: 'USER_STAT_NM', name: 'userStatNm',
  82. label: ITP_MSG_LOCALE.label.status, //상태
  83. width: '6', fixed: false, align: 'center',
  84. sortable: false, hidden: false
  85. },
  86. {
  87. index: 'USER_STAT_DT', name: 'userStatDt',
  88. label: ITP_MSG_LOCALE.label.statusDt, //상태일시
  89. width: '10', fixed: false, align: 'center',
  90. sortable: false, hidden: false
  91. },
  92. {
  93. index: 'ADD_DT', name: 'addDt',
  94. label: ITP_MSG_LOCALE.label.regDt, //등록일
  95. width: '10', fixed: false, align: 'center',
  96. sortable: false, hidden: false
  97. },
  98. {
  99. index: 'LAST_LOGIN_DT', name: 'lastLoginDt',
  100. label: ITP_MSG_LOCALE.label.lastLogin, //마지막 로그인
  101. width: '10', fixed: false, align: 'center',
  102. sortable: false, hidden: false
  103. }
  104. ],
  105. detail: [
  106. {
  107. index: 'VIEW_CD', name: 'viewCd',
  108. label: ITP_MSG_LOCALE.label.viewCd,
  109. width: '10', fixed: false, align: 'center',
  110. sortable: false, hidden: true
  111. },
  112. {
  113. index: 'AUTH_NO', name: 'authNo',
  114. label: ITP_MSG_LOCALE.label.permitCd,
  115. width: '20', fixed: false, align: 'center',
  116. sortable: false, editable: false, edittype: 'text',
  117. editrules: {required: true}
  118. },
  119. {
  120. index: 'AUTH_NM', name: 'authNm',
  121. label: ITP_MSG_LOCALE.label.permitName,
  122. width: '30', fixed: false, align: 'center',
  123. sortable: true, editable: false, edittype: 'text',
  124. editrules: {required: true}
  125. },
  126. {
  127. index: 'USE_YN_NM', name: 'useYnNm',
  128. label: ITP_MSG_LOCALE.label.status,
  129. width: '10', fixed: false, align: 'center',
  130. sortable: false, editable: false, edittype: 'text'
  131. },
  132. {
  133. index: 'ADD_DT', name: 'addDt',
  134. label: ITP_MSG_LOCALE.label.regDt,
  135. width: '10', fixed: false, align: 'center',
  136. sortable: false, editable: false, edittype: 'text'
  137. }
  138. ]
  139. };
  140. /*화면공통 Object*/
  141. let pageObj = {
  142. init: function () {
  143. this.ui.init();
  144. this.event.init();
  145. afflShopObj.init();
  146. },
  147. ui: {
  148. init: function () {
  149. this.view();
  150. this.grid();
  151. this.ready();
  152. },
  153. view: function() {
  154. // 버튼 권한설정
  155. fn_proc_btn_auth('OPER01010');
  156. // 공통코드 표시
  157. $('select').each(function() {
  158. if($(this).data('select-code')) {
  159. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  160. }
  161. });
  162. // 조회일자 지정
  163. $('#ITP_TAB_OPER01010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  164. },
  165. grid: function() {
  166. itp_fn_jqgrid_resize(OPER01010_GRID_ID, OPER01010_GRID_LIST, 'lg');
  167. listObj.empty.init();
  168. itp_fn_fire_window_resize();
  169. },
  170. ready: function() {
  171. listObj.init();
  172. }
  173. },
  174. event: {
  175. init: function () {
  176. this.button();
  177. },
  178. button: function () {
  179. // 버튼 클릭 이벤트
  180. $('button').each(function() {
  181. var id = $(this).attr('id');
  182. $(this).on('click', function() {
  183. switch (id) {
  184. case 'ITP_BTN_OPER01010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  185. case 'ITP_BTN_OPER01010_NEWREG' : listObj.button.create(); break; // 신규등록 버튼
  186. case 'ITP_BTN_OPER01010_MODIFY' : modifyObj.button.modify(); break; // 수정 버튼
  187. case 'ITP_BTN_OPER01010_CANCELLIST' : createObj.button.cancel(); break; // 취소/목록 버튼
  188. case 'ITP_BTN_OPER01010_DELETE' : break; // 삭제 버튼
  189. case 'ITP_BTN_OPER01010_SAVE' : createObj.button.save(); break; // 저장 버튼
  190. case 'ITP_FORM_OPER01010_DETAIL_DUP' : createObj.button.duplicate(); break; // 중복체크
  191. case 'ITP_BTN_OPER01010_RESET_PW' : createObj.button.resetPass(); break; // 상세:비밀번호 초기화
  192. case 'ITP_BTN_OPER01010_DETAIL_ADDROW' : pageObj.grid.button.addRow(); break; // 상세:추가버튼
  193. case 'ITP_BTN_OPER01010_DETAIL_DELROW' : pageObj.grid.button.delRow(); break; // 상세:삭제버튼
  194. }
  195. });
  196. });
  197. $('body').on('click', function(e) {
  198. var gridId = OPER01010_DETAIL_GRID_ID.replace('#', '');
  199. var rids = $(OPER01010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  200. var last_row_id = rids[rids.length - 1];
  201. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'OPER01010_DETAIL');
  202. });
  203. }
  204. },
  205. switchScreen: function(mode) {
  206. $('.itp_det_head').find('button[id^="ITP_BTN_OPER01010_"]').each(function(i) {
  207. $(this).hide();
  208. });
  209. $('div[id$="_CONTAINER"]').each(function(i) {
  210. if($(this).attr('id').startsWith('ITP_AJAX_OPER01010')) {
  211. $(this).hide();
  212. }
  213. });
  214. if(mode === 'LIST') { // 목록
  215. $('#ITP_AJAX_OPER01010_LIST_CONTAINER').show();
  216. fn_show_btn_auth_array(['#ITP_BTN_OPER01010_SRH', '#ITP_BTN_OPER01010_NEWREG']);
  217. } else if(mode == 'ADD') { // 등록
  218. $('#ITP_AJAX_OPER01010_DETAIL_CONTAINER').show();
  219. fn_show_btn_auth_array(['#ITP_BTN_OPER01010_CANCELLIST', '#ITP_BTN_OPER01010_SAVE']);
  220. $('#ITP_FORM_OPER01010_DETAIL').find('input, textarea, select, checkbox').each(function(i, elem) {
  221. $(this).attr('id') === 'ITP_FORM_OPER01010_DETAIL_VIEW_CD' ? $(this).val('C') : $(this).val('');
  222. if(elem.type === 'select') {
  223. $(this).val('').prop('selected', true);
  224. }
  225. });
  226. $('#ITP_FORM_OPER01010_DETAIL_USER_ID').removeAttr('readonly');
  227. $('#ITP_FORM_OPER01010_DETAIL_DUP').removeAttr('disabled');
  228. $('#ITP_FORM_OPER01010_DETAIL_SEARCH_BRAND_ID option').remove();
  229. $('#ITP_FORM_OPER01010_DETAIL_SEARCH_AFFL_SHOP').show();
  230. $('#ITP_FORM_OPER01010_DETAIL_DELETE_AFFL_SHOP').show();
  231. } else if(mode === 'MODIFY') { // 수정
  232. $('#ITP_AJAX_OPER01010_DETAIL_CONTAINER').show();
  233. fn_show_btn_auth_array(['#ITP_BTN_OPER01010_CANCELLIST', '#ITP_BTN_OPER01010_SAVE', '#ITP_BTN_OPER01010_RESET_PW']);
  234. $('#ITP_FORM_OPER01010_DETAIL_USER_ID').attr('readonly', true);
  235. $('#ITP_FORM_OPER01010_DETAIL_DUP').attr('disabled', true);
  236. $('#ITP_FORM_OPER01010_DETAIL_SEARCH_AFFL_SHOP_NM').attr('readonly', true);
  237. $('#ITP_FORM_OPER01010_DETAIL_USER_NM').attr('readonly', true);
  238. $('#ITP_FORM_OPER01010_DETAIL_SEARCH_AFFL_SHOP').hide();
  239. $('#ITP_FORM_OPER01010_DETAIL_DELETE_AFFL_SHOP').hide();
  240. } else if(mode === 'VIEW') { // 보기
  241. $('#ITP_AJAX_OPER01010_VIEW_CONTAINER').show();
  242. fn_show_btn_auth_array(['#ITP_BTN_OPER01010_MODIFY', '#ITP_BTN_OPER01010_CANCELLIST']);
  243. }
  244. },
  245. grid: {
  246. init: function(mode) {
  247. this.mode = mode;
  248. this.gridId = (mode === 'VIEW') ? OPER01010_VIEW_GRID_ID : OPER01010_DETAIL_GRID_ID;
  249. this.unload();
  250. this.load(mode);
  251. },
  252. mode: 'DETAIL',
  253. gridId: '',
  254. button: {
  255. addRow: function() {
  256. // 팝업
  257. var popFn = function(rowDataPop) {
  258. // 기존등록 데이터
  259. var exists = '';
  260. const rowData = $(OPER01010_DETAIL_GRID_ID).getRowData();
  261. $.each(rowData, function(key, value) {
  262. exists = exists + value.authNo + ';';
  263. });
  264. $.each(rowDataPop, function(key, value) {
  265. if(exists.indexOf(value.authNo) < 0) {
  266. value['viewCd'] = (pageObj.grid.mode === 'MODIFY') ? 'U' : "C";
  267. $(OPER01010_DETAIL_GRID_ID).jqGrid('addRowData', value.authNo, value, 'last');
  268. }
  269. });
  270. $(OPER01010_DETAIL_GRID_EMPTY).hide();
  271. };
  272. fn_call_popup('comm', 'AUTH_SCH_POPUP', '#ITP_ASIDE', popFn, null, 'S');
  273. },
  274. delRow: function() {
  275. itp_fn_grid_del_row(OPER01010_DETAIL_GRID_ID);
  276. }
  277. },
  278. load: function() {
  279. let gridView = (this.mode === 'VIEW') ? 'OPER01010_VIEW' : 'OPER01010_DETAIL';
  280. let param = $('#ITP_FORM_' + gridView).serializeObject();
  281. param.gridSize = $.jgrid.defaults.rowNum;
  282. param.pagingYn = false; // 페이징안함
  283. var _this = this;
  284. var option = {
  285. gridId: _this.gridId,
  286. colModel: gridColModel.detail,
  287. param: JSON.stringify(param),
  288. url: DOMAIN + USER_USERAUTH_GRID_LIST,
  289. multiselect: (this.mode !== 'VIEW'),
  290. loadComplete: function(data) {
  291. itp_fn_grid_load_complete(data, _this.gridId, true, undefined, gridView);
  292. },
  293. onSortCol: function(index, columnIndex, sortOrder) {
  294. var sortingFn = {
  295. callBack: function(args) {
  296. $(args).trigger('reloadGrid');
  297. }
  298. };
  299. if (itp_fn_check_grid_is_writing(_this.gridId)) {
  300. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, sortingFn, _this.gridId);
  301. return 'stop';
  302. } else {
  303. itp_fn_grid_sorting(_this.gridId, index, sortOrder);
  304. }
  305. }
  306. };
  307. itp_fn_grid_make_not_paging(option);
  308. },
  309. unload : function() {
  310. $.jgrid.gridUnload(this.gridId);
  311. }
  312. }
  313. };
  314. /*목록화면 Object*/
  315. let listObj = {
  316. init: function () {
  317. this.grid.init();
  318. },
  319. itp_OPER01010_search: false,
  320. button: {
  321. search: function() {
  322. listObj.itp_OPER01010_search = true;
  323. let param = $('#ITP_FORM_OPER01010_SEARCH').serializeObject();
  324. param.gridSize = $.jgrid.defaults.rowNum;
  325. param.gridPage = $.jgrid.defaults.page;
  326. $(OPER01010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  327. },
  328. create: function() {
  329. pageObj.switchScreen('ADD');
  330. itp_fn_form_clear_validate(null, '#ITP_FORM_OPER01010_DETAIL');
  331. // 권한정보 리스트 조회
  332. createObj.init();
  333. }
  334. },
  335. empty: {
  336. init: function() {
  337. var _this = this;
  338. this.push();
  339. $(OPER01010_GRID_EMPTY).on('click', function() {
  340. _this.back();
  341. _this.itp_OPER01010_param.gridSize = $.jgrid.defaults.rowNum;
  342. $(OPER01010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_OPER01010_param)}).trigger('reloadGrid');
  343. });
  344. },
  345. itp_OPER01010_param: {},
  346. push: function() {
  347. let param = $('#ITP_FORM_OPER01010_SEARCH').serializeObject();
  348. listObj.itp_OPER01010_param = param;
  349. },
  350. back: function() {
  351. $('#ITP_FORM_OPER01010_DEVI_TP_CD').val(this.itp_OPER01010_param.deviTpCd);
  352. $('#ITP_FORM_OPER01010_ORDER_YN').val(this.itp_OPER01010_param.orderYn);
  353. $('#ITP_FORM_OPER01010_ADT_AUTH_CD').val(this.itp_OPER01010_param.adtAuthCd);
  354. $('#ITP_FORM_OPER01010_EMAIL_RCV_YN').val(this.itp_OPER01010_param.emailRcvYn);
  355. $('#ITP_FORM_OPER01010_MEMB_EXIT_DT').val(this.itp_OPER01010_param.membExitDt);
  356. $('#ITP_FORM_OPER01010_FROM_DT').val(this.itp_OPER01010_param.fromDt);
  357. $('#ITP_FORM_OPER01010_TO_DT').val(this.itp_OPER01010_param.toDt);
  358. $('#ITP_FORM_OPER01010_KEYWORD').val(this.itp_OPER01010_param.keyword);
  359. }
  360. },
  361. grid: {
  362. init: function () {
  363. // 데이터 없을때
  364. listObj.empty.push();
  365. this.search();
  366. },
  367. colModel: gridColModel.list,
  368. search: function() {
  369. pageObj.switchScreen('LIST');
  370. this.unload();
  371. this.load();
  372. },
  373. load: function() {
  374. let param = $('#ITP_FORM_OPER01010_SEARCH').serializeObject();
  375. param.gridSize = $.jgrid.defaults.rowNum;
  376. var option = {
  377. gridId: OPER01010_GRID_ID,
  378. colModel: gridColModel.list,
  379. param: JSON.stringify(param),
  380. url: DOMAIN + USER_DETAIL_GRID_LIST,
  381. pager: OPER01010_GRID_PAGER,
  382. onCellSelect: function(rowId, cellIdx, cellValue) {
  383. var cm = $(this).jqGrid('getGridParam', 'colModel');
  384. var colNm = cm[cellIdx].name;
  385. if (colNm == 'userNm') {
  386. const userIdVal = $(this).jqGrid('getCell', rowId, 'userId');
  387. const key = {userId: userIdVal, viewCd: 'R'};
  388. var param = $.param(key);
  389. viewObj.init(param);
  390. }
  391. },
  392. loadComplete: function(data) {
  393. console.log(data);
  394. itp_fn_grid_load_complete(data, OPER01010_GRID_ID, true, 'number', 'OPER01010', listObj.itp_OPER01010_search, listObj.empty, true, data.gridRecords, true);
  395. var ids = $(OPER01010_GRID_ID).getDataIDs();
  396. $.each(ids, function(idx, rowId) {
  397. $(OPER01010_GRID_ID).jqGrid('setCell', rowId, 'userNm', '', ITP_GRID_COL_STYLE.link);
  398. });
  399. },
  400. onPaging: function(action) {
  401. itp_fn_grid_paging(OPER01010_GRID_ID, action, param);
  402. }
  403. };
  404. itp_fn_grid_make_remote(option);
  405. },
  406. clearData : function() {
  407. $(OPER01010_GRID_ID).jqGrid('clearGridData', true);
  408. $(OPER01010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  409. $(OPER01010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  410. $(OPER01010_GRID_EMPTY).show();
  411. },
  412. unload : function() {
  413. $.jgrid.gridUnload(OPER01010_GRID_ID);
  414. }
  415. }
  416. };
  417. /*상세화면 Object*/
  418. let viewObj = {
  419. init: function (param) {
  420. this.load(param);
  421. },
  422. load: function(param) {
  423. fn_ajax_call(USER_INFO_USER, param, this.callback, 'GET');
  424. },
  425. callback: function (result) {
  426. console.log(result);
  427. pageObj.switchScreen('VIEW');
  428. $('#ITP_FORM_OPER01010_VIEW #ITP_FORM_OPER01010_VIEW_USER_ID').val(result.userId);
  429. $('#ITP_FORM_OPER01010_VIEW .fnAfflShopNm').text(result.afflShopNm);
  430. $('#ITP_FORM_OPER01010_VIEW .fnBrandNm').text(result.brandNm);
  431. $('#ITP_FORM_OPER01010_VIEW .fnUserNm').text(result.userNm);
  432. $('#ITP_FORM_OPER01010_VIEW .fnUserStatDt').text(result.userStatDt);
  433. $('#ITP_FORM_OPER01010_VIEW .fnUserStatNm').text(result.userStatNm);
  434. $('#ITP_FORM_OPER01010_VIEW .fnUserId').text(result.userId);
  435. $('#ITP_FORM_OPER01010_VIEW .fnEmail').text(result.email);
  436. $('#ITP_FORM_OPER01010_VIEW .fnTelNo').text(result.telNo);
  437. $('#ITP_FORM_OPER01010_VIEW .fnAddDt').text(result.addDt);
  438. $('#ITP_FORM_OPER01010_VIEW .fnLastLoginDt').text(result.lastLoginDt);
  439. // 권한정보 리스트 조회
  440. pageObj.grid.init('VIEW');
  441. // viewObj.grid.load(result.spplyMgrList);
  442. }
  443. };
  444. /*수정화면 Object*/
  445. let modifyObj = {
  446. init: function () {
  447. },
  448. button: {
  449. modify: function (param) {
  450. itp_fn_form_clear_validate(null, '#ITP_FORM_OPER01010_DETAIL');
  451. const userIdVal = $('#ITP_FORM_OPER01010_VIEW_USER_ID').val();
  452. const key = {userId: userIdVal, viewCd: 'R'};
  453. var param = $.param(key);
  454. modifyObj.load(param);
  455. }
  456. },
  457. load: function(param) {
  458. fn_ajax_call(USER_INFO_USER, param, this.callback, 'GET');
  459. },
  460. callback: function (result) {
  461. // console.log(result);
  462. pageObj.switchScreen('MODIFY');
  463. $('#ITP_FORM_OPER01010_DETAIL #ITP_FORM_OPER01010_DETAIL_VIEW_CD').val('U');
  464. $('#ITP_FORM_OPER01010_DETAIL #ITP_FORM_OPER01010_DETAIL_SEARCH_AFFL_SHOP_ID').val(result.afflShopId);
  465. $('#ITP_FORM_OPER01010_DETAIL #ITP_FORM_OPER01010_DETAIL_SEARCH_AFFL_SHOP_NM').val(result.afflShopNm);
  466. var brandId = result.brandId;
  467. var brandNm = result.brandNm;
  468. if(brandId !== '' && brandNm !== '') {
  469. var brandList = [{'brandId':brandId, 'brandNm':brandNm}];
  470. fn_make_select_brand(brandList, 'ITP_FORM_OPER01010_DETAIL_SEARCH_BRAND_ID');
  471. }
  472. $('#ITP_FORM_OPER01010_DETAIL #ITP_FORM_OPER01010_DETAIL_USER_NM').val(result.userNm);
  473. $('#ITP_FORM_OPER01010_DETAIL #ITP_FORM_OPER01010_DETAIL_USER_STAT_CD').val(result.userStatCd);
  474. $('#ITP_FORM_OPER01010_DETAIL #ITP_FORM_OPER01010_DETAIL_USER_ID').val(result.userId);
  475. $('#ITP_FORM_OPER01010_DETAIL .fnUserStatDt').text(result.userStatDt);
  476. $('#ITP_FORM_OPER01010_DETAIL #ITP_FORM_OPER01010_DETAIL_USER_PW').val(result.userPw);
  477. $('#ITP_FORM_OPER01010_DETAIL #ITP_FORM_OPER01010_DETAIL_USER_PW_CONFIRM').val(result.userPw);
  478. $('#ITP_FORM_OPER01010_DETAIL #ITP_FORM_OPER01010_DETAIL_TEL_NO').val(result.telNo);
  479. $('#ITP_FORM_OPER01010_DETAIL #ITP_FORM_OPER01010_DETAIL_EMAIL').val(result.email);
  480. $('#ITP_FORM_OPER01010_DETAIL .fnAddDt').text(result.addDt);
  481. $('#ITP_FORM_OPER01010_DETAIL .fnLastLoginDt').text(result.lastLoginDt);
  482. // 권한정보 리스트 조회
  483. pageObj.grid.init('DETAIL');
  484. }
  485. };
  486. /*신규화면 Object*/
  487. let createObj = {
  488. init: function () {
  489. pageObj.grid.init('DETAIL');
  490. },
  491. button: {
  492. cancel: function() {
  493. listObj.grid.search();
  494. },
  495. save: function() {
  496. const formId = '#ITP_FORM_OPER01010_DETAIL';
  497. itp_fn_form_clear_validate(null, formId);
  498. var vali_userId = itp_fn_form_validate(formId, formId + '_USER_ID', ['empty'], undefined);
  499. var vali_userStatCd = itp_fn_form_validate(formId, formId + '_USER_STAT_CD', ['empty'], undefined);
  500. var vali_userNm = itp_fn_form_validate(formId, formId + '_USER_NM', ['empty'], undefined);
  501. var vali_telNo = itp_fn_form_validate(formId, formId + '_TEL_NO', ['empty'], undefined);
  502. var vali_email = itp_fn_form_validate(formId, formId + '_EMAIL', ['empty'], undefined);
  503. var vali_userPw = true;
  504. var vali_userPwConfirm = true;
  505. if($('#ITP_FORM_OPER01010_DETAIL_VIEW_CD').val() == 'C') { // 신규
  506. vali_userPw = itp_fn_form_validate(formId, formId + '_USER_PW', ['empty'], undefined);
  507. vali_userPwConfirm = itp_fn_form_validate(formId, formId + '_USER_PW_CONFIRM', ['empty'], undefined);
  508. }
  509. if (vali_userId && vali_userStatCd && vali_userNm && vali_userPw && vali_userPwConfirm && vali_telNo && vali_email) {
  510. if (ITP_FORM_OPER01010_DETAIL_IS_DUPLICATE) {
  511. itp_fn_modal_duplicate(ITP_MSG_LOCALE.label.userId, formId + '_USER_ID');
  512. } else {
  513. let gridInsertData = [];
  514. let gridUpdateData = [];
  515. let gridDeleteData = [];
  516. const rowData = $(OPER01010_DETAIL_GRID_ID).getRowData();
  517. const keyValue = $(formId + '_USER_ID').val();
  518. $.each(rowData, function(key, value) {
  519. if (value.viewCd != 'R') {
  520. value.userId = keyValue;
  521. if (value.viewCd == 'C') {
  522. gridInsertData.push(value);
  523. } else if (value.viewCd == 'U') {
  524. gridUpdateData.push(value);
  525. } else if (value.viewCd == 'D') {
  526. gridDeleteData.push(value);
  527. }
  528. }
  529. });
  530. let param = $(formId).serializeObject();
  531. param.gridInsertData = gridInsertData;
  532. param.gridUpdateData = gridUpdateData;
  533. param.gridDeleteData = gridDeleteData;
  534. //console.log(JSON.stringify(param));
  535. var searhFn = function() {
  536. ITP_FORM_OPER01010_DETAIL_IS_WRITING = false;
  537. listObj.grid.search();
  538. };
  539. fn_ajax_call(USER_SAVE_USER, JSON.stringify(param), searhFn, 'POST');
  540. }
  541. }
  542. },
  543. duplicate: function() {
  544. const formId = '#ITP_FORM_OPER01010_DETAIL';
  545. itp_fn_form_clear_validate(null, formId + '_DETAIL');
  546. var vali_userId = itp_fn_form_validate(formId + '_DETAIL', formId + '_USER_ID', ['empty'], undefined);
  547. if (vali_userId) {
  548. var dupFn = function(result) {
  549. if (result.code == 'N') {
  550. ITP_FORM_OPER01010_DETAIL_IS_DUPLICATE = false;
  551. } else {
  552. ITP_FORM_OPER01010_DETAIL_IS_DUPLICATE = true;
  553. }
  554. };
  555. const key = {'userId': $(formId + '_USER_ID').val()};
  556. const param = $.param(key);
  557. fn_ajax_call(USER_CHECK_DUPLICATE, param, dupFn, 'GET');
  558. }
  559. },
  560. resetPass: function() {
  561. var resetPwFn = {
  562. callBack: function(args) {
  563. const key = {'userId': $('#ITP_FORM_OPER01010_DETAIL_USER_ID').val()};
  564. const param = $.param(key);
  565. fn_ajax_call(USER_INTI_USERPW, param, undefined, 'GET');
  566. }
  567. };
  568. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.askResetUserPw, resetPwFn, null);
  569. }
  570. }
  571. };
  572. /*가맹점 Object*/
  573. let afflShopObj = {
  574. init: function () {
  575. // (LOGIN_USER_INFO.authTpCd === '10' || LOGIN_USER_INFO.authTpCd === '20') ? this.action() : this.make();
  576. this.action();
  577. },
  578. make: function() {
  579. $('#ITP_FORM_OPER01010_SEARCH_AFFL_SHOP').hide();
  580. $('#ITP_FORM_OPER01010_DELETE_AFFL_SHOP').hide();
  581. if(AFFL_SHOP_LIST) {
  582. $('#ITP_FORM_OPER01010_SEARCH_AFFL_SHOP_ID').val(LOGIN_USER_INFO.afflShopId);
  583. $('#ITP_FORM_OPER01010_SEARCH_AFFL_SHOP_NM').val(LOGIN_USER_INFO.afflShopNm);
  584. }
  585. if(LOGIN_USER_INFO.brandId !== '') {
  586. fn_make_select_brand(AFFL_BRAND_LIST, 'ITP_FORM_OPER01010_SEARCH_BRAND_ID');
  587. }
  588. },
  589. action: function () {
  590. var _this = this;
  591. // 가맹점 조회 버튼 클릭
  592. $('#ITP_FORM_OPER01010_SEARCH_AFFL_SHOP').on('click', function() {
  593. _this.popup('L');
  594. });
  595. // 가맹점 텍스트 삭제 버튼 클릭
  596. $('#ITP_FORM_OPER01010_DELETE_AFFL_SHOP').on('click', function() {
  597. $('#ITP_FORM_OPER01010_SEARCH_AFFL_SHOP_NM').val('');
  598. $('select#ITP_FORM_OPER01010_SEARCH_BRAND_ID option').remove();
  599. });
  600. // 신규등록 가맹점 조회 버튼 클릭
  601. $('#ITP_FORM_OPER01010_DETAIL_SEARCH_AFFL_SHOP').on('click', function() {
  602. _this.popup('C');
  603. });
  604. // 신규등록 가맹점 텍스트 삭제 버튼 클릭
  605. $('#ITP_FORM_OPER01010_DETAIL_DELETE_AFFL_SHOP').on('click', function() {
  606. $('#ITP_FORM_OPER01010_DETAIL_SEARCH_AFFL_SHOP_NM').val('');
  607. $('select#ITP_FORM_OPER01010_DETAIL_SEARCH_BRAND_ID option').remove();
  608. });
  609. },
  610. popup: function (view) {
  611. // 팝업
  612. var popFn = (view === 'C') ? this.callback.create : this.callback.list;
  613. fn_call_popup('biz', 'BIZPOP_AFFL_SHOP', '#ITP_ASIDE', popFn, null, 'S');
  614. },
  615. callback: {
  616. list: function(rowDataPop) {
  617. // console.log(rowDataPop);
  618. if(rowDataPop.AFFL_SHOP) {
  619. $('#ITP_FORM_OPER01010_SEARCH_AFFL_SHOP_ID').val(rowDataPop.AFFL_SHOP.afflShopId);
  620. $('#ITP_FORM_OPER01010_SEARCH_AFFL_SHOP_NM').val(rowDataPop.AFFL_SHOP.afflShopNm);
  621. }
  622. if(rowDataPop.AFFL_BRAND) {
  623. fn_make_select_brand(rowDataPop.AFFL_BRAND, 'ITP_FORM_OPER01010_SEARCH_BRAND_ID', true, '선택');
  624. }
  625. },
  626. create: function(rowDataPop) {
  627. // console.log(rowDataPop);
  628. if(rowDataPop.AFFL_SHOP) {
  629. $('#ITP_FORM_OPER01010_DETAIL_SEARCH_AFFL_SHOP_ID').val(rowDataPop.AFFL_SHOP.afflShopId);
  630. $('#ITP_FORM_OPER01010_DETAIL_SEARCH_AFFL_SHOP_NM').val(rowDataPop.AFFL_SHOP.afflShopNm);
  631. }
  632. if(rowDataPop.AFFL_BRAND) {
  633. fn_make_select_brand(rowDataPop.AFFL_BRAND, 'ITP_FORM_OPER01010_DETAIL_SEARCH_BRAND_ID', true, '선택');
  634. }
  635. }
  636. }
  637. };