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

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

@ -121,15 +121,15 @@
</tbody>
<template id="productListRow--productList">
<tr data-key="{keyCnt}">
<td class="cmn text-center" {onclick}="" {ondblclick}="">{prductCd}</td>
<td {onclick}="" {ondblclick}="">{prductNm}</td>
<td class="cmn text-end" {onclick}="" {ondblclick}="">{dsuseQy}</td>
<td class="cmn text-center prdDsuseImg" {onclick}="" {ondblclick}=""></td>
<td class="cmn text-center" {onclick}="" {ondblclick}="">{prdValidDe}</td>
<td class="cmn text-center" {onclick}="" {ondblclick}="">{mnfNo}</td>
<td class="cmn text-center" {onclick}="" {ondblclick}="">{mnfSeq}</td>
<td class="cmn text-center" {onclick}="" {ondblclick}="">{minDistbQy} {minDistbUnit}</td>
<td class="cmn text-center" {onclick}="" {ondblclick}="">{pceQy} {pceUnit}</td>
<td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{prductCd}</td>
<td onclick="{onclick}" ondblclick="{ondblclick}">{prductNm}</td>
<td class="cmn text-end" onclick="{onclick}" ondblclick="{ondblclick}">{dsuseQy}</td>
<td class="cmn text-center prdDsuseImg" onclick="{onclick}" ondblclick="{ondblclick}"></td>
<td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{prdValidDe}</td>
<td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{mnfNo}</td>
<td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{mnfSeq}</td>
<td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{minDistbQy} {minDistbUnit}</td>
<td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{pceQy} {pceUnit}</td>
</tr>
</template>
<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
let foundContent = document.getElementById("productListRow--productList").content;
@ -344,12 +344,27 @@
let replacer = (str, dataItem) => str
.replace(/{onclick}/gi, "pageObject['${pageName}'].productList.setCurrent('" + dataItem.getValue("keyCnt") + "');");
let trs = empty ? [document.getElementById("$productListNotFound--productList").content.outerHTML]
: $P.productList.inStrings(foundTr.outerHTML, replacer);
let di = $P.productList.getData(item[0].keyCnt, "item");
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;
}
console.log($P.productFormFields.get());
const data = {...$P.productFormFields.get(), keyCnt: prdRowKey++};
console.log(data);
$P.productList.addData([data]);
console.log($P.productFormFields.get());
const data = {...$P.productFormFields.get(), keyCnt : ""+prdRowKey++};
console.log(data);
$P.productList.append([data]);
// FIXME: 상품필드 초기화 코드 추가
//
}
@ -473,7 +488,7 @@ console.log(data);
, init: () => { setDialogZindex(); }
, onOK: () => {
console.log($P.productList.getCurrent().keyCnt);
debugger
$P.productList.remove($P.productList.getCurrent().keyCnt);
}
});
@ -504,7 +519,6 @@ console.log(data);
// 초기 화면 설정
$P.initForm = () => {
fnMakeScrollableTable($("#table-responsive--${pageName}")[0], $P.scrollDataList);
}

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