forked from HANYANG/HANYANG_MES
364 lines
13 KiB
JavaScript
364 lines
13 KiB
JavaScript
|
|
//Grid용 클래스. 블록 처리용
|
|
class Tb_Jig_class {
|
|
constructor(){
|
|
let _this = this;
|
|
_this.tblList = "";
|
|
_this.ajax_url = "./jig.ajax.php";
|
|
}
|
|
|
|
//리스트 로드
|
|
getMainList () {
|
|
let _this = this;
|
|
|
|
let talert = window.setTimeout(function () { _this.tblList.alert("Loading ...") }, 1000); //1초 이상 지연되면 로딩 출력
|
|
ajax_json({
|
|
url: _this.ajax_url,
|
|
data: { mode: 'getJigList' },
|
|
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();
|
|
Tb_Jig_funcs.setFilter();
|
|
}
|
|
});
|
|
return true;
|
|
};
|
|
|
|
setFilter () {
|
|
let _this = this;
|
|
|
|
_this.tblList.setFilter(function(data){ //필터링
|
|
return (
|
|
true
|
|
&& ( !document.getElementById("S_USE_FLG") || ( !document.getElementById("S_USE_FLG").checked || data.USE_FLG === 'Y' ) )
|
|
&& ( !document.getElementById("S_JIG_NM") || ( (data.JIG_NM).search(document.getElementById("S_JIG_NM").value) !== -1 ) )
|
|
&& ( !document.getElementById("S_JIG_CD") ||( (data.JIG_CD).search(document.getElementById("S_JIG_CD").value) !== -1 ) )
|
|
)
|
|
}, '=', true);
|
|
};
|
|
|
|
//Row 추가
|
|
addRow(){
|
|
let _this = this;
|
|
_this.tblList.addRow({_STATUS_:'I', USE_FLG:'Y', JIG_ACCNT:'PD', JIG_GRP:'ST', SHAPE_TYPE:'NF'});
|
|
}
|
|
|
|
//Cell 클릭 콜백
|
|
cellClick (e, tgt){
|
|
let _this = this;
|
|
_this.tgt = tgt;
|
|
switch( tgt.getField() ){
|
|
case "USE_FLG":
|
|
tgt.setValue( tgt.getValue() == "Y"?"N":"Y" );
|
|
break;
|
|
}
|
|
};
|
|
|
|
//Cell 변경 콜백
|
|
cellEdited (cell){
|
|
let _this = this;
|
|
cell.getData()._STATUS_ = cell.getData()._STATUS_||'U';
|
|
};
|
|
|
|
//Row 클릭 콜백
|
|
rowClick (e, tgt){
|
|
let _this = this;
|
|
|
|
Tb_Jig_Hst_funcs.getMainList(tgt.getData().JIG_CD);
|
|
jQuery(tgt.getElement()).siblings().removeClass("user-checked");
|
|
tgt.getElement().classList.add("user-checked");
|
|
$("#btnAddJigHst").attr("disabled", false);
|
|
$("#btnPutJigHst").attr("disabled", false);
|
|
};
|
|
|
|
//등록
|
|
putJig (){
|
|
let _this = this;
|
|
let pdata = _this.tblList.getData();
|
|
let dupdata = pdata.map( data => data.JIG_CD ).filter( data => data );
|
|
if( dupdata.filter( (data,idx) => dupdata.indexOf(data) !== idx ).length > 0 ){
|
|
kuls_alert("치공구 코드가 중복됩니다.");
|
|
return false;
|
|
}
|
|
let postdata = {
|
|
'mode': 'putJig',
|
|
'reqdata': JSON.stringify(_this.tblList.getData().filter(row=> row._STATUS_)),
|
|
};
|
|
ajax_json({
|
|
url: _this.ajax_url,
|
|
data: postdata,
|
|
success: function (data) {
|
|
if (data.code) {
|
|
kuls_success("적용 되었습니다.");
|
|
_this.getMainList();
|
|
}else{
|
|
Tb_Jig_funcs.tblList.getRows().forEach( row => { //일부 적용된 열 update 처리
|
|
if( data.data.includes(row.getData()['JIG_CD']) ){
|
|
row.update({_STATUS_:'U'});
|
|
}
|
|
} );
|
|
kuls_alert(data.mesg);
|
|
}
|
|
},
|
|
error: function (request, status, error) {
|
|
kuls_alert(error.message);
|
|
},
|
|
complete: function () {
|
|
}
|
|
});
|
|
return true;
|
|
};
|
|
|
|
//시작 실행
|
|
init () {
|
|
let _this = this;
|
|
|
|
const fields = [
|
|
{ formatter: "rownum", title: "No", width: "4%", minWidth:60, },
|
|
{ field: "JIG_CD", title: "치공구코드", width: "10%", minWidth:100, editor:'input', editable:(cell)=>{ let val = cell.getData(); return val._STATUS_ === 'I' }, },
|
|
{ field: "JIG_NM", title: "치공구명", width: "15%", minWidth:120, editor:'input', },
|
|
{ field: "JIG_MODEL", title: "치공구 규격/모델", width: "20%", minWidth:120, editor:'input', },
|
|
{ field: "JIG_MF", title: "제조사", width: "15%", minWidth:120, editor:'input', },
|
|
{ field: "PUR_NM", title: "구입처", width: "10%", minWidth:120, editor:'input', },
|
|
{ field: "PUR_PRICE", title: "구입가격", width: "10%", minWidth:120, editor:'number', formatter: tb_common_funtions.formatterNumber, formatterParams: function() { return {'precision':0}; },},
|
|
{ field: "PUR_DATE", title: "구입일", width: "10%", minWidth:120, editor:'date', editorParams: {max:'9999-12-31'}, },
|
|
{ field: "USE_FLG", title: "사용", width: "6%", minWidth:80, cssClass:'user-editable', formatter: tb_common_funtions.formatterToggleboxGreenIcon, formatterParams: {checkval:'Y'}, },
|
|
];
|
|
|
|
_this.tblList = new Tabulator("#tblJigList",{
|
|
layout: "fitColumns",
|
|
height: "100%",
|
|
data: [], //기본 데이터
|
|
columns: fields, //컬럼 설정
|
|
columnDefaults: { //컬럼 공통 규칙
|
|
vertAlign: "middle",
|
|
hozAlign: "center",
|
|
resizable: "header",//Resize 는 헤더에서만 가능
|
|
headerHozAlign: "center", //헤더 정렬
|
|
headerSortTristate: true, //데이터 정렬 => 정/역/초기화
|
|
},
|
|
rowFormatter:function(row){
|
|
if(row.getData().USE_FLG != "Y"){
|
|
row.getElement().classList.add('text-secondary');
|
|
}
|
|
},
|
|
headerSortElement: "<i class='bi'></i>", //정렬 아이콘
|
|
});
|
|
|
|
_this.tblList.on("tableBuilt", () => { //Tabulator 초기 데이터 불러오기 이벤트
|
|
_this.getMainList();
|
|
});
|
|
|
|
_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);
|
|
});
|
|
_this.tblList.on("rowClick", (e,tgt) => { //Tabulator cell Edited
|
|
_this.rowClick && _this.rowClick(e,tgt);
|
|
});
|
|
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnAddJig").addEventListener(evt,()=>{_this.addRow()}));
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnPutJig").addEventListener(evt,()=>{_this.putJig()}));
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnExcelDown").addEventListener(evt,()=>{_this.excelDataLoad(_this.tblList,'치공구 리스트')}));
|
|
['change','keydown','keyup'].forEach(evt => document.querySelectorAll("#S_JIG_CD, #S_JIG_NM, #S_USE_FLG").forEach(tgt=>tgt.addEventListener(evt,()=>{Tb_Jig_funcs.setFilter()})));
|
|
};
|
|
|
|
excelDataLoad(table_block, title) { //페이징 처리된 리스트에서 엑셀 전체 다운
|
|
let _this = this;
|
|
let filename = title + "_"+luxon.DateTime.now().toFormat('yyyyMMdd')+".xlsx";
|
|
|
|
ajax_json({
|
|
url: _this.ajax_url,
|
|
data: {..._this.searchData, mode: 'getJigList', LINE_NUM: 999999999 },
|
|
success: function (data) {
|
|
if (data.code) {
|
|
tb_common_funtions.tabu2xls(table_block, filename, title, data.data.map( row => {
|
|
return row;
|
|
} ));
|
|
}else{
|
|
kuls_alert(data.mesg);
|
|
}
|
|
},
|
|
error: function (request, status, error) {
|
|
kuls_alert(error.message);
|
|
},
|
|
complete: function () {}
|
|
});
|
|
};
|
|
}
|
|
|
|
|
|
class Tb_Jig_Hst_class {
|
|
constructor(){
|
|
let _this = this;
|
|
_this.tblList = "";
|
|
_this.ajax_url = "./jig.ajax.php";
|
|
_this.jc = "";
|
|
}
|
|
|
|
//리스트 로드
|
|
getMainList (jc) {
|
|
let _this = this;
|
|
_this.jc = jc;
|
|
|
|
let talert = window.setTimeout(function () { _this.tblList.alert("Loading ...") }, 1000); //1초 이상 지연되면 로딩 출력
|
|
ajax_json({
|
|
url: _this.ajax_url,
|
|
data: { mode: 'getJigHstList', JIG_CD: jc },
|
|
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;
|
|
};
|
|
|
|
setFilter () {
|
|
let _this = this;
|
|
|
|
_this.tblList.setFilter(function(data){ //필터링
|
|
return (
|
|
true
|
|
&& ( !document.getElementById("S_USE_FLG") || ( !document.getElementById("S_USE_FLG").checked || data.USE_FLG === 'Y' ) )
|
|
)
|
|
}, '=', true);
|
|
};
|
|
|
|
//Row 추가
|
|
addRow(){
|
|
let _this = this;
|
|
_this.tblList.addRow({_STATUS_:'I', USE_FLG:'Y', JIG_CD:_this.jc,});
|
|
}
|
|
|
|
//Cell 클릭 콜백
|
|
cellClick (e, tgt){
|
|
let _this = this;
|
|
_this.tgt = tgt;
|
|
switch( tgt.getField() ){
|
|
case "USE_FLG":
|
|
tgt.setValue( tgt.getValue() == "Y"?"N":"Y" );
|
|
break;
|
|
|
|
case "JIG_A_EMP_NO":
|
|
popEmployeeList('JIG_A_EMP_NO','JIG_A_EMP_NM', 'BA01', tgt.getRow()._row);
|
|
break;
|
|
}
|
|
};
|
|
|
|
//Cell 변경 콜백
|
|
cellEdited (cell){
|
|
let _this = this;
|
|
cell.getData()._STATUS_ = cell.getData()._STATUS_||'U';
|
|
};
|
|
|
|
// 로케이션 등록
|
|
putJigHst (){
|
|
let _this = this;
|
|
|
|
let postdata = {
|
|
'mode': 'putJigHst',
|
|
'reqdata': JSON.stringify(_this.tblList.getData().filter(row=> row._STATUS_)),
|
|
};
|
|
console.log(postdata);
|
|
ajax_json({
|
|
url: _this.ajax_url,
|
|
data: postdata,
|
|
success: function (data) {
|
|
if (data.code) {
|
|
kuls_success("저장되었습니다.");
|
|
_this.getMainList(_this.jc);
|
|
}else{
|
|
_this.tblList.getRows().forEach( row => { //일부 적용된 열 update 처리
|
|
if( data.data.includes(row.getData()['LOC_CD']) ){
|
|
row.update({_STATUS_:'U'});
|
|
}
|
|
} );
|
|
kuls_alert(data.mesg);
|
|
}
|
|
},
|
|
error: function (request, status, error) {
|
|
kuls_alert(error.message);
|
|
},
|
|
complete: function () {
|
|
}
|
|
});
|
|
return true;
|
|
};
|
|
|
|
init () {
|
|
let _this = this;
|
|
|
|
const fields = [
|
|
{ formatter: "rownum", title: "No", width: "4%", },
|
|
{ field: "JIG_REF_CD", title: "관리코드", width: "10%", headerFilterPlaceholder:"자동채번", headerSort: true, formatter: (cell)=>{ return cell.getValue()||"<span class='text-secondary'>자동채번</span>" }},
|
|
{ field: "JIG_REASON", title: "사유", width: "15%", editor:'input', },
|
|
{ field: "JIG_REPAIR", title: "조치사항", width: "15%", editor:'input', },
|
|
{ field: "JIG_ADATE", title: "조치일", width: "8%", editor:'date', editorParams: {max:'9999-12-31'}, },
|
|
{ field: "JIG_A_EMP_NO", title: "조치자", width: "10%", cssClass:'user-editable', formatter: function(tgt){ return (tgt.getData()['JIG_A_EMP_NM']||''); }, },
|
|
{ field: "JIG_ODATE", title: "반출일", width: "8%", editor:'date', editorParams: {max:'9999-12-31'}, },
|
|
{ field: "JIG_IDATE", title: "반입일", width: "8%", editor:'date', editorParams: {max:'9999-12-31'}, },
|
|
{ field: "REMK", title: "비고", width: "15%", editor:'input', },
|
|
{ field: "USE_FLG", title: "사용", width: "6%", cssClass:'user-editable', formatter: tb_common_funtions.formatterToggleboxGreenIcon, formatterParams: {checkval:'Y'}},
|
|
];
|
|
|
|
_this.tblList = new Tabulator("#tblJigHstList",{
|
|
layout: "fitColumns",
|
|
height: "calc(100% - 20px)",
|
|
data: [], //기본 데이터
|
|
columns: fields, //컬럼 설정
|
|
columnDefaults: { //컬럼 공통 규칙
|
|
vertAlign: "middle",
|
|
hozAlign: "center",
|
|
resizable: "header",//Resize 는 헤더에서만 가능
|
|
headerHozAlign: "center", //헤더 정렬
|
|
headerSortTristate: true, //데이터 정렬 => 정/역/초기화
|
|
},
|
|
rowFormatter:function(row){
|
|
if(row.getData().USE_FLG != "Y"){
|
|
row.getElement().classList.add('text-secondary');
|
|
}
|
|
},
|
|
headerSortElement: "<i class='bi'></i>", //정렬 아이콘
|
|
});
|
|
|
|
_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("#btnAddJigHst").addEventListener(evt,()=>{_this.addRow()}));
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnPutJigHst").addEventListener(evt,()=>{_this.putJigHst()}));
|
|
['change','keydown','keyup'].forEach(evt => document.querySelectorAll("#S_USE_FLG").forEach(tgt=>tgt.addEventListener(evt,()=>{Tb_funcs_Loc.setFilter()})));
|
|
};
|
|
}
|
|
|
|
const Tb_Jig_funcs = new Tb_Jig_class();
|
|
const Tb_Jig_Hst_funcs = new Tb_Jig_Hst_class();
|
|
Tb_Jig_funcs.init();
|
|
Tb_Jig_Hst_funcs.init();
|