forked from HANYANG/HANYANG_MES
984 lines
35 KiB
JavaScript
984 lines
35 KiB
JavaScript
|
|
//Grid용 클래스. 블록 처리용
|
|
class Tb_class_Detail {
|
|
constructor(){
|
|
let _this = this;
|
|
_this.tblList = "";
|
|
_this.ajax_url = "./item.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: 'getDetailList',
|
|
BP_CD: sdata?.BP_CD||'',
|
|
SO_DT_ST: sdata?.SO_DT_ST||'',
|
|
SO_DT_ED: sdata?.SO_DT_ED||'',
|
|
MNG_NO: sdata?.MNG_NO||'',
|
|
SO_NO: sdata?.SO_NO||'',
|
|
OFLD: sdata?.OFLD||'',
|
|
OASC: sdata?.OASC||'',
|
|
LINE_NUM: sdata?.LINE_NUM||'',
|
|
NOW_PAGE: sdata?.NOW_PAGE||'',
|
|
},
|
|
success: function (data) {
|
|
if (data.code) {
|
|
_this.tblList.setData(data.data);
|
|
|
|
//page
|
|
putPagiNation({
|
|
...sdata,
|
|
TARGET: ".tabulator-footer-contents",
|
|
PREB_PAGE: data?.data[0]?.PREB_PAGE,
|
|
NEXB_PAGE: data?.data[0]?.NEXB_PAGE,
|
|
LAST_PAGE: data?.data[0]?.LAST_PAGE,
|
|
PAGE_LISTS: data?.data[0]?.PAGE_LISTS?.split('|'),
|
|
callback: (conf)=>{
|
|
_this.getMainList({
|
|
BP_CD: conf?.BP_CD||'',
|
|
SO_DT_ST: conf?.SO_DT_ST||'',
|
|
SO_DT_ED: conf?.SO_DT_ED||'',
|
|
MNG_NO: conf?.MNG_NO||'',
|
|
SO_NO: conf?.SO_NO||'',
|
|
OFLD: conf?.OFLD||'',
|
|
OASC: conf?.OASC||'',
|
|
LINE_NUM: conf?.LINE_NUM||'',
|
|
NOW_PAGE: conf?.NOW_PAGE||'',
|
|
});
|
|
}
|
|
});
|
|
}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;
|
|
};
|
|
|
|
//Row 클릭 콜백
|
|
rowClick (e, tgt){
|
|
let _this = this;
|
|
if( e.target.classList.contains("btnfile") ) return; //첨부파일시 Row클릭금지
|
|
|
|
jQuery(tgt.getElement()).siblings().removeClass("user-checked");
|
|
tgt.getElement().classList.add("user-checked");
|
|
|
|
if(tgt.getData().MNG_NO){
|
|
Tb_funcs_Item.getMainList(tgt.getData().SO_NO, tgt.getData().SO_SEQ, tgt.getData().MNG_NO);
|
|
$("#btnAddItem").attr("disabled", false);
|
|
$("#btnDelItem").attr("disabled", false);
|
|
$("#btnPutItem").attr("disabled", false);
|
|
|
|
Tb_funcs_Sample.getMainList();
|
|
$("#btnAddSample").attr("disabled", true);
|
|
$("#btnDelSample").attr("disabled", true);
|
|
$("#btnPutSample").attr("disabled", true);
|
|
|
|
Tb_funcs_Test.getMainList();
|
|
$("#btnAddTest").attr("disabled", true);
|
|
$("#btnDelTest").attr("disabled", true);
|
|
$("#btnPutTest").attr("disabled", true);
|
|
} else {
|
|
$("#btnAddItem").attr("disabled", true);
|
|
$("#btnDelItem").attr("disabled", true);
|
|
$("#btnPutItem").attr("disabled", true);
|
|
|
|
$("#btnAddSample").attr("disabled", true);
|
|
$("#btnDelSample").attr("disabled", true);
|
|
$("#btnPutSample").attr("disabled", true);
|
|
|
|
$("#btnAddTest").attr("disabled", true);
|
|
$("#btnDelTest").attr("disabled", true);
|
|
$("#btnPutTest").attr("disabled", true);
|
|
}
|
|
};
|
|
|
|
setFilter () {
|
|
return false;
|
|
|
|
let _this = this;
|
|
let stdate = document.getElementById("S_SO_DT_ST").value;
|
|
let endate = document.getElementById("S_SO_DT_ED").value;
|
|
|
|
_this.tblList.setFilter(function(data){ //필터링
|
|
return (
|
|
true
|
|
&& ( !document.getElementById("S_BP_NM") || ( (data.ORDR_BP_CD+"|"+data.ORDR_BP_NM).search(document.getElementById("S_BP_NM").value) !== -1 ) )
|
|
&& ( (!stdate || stdate <= data['SO_DT']) && (!endate || endate >= data['SO_DT']) )
|
|
)
|
|
}, '=', true);
|
|
};
|
|
|
|
//Cell 클릭 콜백
|
|
cellClick (e, tgt){
|
|
let _this = this;
|
|
_this.tgt = tgt;
|
|
|
|
switch( tgt.getField() ){
|
|
case "TILT_FLG":
|
|
tgt.setValue( tgt.getValue() == "Y"? null : "Y" );
|
|
break;
|
|
case "ASS_FILE":
|
|
break;
|
|
}
|
|
};
|
|
|
|
//Cell 변경 콜백
|
|
cellEdited (cell){
|
|
let _this = this;
|
|
let row = cell.getRow();
|
|
let qty = row.getData().SO_QTY;
|
|
let unit = row.getData().SO_UNIT;
|
|
|
|
cell.getData()._STATUS_ = cell.getData()._STATUS_||'U';
|
|
switch ( cell.getField() ) {
|
|
case "SO_UNIT":
|
|
row.update( unit == "TN" ? {SO_QTY:currency(qty, {precision:3})} : {SO_QTY:currency(qty, {precision:0})} );
|
|
break;
|
|
}
|
|
};
|
|
|
|
//sort
|
|
columnSort(e,tgt) {
|
|
let _this = this;
|
|
let sorters = tgt.getTable().getSorters()[0];
|
|
_this.getMainList({..._this.searchData,OFLD:sorters?.field,OASC:sorters?.dir});
|
|
};
|
|
|
|
popBP () {
|
|
let _this = this;
|
|
|
|
popPartnerList({tgt_id:'#S_BP_CD',tgt_name:'#S_BP_NM'});
|
|
};
|
|
|
|
setPrecision (val) {
|
|
let unit = val.getRow().getData().SO_UNIT;
|
|
let num = 0;
|
|
|
|
switch (unit) {
|
|
case "TN":
|
|
num = 3;
|
|
break;
|
|
case "EA":
|
|
num = 0;
|
|
break;
|
|
}
|
|
|
|
return {'precision':num};
|
|
};
|
|
|
|
// 스펙정보 등록
|
|
putDetail (){
|
|
let _this = this;
|
|
let pdata = _this.tblList.getData();
|
|
let dupdata = pdata.map( data => data.MNG_NO );
|
|
if( dupdata.filter( (data,idx) => dupdata.indexOf(data) !== idx ).length > 0 ){
|
|
kuls_alert("계획번호가 중복됩니다.");
|
|
return false;
|
|
}
|
|
let postdata = {
|
|
'mode': 'putDetailList',
|
|
'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(_this.searchData);
|
|
}else{
|
|
kuls_alert(data.mesg);
|
|
}
|
|
},
|
|
error: function (request, status, error) {
|
|
kuls_alert(error.message);
|
|
},
|
|
complete: function () {
|
|
}
|
|
});
|
|
return true;
|
|
};
|
|
|
|
popDrawList ( cell ){
|
|
let _this = this;
|
|
//팝업 템플릿 로드 후 모달 출력
|
|
Tb_funcs_draw.init(cell.getComponent().getRow());
|
|
};
|
|
|
|
shGFormatter ( cell ) {
|
|
let _this = this;
|
|
return varsSHAPE_GRP[cell.getValue()]?.Code_Exp;
|
|
};
|
|
|
|
shFormatter ( cell ) {
|
|
let _this = this;
|
|
return varsSHAPE_TYPE[cell.getValue()];
|
|
};
|
|
|
|
stFmtParams( cell ){
|
|
let _this = this;
|
|
return tb_common_funtions.precs(cell.getData()['ITEM_CD'] === "F", 3,1);
|
|
}
|
|
|
|
//시작 실행
|
|
init () {
|
|
let _this = this;
|
|
let currow = Object.keys(varsCurrency).reduce( (param,key) => {param[key] = `${key} (${varsCurrency[key]})`; return param;}, {});
|
|
|
|
const fields = [
|
|
//{ formatter: "rownum", title: "No", width: "4%", },
|
|
{ field: "LIST_NUM", title: "No", width: "4%", },
|
|
{ field: "MNG_NO", title: "수주번호", width: "10%", headerSort: true},
|
|
// { field: "SO_NO", title: "관리번호", width: "10%", headerSort: true},
|
|
{ field: "ITEM_CD", title: "수주품명", width: "8%", headerSort: true, formatter:_this.shGFormatter,},
|
|
{ field: "", title: "규격", width: "25%",
|
|
columns:[
|
|
{ field:"OUT_DIA", title:"OD", width:"5%", formatter: tb_common_funtions.formatterNumber, formatterParams: _this.stFmtParams, },
|
|
{ field:"IN_DIA", title:"ID", width:"5%", formatter: tb_common_funtions.formatterNumber, formatterParams: _this.stFmtParams, },
|
|
{ field:"THICK", title:"TH", width:"5%", formatter: tb_common_funtions.formatterNumber, formatterParams: _this.stFmtParams, },
|
|
{ field:"WIDTH", title:"W", width:"5%", formatter: tb_common_funtions.formatterNumber, formatterParams: _this.stFmtParams, },
|
|
{ field:"LENGTH", title:"L", width:"5%", formatter: tb_common_funtions.formatterNumber, formatterParams: _this.stFmtParams, },
|
|
],
|
|
},
|
|
{ field: "MATR_TYPE", title: "재질", width: "12%", editor:'input', },
|
|
{ field: "", title: "도면", width: "12%",
|
|
columns:[
|
|
{ field:"ASS_DRAW", title:"도면번호", width:"10%", },
|
|
{ field:"ASS_FILE", title:"<i class='fa-solid fa-compass-drafting'></i>", width:"2%", noxls:true,
|
|
formatter: tb_common_funtions.formatterButton,
|
|
formatterParams:{
|
|
btnTitle:'',
|
|
btnClass:'btn btn-sm btn-nobd fa-regular fa-image btnfile',
|
|
cfunc: (cell)=> { _this.popDrawList(cell) },
|
|
event: ['click', 'keyup'],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{ field: "REQ_DLVY_DT", title: "납기요청일", width: "7%", editor:'date', editorParams: {max:'9999-12-31'}, },
|
|
{ field: "ITEM_NRULE", title: "일품번호<br>기준", width: "6%", visible:false, formatter: (tgt)=>tgt.getValue()==="Y"?"번호":"수량" },
|
|
{ field: "SO_QTY", title: "수량", width: "5%", editor:'input', formatter: tb_common_funtions.formatterNumber, formatterParams: function(cell) { return _this.setPrecision(cell); }, },
|
|
{ field: "SO_UNIT", title: "단위", width: "5%", editor:'list', cssClass:"user-list", editorParams:{ values: varsUNIT },
|
|
formatter: tb_common_funtions.formatterSelect, formatterParams: { values: varsUNIT }, },
|
|
{ field: "CURRENCY_CD", title: "화폐", width: "6%", editor:'list', cssClass:"user-list", editorParams:{ values: currow },
|
|
formatter: tb_common_funtions.formatterSelect, formatterParams: { values: currow }, },
|
|
{ field: "PWR_WGT", title: "분철단가", width: "8%", editor:'input', formatter:"money", },
|
|
{ field: "UNIT_WGT", title: "단중단가", width: "8%", editor:'input', formatter:"money", },
|
|
{ field: "", title: "가공단가", width: "8%", editor:'input', formatter:"money", },
|
|
{ field: "SO_NET_AMT_LOC", title: "수주금액", width: "8%", editor:'input', formatter: tb_common_funtions.formatterNumber, /*formatter:"money",*/ },
|
|
{ field: "SIZE_CD", title: "사이즈", width: "7%", editor:'input', },
|
|
{ field: "SHAPE_TYPE", title: "형태(형상)", width: "10%", formatter:_this.shFormatter, },
|
|
{ field: "TOP_TAP", title: "탑탭", width: "7%", editor:'input', },
|
|
{ field: "SID_TAP", title: "사이드탭", width: "7%", editor:'input', },
|
|
{ field: "GROV_TYPE", title: "그루브", width: "7%", editor:'input', },
|
|
{ field: "TILT_FLG", title: "틸트", width: "5%", formatter: tb_common_funtions.formatterCheckboxIcon, },
|
|
{ field: "HOLE_SIZE", title: "홀크기", width: "7%", editor:'input', formatter: tb_common_funtions.formatterNumber, },
|
|
{ field: "PL_HD_TYPE", title: "접시머리", width: "7%", editor:'input', },
|
|
{ field: "REMK", title: "비고", width: "10%", editor:'input', },
|
|
];
|
|
|
|
_this.tblList = new Tabulator("#tblDetailList",{
|
|
layout: "fitColumns",
|
|
height: "100%",
|
|
data: [], //기본 데이터
|
|
columns: fields, //컬럼 설정
|
|
columnDefaults: { //컬럼 공통 규칙
|
|
sorter:()=>{},
|
|
headerSort: false,
|
|
vertAlign: "middle",
|
|
hozAlign: "center",
|
|
resizable: "header",//Resize 는 헤더에서만 가능
|
|
headerHozAlign: "center", //헤더 정렬
|
|
headerSortTristate: true, //데이터 정렬 => 정/역/초기화
|
|
},
|
|
footerElement:'<ul class="pagination justify-content-center align-items-center mb-1"><li><a class="pn_link npage btn btn-light"><span class="f_page">1</span></a></li></ul>',
|
|
headerSortElement: "<i class='bi'></i>", //정렬 아이콘
|
|
});
|
|
|
|
_this.tblList.on("tableBuilt", () => { //Tabulator 초기 데이터 불러오기 이벤트
|
|
_this.getMainList();
|
|
});
|
|
_this.tblList.on("rowClick", (e,tgt) => { //Tabulator Row Click
|
|
_this.rowClick && Tb_funcs_Detail.rowClick(e,tgt);
|
|
});
|
|
_this.tblList.on("cellClick", (e,tgt) => { //Tabulator cell Click
|
|
_this.cellClick && Tb_funcs_Detail.cellClick(e,tgt);
|
|
});
|
|
_this.tblList.on("cellEdited", (cell) => { //Tabulator cell Edited
|
|
_this.cellEdited && Tb_funcs_Detail.cellEdited(cell);
|
|
});
|
|
_this.tblList.on("headerClick", (e,tgt) => { //Tabulator cell Edited
|
|
_this.columnSort && _this.columnSort(e,tgt);
|
|
});
|
|
|
|
['click','keypress'].forEach(evt => document.querySelector("#bntListSearch").addEventListener(evt,()=>{
|
|
_this.searchData = {
|
|
BP_CD: document.querySelector('#S_BP_CD').value||'',
|
|
SO_DT_ST: document.querySelector('#S_SO_DT_ST').value||'',
|
|
SO_DT_ED: document.querySelector('#S_SO_DT_ED').value||'',
|
|
MNG_NO: document.querySelector('#S_MNG_NO').value||'',
|
|
SO_NO: document.querySelector('#S_SO_NO')?.value||'',
|
|
LINE_NUM: document.querySelector('#S_LINE_NUM').value||'',
|
|
NOW_PAGE: 1,
|
|
}; // _this.searchData 는 전체적으로 이용되므로 간략화 금지
|
|
|
|
_this.getMainList(_this.searchData)
|
|
}));
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnPutDetail").addEventListener(evt,()=>{_this.putDetail()}));
|
|
['click','keypress'].forEach(evt => document.querySelector("#S_BP_NM").addEventListener(evt,()=>{_this.popBP()}));
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnExcelReport").addEventListener(evt,()=>{_this.excelDataReport('수주보고서')}));
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnExcelDown").addEventListener(evt,()=>{_this.excelDataLoad(_this.tblList,'수주상세.xlsx','수주상세')}));
|
|
['change','keydown','keyup'].forEach(evt => document.querySelectorAll("#S_BP_NM, #S_SO_DT_ST, #S_SO_DT_ED").forEach(tgt=>tgt.addEventListener(evt,()=>{Tb_funcs_Detail.setFilter()})));
|
|
};
|
|
|
|
excelDataLoad(table_block, filename, title) { //페이징 처리된 리스트에서 엑셀 전체 다운
|
|
let _this = this;
|
|
|
|
ajax_json({
|
|
url: _this.ajax_url,
|
|
data: {..._this.searchData, mode: 'getDetailList', LINE_NUM: 999999999 },
|
|
success: function (data) {
|
|
if (data.code) {
|
|
tb_common_funtions.tabu2xls(table_block, filename, title, data.data);
|
|
}else{
|
|
kuls_alert(data.mesg);
|
|
}
|
|
},
|
|
error: function (request, status, error) {
|
|
kuls_alert(error.message);
|
|
},
|
|
complete: function () {}
|
|
});
|
|
};
|
|
|
|
excelDataReport(title){
|
|
let _this = this;
|
|
let sdata = _this.searchData;
|
|
let filename = title+"_"+luxon.DateTime.now().toFormat('yyyyMMdd');
|
|
ajax_json({
|
|
url: _this.ajax_url,
|
|
data: {
|
|
mode: 'getOrderDetailList',
|
|
BP_CD: sdata?.BP_CD,
|
|
SO_DT_ST: sdata?.SO_DT_ST,
|
|
SO_DT_ED: sdata?.SO_DT_ED,
|
|
MNG_NO: sdata?.MNG_NO,
|
|
SO_NO: sdata?.SO_NO,
|
|
BP_NM: sdata?.BP_NM,
|
|
},
|
|
success: function (data) {
|
|
if (data.code) {
|
|
let excelHeader = [
|
|
{ key: 'SO_DT', width: 10, title: '일 자', format:'', sum:'계' },
|
|
//{ key: 'MNG_NO', width: 20, title: '수주번호', format:'', sum:''},
|
|
{ key: 'MNG_SN_ID', width: 20, title: '수주번호', format:'', sum:''},
|
|
{ key: 'SPEC', width: 25, title: '규 격', format:'', sum:''},
|
|
{ key: 'SO_QTY', width: 10, title: '수량', format:'num', sum:''},
|
|
{ key: 'PWR_WGT', width: 12, title: '분철중량', format:'num', sum:true},
|
|
//{ key: 'TOT_WGT', width: 12, title: '총분철', format:'num', sum:true},
|
|
{ key: 'UNIT_WGT', width: 12, title: '단조중량', format:'num', sum:''},
|
|
{ key: 'SO_PRICE_LOC', width: 15, title: '발주단가', format:'price', sum:true},
|
|
//{ key: 'SO_NET_AMT_LOC', width: 15, title: '발주금액', format:'price', sum:true},
|
|
{ key: 'UNIT_DAN', width: 15, title: '분철단가', format:'price2', sum:''},
|
|
{ key: 'PWR_DAN', width: 10, title: '단중단가', format:'price2', sum:''},
|
|
{ key: 'REQ_DLVY_DT', width: 10, title: '납기', format:'', sum:''},
|
|
{ key: 'REMK', width: 20, title: '비고', format:'', sum:''},
|
|
];
|
|
let excelData = data.data.map( v => { return {
|
|
SO_DT: v.SO_DT,
|
|
//MNG_NO: v.MNG_NO,
|
|
MNG_SN_ID: v.MNG_SN_ID,
|
|
SPEC: Math.ceil(v.OUT_DIA) +' x '+ Math.ceil(v.IN_DIA) +' x '+ Math.ceil(v.THICK),
|
|
SO_QTY: 1,//Math.ceil(v.SO_QTY),
|
|
//UNIT_WGT: Math.ceil(v.UNIT_WGT*10)/10,
|
|
PWR_WGT: Math.ceil(v.PWR_WGT*10)/10,
|
|
//TOT_WGT: (Math.ceil(v.PWR_WGT*10)/10)*v.SO_QTY,
|
|
UNIT_WGT: Math.ceil(v.UNIT_WGT*10)/10,
|
|
SO_PRICE_LOC: Math.ceil(v.SO_PRICE_LOC),
|
|
//SO_NET_AMT_LOC: Math.ceil(v.SO_NET_AMT_LOC),
|
|
UNIT_DAN: v.PWR_WGT?(Math.ceil(v.SO_PRICE_LOC*100/v.PWR_WGT)/100):0,
|
|
PWR_DAN: v.UNIT_WGT?(Math.ceil(v.SO_PRICE_LOC*100/v.UNIT_WGT)/100):0,
|
|
REQ_DLVY_DT: v.REQ_DLVY_DT,
|
|
REMK: v.REMK,
|
|
}} );
|
|
|
|
json2xls_report_date(filename, title, excelHeader, excelData, true);
|
|
}else{
|
|
kuls_alert(data.mesg);
|
|
}
|
|
},
|
|
error: function (request, status, error) {
|
|
kuls_alert(error.message);
|
|
},
|
|
complete: function () {}
|
|
});
|
|
};
|
|
}
|
|
|
|
//Grid용 클래스. 블록 처리용
|
|
class Tb_class_Item {
|
|
constructor(){
|
|
let _this = this;
|
|
_this.tblList = "";
|
|
_this.ajax_url = "./item.ajax.php";
|
|
_this.sn = "";
|
|
_this.seq = "";
|
|
_this.mn = "";
|
|
}
|
|
|
|
//리스트 로드
|
|
getMainList (sn, seq, mn) {
|
|
let _this = this;
|
|
_this.sn = sn;
|
|
_this.seq = seq;
|
|
_this.mn = mn;
|
|
|
|
let talert = window.setTimeout(function () { _this.tblList.alert("Loading ...") }, 1000); //1초 이상 지연되면 로딩 출력
|
|
ajax_json({
|
|
url: _this.ajax_url,
|
|
data: { mode: 'getItemList', MNG_NO: _this.mn },
|
|
success: function (data) {
|
|
if (data.code) {
|
|
_this.tblList.setData(data.data.map(sd=>{return {...sd,_OLD_STATUS_:sd._STATUS_};}));
|
|
|
|
let first = true;
|
|
_this.tblList.getRows().forEach(row=>{
|
|
if( row.getData()['PROD_STATUS'] ) { //진행된 일품데이터 선택 못하도록 처리
|
|
row.getCell('CHECK').getElement().querySelector('input').setAttribute('disabled',true);
|
|
}else if( first ){ //수주상세 클릭시, 진행되지 않은 일품데이터의 첫번째 row를 자동으로 선택
|
|
first = false;
|
|
row._row.dispatch('row-click',{},row._row); //다시 로드하기 이전 선택항목 재선택. //앞쪽 row는 의미없고 뒷쪽이 선택 row
|
|
}
|
|
});
|
|
}else{
|
|
kuls_alert(data.mesg);
|
|
}
|
|
},
|
|
error: function (request, status, error) {
|
|
kuls_alert(error.message);
|
|
},
|
|
complete: function () {
|
|
window.clearTimeout(talert);
|
|
_this.tblList.clearAlert();
|
|
}
|
|
});
|
|
return true;
|
|
};
|
|
|
|
//Row 추가
|
|
addRow(){
|
|
let _this = this;
|
|
_this.tblList.addRow({_STATUS_:'I', SO_NO:_this.sn, SO_SEQ:_this.seq, MNG_NO:_this.mn},true);
|
|
}
|
|
|
|
//Row 클릭 콜백
|
|
rowClick (e, tgt){
|
|
let _this = this;
|
|
if( e.target?.classList.contains("btnfile") ) return; //첨부파일시 Row클릭금지
|
|
|
|
jQuery(tgt.getElement()).siblings().removeClass("user-checked");
|
|
tgt.getElement().classList.add("user-checked");
|
|
|
|
if(tgt.getData().MNG_SN_ID){
|
|
Tb_funcs_Sample.getMainList(tgt.getData().MNG_SN_ID);
|
|
$("#btnAddSample").attr("disabled", false);
|
|
$("#btnDelSample").attr("disabled", false);
|
|
$("#btnPutSample").attr("disabled", false);
|
|
|
|
Tb_funcs_Test.getMainList(tgt.getData().MNG_SN_ID);
|
|
$("#btnAddTest").attr("disabled", false);
|
|
$("#btnDelTest").attr("disabled", false);
|
|
$("#btnPutTest").attr("disabled", false);
|
|
} else {
|
|
$("#btnAddSample").attr("disabled", true);
|
|
$("#btnDelSample").attr("disabled", true);
|
|
$("#btnPutSample").attr("disabled", true);
|
|
|
|
$("#btnAddTest").attr("disabled", true);
|
|
$("#btnDelTest").attr("disabled", true);
|
|
$("#btnPutTest").attr("disabled", true);
|
|
}
|
|
};
|
|
|
|
//Cell 클릭 콜백
|
|
cellClick (e, tgt){
|
|
let _this = this;
|
|
_this.tgt = tgt;
|
|
|
|
switch( tgt.getField() ){
|
|
case "SPEM_FLG":
|
|
tgt.setValue( tgt.getValue() == "Y"? null : "Y" );
|
|
break;
|
|
}
|
|
};
|
|
|
|
//Cell 변경 콜백
|
|
cellEdited (cell){
|
|
let _this = this;
|
|
cell.getData()._STATUS_ = cell.getData()._STATUS_||'U';
|
|
};
|
|
|
|
// 아이템 등록
|
|
putItem (){
|
|
let _this = this;
|
|
// let pdata = _this.tblList.getData('active');
|
|
// let dupdata = pdata.map( data => data.SN_ID ).filter( data => data );
|
|
// if( dupdata.filter( (data,idx) => dupdata.indexOf(data) !== idx ).length > 0 ){
|
|
// kuls_alert("일련번호가 중복됩니다.");
|
|
// return false;
|
|
// }
|
|
let postdata = {
|
|
'mode': 'putItemList',
|
|
'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(_this.sn, _this.seq, _this.mn);
|
|
}else{
|
|
kuls_alert(data.mesg);
|
|
}
|
|
},
|
|
error: function (request, status, error) {
|
|
kuls_alert(error.message);
|
|
},
|
|
complete: function () {
|
|
}
|
|
});
|
|
return true;
|
|
};
|
|
|
|
delItem (){
|
|
let _this = this;
|
|
_this.tblList.getSelectedRows().forEach(row => {
|
|
row.update({_STATUS_:'D'});
|
|
row.getElement().classList.add("del-row");
|
|
});
|
|
};
|
|
|
|
revokeItem(row){
|
|
let _this = this;
|
|
row.update({_STATUS_:row.getData()['_OLD_STATUS_']});
|
|
row.getElement().classList.remove("del-row");
|
|
};
|
|
|
|
init () {
|
|
let _this = this;
|
|
|
|
const fields = [
|
|
{ field: "CHECK", formatter:"rowSelection", titleFormatter: "rowSelection", width: "4%", },
|
|
{ field: "MNG_NO", title: "수주번호", width: "29%", },
|
|
{ field: "SN_ID", title: "소재번호", width: "15%", editor:'input', editable: (cell)=>{ return !cell.getRow().getData()['PROD_STATUS'] } },
|
|
{ field: "PLN_IN_DT", title: "입고예정일", width: "18%", editor:'date', editorParams: {max:'9999-12-31'}, },
|
|
{ field: "SPEM_FLG", title: "시편", width: "10%", cssClass:'user-editable', formatter: tb_common_funtions.formatterCheckboxIcon, },
|
|
{ field: "REMK", title: "비고", width: "20%", editor:'input', },
|
|
];
|
|
|
|
_this.tblList = new Tabulator("#tblItemList",{
|
|
layout: "fitColumns",
|
|
height: "100%",
|
|
maxHeight: "100%",
|
|
data: [], //기본 데이터
|
|
columns: fields, //컬럼 설정
|
|
columnDefaults: { //컬럼 공통 규칙
|
|
vertAlign: "middle",
|
|
hozAlign: "center",
|
|
resizable: "header",//Resize 는 헤더에서만 가능
|
|
headerHozAlign: "center", //헤더 정렬
|
|
headerSortTristate: true, //데이터 정렬 => 정/역/초기화
|
|
},
|
|
headerSortElement: "<i class='bi'></i>", //정렬 아이콘
|
|
});
|
|
|
|
_this.tblList.on("rowClick", (e,tgt) => { //Tabulator cell 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);
|
|
});
|
|
_this.tblList.on("rowSelected", (row) => { //Tabulator cell Deslected
|
|
if( row.getData()['PROD_STATUS'] ){
|
|
row.getTable().deselectRow(row);
|
|
}
|
|
});
|
|
_this.tblList.on("rowDeselected", (row) => { //Tabulator cell Deslected
|
|
_this.revokeItem && _this.revokeItem(row);
|
|
});
|
|
|
|
//['click','keypress'].forEach(evt => document.querySelector("#btnAddItem").addEventListener(evt,()=>{_this.addRow()}));
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnPutItem").addEventListener(evt,()=>{_this.putItem()}));
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnDelItem").addEventListener(evt,()=>{_this.delItem()}));
|
|
};
|
|
}
|
|
|
|
//Grid용 클래스. 블록 처리용
|
|
class Tb_class_Sample {
|
|
constructor(){
|
|
let _this = this;
|
|
_this.tblList = "";
|
|
_this.ajax_url = "./item.ajax.php";
|
|
_this.mn = "";
|
|
}
|
|
|
|
//리스트 로드
|
|
getMainList (mn) {
|
|
let _this = this;
|
|
_this.mn = mn;
|
|
|
|
let talert = window.setTimeout(function () { _this.tblList.alert("Loading ...") }, 1000); //1초 이상 지연되면 로딩 출력
|
|
ajax_json({
|
|
url: _this.ajax_url,
|
|
data: { mode: 'getSampleList', MNG_NO:_this.mn },
|
|
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();
|
|
}
|
|
});
|
|
return true;
|
|
};
|
|
|
|
//Row 추가
|
|
addRow(){
|
|
let _this = this;
|
|
_this.tblList.addRow({_STATUS_:'I', MNG_NO:_this.mn},true);
|
|
}
|
|
|
|
//Row 클릭 콜백
|
|
rowClick (e, tgt){
|
|
let _this = this;
|
|
|
|
jQuery(tgt.getElement()).siblings().removeClass("user-checked");
|
|
tgt.getElement().classList.add("user-checked");
|
|
};
|
|
|
|
//Cell 클릭 콜백
|
|
cellClick (e, tgt){
|
|
let _this = this;
|
|
_this.tgt = tgt;
|
|
};
|
|
|
|
//Cell 변경 콜백
|
|
cellEdited (cell){
|
|
let _this = this;
|
|
cell.getData()._STATUS_ = cell.getData()._STATUS_||'U';
|
|
};
|
|
|
|
// 라우팅 등록
|
|
putSample (){
|
|
let _this = this;
|
|
let postdata = {
|
|
'mode': 'putSampleList',
|
|
'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(_this.mn);
|
|
}else{
|
|
kuls_alert(data.mesg);
|
|
}
|
|
},
|
|
error: function (request, status, error) {
|
|
kuls_alert(error.message);
|
|
},
|
|
complete: function () {
|
|
}
|
|
});
|
|
return true;
|
|
};
|
|
|
|
delSample (){
|
|
let _this = this;
|
|
_this.tblList.getSelectedRows().forEach(row => {
|
|
row.update({_STATUS_:'D'});
|
|
row.getElement().classList.add("del-row");
|
|
});
|
|
};
|
|
|
|
init () {
|
|
let _this = this;
|
|
|
|
const fields = [
|
|
{ formatter:"rowSelection", titleFormatter: "rowSelection", title: "No", width: "5%", },
|
|
{ field: "SPEM_NO", title: "시편번호", width: "25%", editor:'input', },
|
|
{ field: "SPEM_SPEC", title: "규격", width: "20%", editor:'input', },
|
|
{ field: "SPEM_BP_NM", title: "시편업체", width: "20%", editor:'list', editorParams: {values: varsSAMP_CUSTOM,}},
|
|
{ field: "SPEM_QTY", title: "수량", width: "13%", editor:'input', formatter: tb_common_funtions.formatterNumber, },
|
|
{ field: "REMK", title: "비고", width: "15%", editor:'input', },
|
|
];
|
|
|
|
_this.tblList = new Tabulator("#tblSampleList",{
|
|
layout: "fitColumns",
|
|
height: "100%",
|
|
maxHeight: "100%",
|
|
data: [], //기본 데이터
|
|
columns: fields, //컬럼 설정
|
|
columnDefaults: { //컬럼 공통 규칙
|
|
vertAlign: "middle",
|
|
hozAlign: "center",
|
|
resizable: "header",//Resize 는 헤더에서만 가능
|
|
headerHozAlign: "center", //헤더 정렬
|
|
headerSortTristate: true, //데이터 정렬 => 정/역/초기화
|
|
},
|
|
headerSortElement: "<i class='bi'></i>", //정렬 아이콘
|
|
});
|
|
|
|
_this.tblList.on("rowClick", (e,tgt) => { //Tabulator cell Click
|
|
_this.rowClick && Tb_funcs_Sample.rowClick(e,tgt);
|
|
});
|
|
_this.tblList.on("cellClick", (e,tgt) => { //Tabulator cell Click
|
|
_this.cellClick && Tb_funcs_Sample.cellClick(e,tgt);
|
|
});
|
|
_this.tblList.on("cellEdited", (cell) => { //Tabulator cell Edited
|
|
_this.cellEdited && Tb_funcs_Sample.cellEdited(cell);
|
|
});
|
|
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnAddSample").addEventListener(evt,()=>{_this.addRow()}));
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnPutSample").addEventListener(evt,()=>{_this.putSample()}));
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnDelSample").addEventListener(evt,()=>{_this.delSample()}));
|
|
};
|
|
}
|
|
|
|
//Grid용 클래스. 블록 처리용
|
|
class Tb_class_Test {
|
|
constructor(){
|
|
let _this = this;
|
|
_this.tblList = "";
|
|
_this.ajax_url = "./item.ajax.php";
|
|
_this.mn = "";
|
|
}
|
|
|
|
//리스트 로드
|
|
getMainList (mn) {
|
|
let _this = this;
|
|
_this.mn = mn;
|
|
|
|
let talert = window.setTimeout(function () { _this.tblList.alert("Loading ...") }, 1000); //1초 이상 지연되면 로딩 출력
|
|
ajax_json({
|
|
url: _this.ajax_url,
|
|
data: { mode: 'getTestList', MNG_NO: mn },
|
|
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();
|
|
}
|
|
});
|
|
return true;
|
|
};
|
|
|
|
//Row 추가
|
|
addRow(){
|
|
let _this = this;
|
|
_this.tblList.addRow({_STATUS_:'I', MNG_NO: _this.mn},true);
|
|
}
|
|
|
|
//Row 클릭 콜백
|
|
rowClick (e, tgt){
|
|
let _this = this;
|
|
|
|
jQuery(tgt.getElement()).siblings().removeClass("user-checked");
|
|
tgt.getElement().classList.add("user-checked");
|
|
};
|
|
|
|
//Cell 클릭 콜백
|
|
cellClick (e, tgt){
|
|
let _this = this;
|
|
_this.tgt = tgt;
|
|
|
|
switch( tgt.getField() ){
|
|
case "INSP_FLG":
|
|
tgt.setValue( tgt.getValue() == "Y"? null : "Y" );
|
|
break;
|
|
}
|
|
};
|
|
|
|
//Cell 변경 콜백
|
|
cellEdited (cell){
|
|
let _this = this;
|
|
cell.getData()._STATUS_ = cell.getData()._STATUS_||'U';
|
|
};
|
|
|
|
// 라우팅 등록
|
|
putTest (){
|
|
let _this = this;
|
|
let pdata = _this.tblList.getData();
|
|
let dupdata = pdata.map( data => data.REQ_INSP_ITEM ).filter( data => data );
|
|
if( dupdata.filter( (data,idx) => dupdata.indexOf(data) !== idx ).length > 0 ){
|
|
kuls_alert("검사종류가 중복됩니다.");
|
|
return false;
|
|
}
|
|
let postdata = {
|
|
'mode': 'putTestList',
|
|
'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(_this.mn);
|
|
}else{
|
|
kuls_alert(data.mesg);
|
|
}
|
|
},
|
|
error: function (request, status, error) {
|
|
kuls_alert(error.message);
|
|
},
|
|
complete: function () {
|
|
}
|
|
});
|
|
return true;
|
|
};
|
|
|
|
delTest (){
|
|
let _this = this;
|
|
_this.tblList.getSelectedRows().forEach(row => {
|
|
row.update({_STATUS_:'D'});
|
|
row.getElement().classList.add("del-row");
|
|
});
|
|
};
|
|
|
|
init () {
|
|
let _this = this;
|
|
|
|
const fields = [
|
|
{ formatter:"rowSelection", titleFormatter: "rowSelection", title: "No", width: "4%", },
|
|
{ field: "REQ_INSP_ITEM", title: "검사종류", width: "30%", editor:'list', cssClass:"user-list", editorParams:{ values: varsREQ_INSP_ITEM },
|
|
formatter: tb_common_funtions.formatterSelect, formatterParams: { values: varsREQ_INSP_ITEM }, },
|
|
{ field: "INSP_FLG", title: "검사<br>여부", width: "11%", formatter: tb_common_funtions.formatterCheckboxIcon, },
|
|
{ field: "INSP_DT", title: "검사일", width: "25%", editor:'date', editorParams: {max:'9999-12-31'}, },
|
|
{ field: "REMK", title: "비고", width: "25%", editor:'input', },
|
|
];
|
|
|
|
_this.tblList = new Tabulator("#tblTestList",{
|
|
layout: "fitColumns",
|
|
height: "100%",
|
|
maxHeight: "100%",
|
|
data: [], //기본 데이터
|
|
columns: fields, //컬럼 설정
|
|
columnDefaults: { //컬럼 공통 규칙
|
|
vertAlign: "middle",
|
|
hozAlign: "center",
|
|
resizable: "header",//Resize 는 헤더에서만 가능
|
|
headerHozAlign: "center", //헤더 정렬
|
|
headerSortTristate: true, //데이터 정렬 => 정/역/초기화
|
|
},
|
|
headerSortElement: "<i class='bi'></i>", //정렬 아이콘
|
|
});
|
|
|
|
_this.tblList.on("rowClick", (e,tgt) => { //Tabulator cell Click
|
|
_this.rowClick && Tb_funcs_Test.rowClick(e,tgt);
|
|
});
|
|
_this.tblList.on("cellClick", (e,tgt) => { //Tabulator cell Click
|
|
_this.cellClick && Tb_funcs_Test.cellClick(e,tgt);
|
|
});
|
|
_this.tblList.on("cellEdited", (cell) => { //Tabulator cell Edited
|
|
_this.cellEdited && Tb_funcs_Test.cellEdited(cell);
|
|
});
|
|
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnAddTest").addEventListener(evt,()=>{_this.addRow()}));
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnPutTest").addEventListener(evt,()=>{_this.putTest()}));
|
|
['click','keypress'].forEach(evt => document.querySelector("#btnDelTest").addEventListener(evt,()=>{_this.delTest()}));
|
|
};
|
|
}
|
|
|
|
const Tb_funcs_Detail = new Tb_class_Detail();
|
|
const Tb_funcs_Item = new Tb_class_Item();
|
|
const Tb_funcs_Sample = new Tb_class_Sample();
|
|
const Tb_funcs_Test = new Tb_class_Test();
|
|
const Tb_funcs_draw = new drawManager();
|
|
|
|
Tb_funcs_Detail.init();
|
|
Tb_funcs_Item.init();
|
|
Tb_funcs_Sample.init();
|
|
Tb_funcs_Test.init();
|
|
|
|
|
|
var config = {
|
|
settings:{showPopoutIcon:false, hasHeaders: true, showCloseIcon: false},
|
|
content:[{
|
|
type: 'column',
|
|
content:[{
|
|
type: 'component',
|
|
height:50,
|
|
componentName: 'so_detail',
|
|
},{
|
|
type: 'row',
|
|
content:[{
|
|
type: 'component',
|
|
componentName: 'item_info',
|
|
},{
|
|
type: 'component',
|
|
componentName: 'sample_info',
|
|
},{
|
|
type: 'component',
|
|
componentName: 'test_info',
|
|
}]
|
|
}],
|
|
}],
|
|
};
|
|
|
|
var GLlayout = new GoldenLayout( config, document.getElementById('lay') );
|
|
GLlayout.registerComponent( 'so_detail', function(container){this.container = container; this.container.getElement().append(document.getElementById('t1'))} );
|
|
GLlayout.registerComponent( 'item_info', function(container){this.container = container; this.container.getElement().append(document.getElementById('t2'))} );
|
|
GLlayout.registerComponent( 'sample_info', function(container){this.container = container; this.container.getElement().append(document.getElementById('t3'))} );
|
|
GLlayout.registerComponent( 'test_info', function(container){this.container = container; this.container.getElement().append(document.getElementById('t4'))} );
|
|
|
|
function dodo(){
|
|
GLlayout.init();
|
|
$(window).resize(function(){
|
|
GLlayout.updateSize();
|
|
});
|
|
}
|
|
|
|
window.addEventListener('resize', function(){
|
|
Tb_funcs_Detail.tblList.redraw(true);
|
|
Tb_funcs_Item.tblList.redraw(true);
|
|
Tb_funcs_Sample.tblList.redraw(true);
|
|
Tb_funcs_Test.tblList.redraw(true);
|
|
console.log(23);
|
|
}); |