forked from HANYANG/HANYANG_MES
181 lines
5.2 KiB
JavaScript
181 lines
5.2 KiB
JavaScript
|
|
//Grid용 클래스. 블록 처리용
|
|
class Tb_class {
|
|
constructor(){
|
|
let _this = this;
|
|
_this.tblList = "";
|
|
_this.ajax_url = "./stockcheck.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: 'getStockCheckList',
|
|
MNG_NO: sdata?.MNG_NO||'',
|
|
},
|
|
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;
|
|
let stdate = document.getElementById("S_WRK_DT_ST").value;
|
|
let endate = document.getElementById("S_WRK_DT_ED").value;
|
|
let sval = document.getElementById("S_WO_NO").value;
|
|
|
|
_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;
|
|
let data = cell.getData();
|
|
let row = cell.getRow();
|
|
|
|
row.update({'_STATUS_':'U'});
|
|
|
|
if(data.QTY) {
|
|
let std = Number(data.QTY);
|
|
let real = Number(data.REAL_QTY);
|
|
let ohcha = std - real;
|
|
|
|
row.update({'OHCHA_QTY':ohcha, '_STATUS_':'U'});
|
|
}
|
|
};
|
|
|
|
// 등록
|
|
putCheck (){
|
|
let _this = this;
|
|
let postdata = {
|
|
'mode': 'putStockCheck',
|
|
'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_SN_ID", title: "일련번호", width: "12%", },
|
|
{ field: "Code_Exp", title: "품 명", width: "8%", },
|
|
{ field: "WH_NM", title: "창 고", width: "10%", },
|
|
{ field: "LOCATION_NM", title: "로케이션", width: "10%", },
|
|
{ field: "QTY", title: "현수량", width: "8%", },
|
|
{ field: "REAL_QTY", title: "실사수량", width: "8%", editor: "number", },
|
|
{ field: "OHCHA_QTY", title: "오차수량", width: "8%", },
|
|
];
|
|
|
|
_this.tblList = new Tabulator("#tblStockCheck",{
|
|
layout: "fitColumns",
|
|
height: "100%",
|
|
data: [], //기본 데이터
|
|
columns: fields, //컬럼 설정
|
|
columnDefaults: { //컬럼 공통 규칙
|
|
sorter:()=>{},
|
|
headerSort: false,
|
|
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("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("#bntListSearch").addEventListener(evt,()=>{
|
|
// _this.searchData = {
|
|
// MNG_NO: document.querySelector('#S_MNG_NO').value||'',
|
|
// }; // _this.searchData 는 전체적으로 이용되므로 간략화 금지
|
|
// _this.getMainList(_this.searchData);
|
|
// }));
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnPutStockCheck").addEventListener(evt,()=>{_this.putCheck()}));
|
|
//['change','keydown','keyup'].forEach(evt => document.querySelectorAll("#S_MNG_NO").forEach(tgt=>tgt.addEventListener(evt,()=>{Tb_funcs.setFilter()})));
|
|
};
|
|
}
|
|
|
|
const Tb_funcs = new Tb_class();
|
|
Tb_funcs.init(); |