fix : 상품 목록 제거 기능 추가(폐기신청서접수 등록 화면), 그리드 이미지 뷰어 수정

dev
이범준 5 months ago
parent 38061cfbed
commit 8ceb9372a7

@ -121,15 +121,15 @@
</tbody> </tbody>
<template id="productListRow--productList"> <template id="productListRow--productList">
<tr data-key="{keyCnt}"> <tr data-key="{keyCnt}">
<td class="cmn text-center" {onclick}="" {ondblclick}="">{prductCd}</td> <td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{prductCd}</td>
<td {onclick}="" {ondblclick}="">{prductNm}</td> <td onclick="{onclick}" ondblclick="{ondblclick}">{prductNm}</td>
<td class="cmn text-end" {onclick}="" {ondblclick}="">{dsuseQy}</td> <td class="cmn text-end" onclick="{onclick}" ondblclick="{ondblclick}">{dsuseQy}</td>
<td class="cmn text-center prdDsuseImg" {onclick}="" {ondblclick}=""></td> <td class="cmn text-center prdDsuseImg" onclick="{onclick}" ondblclick="{ondblclick}"></td>
<td class="cmn text-center" {onclick}="" {ondblclick}="">{prdValidDe}</td> <td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{prdValidDe}</td>
<td class="cmn text-center" {onclick}="" {ondblclick}="">{mnfNo}</td> <td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{mnfNo}</td>
<td class="cmn text-center" {onclick}="" {ondblclick}="">{mnfSeq}</td> <td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{mnfSeq}</td>
<td class="cmn text-center" {onclick}="" {ondblclick}="">{minDistbQy} {minDistbUnit}</td> <td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{minDistbQy} {minDistbUnit}</td>
<td class="cmn text-center" {onclick}="" {ondblclick}="">{pceQy} {pceUnit}</td> <td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{pceQy} {pceUnit}</td>
</tr> </tr>
</template> </template>
<template id="productListNotFound--productList"> <template id="productListNotFound--productList">
@ -326,10 +326,10 @@
}); });
} }
$P.productList.onDatasetChange = item => {
if (!item) return;
let empty = $P.productList.empty; $P.productList.onAppend = item => {
if (!item) return;
// 업무별 DataTables(그리드) tr, td // 업무별 DataTables(그리드) tr, td
let foundContent = document.getElementById("productListRow--productList").content; let foundContent = document.getElementById("productListRow--productList").content;
@ -344,12 +344,27 @@
let replacer = (str, dataItem) => str let replacer = (str, dataItem) => str
.replace(/{onclick}/gi, "pageObject['${pageName}'].productList.setCurrent('" + dataItem.getValue("keyCnt") + "');"); .replace(/{onclick}/gi, "pageObject['${pageName}'].productList.setCurrent('" + dataItem.getValue("keyCnt") + "');");
let trs = empty ? [document.getElementById("$productListNotFound--productList").content.outerHTML] let di = $P.productList.getData(item[0].keyCnt, "item");
: $P.productList.inStrings(foundTr.outerHTML, replacer);
let tr = di.inString(foundTr.outerHTML, replacer);
$("#table-responsive--${pageName}")[0].changeContent(trs.join(), true, true); $("#tbody--productList").append(tr);
fnMakeGridImageViewer($("#tbody--productList").find("td.prdDsuseImg").get(), "dsusePrdImgFiles"); fnMakeGridImageViewer($("#tbody--productList").find("td.prdDsuseImg").last()[0], "dsusePrdImgFiles");
}
$P.productList.onRemove = item => {
let key = item[0].data.keyCnt;
$("#tbody--productList").find("tr[data-key='"+key+"']").remove();
}
$P.productList.onCurrentChange = item => {
if (!item) return;
let key = item.data.keyCnt;
$("#tbody--productList").setCurrentRow(key);
} }
/************************************************************************** /**************************************************************************
@ -456,10 +471,10 @@
return false; return false;
} }
console.log($P.productFormFields.get()); console.log($P.productFormFields.get());
const data = {...$P.productFormFields.get(), keyCnt: prdRowKey++}; const data = {...$P.productFormFields.get(), keyCnt : ""+prdRowKey++};
console.log(data); console.log(data);
$P.productList.addData([data]); $P.productList.append([data]);
// FIXME: 상품필드 초기화 코드 추가 // FIXME: 상품필드 초기화 코드 추가
// //
} }
@ -473,7 +488,7 @@ console.log(data);
, init: () => { setDialogZindex(); } , init: () => { setDialogZindex(); }
, onOK: () => { , onOK: () => {
console.log($P.productList.getCurrent().keyCnt); console.log($P.productList.getCurrent().keyCnt);
debugger
$P.productList.remove($P.productList.getCurrent().keyCnt); $P.productList.remove($P.productList.getCurrent().keyCnt);
} }
}); });
@ -504,7 +519,6 @@ console.log(data);
// 초기 화면 설정 // 초기 화면 설정
$P.initForm = () => { $P.initForm = () => {
fnMakeScrollableTable($("#table-responsive--${pageName}")[0], $P.scrollDataList);
} }

@ -1,49 +1,48 @@
/************************************************************************** /**************************************************************************
* 그리드 내부 이미지 첨부 * 그리드 내부 이미지 첨부
**************************************************************************/ **************************************************************************/
function fnMakeGridImageViewer(tdEls, fileInputElName){ function fnMakeGridImageViewer(tdEl, fileInputElName){
for(let tdEl of tdEls){ let fileInputEl = document.createElement("input");
fileInputEl.name = fileInputElName;
let fileInputEl = document.createElement("input"); fileInputEl.type = "file";
fileInputEl.name = fileInputElName; fileInputEl.setAttribute("hidden","hidden");
fileInputEl.type = "file"; fileInputEl.setAttribute("accept","image/*")
fileInputEl.setAttribute("hidden","hidden"); tdEl.appendChild(fileInputEl);
fileInputEl.setAttribute("accept","image/*")
tdEl.appendChild(fileInputEl); let uploadButtonEl = document.createElement("button");
uploadButtonEl.type = "button";
let uploadButtonEl = document.createElement("button"); uploadButtonEl.classList.add("btn","btn-primary","w-px-50", "mx-1");
uploadButtonEl.type = "button"; uploadButtonEl.textContent = "등록";
uploadButtonEl.classList.add("btn","btn-primary","w-px-50", "mx-1"); tdEl.appendChild(uploadButtonEl);
uploadButtonEl.textContent = "등록";
tdEl.appendChild(uploadButtonEl); let viewButtonEl = document.createElement("button");
viewButtonEl.type = "button";
let viewButtonEl = document.createElement("button"); viewButtonEl.classList.add("btn","btn-primary","w-px-50", "mx-1");
viewButtonEl.type = "button"; viewButtonEl.setAttribute("hidden","hidden");
viewButtonEl.classList.add("btn","btn-primary","w-px-50", "mx-1"); viewButtonEl.textContent = "보기";
viewButtonEl.setAttribute("hidden","hidden"); tdEl.appendChild(viewButtonEl);
viewButtonEl.textContent = "보기";
tdEl.appendChild(viewButtonEl); $(fileInputEl).on("change", function(){
if(this.files != null && this.files.length > 0){
$(fileInputEl).on("change", function(){ $(uploadButtonEl).text("수정");
if(this.files != null && this.files.length > 0){ $(viewButtonEl).removeAttr("hidden");
$(uploadButtonEl).text("수정"); } else {
$(viewButtonEl).removeAttr("hidden"); $(uploadButtonEl).text("등록");
} else { $(viewButtonEl).attr("hidden","hidden");
$(uploadButtonEl).text("등록"); }
$(viewButtonEl).attr("hidden","hidden"); });
}
}); $(uploadButtonEl).on("click", function(){
$(fileInputEl).click();
$(uploadButtonEl).on("click", function(){ });
$(fileInputEl).click();
}); $(viewButtonEl).on("click", function(){
$(viewButtonEl).on("click", function(){ let viewUrl = (window.URL || window.webkitURL).createObjectURL(fileInputEl.files[0]);
window.open((window.URL || window.webkitURL).createObjectURL(fileInputEl.files[0])
, "이미지" window.open(viewUrl, "이미지", "width=500, height=500");
, "width=500, height=500"); });
});
}
} }
Loading…
Cancel
Save