Index: arms/js/analysisCost.js =================================================================== diff -u -r073579fd548d6af80626439ce3204814a00f27b6 -rd346944f3b0c03ca470ae52bb25a0861eeb6dea9 --- arms/js/analysisCost.js (.../analysisCost.js) (revision 073579fd548d6af80626439ce3204814a00f27b6) +++ arms/js/analysisCost.js (.../analysisCost.js) (revision d346944f3b0c03ca470ae52bb25a0861eeb6dea9) @@ -76,13 +76,15 @@ "./js/common/chart/d3/sankey.js" ], [ - "https://fonts.googleapis.com/css?family=Material+Icons", "../reference/jquery-plugins/jspreadsheet-ce-4.13.1/dist/jsuites.js", - "../reference/jquery-plugins/jspreadsheet-ce-4.13.1/dist/jsuites.css", "../reference/jquery-plugins/jspreadsheet-ce-4.13.1/dist/index.js", + "../reference/jquery-plugins/jspreadsheet-ce-4.13.1/dist/jsuites.css", "../reference/jquery-plugins/jspreadsheet-ce-4.13.1/dist/jspreadsheet.css", - // "../reference/jquery-plugins/jspreadsheet-ce-4.13.1/dist/jspreadsheet.datatables.css", - "../reference/jquery-plugins/jspreadsheet-ce-4.13.1/dist/jspreadsheet.theme.css" + "../reference/jquery-plugins/jspreadsheet-ce-4.13.1/dist/jspreadsheet.datatables.css", + "../reference/jquery-plugins/jspreadsheet-ce-4.13.1/dist/jspreadsheet.theme.css", + "./css/jspreadsheet/custom_sheet.css", + "./css/jspreadsheet/custom_icon.css", + "./js/common/jspreadsheet/spreadsheet.js" ] // 추가적인 플러그인 그룹들을 이곳에 추가하면 됩니다. ]; @@ -602,7 +604,8 @@ }); console.log(" [ analysisCost :: manpowerInput ] :: 인력별_연봉정보 => " + JSON.stringify(인력별_연봉정보)); - jspreadsheetRender(인력별_연봉정보); + drawExcel("spreadsheet", 인력별_연봉정보); + //jspreadsheetRender(인력별_연봉정보); // 템플릿 다운로드 excel_download(인력별_연봉정보); @@ -1487,6 +1490,116 @@ window.addEventListener('resize', myChart.resize); } +///////////////////////////////////////////////////// +// 엑셀 그리기 +///////////////////////////////////////////////////// +function drawExcel(targetId, data) { + console.log("analysisCost :: drawExcel"); + console.log(data); + let $targetId = "#" + targetId; + + if($($targetId)[0].jexcel) { + console.log($($targetId)[0].jexcel); + $($targetId)[0].jexcel.destroy(); + } + console.log("width=> " + $($targetId).width()); + var excelWidth=$($targetId).width() - 50; + + var columnList = [ + { type: "text", title: "이름", wRatio: 0.25, readOnly: true }, + { type: "text", title: "키", wRatio: 0.25, readOnly: true }, + { type: "text", title: "연봉", wRatio: 0.5 } + ]; + + SpreadSheetFunctions.setColumns(columnList); + SpreadSheetFunctions.setColumnWidth(excelWidth); + + var customOptions = { + toolbar:false, + pagination:10, + allowInsertColumn: false, + updateTable: function(instace, cell, col, row, val, id) { + cell.classList.add("cell-content"); + + cell.style.whiteSpace = "normal"; + if(col === 2) { + cell.style.textAlign = "right"; + } else { + cell.style.textAlign = "left"; + } + }, + onchange: function(instance, cell, x, y, value) { + var cellName = jspreadsheet.getColumnNameFromId([x,y]); + console.log('onchange :: ' + cell + " :; x :: " + x + " :: y :: " + y +" :: cellName ::" + cellName + ' to: ' + value + '\n'); + if (x == 2) { + var key = instance.jexcel.getValueFromCoords(1, y); + if (!modifiedRows[key]) { + modifiedRows[key] = {}; + } + modifiedRows[key].이름 = instance.jexcel.getValueFromCoords(0, y); + modifiedRows[key].키 = instance.jexcel.getValueFromCoords(1, y); + modifiedRows[key].연봉 = value; + } + } + }; + + SpreadSheetFunctions.setExcelData(data); + SpreadSheetFunctions.setOptions(customOptions); + + $($targetId).spreadsheet($.extend({}, { + columns: SpreadSheetFunctions.getColumns(), + data: SpreadSheetFunctions.getExcelData() + }, SpreadSheetFunctions.getOptions())); + +} + +var SpreadSheetFunctions = ( function () { + let $tabFunction_data; // 엑셀 데이터 + let $tabFunction_columns;// 엑셀 컬럼 + let $tabFunction_options;// 엑셀 (커스텀)옵션 :: 정의 안할 경우 default + let $sheetInstance; + var setESheet = function(obj) { + $sheetInstance = obj; + }; + var setExcelData = function(data) { + $tabFunction_data = data; + }; + var getExcelData = function () { + return $tabFunction_data; + }; + var setColumns = function(columns) { + console.log("setColumns"); + $tabFunction_columns = columns; + }; + var getColumns = function () { + return $tabFunction_columns; + }; + var setOptions = function(options) { + $tabFunction_options = options; + }; + var getOptions = function() { + return $tabFunction_options ? $tabFunction_options : null; + }; + + var setColumnWidth = function (width) { + console.log("setColumnWidth"); + console.log($tabFunction_columns); + $tabFunction_columns = $tabFunction_columns.map(column => ({ + ...column, width: width * column.wRatio + })); + console.log($tabFunction_columns); + }; + + + + return { + setExcelData, getExcelData, + setColumns, getColumns, + setOptions, getOptions, + setColumnWidth + }; +})(); + function jspreadsheetRender(data) { var spreadsheetElement = document.getElementById("spreadsheet"); @@ -1587,6 +1700,8 @@ $(document).ready(function() { $("#cost-excel-batch-update").on('click', function() { + + console.log(modifiedRows); if (Object.keys(modifiedRows).length === 0) { jError("수정된 연봉 데이터가 없습니다."); return;