forked from HANYANG/HANYANG_MES
155 lines
4.7 KiB
JavaScript
155 lines
4.7 KiB
JavaScript
|
|
//Grid용 클래스. 블록 처리용
|
|
class Tb_class {
|
|
constructor(){
|
|
let _this = this;
|
|
_this.tblList = "";
|
|
_this.ajax_url = "./specimen.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: 'getSpecimenList' },
|
|
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 () {
|
|
let _this = this;
|
|
|
|
_this.tblList.setFilter(function(data){ //필터링
|
|
return (
|
|
true
|
|
&& ( !document.getElementById("S_MNG_NO") || ( (data.MNG_NO).search(document.getElementById("S_MNG_NO").value) !== -1 ) )
|
|
)
|
|
}, '=', true);
|
|
};
|
|
|
|
//Cell 변경 콜백
|
|
cellEdited (cell){
|
|
let _this = this;
|
|
cell.getData()._STATUS_ = cell.getData()._STATUS_||'U';
|
|
};
|
|
|
|
//등록
|
|
putSpecimen (){
|
|
let _this = this;
|
|
let postdata = {
|
|
'mode': 'putSpecimen',
|
|
'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{
|
|
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: "MNG_NO", title: "수주번호", width: "11%", },
|
|
{ field: "SPEM_SPEC", title: "사이즈", width: "14%", },
|
|
{ field: "MATR_TYPE", title: "재질", width: "8%", },
|
|
{ field: "SPEM_NO", title: "시편번호", width: "11%", },
|
|
{ field: "SPEM_DT", title: "채취일", width: "10%", editor:'date', editorParams: {max:'9999-12-31'}, },
|
|
{ field: "SPEM_BP_NM", title: "시편업체", width: "10%", },
|
|
{ field: "IN_DT", title: "입고일", width: "10%", editor:'date', editorParams: {max:'9999-12-31'}, },
|
|
{ field: "REMK", title: "비고", width: "22%", },
|
|
];
|
|
|
|
_this.tblList = new Tabulator("#tblSpecimenList",{
|
|
layout: "fitColumns",
|
|
height: "100%",
|
|
data: [], //기본 데이터
|
|
columns: fields, //컬럼 설정
|
|
columnDefaults: { //컬럼 공통 규칙
|
|
vertAlign: "middle",
|
|
hozAlign: "center",
|
|
resizable: "header",//Resize 는 헤더에서만 가능
|
|
headerHozAlign: "center", //헤더 정렬
|
|
headerSortTristate: true, //데이터 정렬 => 정/역/초기화
|
|
},
|
|
headerSortElement: "<i class='bi'></i>", //정렬 아이콘
|
|
});
|
|
|
|
_this.tblList.on("tableBuilt", () => { //Tabulator 초기 데이터 불러오기 이벤트
|
|
_this.getMainList();
|
|
});
|
|
_this.tblList.on("cellEdited", (cell) => { //Tabulator cell Edited
|
|
_this.cellEdited && Tb_funcs.cellEdited(cell);
|
|
});
|
|
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnPutSpecimen").addEventListener(evt,()=>{_this.putSpecimen()}));
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnExcelDown").addEventListener(evt,()=>{_this.excelDataLoad(_this.tblList,'시편 리스트')}));
|
|
['change','keydown','keyup'].forEach(evt => document.querySelectorAll("#S_MNG_NO").forEach(tgt=>tgt.addEventListener(evt,()=>{Tb_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: 'getSpecimenList', 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 () {}
|
|
});
|
|
};
|
|
}
|
|
|
|
const Tb_funcs = new Tb_class();
|
|
Tb_funcs.init(); |