기본코드관리 2분할 조회와 무료용 목록 컬럼 정리

기본코드관리에서 코드종류 선택 시 같은 화면 우측에 세부코드가 즉시 보이도록 2분할 UI로 전환하고, 무료용 대상자 목록의 불필요한 구분 컬럼을 숨겨 화면 구성을 단순화했다.

Made-with: Cursor
This commit is contained in:
taekyoungc
2026-04-14 14:49:15 +09:00
parent 40db578e85
commit 0b4c622b99
3 changed files with 162 additions and 47 deletions

View File

@@ -351,6 +351,9 @@ class Bag extends BaseController
$detailModel = model(CodeDetailModel::class);
$kinds = [];
$countMap = [];
$selectedKind = null;
$detailList = [];
$rowCanEdit = [];
$lgIdx = $this->lgIdx();
try {
$kinds = $kindModel->orderBy('ck_code', 'ASC')->findAll();
@@ -373,11 +376,43 @@ class Bag extends BaseController
}
$level = (int) session()->get('mb_level');
$canManageDetails = Roles::canManageCodeMaster($level);
if ($kinds !== []) {
$selectedCkIdx = (int) ($this->request->getGet('ck_idx') ?? 0);
foreach ($kinds as $row) {
if ((int) $row->ck_idx === $selectedCkIdx) {
$selectedKind = $row;
break;
}
}
if ($selectedKind === null) {
$selectedKind = $kinds[0];
}
}
if ($selectedKind !== null) {
$detailList = $detailModel->where('cd_ck_idx', (int) $selectedKind->ck_idx)
->filterByTenantScope($lgIdx)
->orderBy('cd_sort', 'ASC')
->orderBy('cd_idx', 'ASC')
->findAll();
helper('admin');
$adminLg = admin_effective_lg_idx();
foreach ($detailList as $row) {
$rowCanEdit[$row->cd_idx] = Roles::canEditCodeDetailRow($level, $row, $adminLg);
}
}
return $this->render('기본코드관리', 'bag/code_kinds', [
'codeKinds' => $kinds,
'countMap' => $countMap,
'canManageKinds' => Roles::canManageCodeKindMaster($level),
'canManageDetails' => $canManageDetails,
'selectedKind' => $selectedKind,
'detailList' => $detailList,
'rowCanEdit' => $rowCanEdit,
]);
}

View File

@@ -13,7 +13,6 @@
<thead>
<tr>
<th class="w-16">번호</th>
<th>구분</th>
<th>대상자명</th>
<th>연락처</th>
<th>주소</th>
@@ -28,7 +27,6 @@
<?php foreach ($list as $row): ?>
<tr>
<td class="text-center"><?= esc($row->fr_idx) ?></td>
<td class="text-center"><?= esc($row->fr_type_code) ?></td>
<td class="text-left pl-2"><?= esc($row->fr_name) ?></td>
<td class="text-center"><?= esc($row->fr_phone) ?></td>
<td class="text-left pl-2"><?= esc($row->fr_addr) ?></td>
@@ -47,7 +45,7 @@
<?php endforeach; ?>
<?php if (empty($list)): ?>
<tr>
<td colspan="10" class="text-center text-gray-500 py-4 text-sm space-y-1">
<td colspan="9" class="text-center text-gray-500 py-4 text-sm space-y-1">
<p>등록된 데이터가 없습니다.</p>
<p class="text-gray-400">다른 지자체를 선택 중이면 해당 지자체 기준으로만 조회됩니다. Super Admin 은 상단에서 작업 지자체를 바꿔 보세요.</p>
</td>

View File

@@ -2,49 +2,59 @@
/** @var list<object> $codeKinds */
/** @var array<int,int> $countMap */
/** @var bool $canManageKinds */
/** @var bool $canManageDetails */
/** @var object|null $selectedKind */
/** @var list<object> $detailList */
/** @var array<int,bool> $rowCanEdit */
$canManageKinds = ! empty($canManageKinds);
$canManageDetails = ! empty($canManageDetails);
$showKindActions = $canManageKinds;
$selectedKindId = (int) ($selectedKind->ck_idx ?? 0);
$colCount = 6 + ($showKindActions ? 1 : 0);
$detailColCount = 7 + ($canManageDetails ? 1 : 0);
?>
<div class="space-y-4">
<div class="grid grid-cols-1 xl:grid-cols-2 gap-4">
<section>
<div class="flex flex-wrap items-center justify-between gap-2 mb-2 border-b pb-1">
<h3 class="text-base font-bold text-gray-700">기본코드 종류</h3>
<div class="flex flex-wrap items-center gap-2 text-xs sm:text-sm">
<?php if ($canManageKinds): ?>
<a href="<?= base_url('admin/code-kinds/create') ?>" class="inline-flex items-center rounded bg-[#1c4e80] px-3 py-1.5 text-white shadow hover:opacity-90">코드 종류 등록</a>
<?php elseif (! $canManageKinds): ?>
<span class="text-gray-500">코드 종류 등록·수정은 super admin·본부 관리자만 가능합니다. 세부코드는 행의 링크에서 조회할 수 있습니다.</span>
<?php else: ?>
<span class="text-gray-500">코드 종류 등록·수정은 super admin·본부 관리자만 가능합니다.</span>
<?php endif; ?>
</div>
</div>
<table class="data-table">
<div class="border border-gray-300 overflow-auto">
<table class="data-table w-full">
<thead><tr>
<th class="w-14"><?= $showKindActions ? 'PK' : '번호' ?></th>
<th class="w-24">코드</th>
<th>코드명</th>
<th class="w-28">세부코드</th>
<th class="w-24">세부건수</th>
<th class="w-20">상태</th>
<th class="w-40">등록일</th>
<?php if ($showKindActions): ?>
<th class="w-44">작업</th>
<th class="w-36">작업</th>
<?php endif; ?>
</tr></thead>
<tbody>
<?php if (! empty($codeKinds)): ?>
<?php $i = 0; foreach ($codeKinds as $row): $i++; ?>
<tr>
<?php
$isSelected = (int) $row->ck_idx === $selectedKindId;
$detailUrl = base_url('bag/code-kinds?ck_idx=' . (int) $row->ck_idx);
?>
<tr class="<?= $isSelected ? 'bg-blue-50' : '' ?> cursor-pointer hover:bg-blue-50"
onclick="window.location.href='<?= esc($detailUrl, 'attr') ?>'">
<td class="text-center"><?= $showKindActions ? esc((string) $row->ck_idx) : (string) $i ?></td>
<td class="text-center font-mono"><?= esc($row->ck_code) ?></td>
<td><?= esc($row->ck_name) ?></td>
<td class="text-center">
<a href="<?= base_url('bag/code-details/' . (int) $row->ck_idx) ?>" class="text-blue-600 hover:underline"><?= (int) ($countMap[$row->ck_idx] ?? 0) ?>개 보기</a>
</td>
<td class="text-center"><?= (int) ($countMap[$row->ck_idx] ?? 0) ?>개</td>
<td class="text-center"><?= (int) ($row->ck_state ?? 0) === 1 ? '사용' : '미사용' ?></td>
<td class="text-left"><?= esc($row->ck_regdate ?? '') ?></td>
<?php if ($showKindActions): ?>
<td class="text-center text-sm">
<a href="<?= base_url('bag/code-details/' . (int) $row->ck_idx) ?>" class="text-green-600 hover:underline mr-1">세부코드</a>
<td class="text-center text-sm" onclick="event.stopPropagation()">
<a href="<?= base_url('admin/code-kinds/edit/' . (int) $row->ck_idx) ?>" class="text-blue-600 hover:underline mr-1">수정</a>
<form action="<?= base_url('admin/code-kinds/delete/' . (int) $row->ck_idx) ?>" method="POST" class="inline" onsubmit="return confirm('이 코드 종류를 삭제하시겠습니까?');">
<?= csrf_field() ?>
@@ -59,5 +69,77 @@ $colCount = 6 + ($showKindActions ? 1 : 0);
<?php endif; ?>
</tbody>
</table>
</div>
</section>
<section>
<div class="flex flex-wrap items-center justify-between gap-2 mb-2 border-b pb-1">
<h3 class="text-base font-bold text-gray-700">
세부코드
<?php if ($selectedKind !== null): ?>
— <?= esc($selectedKind->ck_name) ?> (<?= esc($selectedKind->ck_code) ?>)
<?php endif; ?>
</h3>
<?php if ($canManageDetails && $selectedKind !== null): ?>
<a href="<?= base_url('admin/code-details/' . (int) $selectedKind->ck_idx . '/create') ?>" class="inline-flex items-center rounded bg-[#1c4e80] px-3 py-1.5 text-white shadow hover:opacity-90 text-sm">세부코드 등록</a>
<?php endif; ?>
</div>
<?php if ($selectedKind === null): ?>
<div class="border border-gray-300 rounded p-6 text-center text-gray-500">왼쪽에서 코드 종류를 선택해 주세요.</div>
<?php else: ?>
<div class="border border-gray-300 overflow-auto">
<table class="data-table w-full">
<thead>
<tr>
<th class="w-16">번호</th>
<th class="w-24">코드</th>
<th>코드명</th>
<th class="w-24">범위</th>
<th class="w-20">정렬</th>
<th class="w-20">상태</th>
<th class="w-40">등록일</th>
<?php if ($canManageDetails): ?>
<th class="w-28">작업</th>
<?php endif; ?>
</tr>
</thead>
<tbody>
<?php if (! empty($detailList)): ?>
<?php foreach ($detailList as $row): ?>
<?php
$isPlatform = (($row->cd_source ?? 'platform') === 'platform' && (int) ($row->cd_lg_idx ?? 0) === 0);
$scopeLabel = $isPlatform ? '공통' : '지자체';
?>
<tr>
<td class="text-center"><?= esc((string) $row->cd_idx) ?></td>
<td class="text-center font-mono"><?= esc($row->cd_code) ?></td>
<td><?= esc($row->cd_name) ?></td>
<td class="text-center text-xs"><?= esc($scopeLabel) ?></td>
<td class="text-center"><?= (int) ($row->cd_sort ?? 0) ?></td>
<td class="text-center"><?= (int) ($row->cd_state ?? 0) === 1 ? '사용' : '미사용' ?></td>
<td class="text-left"><?= esc($row->cd_regdate ?? '') ?></td>
<?php if ($canManageDetails): ?>
<td class="text-center text-sm">
<?php if (! empty($rowCanEdit[$row->cd_idx])): ?>
<a href="<?= base_url('admin/code-details/edit/' . (int) $row->cd_idx) ?>" class="text-blue-600 hover:underline">수정</a>
<form action="<?= base_url('admin/code-details/delete/' . (int) $row->cd_idx) ?>" method="POST" class="ml-1 inline" onsubmit="return confirm('이 세부코드를 삭제하시겠습니까?');">
<?= csrf_field() ?>
<button type="submit" class="text-red-600 hover:underline">삭제</button>
</form>
<?php else: ?>
<span class="text-gray-400">—</span>
<?php endif; ?>
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr><td colspan="<?= (string) $detailColCount ?>" class="text-center text-gray-400 py-4">등록된 세부코드가 없습니다.</td></tr>
<?php endif; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</section>
</div>