ITP_MPOMNG07010.js 9.6 KB

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