Kaynağa Gözat

재고실사 엑셀업로드 개발중

marseyes 2 yıl önce
ebeveyn
işleme
4546924cbf

+ 49 - 4
src/main/webapp/js/app/stockmng/ITP_STOCKMNG02010.js

@@ -196,6 +196,20 @@ const gridColModel = {
196 196
 			width: '10', fixed: false, align: 'center',
197 197
 			sortable: false, hidden: true
198 198
 		},
199
+		{
200
+			index: 'NORMAL_YN', name: 'normalYn',
201
+			label: "정상여부",
202
+			width: '5', fixed: false, align: 'center',
203
+			sortable: false, editable: false, edittype: 'text',
204
+			editrules: {required: false}
205
+		},
206
+		{
207
+			index: 'ERROR_MSG', name: 'errorMsg',
208
+			label: "에러메시지",
209
+			width: '10', fixed: false, align: 'center',
210
+			sortable: false, editable: false, edittype: 'text',
211
+			editrules: {required: false}
212
+		},
199 213
 		{
200 214
 			index: 'BRAND_NM', name: 'brandNm',
201 215
 			label: "브랜드",
@@ -652,11 +666,21 @@ let stockCddObj = {
652 666
 		        var firstSheetName = sheetNameList[0]; // 첫번째 시트명
653 667
 		        var firstSheet = wb.Sheets[firstSheetName]; // 첫번째 시트 
654 668
 		        var rowObj =XLSX.utils.sheet_to_json(firstSheet, {header:"A", defval: ""});
669
+
670
+				// console.log(JSON.stringify(rowObj));
671
+				// console.log(rowObj.length);
672
+				
673
+				$('#ITP_FORM_STOCKMNG02010_DETAIL_EXCEL_UPLOAD_SELECT_FILE').val('');
674
+				if(rowObj.length < 2) {
675
+					itp_fn_modal_alert_ajax('엑셀파일에 실사 품목 데이터를 기술하세요.');
676
+					return;
677
+				} else if(rowObj.length > 1001) {
678
+					itp_fn_modal_alert_ajax('엑셀 일괄처리는 최대 1000건까지 가능합니다.');
679
+					return;
680
+				}				
655 681
 				
656
-				console.log(JSON.stringify(rowObj));
657
-				// console.log(rowObj);
658 682
 				// console.log(Object.keys(rowObj[0]).length);
659
-				// makeExcelDataList(rowObj);
683
+				stockCddObj.button.makeExcelDataList(rowObj);				
660 684
 		    };
661 685
 		    if(rABS) reader.readAsBinaryString(input.files[0]); 
662 686
 			else reader.readAsArrayBuffer(input.files[0]);			
@@ -674,6 +698,26 @@ let stockCddObj = {
674 698
 			var lidx = window.location.href.lastIndexOf('/');
675 699
 			window.location.assign(window.location.href.substring(0, lidx) + '/excel_template/stock_cdd_v1.xlsx');
676 700
 		}, 
701
+		makeExcelDataList: function(excelData) {
702
+			var processArray = [];
703
+			
704
+			excelData.shift();
705
+			excelData.some(function(data) {
706
+				var processData = {};				
707
+				processData.itemId 	= data.A.toString();		
708
+				processData.itemNm 	= data.B.toString();
709
+				processData.cddQty 	= data.C.toString();
710
+				
711
+				processArray.push(processData);
712
+			});
713
+			
714
+			$.each(processArray, function(key, value) {
715
+				// $(KFRGD02010_EXCEL_UPLOAD_GRID_ID).jqGrid("addRowData", rowId + 1, value, 'last');
716
+				console.log(JSON.stringify(value));	
717
+			});
718
+			
719
+			// 엑셀 목록을 서버에서 조회한다.
720
+		}, 
677 721
 		addRow: function() {
678 722
 			var brandId = $('#ITP_FORM_STOCKMNG02010_DETAIL_BRAND_ID').val();
679 723
 			var whsId = $('#ITP_FORM_STOCKMNG02010_DETAIL_WHS_ID').val();
@@ -705,6 +749,7 @@ let stockCddObj = {
705 749
 					var rids = $(STOCKMNG02010_DETAIL_GRID_ID).jqGrid('getDataIDs');
706 750
 					var last_row_id = rids[rids.length - 1];
707 751
 					$(STOCKMNG02010_DETAIL_GRID_ID).jqGrid('setCell', last_row_id, 'viewCd', 'C');					
752
+					$(STOCKMNG02010_DETAIL_GRID_ID).jqGrid('setCell', last_row_id, 'normalYn', 'Y'); // 정상여부
708 753
 					$(STOCKMNG02010_DETAIL_GRID_ID).jqGrid('setCell', last_row_id, 'brandId', brandId);
709 754
 					$(STOCKMNG02010_DETAIL_GRID_ID).jqGrid('setCell', last_row_id, 'brandNm', brandNm);
710 755
 					$(STOCKMNG02010_DETAIL_GRID_ID).jqGrid('setCell', last_row_id, 'whsId', whsId);
@@ -770,7 +815,7 @@ let stockCddObj = {
770 815
 			param: JSON.stringify(param),
771 816
 			url: DOMAIN + WHS_MNG_LOCATION_GRID_LIST,
772 817
 			pager: STOCKMNG02010_DETAIL_GRID_PAGER,
773
-			multiselect: true,
818
+			// multiselect: true,
774 819
 			onCellSelect: function(rowId, cellIdx, cellValue) {
775 820
 				STOCKMNG02010_DETAIL_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowId, cellIdx, STOCKMNG02010_DETAIL_GRID_LAST_ROW_ID, STOCKMNG02010_DETAIL_GRID_ID);
776 821
 	   		},