일단 화면 등록폼 아이템화 까지.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<html layout:decorate="~{layout/layout-none}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
<html layout:decorate="~{layout/layout-none}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
xmlns:th="http://www.thymeleaf.org">
|
xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
<div layout:fragment="content" th:classappend="'mypage-wrap'">
|
<div layout:fragment="content" th:classappend="'mypage-wrap btm-fixbtn'">
|
||||||
<main id="content" role="main">
|
<main id="content" role="main">
|
||||||
<div class="inner">
|
<div class="inner">
|
||||||
<hgroup class="tit-group">
|
<hgroup class="tit-group">
|
||||||
@@ -14,34 +14,18 @@
|
|||||||
</hgroup>
|
</hgroup>
|
||||||
|
|
||||||
<section class="regist-item-area">
|
<section class="regist-item-area">
|
||||||
<p class="total" th:style="${currentList.totalElements == 0 ? 'display:none':''}">
|
<p class="total" th:style="${currentList.totalElements == 0 ? 'display:none':''}" id="listHeader">
|
||||||
<span>총 <strong>1</strong>건</span>
|
<span>총 <strong id="listCount">1</strong>건</span>
|
||||||
<button type="button" class="btn-reset">
|
<button type="button" class="btn-reset" onclick="formControl.clearAllItems()">
|
||||||
<i class="ico-reset ico-small" aria-hidden="true"></i>
|
<i class="ico-reset ico-small" aria-hidden="true"></i>
|
||||||
<span>초기화</span>
|
<span>초기화</span>
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
<div class="item-list" th:style="${currentList.totalElements == 0 ? 'display:none':''}" id="listBody">
|
<div class="item-list" th:style="${currentList.totalElements == 0 ? 'display:none':''}" id="listBody">
|
||||||
<div class="list-item">
|
|
||||||
<div class="item-tit-group">
|
|
||||||
<p class="item-name">송이<span>400평</span> </p>
|
|
||||||
<div class="btn-group">
|
|
||||||
<button type="button" class="delete"><span class="hide-txt">삭제</span></button>
|
|
||||||
<button type="button" class="edit"><span class="hide-txt">수정</span></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<ul class="detail-list">
|
|
||||||
<li><span>서화면 서화리 161-1</span></li>
|
|
||||||
<li><p>지목</p><span>임야</span></li>
|
|
||||||
<li><p>가능면적</p><span>600평</span></li>
|
|
||||||
<li><p>주생산물 수확량 / 판매량</p><span>35kg / 10kg</span></li>
|
|
||||||
<li><p>부생산물 수확량 / 판매량</p><span>7kg / 2kg</span></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="button" class="btn btn-m btn-secondary btn-full" style="margin-bottom:1.2rem" id="addItemBtn" onclick="formControl.addOpen()">
|
<button type="button" class="btn btn-m btn-secondary btn-full" style="margin-bottom:1.2rem" id="addItemBtn" onclick="formControl.openAddForm()">
|
||||||
<i class="ico-add ico-small" aria-hidden="true"></i>
|
<i class="ico-add ico-small" aria-hidden="true"></i>
|
||||||
<span class="btn-txt">추가 등록</span>
|
<span class="btn-txt">추가 등록</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -53,7 +37,7 @@
|
|||||||
|
|
||||||
<div class="component-input align-center" th:if="${currentList.totalElements == 0}" id="forestProductStatusDiv">
|
<div class="component-input align-center" th:if="${currentList.totalElements == 0}" id="forestProductStatusDiv">
|
||||||
<label class="checkbox-inner">
|
<label class="checkbox-inner">
|
||||||
<input type="checkbox" id="forestProductStatus" name="forestProductStatus" th:value="${MonthStatus.NOTHING}" onchange="formControl.handleCheckboxChange()">
|
<input type="checkbox" id="forestProductStatus" name="forestProductStatus" th:value="${MonthStatus.NOTHING}" onchange="formControl.handleNoDataToggle()">
|
||||||
<span class="checkbox-item">
|
<span class="checkbox-item">
|
||||||
<span class="checkbox-txt">이번달 등록내용 없음</span>
|
<span class="checkbox-txt">이번달 등록내용 없음</span>
|
||||||
</span>
|
</span>
|
||||||
@@ -102,6 +86,7 @@
|
|||||||
<div class="modal-content-inner">
|
<div class="modal-content-inner">
|
||||||
|
|
||||||
<form id="forestForm">
|
<form id="forestForm">
|
||||||
|
<input type="hidden" name="id" id="id">
|
||||||
<article class="alert-box full green">
|
<article class="alert-box full green">
|
||||||
<ul>
|
<ul>
|
||||||
<li>임업과 관련하여 재배 및 채취된 모든 임산물(목재 포함)을 기록해주세요.</li>
|
<li>임업과 관련하여 재배 및 채취된 모든 임산물(목재 포함)을 기록해주세요.</li>
|
||||||
@@ -170,7 +155,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<input type="text" id="availableArea" placeholder="가능 면적을 입력해 주세요" name="availableArea" class="limitDecimalLength">
|
<input type="number" id="availableArea" placeholder="가능 면적을 입력해 주세요" name="availableArea" class="limitDecimalLength">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -201,7 +186,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-field">
|
<div class="input-field">
|
||||||
<input type="text" id="landArea" placeholder="작업 면적을 입력해 주세요" name="landArea" class="limitDecimalLength">
|
<input type="number" id="landArea" placeholder="작업 면적을 입력해 주세요" name="landArea" class="limitDecimalLength">
|
||||||
</div>
|
</div>
|
||||||
<ul class="guide-info">
|
<ul class="guide-info">
|
||||||
<li>예 : 180, 6</li>
|
<li>예 : 180, 6</li>
|
||||||
@@ -398,7 +383,7 @@
|
|||||||
</section>
|
</section>
|
||||||
<div class="component-btns">
|
<div class="component-btns">
|
||||||
<div class="btns-row">
|
<div class="btns-row">
|
||||||
<button type="button" class="btn btn-full btn-l btn-primary" onclick="formControl.addData()">
|
<button type="button" class="btn btn-full btn-l btn-primary" onclick="formControl.saveFormData()">
|
||||||
<span class="btn-txt">등록</span>
|
<span class="btn-txt">등록</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -429,151 +414,241 @@
|
|||||||
|
|
||||||
<section layout:fragment="script">
|
<section layout:fragment="script">
|
||||||
<script th:inline="javascript">
|
<script th:inline="javascript">
|
||||||
|
// ✅ ENV 구조 (전역 설정 및 상태)
|
||||||
let ENV = {
|
let ENV = {
|
||||||
httpUrl: {
|
httpUrl: {
|
||||||
root: /*[[#{uri.front.info.monthly.path}]]*/'rootUrl'
|
root: /*[[#{uri.front.info.monthly.path}]]*/ 'rootUrl'
|
||||||
},
|
},
|
||||||
module:{
|
module: {
|
||||||
addPopup : null
|
modalPopup: null
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
addProducts: []
|
purposeList: /*[[${purposeList}]]*/ [],
|
||||||
|
unitList: /*[[${unitList}]]*/ [],
|
||||||
|
productList: []
|
||||||
},
|
},
|
||||||
target:{
|
elementRefs: {
|
||||||
nothingCheck : document.getElementById("forestProductStatus"),
|
noDataCheckbox: document.getElementById("forestProductStatus"),
|
||||||
addBtn:{
|
addButton: {
|
||||||
button: null,
|
button: null,
|
||||||
icon : null
|
icon: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
submitted: false,
|
isSubmitted: false
|
||||||
};
|
};
|
||||||
let formControl = {
|
|
||||||
init(){
|
|
||||||
this._bindUI();
|
|
||||||
this._listener();
|
|
||||||
},
|
|
||||||
_bindUI(){
|
|
||||||
ENV.module.addPopup = document.querySelector(".addPopup").ui;
|
|
||||||
// ENV.target.addBtn.button = document.getElementById("addItemBtn");
|
|
||||||
// ENV.target.addBtn.icon = button.querySelector("i");
|
|
||||||
|
|
||||||
|
|
||||||
|
const formControl = {
|
||||||
|
init() {
|
||||||
|
this.cacheElements();
|
||||||
|
this.bindDecimalLimit();
|
||||||
},
|
},
|
||||||
_listener(){
|
//모달창
|
||||||
//소수점
|
cacheElements() {
|
||||||
|
ENV.module.modalPopup = document.querySelector(".addPopup").ui;
|
||||||
|
},
|
||||||
|
//숫자입력
|
||||||
|
bindDecimalLimit() {
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
const inputs = document.querySelectorAll(".limitDecimalLength");
|
document.querySelectorAll(".limitDecimalLength").forEach(input => {
|
||||||
|
|
||||||
inputs.forEach(input => {
|
|
||||||
input.addEventListener("input", () => {
|
input.addEventListener("input", () => {
|
||||||
let val = input.value;
|
let val = input.value.replace(/[^0-9.]/g, '');
|
||||||
|
|
||||||
val = val.replace(/[^0-9.]/g, '');
|
|
||||||
const parts = val.split('.');
|
const parts = val.split('.');
|
||||||
if (parts.length > 2) {
|
if (parts.length > 2) val = parts[0] + '.' + parts.slice(1).join('');
|
||||||
val = parts[0] + '.' + parts.slice(1).join('');
|
if (parts[1]) parts[1] = parts[1].slice(0, 2);
|
||||||
}
|
if (val.length > 10) val = val.slice(0, 10);
|
||||||
if (parts.length === 2) {
|
input.value = parts.join('.');
|
||||||
parts[1] = parts[1].slice(0, 2);
|
|
||||||
val = parts[0] + '.' + parts[1];
|
|
||||||
}
|
|
||||||
if (val.length > 10) {
|
|
||||||
val = val.slice(0, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
input.value = val;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
checkNextBtn(){
|
//등록없음 선택에 따른 추가하기 버튼 잠금
|
||||||
|
toggleAddButtonState(isEnabled) {
|
||||||
|
const btn = document.getElementById("addItemBtn");
|
||||||
|
const icon = btn.querySelector("i");
|
||||||
|
btn.disabled = !isEnabled;
|
||||||
|
icon.classList.toggle("ico-add", isEnabled);
|
||||||
|
icon.classList.toggle("ico-add-disabled", !isEnabled);
|
||||||
},
|
},
|
||||||
// button
|
//등록없음 버튼
|
||||||
//TODO 하나로 바꿔야함
|
handleNoDataToggle() {
|
||||||
handleCheckboxChange(){
|
const isChecked = ENV.elementRefs.noDataCheckbox.checked;
|
||||||
const isChecked = document.getElementById("forestProductStatus").checked;
|
this.toggleAddButtonState(!isChecked);
|
||||||
this.addButtonOnOff(!isChecked);
|
|
||||||
},
|
},
|
||||||
addButtonOnOff(isEnabled){
|
// 등록폼 추가
|
||||||
const button = document.getElementById("addItemBtn");
|
openAddForm() {
|
||||||
const icon = button.querySelector("i");
|
const modalContent = document.querySelector('.modal-content');
|
||||||
|
setTimeout(() => { modalContent.scrollTop = 0; }, 0);
|
||||||
|
|
||||||
if (isEnabled) {
|
['landTypeSelect', 'mainYieldUnitCodeSelect', 'mainSaleUnitCodeSelect', 'subYieldUnitCodeSelect', 'subSaleUnitCodeSelect']
|
||||||
button.disabled = false;
|
.forEach(id => etUI.components.SelectBox().core.init(document.getElementById(id)));
|
||||||
icon.classList.remove("ico-add-disabled");
|
|
||||||
icon.classList.add("ico-add");
|
ENV.module.modalPopup.open();
|
||||||
} else {
|
},
|
||||||
button.disabled = true;
|
// selectBox선택값으로 변경
|
||||||
icon.classList.remove("ico-add");
|
setSelectBoxValue(selectBoxId, value) {
|
||||||
icon.classList.add("ico-add-disabled");
|
const selectBox = document.getElementById(selectBoxId);
|
||||||
|
const hiddenInput = selectBox.querySelector('input[type="hidden"]');
|
||||||
|
const label = selectBox.querySelector('.select-txt');
|
||||||
|
const option = selectBox.querySelector(`.option[data-value="${value}"]`);
|
||||||
|
|
||||||
|
if (option && hiddenInput && label) {
|
||||||
|
selectBox.querySelectorAll('.option').forEach(opt => opt.classList.remove('current'));
|
||||||
|
option.classList.add('current');
|
||||||
|
hiddenInput.value = value;
|
||||||
|
label.textContent = option.textContent;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// button
|
//등록 아이템 저장
|
||||||
addOpen(){
|
saveFormData() {
|
||||||
ENV.module.addPopup.open();
|
|
||||||
},
|
|
||||||
addData(){
|
|
||||||
const form = document.getElementById('forestForm');
|
const form = document.getElementById('forestForm');
|
||||||
|
const selects = ['landType', 'mainYieldUnitCode', 'mainSaleUnitCode', 'subYieldUnitCode', 'subSaleUnitCode'];
|
||||||
|
selects.forEach(id => {
|
||||||
|
const sel = document.getElementById(id + 'Select');
|
||||||
|
if (sel && sel.value) form[id].value = sel.value;
|
||||||
|
});
|
||||||
|
|
||||||
const landTypeSelect = document.getElementById('ndTypeSelect');
|
const errors = [];
|
||||||
const mainYieldUnitCodeSelect = document.getElementById('mainYieldUnitCodeSelect');
|
if (!form.cropName.value) errors.push({ field: 'cropName', message: '재배 작물명을 입력해주세요.' });
|
||||||
const mainSaleUnitCodeSelect = document.getElementById('mainSaleUnitCodeSelect');
|
if (form.mainYield.value && !form.mainYieldUnitCode.value) errors.push({ field: 'mainYieldUnitCode', message: '단위를 선택해주세요.' });
|
||||||
const subYieldUnitCodeSelect = document.getElementById('subYieldUnitCodeSelect');
|
if (form.mainSaleAmount.value && !form.mainSaleUnitCode.value) errors.push({ field: 'mainSaleUnitCode', message: '단위를 선택해주세요.' });
|
||||||
const subSaleUnitCodeSelect = document.getElementById('subSaleUnitCodeSelect');
|
if (form.subYield.value && !form.subYieldUnitCode.value) errors.push({ field: 'subYieldUnitCode', message: '단위를 선택해주세요.' });
|
||||||
|
if (form.subSaleAmount.value && !form.subSaleUnitCode.value) errors.push({ field: 'subSaleUnitCode', message: '단위를 선택해주세요.' });
|
||||||
|
|
||||||
if (landTypeSelect && landTypeSelect.value) {
|
kri.form.error(errors);
|
||||||
form.landType.value = landTypeSelect.value;
|
if (errors.length > 0) return;
|
||||||
}
|
|
||||||
if (mainYieldUnitCodeSelect && mainYieldUnitCodeSelect.value) {
|
|
||||||
form.mainYieldUnitCode.value = mainYieldUnitCodeSelect.value;
|
|
||||||
}
|
|
||||||
if (mainSaleUnitCodeSelect && mainSaleUnitCodeSelect.value) {
|
|
||||||
form.mainSaleUnitCode.value = mainSaleUnitCodeSelect.value;
|
|
||||||
}
|
|
||||||
if (subYieldUnitCodeSelect && subYieldUnitCodeSelect.value) {
|
|
||||||
form.subYieldUnitCode.value = subYieldUnitCodeSelect.value;
|
|
||||||
}
|
|
||||||
if (subSaleUnitCodeSelect && subSaleUnitCodeSelect.value) {
|
|
||||||
form.subSaleUnitCode.value = subSaleUnitCodeSelect.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
const errorData = [];
|
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;
|
||||||
|
|
||||||
if(!form.cropName.value) {
|
const idx = ENV.data.productList.findIndex(item => item.id == product.id);
|
||||||
const data = {field:'cropName', message: '재배 작물명을 입력해주세요.'}
|
if (idx !== -1) ENV.data.productList[idx] = product;
|
||||||
errorData.push(data);
|
else ENV.data.productList.push(product);
|
||||||
}
|
|
||||||
if(form.mainYield.value && !form.mainYieldUnitCode.value) {
|
|
||||||
const data = {field:'mainYieldUnitCode', message: '단위를 선택해주세요.'}
|
|
||||||
errorData.push(data);
|
|
||||||
}
|
|
||||||
if(form.mainSaleAmount.value && !form.mainSaleUnitCode.value) {
|
|
||||||
const data = {field:'mainSaleUnitCode', message: '단위를 선택해주세요.'}
|
|
||||||
errorData.push(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(form.subYield.value && !form.subYieldUnitCode.value) {
|
ENV.module.modalPopup.close();
|
||||||
const data = {field:'subYieldUnitCode', message: '단위를 선택해주세요.'}
|
setTimeout(() => productRenderer.addItem(product), 300);
|
||||||
errorData.push(data);
|
},
|
||||||
}
|
// 선택 아이템 수정 (폼 노출)
|
||||||
if(form.subSaleAmount.value && !form.subSaleUnitCode.value) {
|
editItemById(id) {
|
||||||
const data = {field:'subSaleUnitCode', message: '단위를 선택해주세요.'}
|
const product = ENV.data.productList.find(p => p.id == id);
|
||||||
errorData.push(data);
|
if (!product) return;
|
||||||
}
|
|
||||||
kri.form.error(errorData)
|
|
||||||
|
|
||||||
if(errorData.length > 0) {
|
const form = document.getElementById('forestForm');
|
||||||
const formData = new FormData(form);
|
form.reset();
|
||||||
|
|
||||||
const data = {};
|
Object.entries(product).forEach(([key, val]) => {
|
||||||
formData.forEach((value, key) => {
|
const field = form.elements.namedItem(key);
|
||||||
data[key] = value;
|
if (field) field.value = val;
|
||||||
});
|
});
|
||||||
ENV.data.addProducts.push(data);
|
|
||||||
}
|
// SelectBox 값 설정
|
||||||
|
this.setSelectBoxValue('landTypeSelect', product.landType);
|
||||||
|
this.setSelectBoxValue('mainYieldUnitCodeSelect', product.mainYieldUnitCode);
|
||||||
|
this.setSelectBoxValue('mainSaleUnitCodeSelect', product.mainSaleUnitCode);
|
||||||
|
this.setSelectBoxValue('subYieldUnitCodeSelect', product.subYieldUnitCode);
|
||||||
|
this.setSelectBoxValue('subSaleUnitCodeSelect', product.subSaleUnitCode);
|
||||||
|
|
||||||
|
this.openAddForm();
|
||||||
|
},
|
||||||
|
// 선택 아이템 삭제
|
||||||
|
deleteItemById(id) {
|
||||||
|
ENV.data.productList = ENV.data.productList.filter(p => p.id != id);
|
||||||
|
const target = document.querySelector(`#listBody div[data-id='${id}']`);
|
||||||
|
if (target) target.remove();
|
||||||
|
this.updateListHeader();
|
||||||
|
},
|
||||||
|
// 전체 초기화
|
||||||
|
clearAllItems() {
|
||||||
|
location.reload();
|
||||||
|
// ENV.data.productList = [];
|
||||||
|
// document.getElementById('listBody').innerHTML = '';
|
||||||
|
// this.updateListHeader();
|
||||||
|
},
|
||||||
|
// 아이템 겟수 처리
|
||||||
|
updateListHeader() {
|
||||||
|
const header = document.getElementById('listHeader');
|
||||||
|
const count = document.getElementById('listCount');
|
||||||
|
const total = ENV.data.productList.length;
|
||||||
|
header.style.display = total > 0 ? '' : 'none';
|
||||||
|
count.textContent = total;
|
||||||
|
},
|
||||||
|
// 지목 코드
|
||||||
|
getPurposeLabel(code) {
|
||||||
|
const found = ENV.data.purposeList.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 : '-';
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const productRenderer = {
|
||||||
|
//화면에 아이템 추가
|
||||||
|
addItem(product) {
|
||||||
|
const listBody = document.getElementById('listBody');
|
||||||
|
const form = document.getElementById('forestForm');
|
||||||
|
form.reset();
|
||||||
|
listBody.style.display = '';
|
||||||
|
|
||||||
|
const format = val => Number(val).toLocaleString() || '-';
|
||||||
|
const getUnit = formControl.getUnitLabel;
|
||||||
|
const getPurpose = formControl.getPurposeLabel;
|
||||||
|
|
||||||
|
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>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
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>
|
||||||
|
<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>
|
||||||
|
</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.updateListHeader();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user