/* * @Overview 설비 관리 대장 * @History 2024-04-08 / 박민희 */ class Tb_main_class { constructor(container) { let _this = this; this.ajaxUrl = "./facility.ajax.php"; this.clickData = ""; this.container = document.querySelector(container); this.table = this.container.querySelector(".hy-table"); this.addBtn = this.container.querySelector(".add-btn"); this.removeBtn = this.container.querySelector(".remove-btn"); this.tbList =""; } // tableBuild 되었을때 getManList getMainList() { let _this = this; let talert = window.setTimeout(()=> { this.tbList.alert("Loading ...") }, 1000); let FACLT_CD =document.getElementById("FACLT_CD").value; let FACLT_NM =document.getElementById("FACLT_NM").value; let FACLT_GRP =document.getElementById("FACLT_GRP_P").value; let USEFLAG =document.getElementById("use_flag").value; ajax_json({ url: _this.ajaxUrl, data: { mode: "getFacilityList" ,FACLT_CD: FACLT_CD, FACLT_NM:FACLT_NM, FACLT_GRP: FACLT_GRP, USEFLAG : USEFLAG }, success: (data) => { this.tbList.setData(data.data); }, error: (req, status, err) => { kuls_alert(err.message); }, complete: () => { window.clearTimeout(talert); this.tbList.clearAlert(); // this.setFilter(); }, }); } setFilter() {} /* * @Overview 테이블 데이터 추가 함수 * @Parameter 없음 * @function 팝업 띄우기 */ addRow() { this.modalFacility(); } /* * @Overview 팝업 오픈 * @Parameter 설비 추가 및 수정 */ modalFacility(row_data) { let _this = this; vnLoad( '', './facility_pop.inc.php', '', (loadHtml)=>{ this.putFacilityModal = kuls_modal(loadHtml, { dontclose: true }) // rowData form에 입력 if(row_data){ const rowData = row_data.getData(); Object.keys(rowData).forEach( key => { if(document.querySelector(".custom-popup #"+key)){ document.querySelector(".custom-popup #"+key).value = rowData[key]; }; }); document.querySelector(".custom-popup #FACLT_CD").readOnly = true; const fileUrl = _this.getFileUrl('faclt', row_data.getData().FACLT_CD, row_data.getData().SID, row_data.getData().FILE_ID); if(row_data.getData().FILE_ID){ document.querySelector(".img-box").innerHTML = `
도면이미지
` } } const fileInput = document.querySelector("#file_input"); fileInput.addEventListener("change", (event) => { if (event.target.files.length > 0) { this.putTempFile(event.target.files[0], row_data); // 파일과 함께 rowData 전달 } }); // form 데이터 row에 입력 document.querySelector(".awn-popup-confirm .add-btn").addEventListener("click",(e)=>{ let _this = this; e.preventDefault(); const formData = new FormData(document.querySelector("#form")); if( row_data ){ formData.set("FACLT_CD_PK", row_data.getData()['FACLT_CD']); } if (formData.get("FACLT_CD_PK")) { formData.append("mode", "setForm"); }else{ formData.append("mode", "putForm" ); } console.log(formData); ajax_form({ url: _this.ajaxUrl, data: formData, success: (data)=>{ if (data.code) { // document.querySelector("#FACLT_CD_PK").value = faclt_cd; _this.getMainList(); kuls_success("적용 되었습니다."); }else{ kuls_alert(data.mesg); } }, error: function(req, stat, err){ kuls_alert(err.message); } }); this.putFacilityModal.delete(); }); },); }; editRow(){ var form = document.getElementById("form"); let temdata = new FormData(form); let newdata = Object.fromEntries(temdata); //form데이터 newdata["_STATUS_"] = "U"; // return newdata; } /* * @Overview 테이블 행 삭제 함수 * @Parameter 없음 * @function 선택된 모든 행 삭제 */ removeRow() { const selectedRows = this.tbList.getRows().filter(row=>{ return row.getData().check ==="Y" }); if(selectedRows.length > 0 ){ // 선택된 각 행 삭제 selectedRows.forEach((row) => { // STAUS D로 바꾸기 row.getData()._STATUS_ = row.getData()._STATUS_=="I"?null:"D"; const rowElement = row.getElement(); rowElement.classList.add("remove-row"); }); }else{ kuls_alert("삭제할 행을 선택해주세요.") } } //거래처등록 사진 업로드 putTempFile(file){ let _this = this; let formData = new FormData(); formData.append('upfile', file); formData.append('mode', "putTempFile"); ajax_form({ url: _this.ajaxUrl, data: formData, success: (data)=>{ if ( data.code ) { let file_name = data.data.tmp_name; document.querySelector("#tmp_file").value = file_name; }else{ kuls_alert(data.mesg); } }, error: (req, stat, err) => { kuls_alert(err.message); }, }); return true; } getFileUrl = function(kind,FACLT_CD, SID, FILE_ID){ let urlStr = ""; if(kind == "faclt"){ urlStr = '/include/getFile.php'+"?gubun=faclt&nid=" + FACLT_CD + "&sid="+ SID + "&file_id="+ FILE_ID }else{ urlStr = '/include/getFile.php'+"?gubun=faclt&ITEM_CD=" + FACLT_CD + "&ROUT_SQNO="+ SID + "&name="+FILE_ID } return urlStr; } /* * @Overview 테이블 행 순서 변경 함수 * @Parameter 방향 * @function 선택된 모든 행 순서 변경 */ upDownRow(dir) { } // 클릭 이벤트 rowClick(e, tgt) { let _this = this; let clickRow = tgt._row; Tb_process.code = null; Tb_process.getMainList(tgt.getData().FACLT_CD); Tb_repair.getMainList(tgt.getData().FACLT_CD); if (tgt.isSelected()) { //tgt.deselect(); this.clearRemove(tgt); Tb_process.getMainList(null); // Tb_process_check.getMainList(clickData); } else { _this.tbList.deselectRow(); tgt.select(); Tb_process.getMainList(tgt.getData().FACLT_CD); } } clearRemove(tgt){ if(tgt._row.data._STATUS_ == "D"){ // console.log(); tgt._row.data._STATUS_ = ""; tgt._row.getElement().classList.remove("remove-row") // const selectedRows = this.tbList.getSelectedRows(); // 선택된 모든 행 가져오기 } } // 삭제가 가능하도록 ROW SELECT // let rowData = tgt._row.data; //row 클릭 시 rowData 설비에 입력 현재 MAPPING 하지 않은 상태 // let {EDIT_USER_ID,EDIT_TM,FACLT_SPEC // ,INTNL_USE_DEPT_CD,INTNL_USE_DEPT_NM // ,MAJR_EMP_NM,MAKER_NM,MAKE_TM,MAKE_USER_ID,MINR_EMP_NM,PURPOS_USAGE,PUR_BP_NM,PUR_DT,PUR_PRSN_NM,PUR_REPRE_NM,PUR_TEL_NO,MANUL_FLG,USE_FLG,WRK_TEAM, ...otherData} = rowData; // for(let temp in otherData){ // if(document.getElementById(`${temp}`).value !== null){ // document.getElementById(`${temp}`).value = rowData[temp]??''; // } // } // document.getElementById("FACLT_CD").readOnly = true; // Tb_process.getMainList(); // _this.formInit(); //추후 수정 // const output = document.querySelector('.img-box'); // output.innerHTML = ` // 이미지 파일이 존재하지 않습니다 //
// //
// ` /* * @Overview 테이블 행 더블 클릭시에 팝업 * @Parameter 이벤트, 타겟 행 */ rowDblClick(e, tgt) { // popClientEditor({ // // },tgt) let _this = this; let row = tgt; _this.modalFacility(row); } /* * @Overview 선택한 CELL의 정보 또는 상태 변화에 활용하는 함수 * @Parameter 클릭한 CELL 데이터 */ cellClick(e, tgt) { const _this = this; // 체크박스 클릭 switch (tgt.getField()) { case "check": tgt.setValue(tgt.getValue() == "Y" ? "" : "Y"); this.clearRemove(tgt.getRow()) break; case "USE_FLG": tgt.setValue(tgt.getValue() == "Y" ? "" : "Y"); tgt.getElement().classList.add("tabulator-editable") break; default: if( !_this.rowIsClicked ){ //setTimeout을 시작하지 않았으면 _this.rowIsClicked = window.setTimeout(function(){ //0.3초후에 rowClick 함수를 실행 _this.rowClick && _this.rowClick(e, tgt.getRow()); delete _this.rowIsClicked; },200); }else{ //0.3초 이전에 클릭을 다시하면 //window.clearTimeout(_this.rowIsClicked); //rowdblClick 실행 setTimeout을 해제( 값 가지고 오지 마세요 ) delete _this.rowIsClicked; } break; } } // 셀 수정 cellEdited(cell) { cell.getData()._STATUS_ = cell.getData()._STATUS_ || "U"; } //기본건 삭제만 가능 putData() { const _this = this; // 기본키 중복 확인 및 방지 // _STATUS_ 있는 데이터만 들고와서 PUT하기 let postdata = { 'mode': 'deleteForm', 'reqdata': JSON.stringify(this.tbList.getData().filter(row=> row._STATUS_)), }; ajax_json({ url: _this.ajaxUrl, data: postdata, success: function (data) { if (data.code) { kuls_success("저장되었습니다."); _this.getMainList(); Tb_process.getMainList(); Tb_repair.getMainList(); }else{ kuls_alert(data.mesg); } }, error: function (request, status, error) { kuls_alert(error.message); }, complete: function () { } }); return true; } //이미지 미리보기 previewImage=(event)=>{ for (var image of event.target.files) { var reader = new FileReader(); reader.onload = function(event) { var img = document.createElement("img"); img.setAttribute("src", event.target.result); document.querySelector("div#image_container").appendChild(img); }; reader.readAsDataURL(image); } } /* * @Overview 최초 실행 함수 * @Parameter 없음 */ init() { let _this = this; // field 정의 const fields = [ { field:"check", title: "삭제", width: 50, headerSort: false,formatter: tb_common_funtions.formatterCheckboxIcon,formatterParams: { checkval: "Y" },}, { formatter:"rownum", title: "NO", width: 50 }, { field: "FACLT_GRP", title: "설비그룹", width: 110 , headerSort: true, hozAlign:'center', }, { field: "FACLT_CD", title: "설비코드", width: 150 , headerSort: true, hozAlign:'center', }, { field: "FACLT_NM", title: "설비명", width: 150 , headerSort: true, hozAlign:'center', }, //formatter : 숫자 EA { field: "USE_FLG", title: "사용", width: 50, headerSort: true, hozAlign:'center', formatter: tb_common_funtions.formatterToggleboxGreenIcon, formatterParams: { checkval: "Y" }, cssClass: "tabulator-editable" }, //formatter : 숫자 EA { field: "ITEM_GRP", title: "설비그룹", width: 150, visible:false }, { field: "FILE_ID", title: "FILE_ID", width: 50, visible:false}, { field: "FILE_NAME", title: "FILE_NAME", width: 50, visible:false}, { field: "SID", title: "SID", width: 50, visible:false} ]; const commonFieldData = { headerSort: true, vertAlign: "middle", hozAlign: "center", resizable: "header", //Resize 는 헤더에서만 가능 headerHozAlign: "center", //헤더 정렬 headerSortTristate: true, //데이터 정렬 => 정/역/초기화 }; _this.tbList = new Tabulator(this.table, { layout: "fitColumns", // selectableRows: 1, data: [], //기본 데이터 columns: fields, //컬럼 설정 columnDefaults: commonFieldData, headerSortElement: "", }); // 데이터 불러오기 this.tbList.on("tableBuilt", () => { this.getMainList(); }); // row 클릭 시에 // this.tbList.on("rowClick", (e, tgt) => { // if( !_this.rowIsClicked ){ //setTimeout을 시작하지 않았으면 // _this.rowIsClicked = window.setTimeout(function(){ //0.3초후에 rowClick 함수를 실행 // _this.rowClick && _this.rowClick(e, tgt); // delete _this.rowIsClicked; // },200); // }else{ //0.3초 이전에 클릭을 다시하면 // //window.clearTimeout(_this.rowIsClicked); //rowdblClick 실행 setTimeout을 해제( 값 가지고 오지 마세요 ) // delete _this.rowIsClicked; // } // }); // row 클릭 시에 this.tbList.on("rowDblClick", (e, tgt) => { this.rowDblClick && this.rowDblClick(e, tgt); }); // cell 클릭 시에 this.tbList.on("cellClick", (e, tgt) => { this.cellClick && this.cellClick(e, tgt); }); // cell 수정 시에 this.tbList.on("cellEdited", (cell) => { this.cellEdited && this.cellEdited(cell); }); function tabWork(elementId, className) { var element = document.getElementById(elementId); if (!element || !element.classList) { return false; } return element.classList.contains(className); } // 추가 ["click", "keypress"].forEach((evt) => { this.addBtn?.addEventListener(evt, () => { this.addRow && this.addRow(); }); }); // 삭제 ["click", "keypress"].forEach((evt) => { this.removeBtn.addEventListener(evt, () => { // 삭제 함수 _this.removeRow && this.removeRow(); }); }); // 조회 ["click", "keypress"].forEach((evt) => { const filterBtn = document.querySelector("#filter_btn"); filterBtn.addEventListener(evt, () => { this.getMainList && this.getMainList(); // setFilter 또는 setData }); }); // 저장 ["click", "keypress"].forEach((evt) => { let _this = this; const putBtn = document.querySelector("#put_item"); putBtn.addEventListener(evt, () => { // let base64String = document.getElementsByClassName("img-box")[0].outerHTML; // let firstSlice = base64String.indexOf("base64,")+1; // `=" alt` // let base64String = document.getElementsByClassName("img-box")[0].outerHTML; // let firstSlice = base64String.indexOf("base64,")+7; // let lastSlice = base64String.indexOf("\" alt="); // file = base64String.substring(firstSlice,lastSlice); this.putData && this.putData(); Tb_process.putData && Tb_process.putData(); }); }); } } class Tb_process_class { constructor(container) { let _this = this; this.ajaxUrl = "./facility.ajax.php"; this.container = document.querySelector(container); this.table = this.container.querySelector(".hy-table"); this.SEQNO = 0; // this.upBtn = this.container.querySelector(".up-btn") || ""; // this.downBtn = this.container.querySelector(".down-btn") || ""; this.addBtn = this.container.querySelector(".add-btn"); this.removeBtn = this.container.querySelector(".remove-btn"); _this.tbList = ""; } // tableBuild 되었을때 getManList getMainList(FACLT_CD) { // const selectData = Tb_facility.tbList.getSelectedData()[0]?.FACLT_CD; //FACLT_CD : Tb_facility.selectRowgetSelectedData()[0].FACLT_CD this.code = FACLT_CD; let talert = window.setTimeout(()=> { this.tbList.alert("Loading ...") }, 1000); ajax_json({ url: this.ajaxUrl, data: { mode: "getprocess", FACLT_CD: this.code}, success: (data) => { this.tbList.setData(data.data); this.SEQNO = data.data[data.data.length - 1]?data.data[data.data.length - 1].SEQNO : 0; }, error: (req, status, err) => { kuls_alert(err.message); }, complete: () => { window.clearTimeout(talert); this.tbList.clearAlert(); // this.setFilter(); }, }); } putData() { if(this.tbList.getData().filter(row=> row._STATUS_).length == 0){ this.getMainList(); return false; } const postdata = { 'mode': 'putProcess', 'reqdata': JSON.stringify(this.tbList.getData().filter(row=> row._STATUS_)) }; ajax_form({ url: this.ajaxUrl, type: "POST", data: JSON.stringify(postdata), success: (data)=>{ if( data.code ){ kuls_success("적용 되었습니다."); //_this.getRepairInfo(formdata.get("FACLT_CD")); // Tb_funcs.putFacilityModal.delete(); this.getMainList(this.code); }else{ kuls_alert(data.mesg); } }, error: function (request, status, error) { kuls_alert(error.message); }, complete: function(){ } }); }; setFilter() {} /* * @Overview 테이블 행 추가 함수 * @Parameter 없음 * @function 기본키, _STATUS_:I 값을 넣은 행 추가 */ addRow() { if (this.code === undefined){ kuls_alert("설비코드를 선택해주세요") return false; } this.SEQNO += 1; if(this.code){ this.tbList.addRow({ SEQNO: this.SEQNO, FACLT_CD: this.code, _STATUS_: "I" },true); } } /* * @Overview 테이블 행 삭제 함수 * @Parameter 없음 * @function 선택된 모든 행 삭제 */ removeRow() { const selectedRows = this.tbList.getRows().filter(row => { return row.getData().check === "Y" }); if (selectedRows.length > 0) { kuls_confirm("삭제", "하시겠습니까?", () => { // 선택된 각 행 삭제 selectedRows.forEach((row) => { // STAUS D로 바꾸기 row.getData()._STATUS_ = row.getData()._STATUS_ == "I" ? null : "D"; const rowElement = row.getElement(); rowElement.classList.add("remove-row"); }); }) } else { kuls_alert("삭제할 행을 선택해주세요.") } } /* * @Overview 테이블 행 순서 변경 함수 * @Parameter 방향 * @function 선택된 모든 행 순서 변경 */ upDownRow(dir) { } /* * @Overview 삭제 취소 함수 * @Parameter 삭제 행 * @function 클릭시 삭제 취소 & STATUS를 공란으로 변경 */ clearRemove(tgt) { if (tgt._row.data._STATUS_ == "D") { // console.log(); tgt._row.data._STATUS_ = ""; tgt._row.getElement().classList.remove("remove-row") // const selectedRows = this.tbList.getSelectedRows(); // 선택된 모든 행 가져오기 } } /* * @Overview 테이블 행 클릭 함수 * @Parameter 셀 * @function 클릭한 테이블 행 선택 */ rowClick(e,tgt) { // 삭제가 가능하도록 ROW SELECT // staus D로 바꾸기? if (tgt.isSelected()) { tgt.deselect(); } else { this.tbList.deselectRow(); tgt.select(); } } cellClick(e, tgt) { const editor = tgt.getColumn().getDefinition().editor; // 체크박스 클릭 switch (tgt.getField()) { // case "OP_CD": // popOper({ // OP_CD : "OP_CD", // OP_NM: "OP_NM" // },tgt.getRow()); // break; case "USE_FLG": tgt.setValue(tgt.getValue() == "Y" ? "N" : "Y"); break; default: if (!editor) { this.rowClick && this.rowClick(e, tgt.getRow()); } break; case "check": tgt.setValue(tgt.getValue() == "Y" ? "" : "Y"); this.clearRemove(tgt.getRow()) break; } } // 셀 수정 cellEdited(cell) { cell.getData()._STATUS_ = cell.getData()._STATUS_ || "U"; } /* * @Overview 최초 실행 함수 * @Parameter 없음 * 설비별 생산 이력 */ init() { // field 정의 const fields = [ // { field:"check", title: "선택", width: 50, headerSort: false,formatter: tb_common_funtions.formatterCheckboxIcon,formatterParams: { checkval: "Y" },}, { field: "SEQNO", title: "NO", width: 50 }, // { field: "SEQNO", formatter: "rownum", title: "NO", width: 50 }, { field: "OP_CD", title: "공정코드", width: 80 , headerSort: true, hozAlign:'center',},// cssClass:"editable-cell", }, { field: "OP_NM", title: "공정명", width: 80 , headerSort: true, hozAlign:'left',}, { field: "ITEM_GRP", title: "품목그룹", width: 70 , headerSort: true, hozAlign:'center',}, { field: "ITEM_CD", title: "품목코드", width: 100 , headerSort: true, hozAlign:'center', }, { field: "ITEM_NM", title: "품명", width: 300, headerSort: true, hozAlign:'left', }, { field: "REMK", title: "비고", width: 300, headerSort: true, hozAlign:'left', }, // { field: "USE_FLG", title: "사용", width: 50, cssClass:"editable-cell", formatter: tb_common_funtions.formatterToggleboxGreenIcon, formatterParams: {checkval:'Y'} }, ]; const commonFieldData = { headerSort: true, vertAlign: "middle", hozAlign: "center", resizable: "header", //Resize 는 헤더에서만 가능 headerHozAlign: "center", //헤더 정렬 headerSortTristate: true, //데이터 정렬 => 정/역/초기화 }; this.tbList = new Tabulator(this.table, { layout: "fitColumns", // selectableRows: true, data: [], //기본 데이터 columns: fields, //컬럼 설정 columnDefaults: commonFieldData, headerSortElement: "", }); // 데이터 불러오기 this.tbList.on("tableBuilt", () => { // this.getMainList(); }); // row 클릭 시에 // this.tbList.on("rowClick", (e, tgt) => { // this.rowClick && this.rowClick(e, tgt); // }); // cell 클릭 시에 this.tbList.on("cellClick", (e, tgt) => { this.cellClick && this.cellClick(e, tgt); }); // cell 수정 시에 this.tbList.on("cellEdited", (cell) => { this.cellEdited && this.cellEdited(cell); }); /* // 추가 ["click", "keypress"].forEach((evt) => { this.addBtn.addEventListener(evt, () => { // Tb_facility.addRow(); this.addRow && this.addRow(); }); }); // 삭제 ["click", "keypress"].forEach((evt) => { this.removeBtn.addEventListener(evt, () => { // 삭제 함수 this.removeRow && this.removeRow(); }); }); */ } } /* * @Overview 팝업 * @Parameter 없음 */ class Tb_repair_class{ constructor(container) { this.ajaxUrl = "./facility.ajax.php"; this.container = document.querySelector(container); this.table = this.container.querySelector(".hy-table"); // this.upBtn = this.container.querySelector(".up-btn") || ""; // this.downBtn = this.container.querySelector(".down-btn") || ""; // this.addBtn = this.container.querySelector(".add-btn"); // this.removeBtn = this.container.querySelector(".remove-btn"); } getMainList(FACLT_CD) { // const selectData = Tb_facility.tbList.getSelectedData()[0]?.FACLT_CD; //FACLT_CD : Tb_facility.selectRowgetSelectedData()[0].FACLT_CD this.code = FACLT_CD; let talert = window.setTimeout(()=> { this.tbList.alert("Loading ...") }, 1000); ajax_json({ url: this.ajaxUrl, data: { mode: "getRepair", FACLT_CD: this.code}, success: (data) => { this.tbList.setData(data.data); this.SEQNO = data.data[data.data.length - 1]?data.data[data.data.length - 1].SEQNO : 0; }, error: (req, status, err) => { kuls_alert(err.message); }, complete: () => { window.clearTimeout(talert); this.tbList.clearAlert(); // this.setFilter(); }, }); } addRow(){ } removeRow(){} /* * @Overview 선택한 ROW의 정보 또는 상태 변화에 활용하는 함수 * @Parameter 클릭한 row 데이터 */ rowClick(e, tgt) { if (tgt.isSelected()) { tgt.deselect(); } else { tgt.select(); } } /* * @Overview 선택한 CELL의 정보 또는 상태 변화에 활용하는 함수 * @Parameter 클릭한 CELL 데이터 */ cellClick(e, tgt) { const editor = tgt.getColumn().getDefinition().editor; //에디터 속성을 가진 컬럼 변수(컬럼에 editor : input 을 부여하면 수정 가능해진다) switch (tgt.getField()) { default: if (!editor) { this.rowClick && this.rowClick(e, tgt.getRow()); } break; } } // 셀 수정 cellEdited(cell) { cell.getData()._STATUS_ = cell.getData()._STATUS_ || "U"; } init(){ const fields = [ { formatter:"rownum", title:"NO", width:50, headerSort:false }, { field:"REPAIR_DT", title:"수리일", width:150, formatter:"datetime", formatterParams:{ inputFormat:"yyyy-MM-dd", outputFormat:"yyyy.MM.dd", } }, { field:"REPAIR_CONTENT", title:"수리내역", width:150, }, { field:"REPAIR_AMT", title:"수리비용", width:120, formatter:"money", formatterParams:{ decimal:".", thousand:",", symbol:"₩", symbolAfter: false, negativeSign:true, precision:false, } }, { field:"REPAIR_BP_NM", title:"수리업체", width:100, }, { field:"REPAIR_TEL_NO", title:"전화번호", width:200, }, ] const commonFieldData = { headerSort: false, vertAlign: "middle", hozAlign: "center", resizable: "header", //Resize 는 헤더에서만 가능 headerHozAlign: "center", //헤더 정렬 headerSortTristate: true, //데이터 정렬 => 정/역/초기화 }; this.tbList = new Tabulator(this.table, { layout: "fitColumns", data: [], //기본 데이터 columns: fields, //컬럼 설정 columnDefaults: commonFieldData, headerSortElement: "", }); // 데이터 불러오기 this.tbList.on("tableBuilt", () => { // this.getMainList(); }); // row 클릭 시에 this.tbList.on("rowClick", (e, tgt) => { this.rowClick && this.rowClick(e, tgt); }); // cell 클릭 시에 this.tbList.on("cellClick", (e, tgt) => { this.cellClick && this.cellClick(e, tgt); }); // cell 수정 시에 this.tbList.on("cellEdited", (cell) => { this.cellEdited && this.cellEdited(cell); }); } } const Tb_facility = new Tb_main_class("#main_table"); Tb_facility.init(); const Tb_process = new Tb_process_class("#process_table"); Tb_process.init(); const Tb_repair = new Tb_repair_class("#repair_table"); Tb_repair.init(); /* * @Overview form 이미지 등록/수정 및 미리 보기 (html에서 사용중) * @Parameter event */ function previewImage(event) { const reader = new FileReader(); reader.onload = function () { const output = document.querySelector(".img-box"); output.innerHTML = `
도면 이미지
`; // 이미지 미리보기 설정 }; const file = event.target.files[0]; reader.readAsDataURL(file); } //폼에 사진 제거하기 function removeFile(e) { e.preventDefault(); // 기본 이벤트를 방지 const facLtCd = document.querySelector(".custom-popup #FACLT_CD").value; const fileId = document.querySelector(".custom-popup #FILE_ID").value; const sid = document.querySelector(".custom-popup #SID").value; kuls_confirm("삭제", "하시겠습니까?", function() { const talert = window.setTimeout(() => { alert("Loading..."); }, 1000); ajax_json({ url: "./facility.ajax.php", data: { mode: 'deleteImg', FILE_ID: fileId, SID: sid, FACLT_CD: facLtCd, }, success: (data) => { if (data.code) { document.querySelector(".custom-popup #img_preview").src = ''; kuls_alert('삭제되었습니다.'); removeImage(); } else { kuls_alert(data.mesg); } }, error: (err) => { kuls_alert(err.message); }, complete: () => { window.clearTimeout(talert); // this.tbList.clearAlert(); } }); }); } /* * @Overview form 이미지 및 미리 보기 삭제 * @Parameter 없음 */ function removeImage() { // 이미지 미리보기 제거 const output = document.querySelector(".img-box"); output.innerHTML = ""; } localAutoHyphen = (target) => { target.value = target.value .replace(/[^0-9]/g, '') .replace(/^(\d{2,3})(\d{3,4})(\d{4})$/, `$1-$2-$3`); }