ITP_MCOLLMNG01010.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. mobPageObj.init();
  5. });
  6. });
  7. /*API URL*/
  8. const API_MOBILE_GRID_LIST = '/api/rtnmng/rtn/spply-rtn-grid-list'; // 목록
  9. const API_MOBILE_INFO = '/api/rtnmng/rtn/info-rtnOdr'; // 상세
  10. const API_POP_SEARCH_LIST = '/api/whs/mng/pop-whs-search';
  11. const PAGE_MODE_LIST = "LIST";
  12. const PAGE_MODE_VIEW = "VIEW";
  13. let mobPageObj = {
  14. viewMode: PAGE_MODE_LIST,
  15. init: function () {
  16. this.ui.init();
  17. this.event.init();
  18. this.ready();
  19. },
  20. ui: {
  21. init: function () {
  22. this.view();
  23. this.info();
  24. },
  25. view: function() {
  26. // 공통코드 표시
  27. $('select').each(function() {
  28. if($(this).data('select-code')) {
  29. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  30. }
  31. });
  32. // 조회일자 지정
  33. $('#ITP_MOBILE_MCOLLMNG01010 .itp_input.date').datepicker(ITP_DATE_LANGUAGE);
  34. $('#ITP_FORM_MCOLLMNG01010_LIST_SEARCH_FROM_DT').datepicker('setDate', itp_fn_date_add('D', -7));
  35. $('#ITP_FORM_MCOLLMNG01010_LIST_SEARCH_TO_DT').datepicker('setDate', itp_fn_date_add('M', 0));
  36. },
  37. info: function() {
  38. $('input:hidden[id$="_BRAND_ID"]').val(fn_make_user_info.get('brandId'));
  39. $('input:hidden[id$="_STORE_ID"]').val(fn_make_user_info.get('storeId'));
  40. $('input:hidden[id$="_SPPLY_ID"]').val(fn_make_user_info.get('userId'));
  41. }
  42. },
  43. event: {
  44. init: function() {
  45. this.button();
  46. },
  47. button: function() {
  48. $('button[id^="ITP_BTN_MCOLLMNG01010_LIST"]').on('click', function() {
  49. var id = $(this).attr('id');
  50. switch (id) {
  51. case 'ITP_BTN_MCOLLMNG01010_LIST_SEARCH_WHS_NM' : mobPopObj.popWhsNm.init(); break;
  52. case 'ITP_BTN_MCOLLMNG01010_LIST_DELETE_WHS_NM' : mobPopObj.popWhsNm.delete(); break;
  53. case 'ITP_BTN_MCOLLMNG01010_LIST_SEARCH' : mobContObj.list.search(); break;
  54. }
  55. return false;
  56. });
  57. $('button[id^="ITP_BTN_MCOLLMNG01010_VIEW"]').on('click', function() {
  58. var id = $(this).attr('id');
  59. switch (id) {
  60. case 'ITP_BTN_MCOLLMNG01010_VIEW_CANCEL_LIST' : mobContObj.view.cancel(); break;
  61. }
  62. return false;
  63. });
  64. $(document).on('click', '#ITP_LIST_MCOLLMNG01010_LIST_ITEM_ROWS li', function() {
  65. var item = mobContObj.list.rows[$(this).index()];
  66. mobContObj.view.init(item);
  67. });
  68. $(document).on('click', '#ITP_LIST_MCOLLMNG01010_POP_WHS_ROWS li button', function() {
  69. mobPopObj.popWhsNm.choice($(this));
  70. });
  71. }
  72. },
  73. switchScreen: function(mode) {
  74. $('#ITP_MOBILE_MCOLLMNG01010').find('div[id$="_CONTAINER"]').each(function(i) {
  75. $(this).hide();
  76. });
  77. if(mode === PAGE_MODE_LIST) {
  78. $('#ITP_AJAX_MCOLLMNG01010_LIST_CONTAINER').show();
  79. } else if(mode === PAGE_MODE_VIEW) {
  80. $('#ITP_AJAX_MCOLLMNG01010_VIEW_CONTAINER').show();
  81. CommonObj.moreView('#ITP_LIST_MCOLLMNG01010_LIST_ITEM_AREA', false);
  82. }
  83. this.viewMode = mode;
  84. },
  85. ready: function() {
  86. mobContObj.list.init();
  87. }
  88. };
  89. let mobContObj = {
  90. list: {
  91. listPage: 1,
  92. rows: [],
  93. init: function() {
  94. mobPageObj.switchScreen(PAGE_MODE_LIST);
  95. this.search();
  96. },
  97. search: function() {
  98. this.listPage = 1;
  99. this.rows.length = 0;
  100. $('#ITP_LIST_MCOLLMNG01010_LIST_ITEM_ROWS').empty();
  101. setTimeout(function() {
  102. mobContObj.list.load();
  103. }, 100);
  104. },
  105. pager: function(totPage) {
  106. (this.listPage < totPage) ?
  107. CommonObj.moreView('#ITP_LIST_MCOLLMNG01010_LIST_ITEM_AREA', true, mobContObj.list.load) :
  108. CommonObj.moreView('#ITP_LIST_MCOLLMNG01010_LIST_ITEM_AREA', false);
  109. this.listPage += 1;
  110. },
  111. load: function() {
  112. var _this = this;
  113. var callbackFn = function(result) {
  114. console.log(result);
  115. mobContObj.list.pager(result.gridTotal);
  116. $.each(result.gridRows, function (i, item) {
  117. $('#ITP_LIST_MCOLLMNG01010_LIST_ITEM_AREA .panel-group').append($('#ITP_LIST_MCOLLMNG01010_LIST_ITEM_ROWCOPY').html());
  118. var $li = $('#ITP_LIST_MCOLLMNG01010_LIST_ITEM_AREA .panel-group > .item-row:last');
  119. $li.find('.fnBrandNm').text(item.brandNm);
  120. $li.find('.fnRtnPodrUnqNo').text(item.rtnPodrUnqNo);
  121. $li.find('.fnRtnOdrStNm').text(item.rtnOdrStNm);
  122. $li.find('.fnRtnOdrRegDt').text(item.rtnOdrRegDt);
  123. $li.find('.fnColReqDt').text(item.colReqDt);
  124. $li.find('.fnRtnWhsNm').text(item.rtnWhsNm);
  125. $li.find('.fnRtnDodrTotalAmt').text(CommonObj.currency.add(item.rtnDodrTotalAmt));
  126. $li.find('.fnRtnDodrItemQty').text(CommonObj.currency.add(item.rtnDodrItemQty, '개'));
  127. mobContObj.list.rows.push(item);
  128. });
  129. };
  130. const param = $('#ITP_FORM_MCOLLMNG01010_LIST_SEARCH').serializeObject();
  131. param.gridPage = mobContObj.list.listPage;
  132. param.gridSize = mobile_list_size;
  133. console.log(JSON.stringify(param));
  134. fn_ajax_call(API_MOBILE_GRID_LIST, JSON.stringify(param), callbackFn, 'POST');
  135. }
  136. },
  137. view: {
  138. init: function(item) {
  139. mobPageObj.switchScreen(PAGE_MODE_VIEW);
  140. this.search(item);
  141. },
  142. search: function(item) {
  143. var _this = this;
  144. var callbackFn = function(result) {
  145. console.log(result);
  146. _this.view(result);
  147. };
  148. const param = {
  149. 'brandId': fn_make_user_info.get('brandId'),
  150. 'spplyId': fn_make_user_info.get('userId'),
  151. 'rtnPodrUnqNo': item.rtnPodrUnqNo
  152. };
  153. fn_ajax_call(API_MOBILE_INFO, param, callbackFn, 'GET');
  154. },
  155. view: function(result) {
  156. var _this = this;
  157. var id = '#ITP_AJAX_MCOLLMNG01010_VIEW_CONTAINER';
  158. $(id).find('.fnBrandNm').text(result.brandNm);
  159. $(id).find('.fnPchPodrUnqNo').text(result.pchPodrUnqNo);
  160. $(id).find('.fnPodrDt').text(result.podrDt);
  161. $(id).find('.fnPchOdrStNm').text(result.pchOdrStNm);
  162. $(id).find('.fnWhsNm').text(result.whsNm);
  163. $(id).find('.fnPodrTotalAmt').text(CommonObj.currency.add(result.podrItemQty));
  164. $(id).find('.fnPodrMgrNm').text(result.podrMgrNm);
  165. $.each(result.rtnOdrDtlList, function (i, item) {
  166. $('#ITP_LIST_MCOLLMNG01010_VIEW_ITEM_AREA .panel-group').append($('#ITP_LIST_MCOLLMNG01010_VIEW_ITEM_ROWCOPY').html());
  167. var $li = $('#ITP_LIST_MCOLLMNG01010_VIEW_ITEM_AREA .panel-group > .item-row:last');
  168. $li.find('.fnRtnPodrDtlNo').text(item.rtnPodrDtlNo);
  169. $li.find('.fnItemid').text(item.itemId);
  170. $li.find('.fnItemNm').text(item.itemNm);
  171. $li.find('.fnUnitQty').text(item.unitQty);
  172. $li.find('.fnUnitAmt').text(CommonObj.currency.add(item.unitAmt));
  173. $li.find('.fnUnit').text(item.unit);
  174. $li.find('.fnRtnReqQty').text(CommonObj.comma.set(item.rtnReqQty));
  175. $li.find('.fnRtnAmt').text(CommonObj.currency.add(item.rtnAmt));
  176. $li.find('.fnColReqDt').text(result.colReqDt);
  177. });
  178. },
  179. cancel: function () {
  180. var id = '#ITP_AJAX_MCOLLMNG01010_VIEW_CONTAINER';
  181. $(id).find('.fnBrandNm').text('');
  182. $(id).find('.fnPchPodrUnqNo').text('');
  183. $(id).find('.fnPodrDt').text('');
  184. $(id).find('.fnPchOdrStNm').text('');
  185. $(id).find('.fnWhsNm').text('');
  186. $(id).find('.fnPodrTotalAmt').text('');
  187. $(id).find('.fnPodrMgrNm').text('');
  188. $('#ITP_LIST_MCOLLMNG01010_VIEW_ITEM_AREA .panel-group').empty();
  189. mobPageObj.switchScreen(PAGE_MODE_LIST);
  190. }
  191. }
  192. };
  193. let mobPopObj = {
  194. popWhsNm: {
  195. popId: 'ITP_POP_MCOLLMNG01010_WHS_AREA',
  196. rows: [],
  197. init: function () {
  198. this.rows.length = 0;
  199. mobPopObj.show(this.popId);
  200. this.search();
  201. this.action();
  202. },
  203. search: function () {
  204. var _this = this;
  205. $('#ITP_LIST_MCOLLMNG01010_POP_WHS_AREA .panel-group').empty();
  206. var callbackFn = function(result) {
  207. console.log(result);
  208. _this.view(result.gridRows);
  209. };
  210. const param = $('#ITP_FORM_MCOLLMNG01010_POP_WHS').serializeObject();
  211. param.swhsDvsn = 'W01';
  212. fn_ajax_call(API_POP_SEARCH_LIST, JSON.stringify(param), callbackFn, 'POST');
  213. },
  214. view: function(gridRows) {
  215. this.rows = gridRows;
  216. $.each(gridRows, function (i, item) {
  217. $('#ITP_LIST_MCOLLMNG01010_POP_WHS_AREA .panel-group').append($('#ITP_LIST_MCOLLMNG01010_POP_WHS_ROWCOPY').html());
  218. var $li = $('#ITP_LIST_MCOLLMNG01010_POP_WHS_AREA .panel-group > .item-row:last');
  219. $li.find('.fnWhsNm').text(item.whsNm);
  220. $li.find('.fnLocationNm').text(item.locationNm);
  221. $li.find('.fnWhsId').data('whs-id', item.whsId);
  222. });
  223. },
  224. choice: function(elem) {
  225. var _this = this;
  226. var whsId = $(elem).data('whs-id');
  227. $.each(this.rows, function (i, item) {
  228. if(whsId === item.whsId) {
  229. $('#ITP_FORM_MCOLLMNG01010_LIST_SEARCH #ITP_FORM_MCOLLMNG01010_LIST_SEARCH_WHS_ID').val(item.whsId);
  230. $('#ITP_FORM_MCOLLMNG01010_LIST_SEARCH #ITP_FORM_MCOLLMNG01010_LIST_SEARCH_WHS_NM').val(item.whsNm);
  231. _this.close();
  232. return false;
  233. }
  234. });
  235. },
  236. action: function() {
  237. var _this = this;
  238. $('button[id^="ITP_BTN_MCOLLMNG01010_POP_WHS"]').off('click').on('click', function() {
  239. var id = $(this).attr('id');
  240. switch (id) {
  241. case 'ITP_BTN_MCOLLMNG01010_POP_WHS_SEARCH' : _this.search(); break;
  242. case 'ITP_BTN_MCOLLMNG01010_POP_WHS_CHOICE' : _this.choice($(this)); break;
  243. case 'ITP_BTN_MCOLLMNG01010_POP_WHS_CLOSE' : _this.close(); break;
  244. }
  245. return false;
  246. });
  247. },
  248. delete: function() {
  249. $('#ITP_FORM_MCOLLMNG01010_LIST_SEARCH #ITP_FORM_MCOLLMNG01010_LIST_SEARCH_WHS_ID').val('');
  250. $('#ITP_FORM_MCOLLMNG01010_LIST_SEARCH #ITP_FORM_MCOLLMNG01010_LIST_SEARCH_WHS_NM').val('');
  251. },
  252. close: function() {
  253. this.rows.length = 0;
  254. $('#ITP_POP_MCOLLMNG01010_LIST_WHS_AREA .panel-group').empty();
  255. $('#ITP_FORM_MCOLLMNG01010_POP_WHS #ITP_FORM_MCOLLMNG01010_POP_WHS_KEYWORD').val('');
  256. mobPopObj.hide(this.popId);
  257. }
  258. },
  259. show: function(popId) {
  260. $('button[id$="_CLOSE"]').off('click').on('click', function() {
  261. console.log($(this).attr('id'));
  262. if($(this).hasClass('btn-pop-close')) {
  263. mobPopObj.hide(popId);
  264. }
  265. });
  266. $('#' + popId).show();
  267. },
  268. hide: function(popId) {
  269. $('#' + popId).closest('.mobile-pop-close').hide();
  270. }
  271. };