//Grid용 클래스. 블록 처리용 class Tb_class { constructor(){ let _this = this; _this.tblList = ""; _this.ajax_url = "./subul.ajax.php"; } //리스트 로드 getMainList (sdata) { let _this = this; let talert = window.setTimeout(function () { _this.tblList.alert("Loading ...") }, 1000); //1초 이상 지연되면 로딩 출력 ajax_json({ url: _this.ajax_url, data: { mode: 'getSubulList', DATE: sdata||'', }, success: function (data) { if (data.code) { _this.tblList.setData(data.data); }else{ kuls_alert(data.mesg); } }, error: function (request, status, error) { kuls_alert(error.message); }, complete: function () { window.clearTimeout(talert); _this.tblList.clearAlert(); _this.setFilter(); } }); return true; }; //검색 조건 Clear clearInput (){ let _this = this; _this.setFilter(); }; setFilter () { return false; let _this = this; _this.tblList.setFilter(function(data){ //필터링 return ( true //&& ( (data.WRK_FACLT_CD).search(document.getElementById("S_FACLT_NM").value) !== -1 ) //&& ( (!stdate || stdate <= data['WORK_DT']) && (!endate || endate >= data['WORK_DT']) ) //&& ( !sval && !data.WO_NO || sval && data.WO_NO && ( (data.WO_NO).search(sval) !== -1 ) ) ) }, '=', true); }; //Row 추가 addRow(){ let _this = this; } //Row 클릭 콜백 rowClick (e, tgt){ let _this = this; }; //Cell 클릭 콜백 cellClick (e, tgt){ let _this = this; }; //Cell 변경 콜백 cellEdited (cell){ let _this = this; }; //시작 실행 init () { let _this = this; const fields = [ { formatter:"rownum", title: "No", width: "4%", }, { field: "MNG_SN_ID", title: "일련번호", width: "10%", }, { field: "Code_Exp", title: "품 명", width: "6%", }, { field: "", title: "기초재고", columns:[ { field:"BF_QTY", title:"수량", width:"6%", formatter: tb_common_funtions.formatterNumber, formatterParams: function() { return {'precision':0}; }, bottomCalc:"sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: {precision:0}, }, { field:"BF_PRICE", title:"단가", width:"7%", formatter: tb_common_funtions.formatterNumber, formatterParams: function() { return {'precision':0}; }, bottomCalc:"sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: {precision:0},}, { field:"BF_AMT", title:"금액", width:"7%", formatter: tb_common_funtions.formatterNumber, formatterParams: function() { return {'precision':0}; }, bottomCalc:"sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: {precision:0}, }, ], }, { field: "", title: "입고", columns:[ { field:"IN_QTY", title:"수량", width:"6%", formatter: tb_common_funtions.formatterNumber, formatterParams: function() { return {'precision':0}; }, bottomCalc:"sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: {precision:0}, }, { field:"IN_PRICE", title:"단가", width:"7%", formatter: tb_common_funtions.formatterNumber, formatterParams: function() { return {'precision':0}; }, bottomCalc:"sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: {precision:0}, }, { field:"IN_AMT", title:"금액", width:"7%", formatter: tb_common_funtions.formatterNumber, formatterParams: function() { return {'precision':0}; }, bottomCalc:"sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: {precision:0}, }, ], }, { field: "", title: "출고", columns:[ { field:"OT_QTY", title:"수량", width:"6%", formatter: tb_common_funtions.formatterNumber, formatterParams: function() { return {'precision':0}; }, bottomCalc:"sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: {precision:0}, }, { field:"OT_PRICE", title:"단가", width:"7%", formatter: tb_common_funtions.formatterNumber, formatterParams: function() { return {'precision':0}; }, bottomCalc:"sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: {precision:0}, }, { field:"OT_AMT", title:"금액", width:"7%", formatter: tb_common_funtions.formatterNumber, formatterParams: function() { return {'precision':0}; }, bottomCalc:"sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: {precision:0}, }, ], }, { field: "", title: "기말재고", columns:[ { field:"AF_QTY", title:"수량", width:"6%", formatter: tb_common_funtions.formatterNumber, formatterParams: function() { return {'precision':0}; }, bottomCalc:"sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: {precision:0}, }, { field:"AF_PRICE", title:"단가", width:"7%", formatter: tb_common_funtions.formatterNumber, formatterParams: function() { return {'precision':0}; }, bottomCalc:"sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: {precision:0}, }, { field:"AF_AMT", title:"금액", width:"7%", formatter: tb_common_funtions.formatterNumber, formatterParams: function() { return {'precision':0}; }, bottomCalc:"sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: {precision:0}, }, ], }, ]; _this.tblList = new Tabulator("#tblSubul",{ layout: "fitColumns", height: "100%", data: [], //기본 데이터 columns: fields, //컬럼 설정 columnDefaults: { //컬럼 공통 규칙 sorter:()=>{}, headerSort: false, vertAlign: "middle", hozAlign: "center", resizable: "header",//Resize 는 헤더에서만 가능 headerHozAlign: "center", //헤더 정렬 headerSortTristate: true, //데이터 정렬 => 정/역/초기화 }, headerSortElement: "", //정렬 아이콘 }); _this.tblList.on("tableBuilt", () => { //Tabulator 초기 데이터 불러오기 이벤트 _this.getMainList(); }); _this.tblList.on("rowClick", (e,tgt) => { //Tabulator Row Click _this.rowClick && _this.rowClick(e,tgt); }); _this.tblList.on("cellClick", (e,tgt) => { //Tabulator cell Click _this.cellClick && _this.cellClick(e,tgt); }); _this.tblList.on("cellEdited", (cell) => { //Tabulator cell Edited _this.cellEdited && _this.cellEdited(cell); }); ['click','keypress'].forEach(evt => document.querySelector("#btnExcelDown").addEventListener(evt,()=>{_this.excelDataLoad(_this.tblList,'월별수불현황')})); ['change','keydown','keyup'].forEach(evt => document.querySelector("#S_DATE").addEventListener(evt,(e)=>{_this.getMainList(e.target.value);})); }; excelDataLoad(table_block, title) { //페이징 처리된 리스트에서 엑셀 전체 다운 let _this = this; let filename = title + "_"+document.querySelector("#S_DATE").value+".xlsx"; tb_common_funtions.tabu2xls(table_block, filename, title, _this.tblList.getData('active').map( row => { row.BF_PRICE = Math.round(row.BF_PRICE*10)/10; row.BF_AMT = Math.round(row.BF_AMT*10)/10; row.IN_PRICE = Math.round(row.IN_PRICE*10)/10; row.IN_AMT = Math.round(row.IN_AMT*10)/10; row.OT_PRICE = Math.round(row.OT_PRICE*10)/10; row.OT_AMT = Math.round(row.OT_AMT*10)/10; row.AF_PRICE = Math.round(row.AF_PRICE*10)/10; row.AF_AMT = Math.round(row.AF_AMT*10)/10; return row; } )); } } const Tb_funcs = new Tb_class(); Tb_funcs.init();