ITP_INOUTMNG01010.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. require(['config'], function() {
  2. require([], function($) {
  3. pageObj.init();
  4. });
  5. });
  6. /********************************************************
  7. --------------------------------------------------------
  8. - Object 목록 -
  9. --------------------------------------------------------
  10. * const gridColModel = {} : 화면 Grid Object *
  11. * let pageObj = {} : 화면공통 Object *
  12. * let listObj = {} : 목록화면 Object *
  13. * let modifyObj = {} : 수정화면 Object *
  14. *******************************************************/
  15. /*화면 변수*/
  16. const INOUTMNG01010_GRID_ID = '#ITP_INOUTMNG01010_jqGrid';
  17. const INOUTMNG01010_GRID_LIST = '#ITP_INOUTMNG01010_jqGrid_list';
  18. const INOUTMNG01010_GRID_PAGER = '#ITP_INOUTMNG01010_jqGridPager';
  19. const INOUTMNG01010_GRID_EMPTY = '#ITP_INOUTMNG01010_jqGridEmpty';
  20. const INOUTMNG01010_DETAIL_GRID_ID = '#ITP_INOUTMNG01010_DETAIL_jqGrid';
  21. const INOUTMNG01010_DETAIL_GRID_LIST = '#ITP_INOUTMNG01010_DETAIL_jqGrid_list';
  22. const INOUTMNG01010_DETAIL_GRID_PAGER = '#ITP_INOUTMNG01010_DETAIL_jqGridPager';
  23. const INOUTMNG01010_DETAIL_GRID_EMPTY = '#ITP_INOUTMNG01010_DETAIL_jqGridEmpty';
  24. //let ITP_FORM_INOUTMNG01010_DETAIL_IS_WRITING = false;
  25. let INOUTMNG01010_GRID_LAST_ROW_ID;
  26. /*API URL*/
  27. let API_DETAIL_GRID_LIST = '/api/pomng/inoutmng/target-grid-list'; // 목록
  28. let API_DETAIL_SAVE = '/api/pomng/inoutmng/save-inst-shmt'; // 출하지시
  29. /*화면 Grid ColModel*/
  30. const gridColModel = {
  31. list: [
  32. {
  33. index: 'BRAND_ID', name: 'brandId',
  34. label: ITP_MSG_LOCALE.label.brandId, //브랜드아이디
  35. width: '13', fixed: false, align: 'center',
  36. sortable: false, hidden: true
  37. },
  38. {
  39. index: 'BRAND_NM', name: 'brandNm',
  40. label: ITP_MSG_LOCALE.label.brandNm, //브랜드명
  41. width: '10', fixed: false, align: 'left',
  42. minwidth: 100,
  43. sortable: false, hidden: false
  44. },
  45. {
  46. index: 'PCH_PODR_UNQ_NO', name: 'pchPodrUnqNo',
  47. label: ITP_MSG_LOCALE.label.pchPodrUnqNo, //구매발주번호
  48. width: '10', fixed: false, align: 'center',
  49. minwidth: 140,
  50. sortable: false, hidden: false
  51. },
  52. {
  53. index: 'PCH_PODR_DTL_NO', name: 'pchPodrDtlNo',
  54. label: ITP_MSG_LOCALE.label.pchPodrDtlNo, //구매발주항번
  55. width: '10', fixed: false, align: 'right',
  56. sortable: false, hidden: false
  57. },
  58. {
  59. index: 'ITEM_ID', name: 'itemId',
  60. label: ITP_MSG_LOCALE.label.itemId, //품목아이디
  61. width: '10', fixed: false, align: 'center',
  62. minwidth: 140,
  63. sortable: false, hidden: false
  64. },
  65. {
  66. index: 'ITEM_NM', name: 'itemNm',
  67. label: ITP_MSG_LOCALE.label.itemNm, //품목명
  68. width: '10', fixed: false, align: 'left',
  69. minwidth: 100,
  70. sortable: false, hidden: false
  71. },
  72. {
  73. index: 'WHS_ID', name: 'whsId',
  74. label: ITP_MSG_LOCALE.label.whsId, //납품창고아이디
  75. width: '13', fixed: false, align: 'center',
  76. sortable: false, hidden: true
  77. },
  78. {
  79. index: 'WHS_NM', name: 'whsNm',
  80. label: ITP_MSG_LOCALE.label.whsNm, //납품창고명
  81. width: '15', fixed: false, align: 'left',
  82. minwidth: 220,
  83. sortable: false, hidden: false
  84. },
  85. {
  86. index: 'LOCATION', name: 'location',
  87. label: ITP_MSG_LOCALE.label.location, //납품LOCATION
  88. width: '15', fixed: false, align: 'center',
  89. sortable: false, hidden: true
  90. },
  91. {
  92. index: 'UNIT_AMT', name: 'unitAmt',
  93. label: ITP_MSG_LOCALE.label.unitAmt, //단가
  94. width: '6', fixed: false, align: 'right',
  95. minwidth: 80,
  96. sortable: false, hidden: false,
  97. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  98. },
  99. {
  100. index: 'PODR_QTY', name: 'podrQty',
  101. label: ITP_MSG_LOCALE.label.podrQty, //발주수량
  102. width: '10', fixed: false, align: 'right',
  103. sortable: false, hidden: false,
  104. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  105. },
  106. {
  107. index: 'SHMT_QTY', name: 'shmtQty',
  108. label: ITP_MSG_LOCALE.label.shmtQty, //출고수량
  109. width: '10', fixed: false, align: 'right',
  110. sortable: true, editable: false, edittype: 'text',
  111. hidden: true
  112. },
  113. {
  114. index: 'STCK_QTY', name: 'stckQty',
  115. label: ITP_MSG_LOCALE.label.stckQty, //현 재고
  116. width: '10', fixed: false, align: 'right',
  117. sortable: false, hidden: false,
  118. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  119. },
  120. {
  121. index: 'EXPRY_YN', name: 'expryYn',
  122. label: ITP_MSG_LOCALE.label.expryYn, //유통기한여부
  123. width: '10', fixed: false, align: 'center',
  124. minwidth: 100,
  125. sortable: false, hidden: false
  126. },
  127. {
  128. index: 'EXPRY_PERIOD', name: 'expryPeriod',
  129. label: ITP_MSG_LOCALE.label.expryPeriod, //유통기한기간
  130. width: '10', fixed: false, align: 'center',
  131. sortable: false, hidden: true
  132. },
  133. {
  134. index: 'EXPRY_DATE', name: 'expryDate',
  135. label: ITP_MSG_LOCALE.label.expryDate, //유통일자
  136. width: '20', fixed: false, align: 'center',
  137. sortable: false, hidden: true,
  138. editable: false, sorttype: "date",
  139. editoptions: { dataInit: function(e) { $(e).datepicker(ITP_DATE_LANGUAGE); } }
  140. },
  141. {
  142. index: 'PODR_AMT', name: 'podrAmt',
  143. label: ITP_MSG_LOCALE.label.podrAmt, //발주금액
  144. width: '10', fixed: false, align: 'right',
  145. sortable: false, hidden: false,
  146. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  147. },
  148. {
  149. index: 'DLV_REQ_DT', name: 'dlvReqDt',
  150. label: ITP_MSG_LOCALE.label.dlvReqDt, //납품요청일
  151. width: '10', fixed: false, align: 'center',
  152. minwidth: 100,
  153. sortable: false, hidden: false
  154. },
  155. {
  156. index: 'SHMT_WHS_ID', name: 'shmtWhsId',
  157. label: ITP_MSG_LOCALE.label.shmtWhsId, //출고창고아이디
  158. width: '10', fixed: false, align: 'right',
  159. sortable: false, hidden: true
  160. },
  161. {
  162. index: 'SHMT_LOCATION', name: 'shmtLocation',
  163. label: ITP_MSG_LOCALE.label.shmtLocation, //출고LOCATION
  164. width: '10', fixed: false, align: 'center',
  165. sortable: false, hidden: true
  166. },
  167. {
  168. index: 'SHMT_WHS_NM', name: 'shmtWhsNm',
  169. label: ITP_MSG_LOCALE.label.shmtWhsNm, //출고창고명
  170. width: '10', fixed: false, align: 'left',
  171. minwidth: 220,
  172. sortable: false, hidden: false
  173. }
  174. ],
  175. detail: [
  176. {
  177. index: 'BRAND_ID', name: 'brandId',
  178. label: ITP_MSG_LOCALE.label.brandId, //브랜드아이디
  179. width: '13', fixed: false, align: 'center',
  180. sortable: false, hidden: true
  181. },
  182. {
  183. index: 'BRAND_NM', name: 'brandNm',
  184. label: ITP_MSG_LOCALE.label.brandNm, //브랜드명
  185. width: '10', fixed: false, align: 'center',
  186. sortable: false, hidden: false
  187. },
  188. {
  189. index: 'PCH_PODR_UNQ_NO', name: 'pchPodrUnqNo',
  190. label: ITP_MSG_LOCALE.label.pchPodrUnqNo, //구매발주번호
  191. width: '10', fixed: false, align: 'center',
  192. sortable: false, hidden: false
  193. },
  194. {
  195. index: 'PCH_PODR_DTL_NO', name: 'pchPodrDtlNo',
  196. label: ITP_MSG_LOCALE.label.pchPodrDtlNo, //구매발주항번
  197. width: '10', fixed: false, align: 'center',
  198. sortable: false, hidden: false
  199. },
  200. {
  201. index: 'ITEM_ID', name: 'itemId',
  202. label: ITP_MSG_LOCALE.label.itemId, //품목아이디
  203. width: '10', fixed: false, align: 'center',
  204. sortable: false, hidden: false
  205. },
  206. {
  207. index: 'ITEM_NM', name: 'itemNm',
  208. label: ITP_MSG_LOCALE.label.itemNm, //품목명
  209. width: '10', fixed: false, align: 'left',
  210. sortable: false, hidden: false
  211. },
  212. {
  213. index: 'WHS_ID', name: 'whsId',
  214. label: ITP_MSG_LOCALE.label.whsId, //납품창고아이디
  215. width: '13', fixed: false, align: 'center',
  216. sortable: false, hidden: true
  217. },
  218. {
  219. index: 'WHS_NM', name: 'whsNm',
  220. label: ITP_MSG_LOCALE.label.whsNm, //납품창고명
  221. width: '15', fixed: false, align: 'left',
  222. sortable: false, hidden: false
  223. },
  224. {
  225. index: 'LOCATION', name: 'location',
  226. label: ITP_MSG_LOCALE.label.location, //납품LOCATION
  227. width: '15', fixed: false, align: 'center',
  228. sortable: false, hidden: true
  229. },
  230. {
  231. index: 'UNIT_AMT', name: 'unitAmt',
  232. label: ITP_MSG_LOCALE.label.unitAmt, //단가
  233. width: '6', fixed: false, align: 'right',
  234. sortable: false, hidden: false,
  235. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  236. },
  237. {
  238. index: 'PODR_QTY', name: 'podrQty',
  239. label: ITP_MSG_LOCALE.label.podrQty, //발주수량
  240. width: '10', fixed: false, align: 'right',
  241. sortable: false, hidden: false,
  242. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  243. },
  244. {
  245. index: 'SHMT_QTY', name: 'shmtQty',
  246. label: ITP_MSG_LOCALE.label.shmtQty, //출고수량
  247. width: '10', fixed: false, align: 'right',
  248. sortable: true, editable: true, edittype: 'text',
  249. editrules: { required: true, number: true },
  250. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  251. },
  252. {
  253. index: 'STCK_QTY', name: 'stckQty',
  254. label: ITP_MSG_LOCALE.label.stckQty, //현 재고
  255. width: '10', fixed: false, align: 'right',
  256. sortable: false, hidden: false,
  257. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  258. },
  259. {
  260. index: 'EXPRY_YN', name: 'expryYn',
  261. label: ITP_MSG_LOCALE.label.expryYn, //유통기한여부
  262. width: '10', fixed: false, align: 'center',
  263. sortable: false, hidden: false
  264. },
  265. {
  266. index: 'EXPRY_PERIOD', name: 'expryPeriod',
  267. label: ITP_MSG_LOCALE.label.expryPeriod, //유통기한기간
  268. width: '10', fixed: false, align: 'center',
  269. sortable: false, hidden: true
  270. },
  271. {
  272. index: 'EXPRY_DATE', name: 'expryDate',
  273. label: ITP_MSG_LOCALE.label.expryDate, //유통일자
  274. width: '20', fixed: false, align: 'center',
  275. sortable: false, hidden: false,
  276. editable: true, sorttype: "date",
  277. editoptions: { dataInit: function(e) { $(e).datepicker(ITP_DATE_LANGUAGE); } }
  278. },
  279. {
  280. index: 'PODR_AMT', name: 'podrAmt',
  281. label: ITP_MSG_LOCALE.label.podrAmt, //발주금액
  282. width: '10', fixed: false, align: 'right',
  283. sortable: false, hidden: false,
  284. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  285. },
  286. {
  287. index: 'DLV_REQ_DT', name: 'dlvReqDt',
  288. label: ITP_MSG_LOCALE.label.dlvReqDt, //납품요청일
  289. width: '10', fixed: false, align: 'center',
  290. sortable: false, hidden: false
  291. },
  292. {
  293. index: 'SHMT_WHS_ID', name: 'shmtWhsId',
  294. label: ITP_MSG_LOCALE.label.shmtWhsId, //출고창고아이디
  295. width: '10', fixed: false, align: 'right',
  296. sortable: false, hidden: true
  297. },
  298. {
  299. index: 'SHMT_LOCATION', name: 'shmtLocation',
  300. label: ITP_MSG_LOCALE.label.shmtLocation, //출고LOCATION
  301. width: '10', fixed: false, align: 'center',
  302. sortable: false, hidden: true
  303. },
  304. {
  305. index: 'SHMT_WHS_NM', name: 'shmtWhsNm',
  306. label: ITP_MSG_LOCALE.label.shmtWhsNm, //출고창고명
  307. width: '10', fixed: false, align: 'center',
  308. sortable: false, hidden: false
  309. }
  310. ]
  311. };
  312. /*화면공통 Object*/
  313. let pageObj = {
  314. init: function () {
  315. this.ui.init();
  316. this.event.init();
  317. this.action();
  318. },
  319. ui: {
  320. init: function () {
  321. this.view();
  322. this.grid();
  323. this.ready();
  324. },
  325. view: function() {
  326. // 버튼 권한설정
  327. fn_proc_btn_auth('INOUTMNG01010');
  328. // 공통코드 표시
  329. $('select').each(function() {
  330. if($(this).data('select-code')) {
  331. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  332. }
  333. });
  334. // 조회일자 지정
  335. var now = new Date();
  336. $('#ITP_TAB_INOUTMNG01010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  337. $('#ITP_FORM_INOUTMNG01010_SEARCH_FROM_DT').datepicker('setDate', new Date(now.setDate(now.getDate())));
  338. $('#ITP_FORM_INOUTMNG01010_SEARCH_TO_DT').datepicker('setDate', new Date(now.setDate(now.getDate() + 30)));
  339. },
  340. grid: function() {
  341. itp_fn_jqgrid_resize(INOUTMNG01010_GRID_ID, INOUTMNG01010_GRID_LIST, 'lg');
  342. //listObj.empty.init();
  343. itp_fn_fire_window_resize();
  344. },
  345. ready: function() {
  346. listObj.init();
  347. }
  348. },
  349. action: function () {
  350. var _this = this;
  351. // 출하창고 조회 버튼 클릭
  352. $('#ITP_FORM_INOUTMNG01010_SEARCH_SHMT_WHS_NM').on('click', function() {
  353. _this.popup('S');
  354. });
  355. // 출하창고 텍스트 삭제 버튼 클릭
  356. $('#ITP_FORM_INOUTMNG01010_DELETE_SHMT_WHS_NM').on('click', function() {
  357. $('#ITP_FORM_INOUTMNG01010_SEARCH_SSHMT_WHS_NM').val('');
  358. $('#ITP_FORM_INOUTMNG01010_SEARCH_SSHMTWHS_ID').val('');
  359. });
  360. // 납품장소 조회 버튼 클릭
  361. $('#ITP_FORM_INOUTMNG01010_SEARCH_WHS_NM').on('click', function() {
  362. _this.popup('W');
  363. });
  364. // 납품장소 텍스트 삭제 버튼 클릭
  365. $('#ITP_FORM_INOUTMNG01010_DELETE_WHS_NM').on('click', function() {
  366. $('#ITP_FORM_INOUTMNG01010_SEARCH_SWHS_NM').val('');
  367. $('#ITP_FORM_INOUTMNG01010_SEARCH_SWHS_ID').val('');
  368. });
  369. },
  370. popup: function (arg) {
  371. var popFn;
  372. // 팝업
  373. if (arg == "S") {
  374. popFn = this.callback.shmtwhs;
  375. } else {
  376. popFn = this.callback.whs;
  377. }
  378. var whsDvsn = "";
  379. if (arg == "S") {
  380. whsDvsn = "W01";
  381. } else {
  382. whsDvsn = "W02";
  383. }
  384. const key = { brandId: fn_make_user_info.get('brandId'), storeId: fn_make_user_info.get('storeId'), whsDvsn: whsDvsn };
  385. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key, 'S');
  386. },
  387. callback: {
  388. shmtwhs: function(rowDataPop) {
  389. if (rowDataPop) {
  390. $('#ITP_FORM_INOUTMNG01010_SEARCH_SSHMT_WHS_NM').val(rowDataPop.whsNm);
  391. $('#ITP_FORM_INOUTMNG01010_SEARCH_SSHMTWHS_ID').val(rowDataPop.whsId);
  392. }
  393. },
  394. whs: function(rowDataPop) {
  395. if (rowDataPop) {
  396. $('#ITP_FORM_INOUTMNG01010_SEARCH_SWHS_NM').val(rowDataPop.whsNm);
  397. $('#ITP_FORM_INOUTMNG01010_SEARCH_SWHS_ID').val(rowDataPop.whsId);
  398. }
  399. }
  400. },
  401. event: {
  402. init: function () {
  403. this.button();
  404. },
  405. button: function () {
  406. // 버튼 클릭 이벤트
  407. $('button').each(function() {
  408. var id = $(this).attr('id');
  409. $(this).on('click', function() {
  410. switch (id) {
  411. case 'ITP_BTN_INOUTMNG01010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  412. case 'ITP_BTN_INOUTMNG01010_OUC' : listObj.button.shmtcreat(); break; // 출하생성 버튼
  413. case 'ITP_BTN_INOUTMNG01010_OUT' : modifyObj.button.save(); break; // 출하지시 버튼
  414. case 'ITP_BTN_INOUTMNG01010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼
  415. case 'ITP_BTN_INOUTMNG01010_EXCEL' : listObj.excelDown(); break; // 엑셀다운로드
  416. }
  417. });
  418. });
  419. $('body').on('click', function(e) {
  420. var gridId = (INOUTMNG01010_DETAIL_GRID_ID).replace('#', '');
  421. var rids = $(INOUTMNG01010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  422. var last_row_id = rids[rids.length - 1];
  423. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'INOUTMNG01010_DETAIL');
  424. });
  425. }
  426. },
  427. switchScreen: function(mode) {
  428. $('.itp_det_head').find('button[id^="ITP_BTN_INOUTMNG01010_"]').each(function(i) {
  429. $(this).hide();
  430. });
  431. $('#ITP_TAB_INOUTMNG01010').find('div[id$="_CONTAINER"]').each(function(i) {
  432. $(this).hide();
  433. });
  434. if(mode == 'LIST') { // 목록
  435. $('#ITP_AJAX_INOUTMNG01010_LIST_CONTAINER').show();
  436. $('#ITP_FORM_INOUTMNG01010_DELETE_SHMT_WHS_NM').show();
  437. $('#ITP_FORM_INOUTMNG01010_DELETE_WHS_NM').show();
  438. fn_show_btn_auth_array(['#ITP_BTN_INOUTMNG01010_SRH', '#ITP_BTN_INOUTMNG01010_OUC']);
  439. $('#ITP_FORM_INOUTMNG01010_DETAIL_SBRAND_ID').val(fn_make_user_info.get('brandId'));
  440. $('#ITP_BTN_INOUTMNG01010_EXCEL').show();
  441. } else if(mode == 'DETAIL') { // 출하지시 상세
  442. $('#ITP_AJAX_INOUTMNG01010_DETAIL_CONTAINER').show();
  443. fn_show_btn_auth_array(['#ITP_BTN_INOUTMNG01010_OUT', '#ITP_BTN_INOUTMNG01010_CANCELLIST']);
  444. $('#ITP_FORM_INOUTMNG01010_DETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
  445. //pageObj.grid.init(param);
  446. }
  447. },
  448. grid: {
  449. init: function(param) {
  450. this.gridId = INOUTMNG01010_DETAIL_GRID_ID;
  451. this.gridList = INOUTMNG01010_DETAIL_GRID_LIST;
  452. this.gridEmpty = INOUTMNG01010_DETAIL_GRID_EMPTY;
  453. var now = new Date();
  454. $('#ITP_TAB_INOUTMNG01010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  455. $('#ITP_FORM_INOUTMNG01010_DETAIL_DLV_SCH_DT').datepicker('setDate', new Date(param.dlvSchDt));
  456. $('#ITP_FORM_INOUTMNG01010_DETAIL .fnBrandNm').text(param.brandNm);
  457. this.gridRows = param.recordData;
  458. this.unload();
  459. this.load(param.recordData);
  460. },
  461. gridId: '',
  462. button: {},
  463. gridList: '',
  464. gridEmpty: '',
  465. gridRows: '',
  466. load: function(gridRows) {
  467. var _this = this;
  468. var option = {
  469. gridId: _this.gridId,
  470. colModel: gridColModel.detail,
  471. data: gridRows,
  472. loadComplete: function(data) {
  473. $(INOUTMNG01010_DETAIL_GRID_LIST).find('.ui-jqgrid .ui-jqgrid-bdiv').css('overflow-x', 'hidden');
  474. data.records === 0 ? _this.clearData(mode) : $(INOUTMNG01010_DETAIL_GRID_EMPTY).hide();
  475. },
  476. onCellSelect: function(rowid, cellIdx, cellValue) {
  477. INOUTMNG01010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowid, cellIdx, INOUTMNG01010_GRID_LAST_ROW_ID, _this.gridId, ['pchReqDtlNo']);
  478. }
  479. };
  480. itp_fn_grid_make_local(option);
  481. },
  482. clearData : function(mode) {
  483. $(INOUTMNG01010_DETAIL_GRID_ID).jqGrid('clearGridData', true);
  484. $(INOUTMNG01010_DETAIL_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  485. $(INOUTMNG01010_DETAIL_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  486. $(INOUTMNG01010_DETAIL_GRID_EMPTY).show();
  487. },
  488. unload : function() {
  489. $.jgrid.gridUnload(this.gridId);
  490. }
  491. }
  492. };
  493. /*목록화면 Object*/
  494. let listObj = {
  495. init: function () {
  496. this.grid.init();
  497. },
  498. itp_INOUTMNG01010_search: false,
  499. button: {
  500. search: function() {
  501. listObj.itp_INOUTMNG01010_search = true;
  502. let param = $('#ITP_FORM_INOUTMNG01010_SEARCH').serializeObject();
  503. param.gridSize = $.jgrid.defaults.rowNum;
  504. param.gridPage = $.jgrid.defaults.page;
  505. $(INOUTMNG01010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  506. },
  507. shmtcreat: function() {
  508. //선택되어진 row 값 전송할예정
  509. let gridUpdateData = [];
  510. const rowKey = $(INOUTMNG01010_GRID_ID).getGridParam('selrow');
  511. if (!rowKey) {
  512. return;
  513. }
  514. var selectedIds = $(INOUTMNG01010_GRID_ID).getGridParam('selarrrow');
  515. var brandNm = "";
  516. var maxDlvSchDt = "";
  517. for (var i=selectedIds.length-1; i>=0; i--) {
  518. var rowData = $(INOUTMNG01010_GRID_ID).jqGrid('getRowData', selectedIds[i]);
  519. gridUpdateData.push(rowData);
  520. if (rowData.dlvReqDt > maxDlvSchDt) {
  521. maxDlvSchDt = rowData.dlvReqDt;
  522. }
  523. sbrandNm =rowData.brandNm;
  524. }
  525. let param = {brandNm: sbrandNm, dlvSchDt: maxDlvSchDt };
  526. param.recordData = gridUpdateData;
  527. pageObj.switchScreen('DETAIL');
  528. itp_fn_form_clear_validate(null, '#ITP_FORM_INOUTMNG01010_DETAIL');
  529. pageObj.grid.init(param);
  530. }
  531. },
  532. empty: {
  533. init: function() {
  534. /*
  535. var _this = this;
  536. this.push();
  537. $(INOUTMNG01010_GRID_EMPTY).on('click', function() {
  538. _this.back();
  539. _this.itp_INOUTMNG01010_param.gridSize = $.jgrid.defaults.rowNum;
  540. $(INOUTMNG01010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_INOUTMNG01010_param)}).trigger('reloadGrid');
  541. });
  542. */
  543. },
  544. itp_INOUTMNG01010_param: {},
  545. push: function() {
  546. /*
  547. let param = $('#ITP_FORM_INOUTMNG01010_SEARCH').serializeObject();
  548. listObj.itp_INOUTMNG01010_param = param;
  549. */
  550. },
  551. back: function() {
  552. /*
  553. $('#ITP_FORM_INOUTMNG01010_SEARCH_FROM_DT').val(this.itp_INOUTMNG01010_param.fromDt);
  554. $('#ITP_FORM_INOUTMNG01010_SEARCH_TO_DT').val(this.itp_INOUTMNG01010_param.toDt);
  555. $('#ITP_FORM_INOUTMNG01010_SEARCH_SSHMTWHS_ID').val(this.itp_INOUTMNG01010_param.sshmtWhsId);
  556. $('#ITP_FORM_INOUTMNG01010_SEARCH_SSHMT_WHS_NM').val(this.itp_INOUTMNG01010_param.sshmtWhsNm);
  557. $('#ITP_FORM_INOUTMNG01010_SEARCH_SWHS_NM').val(this.itp_INOUTMNG01010_param.swhsNm);
  558. $('#ITP_FORM_INOUTMNG01010_SEARCH_SWHS_ID').val(this.itp_INOUTMNG01010_param.swhsId);
  559. $('#ITP_FORM_INOUTMNG01010_SEARCH_ITEM_NM').val(this.itp_INOUTMNG01010_param.sItemNm);
  560. */
  561. }
  562. },
  563. grid: {
  564. init: function () {
  565. // 데이터 없을때
  566. listObj.empty.push();
  567. itp_fn_jqgrid_resize(INOUTMNG01010_GRID_ID, INOUTMNG01010_GRID_LIST, 'lg');
  568. itp_fn_fire_window_resize();
  569. this.search();
  570. },
  571. colModel: gridColModel.list,
  572. search: function() {
  573. pageObj.switchScreen('LIST');
  574. this.unload();
  575. this.load();
  576. },
  577. load: function() {
  578. let param = $('#ITP_FORM_INOUTMNG01010_SEARCH').serializeObject();
  579. param.gridSize = $.jgrid.defaults.rowNum;
  580. var option = {
  581. multiselect: true,
  582. autowidth: true,
  583. gridId: INOUTMNG01010_GRID_ID,
  584. colModel: gridColModel.list,
  585. param: param,
  586. url: DOMAIN + API_DETAIL_GRID_LIST,
  587. pager: INOUTMNG01010_GRID_PAGER,
  588. loadComplete: function(data) {
  589. itp_fn_grid_load_complete(data, INOUTMNG01010_GRID_ID, true, 'number', 'INOUTMNG01010', listObj.itp_INOUTMNG01010_search, listObj.empty, true, data.gridRecords, true);
  590. },
  591. onPaging: function(action) {
  592. itp_fn_grid_paging(INOUTMNG01010_GRID_ID, action, param);
  593. }
  594. };
  595. itp_fn_grid_make_remote(option);
  596. },
  597. button: {
  598. },
  599. unload : function() {
  600. $.jgrid.gridUnload(INOUTMNG01010_GRID_ID);
  601. },
  602. clearData : function() {
  603. $(INOUTMNG01010_GRID_ID).jqGrid('clearGridData', true);
  604. $(INOUTMNG01010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  605. $(INOUTMNG01010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  606. $(INOUTMNG01010_GRID_EMPTY).show();
  607. }
  608. },
  609. excelDown: function() {
  610. var param = {
  611. 'url': API_DETAIL_GRID_LIST,
  612. 'param': $('#ITP_FORM_INOUTMNG01010_SEARCH').serializeObject(),
  613. 'gridColumns': $(INOUTMNG01010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  614. 'fileName': '출하지시대상정보.xlsx',
  615. 'sheetName': '출하지시대상리스트'
  616. };
  617. itp_fn_remote_to_excel(param);
  618. }
  619. };
  620. /*수정화면 Object*/
  621. let modifyObj = {
  622. init: function (param) {
  623. this.load(param);
  624. },
  625. button: {
  626. modify: function (param) {
  627. itp_fn_form_clear_validate(null, '#ITP_FORM_INOUTMNG01010_DETAIL');
  628. //const selectVal = $('#ITP_FORM_INOUTMNG01010_VIEW_STORE_ID').val();
  629. //const key = {brandId:fn_make_user_info.get('brandId'), storeId: selectVal, viewCd: 'R'};
  630. //var param = $.param(key);
  631. //modifyObj.load(param);
  632. },
  633. cancel: function() {
  634. document.getElementById('ITP_FORM_INOUTMNG01010_DETAIL').reset();
  635. listObj.grid.search();
  636. },
  637. save: function() {
  638. $('body').trigger('click');
  639. const formId = ('#ITP_FORM_INOUTMNG01010_DETAIL');
  640. itp_fn_form_clear_validate(null, formId);
  641. if (itp_fn_form_event.isValid(formId)) {
  642. var modalFn = {
  643. callBack: () => {
  644. itp_fn_form_event.removeChar('#ITP_FORM_INOUTMNG01010_DETAIL');
  645. var chkQtyYn = "N";
  646. let gridInsertData = [];
  647. const rowData = $(INOUTMNG01010_DETAIL_GRID_ID).getRowData();
  648. $.each(rowData, function(key, value) {
  649. if (value.shmtQty == '' || parseInt(value.shmtQty) < 1 ) {
  650. alert("출고수량을 입력해주세요!");
  651. chkQtyYn = "Y";
  652. return false;
  653. }
  654. if (parseInt(value.stckQty) < parseInt(value.shmtQty)) {
  655. alert("출고지시할 수량이 부족합니다.");
  656. chkQtyYn = "Y";
  657. return false;
  658. }
  659. if (parseInt(value.podrQty) < parseInt(value.shmtQty) ) {
  660. alert("출고수량이 발주수량보다 클수 없습니다!");
  661. chkQtyYn = "Y";
  662. return false;
  663. }
  664. gridInsertData.push(value);
  665. });
  666. if (chkQtyYn == "Y") return;
  667. let param = $(formId).serializeObject();
  668. param.viewCd = "C";
  669. param.gridInsertData = gridInsertData;
  670. console.log(JSON.stringify(param));
  671. var searhFn = function () {
  672. //ITP_FORM_INOUTMNG01010_DETAIL_IS_WRITING = false;
  673. pageObj.grid.clearData();
  674. modifyObj.button.cancel();
  675. }
  676. fn_ajax_call(API_DETAIL_SAVE, JSON.stringify(param), searhFn, 'POST');
  677. }
  678. };
  679. itp_fn_modal_confirm('출하지시 하시겠습니까?', modalFn);
  680. }
  681. }
  682. },
  683. load: function(param) {
  684. //console.log(param);
  685. //pageObj.grid.load("DETAIL",param);
  686. }
  687. };