코드관리 삭제버튼 오류수정

강석 최 2022-08-22 19:00:41 +09:00
parent 81f0d616a1
commit 02e620ffeb
2 changed files with 20 additions and 10 deletions

View File

@ -44,7 +44,9 @@ $(document).on('click', '.rowDeleteBtn', function (){
switch ($(this).parents("table")[0].id){
case "categoryTable":
selectedCategoryIdx = $(this).parents('tr')[0].rowIndex-1;
codeCategoryList.splice(selectedItemIdx, 1);
codeCategoryList.splice(selectedCategoryIdx, 1);
$("#emptyTr").show();
$("#itemBtnRow").hide();
break;
case "itemTable":
selectedItemIdx = $(this).parents('tr')[0].rowIndex-1;
@ -54,14 +56,19 @@ $(document).on('click', '.rowDeleteBtn', function (){
$(this).parents('tr').remove();
})
$(document).on('click', '.categoryTr', function (){
selectedCategoryIdx = this.rowIndex-1;
$(".allChk").prop("checked", false);
$('#itemTable').find('tbody').find('tr').remove();
$("#itemBtnRow").show();
$(document).on('click', '.categoryTr', function (event){
$("#itemTable").find("tbody").find("tr").remove();
if(event.target.classList.value === "bi bi-x"
|| event.target.classList.value.includes("rowDeleteBtn")) {
}else{
selectedCategoryIdx = this.rowIndex-1;
$("#itemBtnRow").show();
$("#emptyTr").hide();
if(codeCategoryList[selectedCategoryIdx].itemList.length>0){
makeItemTr(codeCategoryList[selectedCategoryIdx].itemList);
if(codeCategoryList[selectedCategoryIdx]!==undefined
&& codeCategoryList[selectedCategoryIdx].itemList.length>0){
makeItemTr(codeCategoryList[selectedCategoryIdx].itemList);
}
}
})
@ -139,7 +146,7 @@ function makeItemTr(itemList){
itemList.forEach(function (item, idx){
$("#itemTable").find('tbody').append(
'<tr class="itemTr" '+(item.status==="delete"?'style="display:none;"':'')+'>' +
'<td>'+(item.status==="new"?'<button class="btn btn-sm btn-outline-danger rowDeleteBtn"><i class="bi bi-x"></i></button>':'<input type="checkbox" class="codeItemChk">')+'</td>'+
'<td>'+(item.status==="new"?'<button class="btn btn-sm btn-outline-danger rowDeleteBtn"><i class="bi bi-x"></i></button>':'')+'</td>'+
'<td><input type="text" class="form-control form-control-sm itemInput" name="itemCd" value="'+item.itemCd+'"></td>'+
'<td><input type="text" class="form-control form-control-sm itemInput" name="itemValue" value="'+item.itemValue+'"></td>'+
'<td><input type="checkbox" class="itemInput" name="useChk" '+(item.useChk==="T"?'checked':'')+'></td>'+

View File

@ -59,8 +59,11 @@
</tr>
</thead>
<tbody class="overflow-scroll">
<tr><td colspan="4">분류를 선택해주세요.</td></tr>
</tbody>
<tfoot>
<tr id="emptyTr"><td colspan="4">분류를 선택해주세요.</td></tr>
</tfoot>
</table>
</div>
<div class="row justify-content-center" id="itemBtnRow" style="display: none">