에러날것임. 소스 보존을 위해
This commit is contained in:
@@ -36,6 +36,14 @@
|
||||
</button>
|
||||
|
||||
|
||||
<div class="component-input align-center" id="forestProductStatusDiv">
|
||||
<label class="checkbox-inner">
|
||||
<input type="checkbox" id="forestProductStatus" name="forestProductStatus"
|
||||
th:value="${MonthStatus.NOTHING}" onchange="formControl.handleNoDataToggle()">
|
||||
<span class="checkbox-item"><span class="checkbox-txt">이번달 등록내용 없음</span></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
@@ -45,7 +53,7 @@
|
||||
<div class="component-btns fixed">
|
||||
<div class="btns-row">
|
||||
<!-- 비활성화 스타일/ 버튼 속성 disabled 추가-->
|
||||
<button type="button" class="btn btn-l btn-primary" id="complateBtn">
|
||||
<button type="button" class="btn btn-l btn-primary" id="complateBtn" disabled>
|
||||
<span class="btn-txt">등록 완료</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -74,7 +82,7 @@
|
||||
</div>
|
||||
<div class="modal-content">
|
||||
<div class="modal-content-inner">
|
||||
<form id="forestForm">
|
||||
<form id="popupForm">
|
||||
<input type="hidden" name="id" id="id">
|
||||
<input type="hidden" name="transferType" id="transferType">
|
||||
|
||||
@@ -257,7 +265,7 @@
|
||||
|
||||
<div class="component-btns">
|
||||
<div class="btns-row">
|
||||
<button type="button" class="btn btn-full btn-l btn-primary">
|
||||
<button type="button" class="btn btn-full btn-l btn-primary" onclick="formControl.saveFormData()">
|
||||
<span class="btn-txt">등록</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -302,7 +310,11 @@
|
||||
editable: /*[[${editable}]]*/,
|
||||
},
|
||||
elementRefs: {
|
||||
|
||||
noDataCheckbox: document.getElementById("forestProductStatus"),
|
||||
addButton: {
|
||||
button: null,
|
||||
icon: null
|
||||
}
|
||||
},
|
||||
isSubmitted: false
|
||||
};
|
||||
@@ -320,7 +332,6 @@
|
||||
ENV.module.modalPopup = document.querySelector(".addPopup").ui;
|
||||
},
|
||||
bindDecimalLimit() {
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.querySelectorAll(".limitDecimalLength").forEach(input => {
|
||||
input.addEventListener("input", () => {
|
||||
alert('22');
|
||||
@@ -332,22 +343,15 @@
|
||||
input.value = parts.join('.');
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
bindAmountLimit() {
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.querySelectorAll(".limitAmountLength").forEach(input => {
|
||||
input.addEventListener("input", () => {
|
||||
// 숫자 이외 문자 제거
|
||||
let val = input.value.replace(/[^0-9]/g, '');
|
||||
|
||||
// 최대 10자리 제한
|
||||
if (val.length > 10) {
|
||||
val = val.slice(0, 10);
|
||||
}
|
||||
|
||||
input.value = val;
|
||||
});
|
||||
document.querySelectorAll(".limitAmountLength").forEach(input => {
|
||||
input.addEventListener("input", () => {
|
||||
let val = input.value.replace(/[^0-9]/g, '');
|
||||
if (val.length > 10) {
|
||||
val = val.slice(0, 10);
|
||||
}
|
||||
input.value = val;
|
||||
});
|
||||
});
|
||||
},
|
||||
@@ -357,6 +361,10 @@
|
||||
const icon = addItemBtn.querySelector("i");
|
||||
//이전 데이터 취득 버튼
|
||||
const callPastInfoBtn = document.getElementById("callPastInfoBtn");
|
||||
|
||||
//데이터 없음 버튼
|
||||
const forestProductStatus = document.getElementById("forestProductStatus");
|
||||
|
||||
//등록 완료 버튼
|
||||
const next = document.getElementById('complateBtn');
|
||||
|
||||
@@ -382,8 +390,8 @@
|
||||
next.disabled = true;
|
||||
|
||||
} else if (ENV.data.currentStatus == "REGISTERED") {
|
||||
if (ENV.data.productList.length > 0) {
|
||||
ENV.data.productList.forEach(data => productRenderer.addItem(data, true));
|
||||
if (ENV.data.bankList.length > 0) {
|
||||
ENV.data.bankList.forEach(data => productRenderer.addItem(data, true));
|
||||
this.updateLayout();
|
||||
} else {
|
||||
|
||||
@@ -392,11 +400,11 @@
|
||||
} else {
|
||||
|
||||
if (ENV.data.currentStatus == "REGISTERED") {
|
||||
if (ENV.data.productList.length > 0) {
|
||||
ENV.data.productList.forEach(data => productRenderer.addItem(data, false));
|
||||
if (ENV.data.bankList.length > 0) {
|
||||
ENV.data.bankList.forEach(data => productRenderer.addItem(data, false));
|
||||
const header = document.getElementById('listHeader');
|
||||
const count = document.getElementById('listCount');
|
||||
const total = ENV.data.productList.length;
|
||||
const total = ENV.data.bankList.length;
|
||||
header.style.display = total > 0 ? '' : 'none';
|
||||
count.textContent = total;
|
||||
}
|
||||
@@ -422,8 +430,201 @@
|
||||
|
||||
ENV.module.modalPopup.open();
|
||||
},
|
||||
handleNoDataToggle() {
|
||||
if (!ENV.data.editable && ENV.data.currentStatus == "NOTHING") {
|
||||
ENV.elementRefs.noDataCheckbox.checked = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateLayout();
|
||||
|
||||
},
|
||||
updateLayout() {
|
||||
|
||||
|
||||
const isChecked = ENV.elementRefs.noDataCheckbox.checked;
|
||||
const btn = document.getElementById("addItemBtn");
|
||||
const icon = btn.querySelector("i");
|
||||
|
||||
const status = document.getElementById('forestProductStatusDiv');
|
||||
const callPastInfoBtn = document.getElementById("callPastInfoBtn");
|
||||
|
||||
const next = document.getElementById('complateBtn');
|
||||
const header = document.getElementById('listHeader');
|
||||
const count = document.getElementById('listCount');
|
||||
const total = ENV.data.bankList.length;
|
||||
|
||||
|
||||
header.style.display = total > 0 ? '' : 'none';
|
||||
status.style.display = total > 0 ? 'none' : '';
|
||||
callPastInfoBtn.style.display = total > 0 ? 'none' : '';
|
||||
count.textContent = total;
|
||||
|
||||
|
||||
btn.disabled = isChecked;
|
||||
icon.classList.toggle("ico-add", !isChecked);
|
||||
icon.classList.toggle("ico-add-disabled", isChecked);
|
||||
if (isChecked) {
|
||||
next.disabled = !isChecked;
|
||||
} else {
|
||||
next.disabled = total <= 0;
|
||||
}
|
||||
|
||||
},
|
||||
saveFormData() {
|
||||
const form = document.getElementById('popupForm');
|
||||
const selects = ['cropCode', 'transferCategory', 'unitCode'];
|
||||
selects.forEach(id => {
|
||||
const sel = document.getElementById(id + 'Select');
|
||||
if (sel && sel.value) form[id].value = sel.value;
|
||||
});
|
||||
|
||||
const errors = [];
|
||||
if (!form.transferCategory.value) errors.push({field: 'transferCategory', message: '수입종류를 선택해주세요.'});
|
||||
if (form.transferCategory.value && document.getElementsByName(form.transferCategory.value+"_value")
|
||||
&& !document.getElementsByName(form.transferCategory.value+"_value").value){
|
||||
errors.push({field: form.transferCategory.value+"_value", message: '수입대상을 입력해주세요.'});
|
||||
}
|
||||
if (!form.sourcePurpose.value) errors.push({field: 'sourcePurpose', message: '수입원을 입력해주세요.'});
|
||||
|
||||
if (form.count.value && !form.unitCode.value) errors.push({
|
||||
field: 'unitCode',
|
||||
message: '단위를 선택해주세요.'
|
||||
});
|
||||
if (!form.price.value) errors.push({field: 'price', message: '금액을 입력해주세요.'});
|
||||
|
||||
kri.form.error(errors);
|
||||
if (errors.length > 0) return;
|
||||
|
||||
const formData = new FormData(form);
|
||||
const product = {};
|
||||
formData.forEach((value, key) => product[key] = value);
|
||||
product.id = product.id ? Number(product.id) : Math.floor(Math.random() * 1000000) + 1;
|
||||
|
||||
const idx = ENV.data.productList.findIndex(item => item.id == product.id);
|
||||
if (idx !== -1) ENV.data.productList[idx] = product;
|
||||
else ENV.data.productList.push(product);
|
||||
|
||||
ENV.module.modalPopup.close();
|
||||
setTimeout(() => productRenderer.addItem(product, true), 300);
|
||||
},
|
||||
|
||||
getCategoryLabel(code) {
|
||||
const found = ENV.data.transferCategoryList.find(i => i.id === code);
|
||||
return found ? found.codeText : '-';
|
||||
},
|
||||
// 단위 코드
|
||||
getUnitLabel(code) {
|
||||
const found = ENV.data.unitList.find(i => i.id === code);
|
||||
return found ? found.codeText : '-';
|
||||
},
|
||||
// 재배형태
|
||||
getCropLabel(code) {
|
||||
const found = ENV.data.codeRecordCropList.find(i => i.id === code);
|
||||
return found ? found.codeText : '-';
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
const productRenderer = {
|
||||
//화면에 아이템 추가
|
||||
addItem(product, isEdit) {
|
||||
const listBody = document.getElementById('listBody');
|
||||
const form = document.getElementById('popupForm');
|
||||
form.reset();
|
||||
listBody.style.display = '';
|
||||
|
||||
const format = val => Number(val).toLocaleString() || '-';
|
||||
const getUnit = formControl.getUnitLabel;
|
||||
const getCategory = formControl.getCategoryLabel;
|
||||
const getCrop = formControl.getCropLabel;
|
||||
|
||||
const tag01 = product.transferCategory == 'code.bank.input.99' ? product[`${product.transferCategory}_value`] :getCategory(product.transferCategory) ;
|
||||
|
||||
|
||||
|
||||
const tag1 = product.landArea ? `<span>${format(product.landArea)}평</span>` : '';
|
||||
|
||||
let tag2 = '';
|
||||
if (product.town && product.streetNum) tag2 = `<li><span>${product.town} ${product.streetNum}</span></li>`;
|
||||
else if (product.town) tag2 = `<li><span>${product.town}</span></li>`;
|
||||
else if (product.streetNum) tag2 = `<li><span>${product.streetNum}</span></li>`;
|
||||
|
||||
const tag3 = product.landType ? `<li><p>지목</p><span>${getPurpose(product.landType)}</span></li>` : '';
|
||||
const tag4 = product.availableArea ? `<li><p>가능면적</p><span>${format(product.availableArea)}평</span></li>` : '';
|
||||
|
||||
let tag5 = '';
|
||||
if (product.mainYield && product.mainSaleAmount) {
|
||||
tag5 = `<li><p>주생산물 수확량 / 판매량</p><span>${format(product.mainYield)}${getUnit(product.mainYieldUnitCode)} / ${format(product.mainSaleAmount)}${getUnit(product.mainSaleUnitCode)}</span></li>`;
|
||||
} else if (product.mainYield) {
|
||||
tag5 = `<li><p>주생산물 수확량</p><span>${format(product.mainYield)}${getUnit(product.mainYieldUnitCode)}</span></li>`;
|
||||
} else if (product.mainSaleAmount) {
|
||||
tag5 = `<li><p>주생산물 판매량</p><span>${format(product.mainSaleAmount)}${getUnit(product.mainSaleUnitCode)}</span></li>`;
|
||||
}
|
||||
|
||||
let tag6 = '';
|
||||
if (product.subYield && product.subSaleAmount) {
|
||||
tag6 = `<li><p>부생산물 수확량 / 판매량</p><span>${format(product.subYield)}${getUnit(product.subYieldUnitCode)} / ${format(product.subSaleAmount)}${getUnit(product.subSaleUnitCode)}</span></li>`;
|
||||
} else if (product.subYield) {
|
||||
tag6 = `<li><p>부생산물 수확량</p><span>${format(product.subYield)}${getUnit(product.subYieldUnitCode)}</span></li>`;
|
||||
} else if (product.subSaleAmount) {
|
||||
tag6 = `<li><p>부생산물 판매량</p><span>${format(product.subSaleAmount)}${getUnit(product.subSaleUnitCode)}</span></li>`;
|
||||
}
|
||||
|
||||
let buttonGroupHtml = '';
|
||||
if (isEdit) {
|
||||
buttonGroupHtml = `
|
||||
<div class="btn-group">
|
||||
<button type="button" class="delete" onclick="formControl.deleteItemById(${product.id})"><span class="hide-txt">삭제</span></button>
|
||||
<button type="button" class="edit" onclick="formControl.editItemById(${product.id})"><span class="hide-txt">수정</span></button>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
const div = document.createElement('div');
|
||||
div.className = 'list-item';
|
||||
div.dataset.id = product.id;
|
||||
div.innerHTML = `
|
||||
<div class="item-tit-group">
|
||||
<p class="item-name">${product.cropName} ${tag1}</p>
|
||||
${buttonGroupHtml}
|
||||
</div>
|
||||
<ul class="detail-list">${tag2}${tag3}${tag4}${tag5}${tag6}</ul>
|
||||
`;
|
||||
|
||||
const existing = listBody.querySelector(`[data-id="${product.id}"]`);
|
||||
existing ? listBody.replaceChild(div, existing) : listBody.appendChild(div);
|
||||
formControl.updateLayout();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
`<div class="list-item">
|
||||
<div class="item-tit-group">
|
||||
<p class="item-name">${tag01} <span>(${product.sourcePurpose})</span></p>
|
||||
${buttonGroupHtml}
|
||||
</div>`
|
||||
<ul class="detail-list">
|
||||
<li>
|
||||
<p>재배형태</p>
|
||||
<span>${getCrop(product.cropCode)}</span>
|
||||
</li>
|
||||
<li>
|
||||
<p>수입원</p>
|
||||
<span>회사</span>
|
||||
</li>
|
||||
<li>
|
||||
<p>수량</p>
|
||||
<span>1대</span>
|
||||
</li>
|
||||
<li>
|
||||
<p>현금</p>
|
||||
<span>1,100,000원</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user