ITP_MPOMNG07010.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. // 조회일자 지정
  34. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH_FROM_DT').val(itp_fn_date_add('M', -1));
  35. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH_TO_DT').val(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. }
  41. },
  42. event: {
  43. init: function() {
  44. this.button();
  45. },
  46. button: function() {
  47. $('button[id^="ITP_BTN_MPOMNG07010_LIST"]').on('click', function() {
  48. var id = $(this).attr('id');
  49. switch (id) {
  50. case 'ITP_BTN_MPOMNG07010_LIST_SEARCH_WHS_NM' : mobPopObj.popWhsNm.init(); break;
  51. case 'ITP_BTN_MPOMNG07010_LIST_DELETE_WHS_NM' : mobPopObj.popWhsNm.delete(); break;
  52. case 'ITP_BTN_MPOMNG07010_LIST_SEARCH_SPPLY_NM' : mobPopObj.popSpply.init(); break;
  53. case 'ITP_BTN_MPOMNG07010_LIST_DELETE_SPPLY_NM' : mobPopObj.popSpply.delete(); break;
  54. case 'ITP_BTN_MPOMNG07010_LIST_SEARCH' : mobContentObj.list.search(); break;
  55. }
  56. return false;
  57. });
  58. $(document).on('click', '#ITP_LIST_MPOMNG07010_LIST_ITEM_ROWS li', function() {
  59. var item = mobContentObj.list.rows[$(this).index()];
  60. mobContentObj.view.init(item);
  61. });
  62. $(document).on('click', '#ITP_POP_MPOMNG07010_LIST_SPPLY_ROWS li button', function() {
  63. mobPopObj.popSpply.choice($(this));
  64. });
  65. $(document).on('click', '#ITP_LIST_MPOMNG07010_POP_WHS_ROWS li button', function() {
  66. mobPopObj.popWhsNm.choice($(this));
  67. });
  68. }
  69. },
  70. switchScreen: function(mode) {
  71. $('#ITP_MOBILE_MPOMNG07010').find('div[id$="_CONTAINER"]').each(function(i) {
  72. $(this).hide();
  73. });
  74. if(mode === PAGE_MODE_LIST) {
  75. $('#ITP_AJAX_MPOMNG07010_LIST_CONTAINER').show();
  76. this.moreView(true);
  77. }
  78. this.viewMode = mode;
  79. },
  80. moreView: function(isScroll) {
  81. var _this = this;
  82. if(isScroll) {
  83. $('#ITP_LIST_MPOMNG07010_LIST_ITEM_AREA').on('scroll', function () {
  84. if($(this).scrollTop() + $(this).innerHeight() + 1 >= $(this)[0].scrollHeight) {
  85. if(mobContentObj.list.totPage > mobContentObj.list.listPage) {
  86. if(!mobContentObj.list.isSearch) {
  87. mobContentObj.list.load();
  88. }
  89. }
  90. }
  91. });
  92. } else {
  93. $('#ITP_LIST_MPOMNG07010_LIST_AREA').off('scroll');
  94. }
  95. },
  96. ready: function() {
  97. mobContentObj.list.init();
  98. }
  99. };
  100. let mobContentObj = {
  101. list: {
  102. listSize: 10,
  103. listPage: 0,
  104. totPage: 0,
  105. isSearch: false,
  106. rows: [],
  107. init: function() {
  108. mobPageObj.switchScreen(PAGE_MODE_LIST);
  109. this.search();
  110. },
  111. search: function() {
  112. this.listPage = 0;
  113. this.totPage = 0;
  114. this.rows.length = 0;
  115. $('#ITP_LIST_MPOMNG07010_LIST_ITEM_ROWS').empty();
  116. this.load();
  117. },
  118. load: function() {
  119. var _this = this;
  120. this.isSearch = true;
  121. var callbackFn = function(result) {
  122. console.log(result);
  123. _this.isSearch = false;
  124. _this.totPage = result.gridTotal;
  125. $.each(result.gridRows, function (i, item) {
  126. $('#ITP_LIST_MPOMNG07010_LIST_ITEM_AREA .panel-group').append($('#ITP_LIST_MPOMNG07010_LIST_ITEM_ROWCOPY').html());
  127. var $li = $('#ITP_LIST_MPOMNG07010_LIST_ITEM_AREA .panel-group > .list-row:last');
  128. $li.find('.fnPchPodrUnqNo').text(item.pchPodrUnqNo);
  129. $li.find('.fnDlvCmpltDt').text(item.dlvCmpltDt);
  130. $li.find('.fnDlvSchDt').text(item.dlvSchDt);
  131. $li.find('.fnSpplyNm').text(item.spplyNm);
  132. $li.find('.fnWhsNm').text(item.whsNm);
  133. $li.find('.fnItemNm').text(item.itemNm);
  134. $li.find('.fnPodrQty').text(CommonObj.comma.set(item.podrQty));
  135. $li.find('.fnDlvQty').text(CommonObj.comma.set(item.dlvQty));
  136. _this.rows.push(item);
  137. });
  138. };
  139. var errFn = function() { _this.isSearch = false;};
  140. const param = $('#ITP_FORM_MPOMNG07010_LIST_SEARCH').serializeObject();
  141. param.gridPage = ++this.listPage;
  142. param.gridSize = this.listSize;
  143. param.fromDt = param.fromDt.replace(/-/g, ".");
  144. param.toDt = param.toDt.replace(/-/g, ".");
  145. console.log(JSON.stringify(param));
  146. fn_ajax_call(API_MOBILE_GRID_LIST, JSON.stringify(param), callbackFn, 'POST', errFn);
  147. }
  148. }
  149. };
  150. let mobPopObj = {
  151. popSpply: {
  152. popId: 'ITP_POP_MPOMNG07010_SPPLY_AREA',
  153. rows: [],
  154. init: function() {
  155. this.rows.length = 0;
  156. mobPopObj.show(this.popId);
  157. this.search();
  158. this.action();
  159. },
  160. search: function() {
  161. var _this = this;
  162. $('#ITP_POP_MPOMNG07010_LIST_SPPLY_AREA .panel-group').empty();
  163. var callbackFn = function(result) {
  164. console.log(result);
  165. _this.view(result.gridRows);
  166. };
  167. let param = $('#ITP_FORM_MPOMNG07010_POP_SPPLY_SEARCH').serializeObject();
  168. fn_ajax_call(API_POP_SPPLY_LIST, JSON.stringify(param), callbackFn, 'POST');
  169. },
  170. view: function(gridRows) {
  171. this.rows = gridRows;
  172. $.each(gridRows, function (i, item) {
  173. $('#ITP_POP_MPOMNG07010_LIST_SPPLY_AREA .panel-group').append($('#ITP_POP_MPOMNG07010_LIST_SPPLY_ROWCOPY').html());
  174. var $li = $('#ITP_POP_MPOMNG07010_LIST_SPPLY_AREA .panel-group > .list-row:last');
  175. $li.find('.fnSpplyNm').text(item.spplyNm);
  176. $li.find('.fnStNm').text($li.find('.fnStNm').text().replace('$', item.stNm));
  177. $li.find('.fnSpplyId').data('item-key', item.spplyId);
  178. });
  179. },
  180. choice: function(elem) {
  181. var _this = this;
  182. var spplyId = $(elem).data('item-key');
  183. $.each(this.rows, function (i, item) {
  184. if(spplyId === item.spplyId) {
  185. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_SPPLY_ID').val(item.spplyId);
  186. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_SPPLY_NM').val(item.spplyNm);
  187. _this.close();
  188. return false;
  189. }
  190. });
  191. },
  192. action: function() {
  193. var _this = this;
  194. $('button[id^="ITP_BTN_MPOMNG07010_POP_SPPLY"]').off('click').on('click', function() {
  195. var id = $(this).attr('id');
  196. switch (id) {
  197. case 'ITP_BTN_MPOMNG07010_POP_SPPLY_SEARCH' : _this.search(); break;
  198. case 'ITP_BTN_MPOMNG07010_POP_SPPLY_CHOICE' : _this.choice($(this)); break;
  199. case 'ITP_BTN_MPOMNG07010_POP_SPPLY_CLOSE' : _this.close(); break;
  200. }
  201. return false;
  202. });
  203. },
  204. delete: function() {
  205. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_SPPLY_ID').val('');
  206. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_SPPLY_NM').val('');
  207. },
  208. close: function() {
  209. this.rows.length = 0;
  210. $('#ITP_POP_MPOMNG07010_LIST_SPPLY_AREA .panel-group').empty();
  211. $('#ITP_FORM_MPOMNG07010_POP_SPPLY_SEARCH #ITP_FORM_MPOMNG07010_POP_SPPLY_KEYWORD').val('');
  212. mobPopObj.hide(this.popId);
  213. }
  214. },
  215. popWhsNm: {
  216. popId: 'ITP_POP_MPOMNG07010_WHS_AREA',
  217. rows: [],
  218. init: function () {
  219. this.rows.length = 0;
  220. mobPopObj.show(this.popId);
  221. this.search();
  222. this.action();
  223. },
  224. search: function () {
  225. var _this = this;
  226. $('#ITP_LIST_MPOMNG07010_POP_WHS_AREA .panel-group').empty();
  227. var callbackFn = function(result) {
  228. console.log(result);
  229. _this.view(result.gridRows);
  230. };
  231. const param = $('#ITP_FORM_MPOMNG07010_POP_WHS').serializeObject();
  232. fn_ajax_call(API_POP_SEARCH_LIST, JSON.stringify(param), callbackFn, 'POST');
  233. },
  234. view: function(gridRows) {
  235. this.rows = gridRows;
  236. $.each(gridRows, function (i, item) {
  237. $('#ITP_LIST_MPOMNG07010_POP_WHS_AREA .panel-group').append($('#ITP_LIST_MPOMNG07010_POP_WHS_ROWCOPY').html());
  238. var $li = $('#ITP_LIST_MPOMNG07010_POP_WHS_AREA .panel-group > .list-row:last');
  239. $li.find('.fnWhsNm').text(item.whsNm);
  240. $li.find('.fnLocationNm').text(item.locationNm);
  241. $li.find('.fnWhsId').data('whs-id', item.whsId);
  242. });
  243. },
  244. choice: function(elem) {
  245. var _this = this;
  246. var whsId = $(elem).data('whs-id');
  247. $.each(this.rows, function (i, item) {
  248. if(whsId === item.whsId) {
  249. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_WHS_ID').val(item.whsId);
  250. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_WHS_NM').val(item.whsNm);
  251. _this.close();
  252. return false;
  253. }
  254. });
  255. },
  256. action: function() {
  257. var _this = this;
  258. $('button[id^="ITP_BTN_MPOMNG07010_POP_WHS"]').off('click').on('click', function() {
  259. var id = $(this).attr('id');
  260. switch (id) {
  261. case 'ITP_BTN_MPOMNG07010_POP_WHS_SEARCH' : _this.search(); break;
  262. case 'ITP_BTN_MPOMNG07010_POP_WHS_CHOICE' : _this.choice($(this)); break;
  263. case 'ITP_BTN_MPOMNG07010_POP_WHS_CLOSE' : _this.close(); break;
  264. }
  265. return false;
  266. });
  267. },
  268. delete: function() {
  269. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_WHS_ID').val('');
  270. $('#ITP_FORM_MPOMNG07010_LIST_SEARCH #ITP_FORM_MPOMNG07010_LIST_SEARCH_WHS_NM').val('');
  271. },
  272. close: function() {
  273. this.rows.length = 0;
  274. $('#ITP_POP_MPOMNG07010_LIST_WHS_AREA .panel-group').empty();
  275. $('#ITP_FORM_MPOMNG07010_POP_WHS #ITP_FORM_MPOMNG07010_POP_WHS_KEYWORD').val('');
  276. mobPopObj.hide(this.popId);
  277. }
  278. },
  279. show: function(popId) {
  280. $('button[id$="_CLOSE"]').off('click').on('click', function() {
  281. console.log($(this).attr('id'));
  282. if($(this).hasClass('btn-pop-close')) {
  283. mobPopObj.hide(popId);
  284. }
  285. });
  286. $('#' + popId).show();
  287. },
  288. hide: function(popId) {
  289. $('#' + popId).closest('.mobile-pop-close').hide();
  290. }
  291. };