- 新增 assets:fusion.css(样板全量 token/组件/动效)、fusion.js(主题/抽屉/弹层/开关/按住确认/计算器引擎/三态全选/toast)、日夜 Logo - pageHeader/pageFooter 重写为样板侧栏骨架:固定侧栏导航、底部账户区、日间/夜间 token 切换、导入弹层、详情抽屉容器 - 新增工作台(风险入口卡+今日待办+快捷入口)、任务中心(四组分段+行内处理)、档案库目录管理三栏视图 - 档案列表恢复样板分段标签/KPI 卡/筛选条/批量条/行点击抽屉 - 档案详情页 + 右侧抽屉(概要/还款计划/附件三标签)按样板实现,保留全部真实绑定 - 新建/编辑档案改造为五步向导(字段与联动 JS 全量保留) - 登录页左右布局、用户管理、个人设置、删除审批、统计查询四口径页签、便捷查询、两个计算器全部按样板重构 - 页面 view 抽取至 app/views/pages/,index.php 保留全部业务逻辑与路由 - 业务功能零删减:表单字段、权限、审批闭环、导入导出、计算口径均不变 Co-authored-by: multica-agent <github@multica.ai>
167 lines
8.7 KiB
PHP
167 lines
8.7 KiB
PHP
<?php
|
|
requireAdmin();
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$approvalId = trim((string)($_POST['approval_id'] ?? ''));
|
|
$do = (string)($_POST['do'] ?? '');
|
|
$approvals = loadDeleteApprovals();
|
|
foreach ($approvals as &$ap) {
|
|
if (($ap['id'] ?? '') !== $approvalId || ($ap['status'] ?? '') !== 'pending') {
|
|
continue;
|
|
}
|
|
if ((int)$ap['requested_by'] === (int)$me['id']) {
|
|
flash('error', '不能由申请人本人审核');
|
|
break;
|
|
}
|
|
if ($do === 'approve' && ($ap['target_type'] ?? '') === 'archive') {
|
|
hardDeleteArchive($pdo, (int)$ap['target_id']);
|
|
$ap['status'] = 'approved';
|
|
$ap['approved_by'] = (int)$me['id'];
|
|
$ap['approved_at'] = now();
|
|
flash('ok', '删除已由第二管理员审核并执行');
|
|
break;
|
|
}
|
|
if ($do === 'approve' && ($ap['target_type'] ?? '') === 'archive_batch') {
|
|
$ids = array_values(array_unique(array_filter(array_map('intval', (array)($ap['target_ids'] ?? [])))));
|
|
foreach ($ids as $aid) {
|
|
hardDeleteArchive($pdo, $aid);
|
|
}
|
|
$ap['status'] = 'approved';
|
|
$ap['approved_by'] = (int)$me['id'];
|
|
$ap['approved_at'] = now();
|
|
flash('ok', '批量删除已审核并执行(' . count($ids) . ' 条)');
|
|
break;
|
|
}
|
|
if ($do === 'reject') {
|
|
$ap['status'] = 'rejected';
|
|
$ap['approved_by'] = (int)$me['id'];
|
|
$ap['approved_at'] = now();
|
|
flash('ok', '已驳回删除申请');
|
|
break;
|
|
}
|
|
}
|
|
unset($ap);
|
|
saveDeleteApprovals($approvals);
|
|
redirectBackOr('index.php?action=delete_approvals');
|
|
}
|
|
$approvals = array_reverse(loadDeleteApprovals());
|
|
$allApprovals = $approvals;
|
|
$filterStatus = (string)($_GET['status'] ?? 'pending');
|
|
$filterTarget = trim((string)($_GET['target_id'] ?? ''));
|
|
$filterRequester = trim((string)($_GET['requester'] ?? ''));
|
|
$approvals = array_values(array_filter($approvals, function ($ap) use ($filterStatus, $filterTarget, $filterRequester) {
|
|
if ($filterStatus !== 'all' && ($ap['status'] ?? '') !== $filterStatus) {
|
|
return false;
|
|
}
|
|
if ($filterTarget !== '' && (string)($ap['target_id'] ?? '') !== $filterTarget) {
|
|
return false;
|
|
}
|
|
if ($filterRequester !== '' && mb_stripos((string)($ap['requested_name'] ?? ''), $filterRequester) === false) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}));
|
|
$usersMap = [];
|
|
$archiveMap = fetchArchiveSimpleMap($pdo);
|
|
foreach ($pdo->query('SELECT id,username FROM users')->fetchAll() as $u) {
|
|
$usersMap[(int)$u['id']] = (string)$u['username'];
|
|
}
|
|
$statusOptions = ['pending' => '待审批', 'approved' => '已通过', 'rejected' => '已驳回'];
|
|
$statusPillMap = ['pending' => 'due', 'approved' => 'ok', 'rejected' => 'done'];
|
|
$typeLabelMap = ['archive' => '档案', 'archive_batch' => '批量档案'];
|
|
$targetOptions = [];
|
|
$requesterOptions = [];
|
|
foreach ($allApprovals as $ap) {
|
|
$tid = (string)($ap['target_id'] ?? '');
|
|
if ($tid !== '' && !isset($targetOptions[$tid])) {
|
|
$aid = (int)$tid;
|
|
$targetOptions[$tid] = 'ID:' . $aid . (isset($archiveMap[$aid]) ? ' · ' . (string)$archiveMap[$aid]['name'] : '');
|
|
}
|
|
$rname = trim((string)($ap['requested_name'] ?? ''));
|
|
if ($rname !== '') {
|
|
$requesterOptions[$rname] = true;
|
|
}
|
|
}
|
|
$hasFilter = $filterStatus !== 'pending' || $filterTarget !== '' || $filterRequester !== '';
|
|
pageHeader($me); ?>
|
|
<div class="page-head">
|
|
<div>
|
|
<h1 class="page-title">删除审批</h1>
|
|
<div class="page-sub">双管理员删除闭环 · 申请人不能自审</div>
|
|
</div>
|
|
</div>
|
|
<form method="get" action="index.php" class="filter-bar" style="margin-top:0;">
|
|
<input type="hidden" name="action" value="delete_approvals">
|
|
<select name="status" aria-label="按状态筛选" onchange="this.form.submit()">
|
|
<option value="all" <?= $filterStatus === 'all' ? 'selected' : '' ?>>全部状态</option>
|
|
<?php foreach ($statusOptions as $sv => $sl): ?>
|
|
<option value="<?= $sv ?>" <?= $filterStatus === $sv ? 'selected' : '' ?>><?= $sl ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<select name="target_id" aria-label="按删除目标筛选" onchange="this.form.submit()">
|
|
<option value="" <?= $filterTarget === '' ? 'selected' : '' ?>>全部目标</option>
|
|
<?php foreach ($targetOptions as $tid => $tlabel): ?>
|
|
<option value="<?= e($tid) ?>" <?= $filterTarget === (string)$tid ? 'selected' : '' ?>><?= e($tlabel) ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<select name="requester" aria-label="按申请人筛选" onchange="this.form.submit()">
|
|
<option value="" <?= $filterRequester === '' ? 'selected' : '' ?>>全部申请人</option>
|
|
<?php foreach (array_keys($requesterOptions) as $rname): ?>
|
|
<option value="<?= e($rname) ?>" <?= $filterRequester === $rname ? 'selected' : '' ?>><?= e($rname) ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<span class="filter-note"><?= count($approvals) ?> 条申请</span>
|
|
<?php if ($hasFilter): ?>
|
|
<span class="filter-spacer"></span>
|
|
<a class="btn btn--plain btn--sm" href="index.php?action=delete_approvals">清除全部筛选</a>
|
|
<?php endif; ?>
|
|
</form>
|
|
<div class="table-card">
|
|
<?php if ($approvals): ?>
|
|
<table>
|
|
<thead><tr><th>申请时间</th><th>删除目标</th><th>类型</th><th>申请人</th><th>状态</th><th class="cell-right">审批操作</th></tr></thead>
|
|
<tbody>
|
|
<?php foreach ($approvals as $i => $ap):
|
|
$st = (string)($ap['status'] ?? '');
|
|
$isSelf = (int)($ap['requested_by'] ?? 0) === (int)$me['id'];
|
|
?>
|
|
<tr class="stagger-in" style="animation-delay:<?= min($i, 8) * 45 ?>ms; cursor:default;">
|
|
<td class="num"><?= e((string)$ap['requested_at']) ?></td>
|
|
<td style="white-space:normal; max-width:360px;">
|
|
<div class="cell-main"><?= e(approvalTargetLabel($ap, $archiveMap)) ?></div>
|
|
<div class="cell-sub">申请单号 <span class="num"><?= e((string)$ap['id']) ?></span></div>
|
|
</td>
|
|
<td><?= e($typeLabelMap[(string)($ap['target_type'] ?? '')] ?? (string)($ap['target_type'] ?? '')) ?></td>
|
|
<td><?= e((string)$ap['requested_name']) ?></td>
|
|
<td><span class="pill pill--<?= $statusPillMap[$st] ?? 'pending' ?>"><?= e($statusOptions[$st] ?? $st) ?></span></td>
|
|
<td class="cell-right">
|
|
<?php if ($st !== 'pending'): ?>
|
|
<span style="font-size:12px; color:var(--text-3);">已处理</span>
|
|
<?php elseif ($isSelf): ?>
|
|
<span style="font-size:12px; color:var(--text-3);">申请人不能自审</span>
|
|
<?php else: ?>
|
|
<div style="display:inline-flex; gap:6px;">
|
|
<form method="post" style="margin:0;">
|
|
<input type="hidden" name="approval_id" value="<?= e((string)$ap['id']) ?>">
|
|
<input type="hidden" name="do" value="approve">
|
|
<input type="hidden" name="redirect_to" value="<?= e(currentUrlFromServer()) ?>">
|
|
<button type="submit" class="btn btn--danger btn--sm">通过并删除</button>
|
|
</form>
|
|
<form method="post" style="margin:0;">
|
|
<input type="hidden" name="approval_id" value="<?= e((string)$ap['id']) ?>">
|
|
<input type="hidden" name="do" value="reject">
|
|
<input type="hidden" name="redirect_to" value="<?= e(currentUrlFromServer()) ?>">
|
|
<button type="submit" class="btn btn--plain btn--sm">驳回</button>
|
|
</form>
|
|
</div>
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php else: ?>
|
|
<div class="empty">暂无符合条件的审批记录</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php pageFooter(); exit;
|