ITP_MPOMNG07010.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. mobPageObj.init();
  5. });
  6. });
  7. /*API URL*/
  8. const API_MOBILE_GRID_LIST = '/api/pomng/inoutmng/warehouse-grid-list'; // 목록
  9. const API_MOBILE_INFO = '/api/pomng/po/info-pchOdr'; // 상세
  10. const API_POP_SEARCH_LIST = '/api/whs/mng/pop-whs-search';
  11. const API_POP_SPPLY_LIST = '/api/spply/pop-grid-list';
  12. const PAGE_MODE_LIST = "LIST";
  13. const PAGE_MODE_VIEW = "VIEW";
  14. let mobPageObj = {
  15. viewMode: PAGE_MODE_LIST,
  16. init: function () {
  17. this.ui.init();
  18. this.event.init();
  19. this.ready();
  20. },
  21. ui: {
  22. init: function () {
  23. this.view();
  24. this.info();
  25. },
  26. view: function() {
  27. // 공통코드 표시
  28. $('select').each(function() {
  29. if($(this).data('select-code')) {
  30. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  31. }
  32. });
  33. (fn_make_user_info.get('authTpCd') === '50') ? $('#ITP_FORM_MPOMNG07010_LIST_SEARCH .schSpply').hide() : $('#ITP_FORM_MPOMNG07010_LIST_SEARCH .schSpply').show();
  34. // 조회일자 지정
  35. $('#ITP_MOBILE_MPOMNG07010 .itp_input.date').datepicker(ITP_DATE_LANGUAGE);
  36. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH_FROM_DT').datepicker('setDate', itp_fn_date_add('M', -1));
  37. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH_TO_DT').datepicker('setDate', itp_fn_date_add('M', 0));
  38. },
  39. info: function() {
  40. $('input:hidden[id$="_BRAND_ID"]').val(fn_make_user_info.get('brandId'));
  41. $('input:hidden[id$="_STORE_ID"]').val(fn_make_user_info.get('storeId'));
  42. }
  43. },
  44. event: {
  45. init: function() {
  46. this.button();
  47. },
  48. button: function() {
  49. $('button[id^="ITP_BTN_MPOMNG07010_LIST"]').on('click', function() {
  50. var id = $(this).attr('id');
  51. switch (id) {
  52. case 'ITP_BTN_MPOMNG07010_LIST_SEARCH_WHS_NM' : mobPopObj.popWhsNm.init(); break;
  53. case 'ITP_BTN_MPOMNG07010_LIST_DELETE_WHS_NM' : mobPopObj.popWhsNm.delete(); break;
  54. case 'ITP_BTN_MPOMNG07010_LIST_SEARCH_SPPLY_NM' : mobPopObj.popSpply.init(); break;
  55. case 'ITP_BTN_MPOMNG07010_LIST_DELETE_SPPLY_NM' : mobPopObj.popSpply.delete(); break;
  56. case 'ITP_BTN_MPOMNG07010_LIST_SEARCH' : mobContObj.list.search(); break;
  57. }
  58. return false;
  59. });
  60. $(document).on('click', '#ITP_LIST_MPOMNG07010_LIST_ITEM_ROWS li', function() {
  61. var item = mobContObj.list.rows[$(this).index()];
  62. mobContObj.view.init(item);
  63. });
  64. $(document).on('click', '#ITP_POP_MPOMNG07010_LIST_SPPLY_ROWS li button', function() {
  65. mobPopObj.popSpply.choice($(this));
  66. });
  67. $(document).on('click', '#ITP_LIST_MPOMNG07010_POP_WHS_ROWS li button', function() {
  68. mobPopObj.popWhsNm.choice($(this));
  69. });
  70. }
  71. },
  72. switchScreen: function(mode) {
  73. $('#ITP_MOBILE_MPOMNG07010').find('div[id$="_CONTAINER"]').each(function(i) {
  74. $(this).hide();
  75. });
  76. if(mode === PAGE_MODE_LIST) {
  77. $('#ITP_AJAX_MPOMNG07010_LIST_CONTAINER').show();
  78. }
  79. this.viewMode = mode;
  80. },
  81. ready: function() {
  82. mobContObj.list.init();
  83. }
  84. };
  85. let mobContObj = {
  86. list: {
  87. listPage: 1,
  88. rows: [],
  89. init: function() {
  90. mobPageObj.switchScreen(PAGE_MODE_LIST);
  91. this.search();
  92. },
  93. search: function() {
  94. this.listPage = 1;
  95. this.rows.length = 0;
  96. $('#ITP_LIST_MPOMNG07010_LIST_ITEM_ROWS').empty();
  97. setTimeout(function() {
  98. mobContObj.list.load();
  99. }, 100);
  100. },
  101. pager: function(totPage) {
  102. (this.listPage < totPage) ?
  103. CommonObj.moreView('#ITP_LIST_MPOMNG07010_LIST_ITEM_AREA', true, mobContObj.list.load) :
  104. CommonObj.moreView('#ITP_LIST_MPOMNG07010_LIST_ITEM_AREA', false);
  105. this.listPage += 1;
  106. },
  107. load: function() {
  108. var _this = this;
  109. var callbackFn = function(result) {
  110. console.log(result);
  111. mobContObj.list.pager(result.gridTotal);
  112. $.each(result.gridRows, function (i, item) {
  113. $('#ITP_LIST_MPOMNG07010_LIST_ITEM_AREA .panel-group').append($('#ITP_LIST_MPOMNG07010_LIST_ITEM_ROWCOPY').html());
  114. var $li = $('#ITP_LIST_MPOMNG07010_LIST_ITEM_AREA .panel-group > .item-row:last');
  115. $li.find('.fnDlvSttmtUnqNo').text(item.dlvSttmtUnqNo);
  116. $li.find('.fnItemNm').text(item.itemNm);
  117. $li.find('.fnDlvMgrNm').text(item.dlvMgrNm);
  118. $li.find('.fnWhsCnfmNm').text(item.whsCnfmNm);
  119. $li.find('.fnDlvReqDt').text(item.dlvReqDt);
  120. $li.find('.fnDlvSchDt').text(item.dlvSchDt);
  121. $li.find('.fnPodrQty').text(CommonObj.comma.set(item.podrQty) + ' ' + item.unit);
  122. $li.find('.fnWhsAmt').text(CommonObj.currency.add(item.whsAmt));
  123. $li.find('.fnDlvQty').text(CommonObj.comma.set(item.dlvQty) + ' ' + item.unit);
  124. $li.find('.fnWhsQty').text(CommonObj.comma.set(item.whsQty) + ' ' + item.unit);
  125. mobContObj.list.rows.push(item);
  126. });
  127. };
  128. const param = $('#ITP_FORM_MPOMNG07010_LIST_SEARCH').serializeObject();
  129. param.gridPage = mobContObj.list.listPage;
  130. param.gridSize = mobile_list_size;
  131. fn_ajax_call(API_MOBILE_GRID_LIST, JSON.stringify(param), callbackFn, 'POST');
  132. }
  133. }
  134. };
  135. let mobPopObj = {
  136. popSpply: {
  137. popId: 'ITP_POP_MPOMNG07010_SPPLY_AREA',
  138. rows: [],
  139. init: function() {
  140. this.rows.length = 0;
  141. mobPopObj.show(this.popId);
  142. this.search();
  143. this.action();
  144. },
  145. search: function() {
  146. var _this = this;
  147. $('#ITP_POP_MPOMNG07010_LIST_SPPLY_AREA .panel-group').empty();
  148. var callbackFn = function(result) {
  149. console.log(result);
  150. _this.view(result.gridRows);
  151. };
  152. let param = $('#ITP_FORM_MPOMNG07010_POP_SPPLY_SEARCH').serializeObject();
  153. fn_ajax_call(API_POP_SPPLY_LIST, JSON.stringify(param), callbackFn, 'POST');
  154. },
  155. view: function(gridRows) {
  156. this.rows = gridRows;
  157. $.each(gridRows, function (i, item) {
  158. $('#ITP_POP_MPOMNG07010_LIST_SPPLY_AREA .panel-group').append($('#ITP_POP_MPOMNG07010_LIST_SPPLY_ROWCOPY').html());
  159. var $li = $('#ITP_POP_MPOMNG07010_LIST_SPPLY_AREA .panel-group > .row_2:last');
  160. $li.find('.fnSpplyNm').text(item.spplyNm);
  161. $li.find('.fnStNm').text($li.find('.fnStNm').text().replace('$', item.stNm));
  162. $li.find('.fnSpplyId').data('item-key', item.spplyId);
  163. });
  164. },
  165. choice: function(elem) {
  166. var _this = this;
  167. var spplyId = $(elem).data('item-key');
  168. $.each(this.rows, function (i, item) {
  169. if(spplyId === item.spplyId) {
  170. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_SPPLY_ID').val(item.spplyId);
  171. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_SPPLY_NM').val(item.spplyNm);
  172. _this.close();
  173. return false;
  174. }
  175. });
  176. },
  177. action: function() {
  178. var _this = this;
  179. $('button[id^="ITP_BTN_MPOMNG07010_POP_SPPLY"]').off('click').on('click', function() {
  180. var id = $(this).attr('id');
  181. switch (id) {
  182. case 'ITP_BTN_MPOMNG07010_POP_SPPLY_SEARCH' : _this.search(); break;
  183. case 'ITP_BTN_MPOMNG07010_POP_SPPLY_CHOICE' : _this.choice($(this)); break;
  184. case 'ITP_BTN_MPOMNG07010_POP_SPPLY_CLOSE' : _this.close(); break;
  185. }
  186. return false;
  187. });
  188. },
  189. delete: function() {
  190. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_SPPLY_ID').val('');
  191. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_SPPLY_NM').val('');
  192. },
  193. close: function() {
  194. this.rows.length = 0;
  195. $('#ITP_POP_MPOMNG07010_LIST_SPPLY_AREA .panel-group').empty();
  196. $('#ITP_FORM_MPOMNG07010_POP_SPPLY_SEARCH #ITP_FORM_MPOMNG07010_POP_SPPLY_KEYWORD').val('');
  197. mobPopObj.hide(this.popId);
  198. }
  199. },
  200. popWhsNm: {
  201. popId: 'ITP_POP_MPOMNG07010_WHS_AREA',
  202. rows: [],
  203. init: function () {
  204. this.rows.length = 0;
  205. mobPopObj.show(this.popId);
  206. this.search();
  207. this.action();
  208. },
  209. search: function () {
  210. var _this = this;
  211. $('#ITP_LIST_MPOMNG07010_POP_WHS_AREA .panel-group').empty();
  212. var callbackFn = function(result) {
  213. console.log(result);
  214. _this.view(result.gridRows);
  215. };
  216. const param = $('#ITP_FORM_MPOMNG07010_POP_WHS').serializeObject();
  217. (fn_make_user_info.get('authTpCd') === '50') ? param.swhsDvsn = 'W02' : param.swhsDvsn = '';
  218. fn_ajax_call(API_POP_SEARCH_LIST, JSON.stringify(param), callbackFn, 'POST');
  219. },
  220. view: function(gridRows) {
  221. this.rows = gridRows;
  222. $.each(gridRows, function (i, item) {
  223. $('#ITP_LIST_MPOMNG07010_POP_WHS_AREA .panel-group').append($('#ITP_LIST_MPOMNG07010_POP_WHS_ROWCOPY').html());
  224. var $li = $('#ITP_LIST_MPOMNG07010_POP_WHS_AREA .panel-group > .row_2:last');
  225. $li.find('.fnWhsNm').text(item.whsNm);
  226. $li.find('.fnLocationNm').text(item.locationNm);
  227. $li.find('.fnWhsId').data('whs-id', item.whsId);
  228. });
  229. },
  230. choice: function(elem) {
  231. var _this = this;
  232. var whsId = $(elem).data('whs-id');
  233. $.each(this.rows, function (i, item) {
  234. if(whsId === item.whsId) {
  235. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_WHS_ID').val(item.whsId);
  236. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_WHS_NM').val(item.whsNm);
  237. _this.close();
  238. return false;
  239. }
  240. });
  241. },
  242. action: function() {
  243. var _this = this;
  244. $('button[id^="ITP_BTN_MPOMNG07010_POP_WHS"]').off('click').on('click', function() {
  245. var id = $(this).attr('id');
  246. switch (id) {
  247. case 'ITP_BTN_MPOMNG07010_POP_WHS_SEARCH' : _this.search(); break;
  248. case 'ITP_BTN_MPOMNG07010_POP_WHS_CHOICE' : _this.choice($(this)); break;
  249. case 'ITP_BTN_MPOMNG07010_POP_WHS_CLOSE' : _this.close(); break;
  250. }
  251. return false;
  252. });
  253. },
  254. delete: function() {
  255. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_WHS_ID').val('');
  256. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_WHS_NM').val('');
  257. },
  258. close: function() {
  259. this.rows.length = 0;
  260. $('#ITP_POP_MPOMNG07010_LIST_WHS_AREA .panel-group').empty();
  261. $('#ITP_FORM_MPOMNG07010_POP_WHS #ITP_FORM_MPOMNG07010_POP_WHS_KEYWORD').val('');
  262. mobPopObj.hide(this.popId);
  263. }
  264. },
  265. show: function(popId) {
  266. $('button[id$="_CLOSE"]').off('click').on('click', function() {
  267. console.log($(this).attr('id'));
  268. if($(this).hasClass('btn-pop-close')) {
  269. mobPopObj.hide(popId);
  270. }
  271. });
  272. $('#' + popId).show();
  273. },
  274. hide: function(popId) {
  275. $('#' + popId).closest('.mobile-pop-close').hide();
  276. }
  277. };