ITP_STOCKMNG02010.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. /********************************************************
  2. --------------------------------------------------------
  3. - Object 목록 -
  4. --------------------------------------------------------
  5. * const gridColModel = {} : 화면 Grid Object *
  6. * let pageObj = {} : 화면공통 Object *
  7. * let listObj = {} : 목록화면 Object *
  8. * let viewObj = {} : 상세화면 Object *
  9. * let stockCddObj = {} : 재고실사 Object *
  10. *******************************************************/
  11. /*화면 변수*/
  12. const STOCKMNG02010_GRID_ID = '#ITP_STOCKMNG02010_jqGrid';
  13. const STOCKMNG02010_GRID_LIST = '#ITP_STOCKMNG02010_jqGrid_list';
  14. const STOCKMNG02010_GRID_PAGER = '#ITP_STOCKMNG02010_jqGridPager';
  15. const STOCKMNG02010_GRID_EMPTY = '#ITP_STOCKMNG02010_jqGridEmpty';
  16. const STOCKMNG02010_VIEW_GRID_ID = '#ITP_STOCKMNG02010_VIEW_jqGrid';
  17. const STOCKMNG02010_VIEW_GRID_LIST = '#ITP_STOCKMNG02010_VIEW_jqGrid_list';
  18. const STOCKMNG02010_VIEW_GRID_PAGER = '#ITP_STOCKMNG02010_VIEW_jqGridPager';
  19. const STOCKMNG02010_VIEW_GRID_EMPTY = '#ITP_STOCKMNG02010_VIEW_jqGridEmpty';
  20. const STOCKMNG02010_DETAIL_GRID_ID = '#ITP_STOCKMNG02010_DETAIL_jqGrid';
  21. const STOCKMNG02010_DETAIL_GRID_LIST = '#ITP_STOCKMNG02010_DETAIL_jqGrid_list';
  22. const STOCKMNG02010_DETAIL_GRID_PAGER = '#ITP_STOCKMNG02010_DETAIL_jqGridPager';
  23. const STOCKMNG02010_DETAIL_GRID_EMPTY = '#ITP_STOCKMNG02010_DETAIL_jqGridEmpty';
  24. let ITP_FORM_STOCKMNG02010_DETAIL_IS_DUPLICATE = false;
  25. let ITP_FORM_STOCKMNG02010_DETAIL_IS_WRITING = false;
  26. let STOCKMNG02010_DETAIL_GRID_LAST_ROW_ID;
  27. /* 공통코드 리스트 */
  28. // let ITP_COMMON_CD_STCK_DVSN = fn_make_common_cd_list(CODE_LIST, 'STCK_DVSN', true);
  29. // let ITP_COMMON_CD_LOC_ST_CD = fn_make_common_cd_list(CODE_LIST, 'LOC_ST_CD', true);
  30. /*API URL*/
  31. let WHS_MNG_INFO_WHS = '/api/whs/mng/info-whs';
  32. let WHS_MNG_ADD_WHS = '/api/whs/mng/add-whs';
  33. let WHS_MNG_MIDIFY_WHS = '/api/whs/mng/modify-whs';
  34. let WHS_MNG_REMOVE_WHS = '/api/whs/mng/remove-whs';
  35. let STOCK_CDD_DETAIL_GRID_LIST = '/api/stock/cdd/detail-grid-list';
  36. let WHS_MNG_DETAIL_GRID_LIST = '/api/whs/mng/detail-grid-list';
  37. let WHS_MNG_LOCATION_GRID_LIST = '/api/whs/mng/location-grid-list';
  38. /*화면 Grid ColModel*/
  39. const gridColModel = {
  40. list: [
  41. {
  42. index: 'BRAND_ID', name: 'brandId',
  43. label: "브랜드ID",
  44. width: '0', fixed: false, align: 'center',
  45. sortable: false, hidden: true
  46. },
  47. {
  48. index: 'STORE_ID', name: 'storeId',
  49. label: "매장ID",
  50. width: '0', fixed: false, align: 'center',
  51. sortable: false, hidden: true
  52. },
  53. {
  54. index: 'BRAND_NM', name: 'brandNm',
  55. label: ITP_MSG_LOCALE.label.brandNm, //브랜드
  56. width: '10', fixed: false, align: 'center',
  57. sortable: false, hidden: false
  58. },
  59. {
  60. index: 'STORE_NM', name: 'storeNm',
  61. label: "매장명",
  62. width: '10', fixed: false, align: 'center',
  63. sortable: false, hidden: false
  64. },
  65. {
  66. index: 'WHS_ID', name: 'whsId',
  67. label: "창고번호",
  68. width: '8', fixed: false, align: 'center',
  69. sortable: false, hidden: false
  70. },
  71. {
  72. index: 'WHS_NM', name: 'whsNm',
  73. label: "창고명",
  74. width: '10', fixed: false, align: 'center',
  75. sortable: false, hidden: false
  76. },
  77. {
  78. index: 'LOCATION_NM', name: 'locationNm',
  79. label: "Location",
  80. width: '10', fixed: false, align: 'center',
  81. sortable: false, hidden: false
  82. },
  83. {
  84. index: 'CDD_MGR_NM', name: 'cddMgrNm',
  85. label: "실사담당자",
  86. width: '8', fixed: false, align: 'center',
  87. sortable: false, hidden: false
  88. },
  89. {
  90. index: 'CDD_DT', name: 'cddDt',
  91. label: "실사일자",
  92. width: '8', fixed: false, align: 'center',
  93. sortable: false, hidden: false
  94. },
  95. {
  96. index: 'CDD_TM', name: 'cddTm',
  97. label: "실사시각",
  98. width: '8', fixed: false, align: 'center',
  99. sortable: false, hidden: false
  100. },
  101. {
  102. index: 'CDD_DVSN_NM', name: 'cddDvsnNm',
  103. label: "실사구분",
  104. width: '10', fixed: false, align: 'center',
  105. sortable: false, hidden: false
  106. }
  107. ],
  108. view: [
  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: 'LOCATION', name: 'location',
  117. label: "로케이션",
  118. width: '10', fixed: false, align: 'center',
  119. sortable: false, editable: false, edittype: 'text',
  120. editrules: {required: true}
  121. },
  122. {
  123. index: 'LOCATION_NM', name: 'locationNm',
  124. label: "로케이션명",
  125. width: '12', fixed: false, align: 'center',
  126. sortable: true, editable: false, edittype: 'text',
  127. editrules: {required: true}
  128. },
  129. {
  130. index: 'STCK_DVSN_NM', name: 'stckDvsnNm',
  131. label: "관리등록",
  132. width: '10', fixed: false, align: 'center',
  133. sortable: false, editable: false, edittype: 'text'
  134. },
  135. {
  136. index: 'LOC_ST_NM', name: 'locStNm',
  137. label: "상태",
  138. width: '10', fixed: false, align: 'center',
  139. sortable: false, editable: false, edittype: 'text'
  140. }
  141. ],
  142. detail: [
  143. {
  144. index: 'VIEW_CD', name: 'viewCd',
  145. label: ITP_MSG_LOCALE.label.viewCd,
  146. width: '10', fixed: false, align: 'center',
  147. sortable: false, hidden: true
  148. },
  149. {
  150. index: 'BRAND_NM', name: 'brandNm',
  151. label: "브랜드",
  152. width: '10', fixed: false, align: 'center',
  153. sortable: false, editable: false, edittype: 'text',
  154. editrules: {required: false}
  155. },
  156. {
  157. index: 'WHS_ID', name: 'whsId',
  158. label: "창고번호",
  159. width: '10', fixed: false, align: 'center',
  160. sortable: false, editable: false, edittype: 'text',
  161. editrules: {required: false}
  162. },
  163. {
  164. index: 'WHS_NM', name: 'whsNm',
  165. label: "창고명",
  166. width: '10', fixed: false, align: 'center',
  167. sortable: false, editable: false, edittype: 'text',
  168. editrules: {required: false}
  169. },
  170. {
  171. index: 'LOCATION_NM', name: 'locationNm',
  172. label: "Location",
  173. width: '10', fixed: false, align: 'center',
  174. sortable: false, editable: false, edittype: 'text',
  175. editrules: {required: false}
  176. },
  177. {
  178. index: 'ITEM_ID', name: 'itemId',
  179. label: "품목번호",
  180. width: '12', fixed: false, align: 'center',
  181. sortable: false, editable: false, edittype: 'text',
  182. editrules: {required: false}
  183. },
  184. {
  185. index: 'ITEM_NM', name: 'itemNm',
  186. label: "품목명",
  187. width: '10', fixed: false, align: 'center',
  188. sortable: false, editable: false, edittype: 'text',
  189. editrules: {required: false}
  190. },
  191. {
  192. index: 'UNIT', name: 'unit',
  193. label: "단위",
  194. width: '8', fixed: false, align: 'center',
  195. sortable: false, editable: false, edittype: 'text',
  196. editrules: {required: false}
  197. },
  198. {
  199. index: 'STCK_QTY', name: 'stckQty',
  200. label: "현재고수량",
  201. width: '8', fixed: false, align: 'center',
  202. sortable: false, editable: false, edittype: 'text',
  203. editrules: {required: false}
  204. },
  205. {
  206. index: 'CDD_QTY', name: 'cddQty',
  207. label: "실사수량",
  208. width: '10', fixed: false, align: 'center',
  209. sortable: false, editable: true, edittype: 'text',
  210. editrules: {required: true}
  211. }
  212. ]
  213. };
  214. require(['config'], function() {
  215. require([
  216. ], function($) {
  217. pageObj.init();
  218. });
  219. });
  220. /*화면공통 Object*/
  221. let pageObj = {
  222. init: function () {
  223. this.ui.init();
  224. this.event.init();
  225. },
  226. ui: {
  227. init: function () {
  228. this.view();
  229. this.grid();
  230. this.ready();
  231. },
  232. view: function() {
  233. // 버튼 권한설정
  234. fn_proc_btn_auth('STOCKMNG02010');
  235. // 브랜드ID 지정
  236. var data = JSON.parse(sessionStorage.getItem('itp_manage_brand_info'));
  237. $('#ITP_FORM_STOCKMNG02010_SEARCH_BRAND_ID').val(data.brandId);
  238. pageObj.fnWhsList(function() {
  239. pageObj.fnLocationList();
  240. }); // 창고리스트
  241. // 공통코드 표시
  242. // fn_make_select(CODE_LIST, 'WHS_DVSN', 'ITP_FORM_STOCKMNG02010_WHS_DVSN');
  243. // 조회일자 지정
  244. var now = new Date();
  245. $('#ITP_TAB_STOCKMNG02010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  246. $('#ITP_FORM_STOCKMNG02010_SEARCH_FROM_DT').datepicker('setDate', new Date(now.setMonth(now.getMonth() - 1)));
  247. $('#ITP_FORM_STOCKMNG02010_SEARCH_TO_DT').datepicker('setDate', new Date());
  248. $('#ITP_FORM_STOCKMNG02010_DETAIL_CDD_DT').val(itp_fn_date_format(new Date(), 2));
  249. },
  250. grid: function() {
  251. itp_fn_jqgrid_resize(STOCKMNG02010_GRID_ID, STOCKMNG02010_GRID_LIST, 'lg');
  252. listObj.empty.init();
  253. itp_fn_fire_window_resize();
  254. },
  255. ready: function() {
  256. listObj.init();
  257. }
  258. },
  259. event: {
  260. init: function () {
  261. this.button();
  262. this.change();
  263. },
  264. button: function () {
  265. // 버튼 클릭 이벤트
  266. $('button').each(function() {
  267. var id = $(this).attr('id');
  268. $(this).on('click', function() {
  269. switch (id) {
  270. case 'ITP_BTN_STOCKMNG02010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  271. case 'ITP_BTN_STOCKMNG02010_STOCK_CDD' : listObj.button.fnStockCdd(); break; // 재고실사 버튼
  272. case 'ITP_BTN_STOCKMNG02010_CANCELLIST' : stockCddObj.button.cancel(); break; // 취소/목록 버튼
  273. // case 'ITP_BTN_STOCKMNG02010_DELETE' : break; // 삭제 버튼
  274. case 'ITP_BTN_STOCKMNG02010_SAVE' : stockCddObj.button.save(); break; // 저장 버튼
  275. // case 'ITP_BTN_STOCKMNG02010_DETAIL_ADDROW' : locInfoObj.button.addRow(); break; // 상세:추가버튼
  276. // case 'ITP_BTN_STOCKMNG02010_DETAIL_DELROW' : locInfoObj.button.delRow(); break; // 상세:삭제버튼
  277. }
  278. });
  279. });
  280. $('body').on('click', function(e) {
  281. var gridId = STOCKMNG02010_DETAIL_GRID_ID.replace('#', '');
  282. var rids = $(STOCKMNG02010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  283. var last_row_id = rids[rids.length - 1];
  284. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'STOCKMNG02010_DETAIL');
  285. });
  286. },
  287. change: function () {
  288. // 창고 변경
  289. $('#ITP_FORM_STOCKMNG02010_SEARCH_WHS_ID').on('change', function() {
  290. pageObj.fnLocationList(function() {
  291. listObj.button.search(); // 조회
  292. }); // 로케이션 리스트
  293. });
  294. $('#ITP_FORM_STOCKMNG02010_SEARCH_LOCATION').on('change', function() {
  295. listObj.button.search(); // 조회
  296. });
  297. }
  298. },
  299. switchScreen: function(mode) {
  300. if(mode == 'LIST') { // 목록
  301. $('#ITP_BTN_STOCKMNG02010_MODIFY').hide();
  302. $('#ITP_BTN_STOCKMNG02010_CANCELLIST').hide();
  303. $('#ITP_BTN_STOCKMNG02010_DELETE').hide();
  304. $('#ITP_BTN_STOCKMNG02010_SAVE').hide();
  305. fn_show_btn_auth('#ITP_BTN_STOCKMNG02010_SRH');
  306. fn_show_btn_auth('#ITP_BTN_STOCKMNG02010_STOCK_CDD');
  307. $('#ITP_AJAX_STOCKMNG02010_LIST_CONTAINER').show();
  308. $('#ITP_AJAX_STOCKMNG02010_DETAIL_CONTAINER').hide();
  309. $('#ITP_AJAX_STOCKMNG02010_VIEW_CONTAINER').hide();
  310. } else if(mode == 'ADD') { // 재고실사
  311. ITP_FORM_STOCKMNG02010_DETAIL_IS_DUPLICATE = true;
  312. $('#ITP_BTN_STOCKMNG02010_SRH').hide();
  313. $('#ITP_BTN_STOCKMNG02010_MODIFY').hide();
  314. $('#ITP_BTN_STOCKMNG02010_STOCK_CDD').hide();
  315. $('#ITP_BTN_STOCKMNG02010_DELETE').hide();
  316. fn_show_btn_auth('#ITP_BTN_STOCKMNG02010_CANCELLIST');
  317. fn_show_btn_auth('#ITP_BTN_STOCKMNG02010_SAVE');
  318. $('#ITP_AJAX_STOCKMNG02010_LIST_CONTAINER').hide();
  319. $('#ITP_AJAX_STOCKMNG02010_DETAIL_CONTAINER').show();
  320. $('#ITP_AJAX_STOCKMNG02010_VIEW_CONTAINER').hide();
  321. $('#ITP_FORM_STOCKMNG02010_DETAIL_BRAND_ID').val($('#ITP_FORM_STOCKMNG02010_SEARCH_BRAND_ID').val());
  322. $('#ITP_FORM_STOCKMNG02010_DETAIL_STORE_ID').val($('#ITP_FORM_STOCKMNG02010_SEARCH_STORE_ID').val());
  323. $('#ITP_FORM_STOCKMNG02010_DETAIL_WHS_ID').val($('#ITP_FORM_STOCKMNG02010_SEARCH_WHS_ID').val());
  324. $('#ITP_FORM_STOCKMNG02010_DETAIL_LOCATION').val($('#ITP_FORM_STOCKMNG02010_SEARCH_LOCATION').val());
  325. } else if(mode == 'VIEW') { // 보기
  326. $('#ITP_BTN_STOCKMNG02010_SRH').hide();
  327. $('#ITP_BTN_STOCKMNG02010_STOCK_CDD').hide();
  328. $('#ITP_BTN_STOCKMNG02010_DELETE').hide();
  329. $('#ITP_BTN_STOCKMNG02010_SAVE').hide();
  330. fn_show_btn_auth('#ITP_BTN_STOCKMNG02010_MODIFY');
  331. fn_show_btn_auth('#ITP_BTN_STOCKMNG02010_CANCELLIST');
  332. $('#ITP_AJAX_STOCKMNG02010_LIST_CONTAINER').hide();
  333. $('#ITP_AJAX_STOCKMNG02010_DETAIL_CONTAINER').hide();
  334. $('#ITP_AJAX_STOCKMNG02010_VIEW_CONTAINER').show();
  335. }
  336. },
  337. fnWhsList: function(fnCall) {
  338. const brandIdVal = $('#ITP_FORM_STOCKMNG02010_SEARCH_BRAND_ID').val();
  339. const param = {sbrandId: brandIdVal, pagingYn: false};
  340. fn_ajax_call(WHS_MNG_DETAIL_GRID_LIST, JSON.stringify(param), function(result) {
  341. fn_make_select_whs(result.gridRows, 'ITP_FORM_STOCKMNG02010_SEARCH_WHS_ID');
  342. fn_make_select_whs(result.gridRows, 'ITP_FORM_STOCKMNG02010_DETAIL_WHS_ID');
  343. if (fnCall !== undefined || typeof fnCall !== 'undefined') fnCall();
  344. }, 'POST');
  345. },
  346. fnLocationList: function(fnCall) {
  347. const brandIdVal = $('#ITP_FORM_STOCKMNG02010_SEARCH_BRAND_ID').val();
  348. const whsIdVal = $('#ITP_FORM_STOCKMNG02010_SEARCH_WHS_ID').val();
  349. const param = {brandId: brandIdVal, whsId: whsIdVal, pagingYn: false};
  350. fn_ajax_call(WHS_MNG_LOCATION_GRID_LIST, JSON.stringify(param), function(result) {
  351. fn_make_select_location(result.gridRows, 'ITP_FORM_STOCKMNG02010_SEARCH_LOCATION');
  352. fn_make_select_location(result.gridRows, 'ITP_FORM_STOCKMNG02010_DETAIL_LOCATION');
  353. if (fnCall !== undefined || typeof fnCall !== 'undefined') fnCall();
  354. }, 'POST');
  355. }
  356. };
  357. /*목록화면 Object*/
  358. let listObj = {
  359. init: function () {
  360. this.grid.init();
  361. },
  362. itp_STOCKMNG02010_search: false,
  363. button: {
  364. search: function() {
  365. listObj.itp_STOCKMNG02010_search = true;
  366. let param = $('#ITP_FORM_STOCKMNG02010_SEARCH').serializeObject();
  367. param.gridSize = $.jgrid.defaults.rowNum;
  368. param.gridPage = $.jgrid.defaults.page;
  369. $(STOCKMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  370. },
  371. fnStockCdd: function() {
  372. pageObj.switchScreen('ADD');
  373. itp_fn_form_clear_validate(null, '#ITP_FORM_STOCKMNG02010_DETAIL');
  374. stockCddObj.init();
  375. }
  376. },
  377. empty: {
  378. init: function() {
  379. var _this = this;
  380. this.push();
  381. $(STOCKMNG02010_GRID_EMPTY).on('click', function() {
  382. _this.back();
  383. _this.itp_STOCKMNG02010_param.gridSize = $.jgrid.defaults.rowNum;
  384. $(STOCKMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_STOCKMNG02010_param)}).trigger('reloadGrid');
  385. });
  386. },
  387. itp_STOCKMNG02010_param: {},
  388. push: function() {
  389. let param = $('#ITP_FORM_STOCKMNG02010_SEARCH').serializeObject();
  390. listObj.itp_STOCKMNG02010_param = param;
  391. },
  392. back: function() {
  393. $('#ITP_FORM_STOCKMNG02010_DEVI_TP_CD').val(this.itp_STOCKMNG02010_param.deviTpCd);
  394. $('#ITP_FORM_STOCKMNG02010_ORDER_YN').val(this.itp_STOCKMNG02010_param.orderYn);
  395. $('#ITP_FORM_STOCKMNG02010_ADT_AUTH_CD').val(this.itp_STOCKMNG02010_param.adtAuthCd);
  396. $('#ITP_FORM_STOCKMNG02010_EMAIL_RCV_YN').val(this.itp_STOCKMNG02010_param.emailRcvYn);
  397. $('#ITP_FORM_STOCKMNG02010_MEMB_EXIT_DT').val(this.itp_STOCKMNG02010_param.membExitDt);
  398. $('#ITP_FORM_STOCKMNG02010_FROM_DT').val(this.itp_STOCKMNG02010_param.fromDt);
  399. $('#ITP_FORM_STOCKMNG02010_TO_DT').val(this.itp_STOCKMNG02010_param.toDt);
  400. $('#ITP_FORM_STOCKMNG02010_KEYWORD').val(this.itp_STOCKMNG02010_param.keyword);
  401. }
  402. },
  403. grid: {
  404. init: function () {
  405. // 데이터 없을때
  406. listObj.empty.push();
  407. this.search();
  408. },
  409. colModel: gridColModel.list,
  410. search: function() {
  411. pageObj.switchScreen('LIST');
  412. this.unload();
  413. this.load();
  414. },
  415. load: function() {
  416. var data = JSON.parse(sessionStorage.getItem('itp_manage_brand_info'));
  417. $('#ITP_FORM_STOCKMNG02010_SEARCH_BRAND_ID').val(data.brandId);
  418. let param = $('#ITP_FORM_STOCKMNG02010_SEARCH').serializeObject();
  419. param.gridSize = $.jgrid.defaults.rowNum;
  420. var option = {
  421. gridId: STOCKMNG02010_GRID_ID,
  422. colModel: gridColModel.list,
  423. param: JSON.stringify(param),
  424. url: DOMAIN + STOCK_CDD_DETAIL_GRID_LIST,
  425. pager: STOCKMNG02010_GRID_PAGER,
  426. onCellSelect: function(rowId, cellIdx, cellValue) {
  427. var cm = $(this).jqGrid('getGridParam', 'colModel');
  428. var colNm = cm[cellIdx].name;
  429. if (colNm == 'whsNm') {
  430. const brandIdVal = $(this).jqGrid('getCell', rowId, 'brandId');
  431. const whsIdVal = $(this).jqGrid('getCell', rowId, 'whsId');
  432. const key = {brandId: brandIdVal, whsId: whsIdVal, viewCd: 'R'};
  433. var param = $.param(key);
  434. viewObj.init(param);
  435. }
  436. },
  437. loadComplete: function(data) {
  438. console.log(data);
  439. itp_fn_grid_load_complete(data, STOCKMNG02010_GRID_ID, true, 'number', 'STOCKMNG02010', listObj.itp_STOCKMNG02010_search, listObj.empty, true, data.gridRecords, true);
  440. var ids = $(STOCKMNG02010_GRID_ID).getDataIDs();
  441. $.each(ids, function(idx, rowId) {
  442. $(STOCKMNG02010_GRID_ID).jqGrid('setCell', rowId, 'whsNm', '', ITP_GRID_COL_STYLE.link);
  443. });
  444. },
  445. onPaging: function(action) {
  446. itp_fn_grid_paging(STOCKMNG02010_GRID_ID, action, param);
  447. }
  448. };
  449. itp_fn_grid_make_remote(option);
  450. },
  451. clearData : function() {
  452. $(STOCKMNG02010_GRID_ID).jqGrid('clearGridData', true);
  453. $(STOCKMNG02010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  454. $(STOCKMNG02010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  455. $(STOCKMNG02010_GRID_EMPTY).show();
  456. },
  457. unload : function() {
  458. $.jgrid.gridUnload(STOCKMNG02010_GRID_ID);
  459. }
  460. }
  461. };
  462. /*상세화면 Object*/
  463. let viewObj = {
  464. init: function (param) {
  465. this.load(param);
  466. },
  467. load: function(param) {
  468. fn_ajax_call(WHS_MNG_INFO_WHS, param, this.callback, 'GET');
  469. },
  470. callback: function (result) {
  471. // console.log(result);
  472. pageObj.switchScreen('VIEW');
  473. $('#ITP_FORM_STOCKMNG02010_VIEW #ITP_FORM_STOCKMNG02010_VIEW_BRAND_ID').val(result.brandId);
  474. $('#ITP_FORM_STOCKMNG02010_VIEW #ITP_FORM_STOCKMNG02010_VIEW_STORE_ID').val(result.storeId);
  475. $('#ITP_FORM_STOCKMNG02010_VIEW #ITP_FORM_STOCKMNG02010_VIEW_WHS_ID').val(result.whsId);
  476. $('#ITP_FORM_STOCKMNG02010_VIEW .fnBrandNm').text(result.brandNm);
  477. $('#ITP_FORM_STOCKMNG02010_VIEW .fnStCd').text(result.whsStNm);
  478. $('#ITP_FORM_STOCKMNG02010_VIEW .fnWhsId').text(result.whsId);
  479. $('#ITP_FORM_STOCKMNG02010_VIEW .fnWhsNm').text(result.whsNm);
  480. $('#ITP_FORM_STOCKMNG02010_VIEW .fnTelNo').text(result.mgrTelNo);
  481. $('#ITP_FORM_STOCKMNG02010_VIEW .fnMgrNm').text(result.mgrNm);
  482. $('#ITP_FORM_STOCKMNG02010_VIEW .fnSpplyNm').text(result.storeNm ? result.storeNm : '');
  483. $('#ITP_FORM_STOCKMNG02010_VIEW .fnRegDtm').text(result.sysRegDttm);
  484. if(result.zipNo) {
  485. $('#ITP_FORM_STOCKMNG02010_VIEW .fnAddress').text('('+result.zipNo+') ' + result.addr1 + ' ' + result.addr2);
  486. }
  487. // 권한정보 리스트 조회
  488. viewObj.grid.init();
  489. },
  490. grid: {
  491. init: function() {
  492. this.unload();
  493. this.load();
  494. },
  495. load : function() {
  496. let param = $('#ITP_FORM_STOCKMNG02010_VIEW').serializeObject();
  497. param.gridSize = $.jgrid.defaults.rowNum;
  498. param.pagingYn = false; // 페이징안함
  499. var option = {
  500. gridId: STOCKMNG02010_VIEW_GRID_ID,
  501. colModel: gridColModel.view,
  502. param: JSON.stringify(param),
  503. url: DOMAIN + WHS_MNG_LOCATION_GRID_LIST,
  504. pager: STOCKMNG02010_VIEW_GRID_PAGER,
  505. loadComplete: function(data) {
  506. itp_fn_grid_load_complete(data, STOCKMNG02010_VIEW_GRID_ID, true, undefined, 'STOCKMNG02010_VIEW');
  507. },
  508. onPaging: function(action) {
  509. var pagingFn = {
  510. callBack: function(args) {
  511. $(args).trigger('reloadGrid');
  512. }
  513. };
  514. if (itp_fn_check_grid_is_writing(STOCKMNG02010_VIEW_GRID_ID)) {
  515. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, pagingFn, STOCKMNG02010_VIEW_GRID_ID);
  516. return 'stop';
  517. } else {
  518. itp_fn_grid_paging(STOCKMNG02010_VIEW_GRID_ID, action, param);
  519. }
  520. },
  521. onSortCol: function(index, columnIndex, sortOrder) {
  522. var sortingFn = {
  523. callBack: function(args) {
  524. $(args).trigger('reloadGrid');
  525. }
  526. };
  527. if (itp_fn_check_grid_is_writing(STOCKMNG02010_VIEW_GRID_ID)) {
  528. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, sortingFn, STOCKMNG02010_VIEW_GRID_ID);
  529. return 'stop';
  530. } else {
  531. itp_fn_grid_sorting(STOCKMNG02010_VIEW_GRID_ID, index, sortOrder);
  532. }
  533. }
  534. };
  535. itp_fn_grid_make_remote(option);
  536. },
  537. clearData : function() {
  538. $(STOCKMNG02010_VIEW_GRID_ID).jqGrid('clearGridData', true);
  539. $(STOCKMNG02010_VIEW_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  540. $(STOCKMNG02010_VIEW_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  541. $(STOCKMNG02010_VIEW_GRID_EMPTY).show();
  542. },
  543. unload : function() {
  544. $.jgrid.gridUnload(STOCKMNG02010_VIEW_GRID_ID);
  545. }
  546. }
  547. };
  548. /*재고실사 Object*/
  549. let stockCddObj = {
  550. init: function () {
  551. this.unload();
  552. this.load();
  553. },
  554. button: {
  555. cancel: function() {
  556. listObj.grid.search();
  557. },
  558. save: function() {
  559. var detailViewCd = $('#ITP_FORM_STOCKMNG02010_DETAIL_VIEW_CD').val();
  560. const formId = '#ITP_FORM_STOCKMNG02010_DETAIL';
  561. itp_fn_form_clear_validate(null, formId);
  562. var vali_whsStatCd = itp_fn_form_validate(formId, formId + '_WHS_ST_CD', ['empty'], undefined); // 상태
  563. var vali_whsNm = itp_fn_form_validate(formId, formId + '_WHS_NM', ['empty'], undefined);
  564. if (vali_whsStatCd && vali_whsNm) {
  565. let gridInsertData = [];
  566. let gridUpdateData = [];
  567. let gridDeleteData = [];
  568. const rowData = $(STOCKMNG02010_DETAIL_GRID_ID).getRowData();
  569. // const keyValue = $(formId + '_WHS_ID').val();
  570. $.each(rowData, function(key, value) {
  571. if (value.viewCd != 'R') {
  572. // value.whsId = keyValue;
  573. if (value.viewCd == 'C') {
  574. gridInsertData.push(value);
  575. } else if (value.viewCd == 'U') {
  576. gridUpdateData.push(value);
  577. } else if (value.viewCd == 'D') {
  578. gridDeleteData.push(value);
  579. }
  580. }
  581. });
  582. let param = $(formId).serializeObject();
  583. param.gridInsertData = gridInsertData;
  584. param.gridUpdateData = gridUpdateData;
  585. param.gridDeleteData = gridDeleteData;
  586. //console.log(JSON.stringify(param));
  587. var searhFn = function() {
  588. ITP_FORM_STOCKMNG02010_DETAIL_IS_WRITING = false;
  589. listObj.grid.search();
  590. };
  591. fn_ajax_call(detailViewCd == 'C' ? WHS_MNG_ADD_WHS : WHS_MNG_MIDIFY_WHS, JSON.stringify(param), searhFn, 'POST');
  592. }
  593. }
  594. },
  595. load: function () {
  596. let param = $('#ITP_FORM_STOCKMNG02010_DETAIL').serializeObject();
  597. param.gridSize = $.jgrid.defaults.rowNum;
  598. param.pagingYn = false; // 페이지안함
  599. var option = {
  600. gridId: STOCKMNG02010_DETAIL_GRID_ID,
  601. colModel: gridColModel.detail,
  602. param: JSON.stringify(param),
  603. url: DOMAIN + WHS_MNG_LOCATION_GRID_LIST,
  604. pager: STOCKMNG02010_DETAIL_GRID_PAGER,
  605. multiselect: true,
  606. loadComplete: function(data) {
  607. itp_fn_grid_load_complete(data, STOCKMNG02010_DETAIL_GRID_ID, true, undefined, 'STOCKMNG02010_DETAIL');
  608. },
  609. onPaging: function(action) {
  610. var pagingFn = {
  611. callBack: function(args) {
  612. $(args).trigger('reloadGrid');
  613. }
  614. };
  615. if (itp_fn_check_grid_is_writing(STOCKMNG02010_DETAIL_GRID_ID)) {
  616. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, pagingFn, STOCKMNG02010_DETAIL_GRID_ID);
  617. return 'stop';
  618. } else {
  619. itp_fn_grid_paging(STOCKMNG02010_DETAIL_GRID_ID, action, param);
  620. }
  621. },
  622. onSortCol: function(index, columnIndex, sortOrder) {
  623. var sortingFn = {
  624. callBack: function(args) {
  625. $(args).trigger('reloadGrid');
  626. }
  627. };
  628. if (itp_fn_check_grid_is_writing(STOCKMNG02010_DETAIL_GRID_ID)) {
  629. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, sortingFn, STOCKMNG02010_DETAIL_GRID_ID);
  630. return 'stop';
  631. } else {
  632. itp_fn_grid_sorting(STOCKMNG02010_DETAIL_GRID_ID, index, sortOrder);
  633. }
  634. }
  635. };
  636. itp_fn_grid_make_remote(option);
  637. },
  638. clearData : function() {
  639. $(STOCKMNG02010_DETAIL_GRID_ID).jqGrid('clearGridData', true);
  640. $(STOCKMNG02010_DETAIL_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  641. $(STOCKMNG02010_DETAIL_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  642. $(STOCKMNG02010_DETAIL_GRID_EMPTY).show();
  643. },
  644. unload : function() {
  645. $.jgrid.gridUnload(STOCKMNG02010_DETAIL_GRID_ID);
  646. }
  647. };