fix(portal): 修风控预警列表 422(limit 上限是 5,改为不传);运营邮件改用 page/page_size;审计 limit 钳制到 1-100
- risk/alerts 传 limit=20 会 422 query.limit<=5,导致整张表格渲染不出来、 行内确认/升级/解决按钮随之消失 —— 这正是验收清单 3-3/3-6~3-9 看不到功能的原因 - 实测列表返回 2 条预警;处置接口有状态前置条件(409 = 当前状态不允许) - 清单 3-3/3-6 更新为实测结果并写明 limit 上限与状态机约束
This commit is contained in:
+33
-17
@@ -744,25 +744,34 @@ async function loadRisk() {
|
||||
}
|
||||
|
||||
async function loadAlerts() {
|
||||
const r = await GET('/api/v1/risk/alerts', { limit: 20 });
|
||||
const items = r.body?.data?.items || r.body?.data || [];
|
||||
// 刻意**不传 limit**:该接口的 limit 上限是 5(传 20 会 422
|
||||
// `query.limit: Input should be less than or equal to 5`),
|
||||
// 不传则用平台默认值,最稳。
|
||||
const r = await GET('/api/v1/risk/alerts');
|
||||
const items = Array.isArray(r.body?.data) ? r.body.data
|
||||
: (r.body?.data?.items || []);
|
||||
const box = $('alerts');
|
||||
if (!Array.isArray(items) || !items.length) {
|
||||
box.innerHTML = `<div class="muted">没有预警数据(HTTP ${r.status})。可先点「触发一次扫描」。</div>`;
|
||||
box.innerHTML = `<div class="muted">没有预警数据(HTTP ${r.status}${r.body?.code ? ' code=' + r.body.code : ''})。可先点「触发一次扫描」。</div>
|
||||
<pre>${esc(pretty(r.body))}</pre>`;
|
||||
return;
|
||||
}
|
||||
box.innerHTML = `<table><thead><tr><th>预警号</th><th>客户</th><th>规则</th><th>等级</th><th>状态</th><th>操作</th></tr></thead><tbody>`
|
||||
+ items.map((a) => `<tr>
|
||||
<td><code>${esc(a.alert_no ?? a.alert_id)}</code></td>
|
||||
<td>${esc(a.customer_id)}</td>
|
||||
<td>${esc(a.rule_code ?? a.rule ?? '')}</td>
|
||||
<td>${esc(a.level ?? a.severity ?? '')}</td>
|
||||
<td>${esc(a.status)}</td>
|
||||
box.innerHTML = `<table><thead><tr><th>预警号</th><th>客户</th><th>等级</th><th>规则</th><th>状态</th><th>操作</th></tr></thead><tbody>`
|
||||
+ items.map((a) => {
|
||||
const no = esc(a.alert_no ?? a.alert_id ?? '');
|
||||
const rules = Array.isArray(a.rule_codes) ? a.rule_codes.join(', ') : (a.rule_code ?? '');
|
||||
return `<tr>
|
||||
<td><code>${no}</code></td>
|
||||
<td>${esc(a.customer_name || a.customer_no || a.customer_id || '')}</td>
|
||||
<td>${esc(a.risk_level ?? a.level ?? '')}</td>
|
||||
<td>${esc(rules)}</td>
|
||||
<td>${esc(a.status ?? '')}</td>
|
||||
<td>
|
||||
<button class="act" onclick="ack('${esc(a.alert_no ?? a.alert_id)}')">确认</button>
|
||||
<button class="act warn" onclick="esc_( '${esc(a.alert_no ?? a.alert_id)}')">升级</button>
|
||||
<button class="act primary" onclick="resolve('${esc(a.alert_no ?? a.alert_id)}')">解决</button>
|
||||
</td></tr>`).join('')
|
||||
<button class="act" onclick="ack('${no}')">确认</button>
|
||||
<button class="act warn" onclick="esc_('${no}')">升级</button>
|
||||
<button class="act primary" onclick="resolve('${no}')">解决</button>
|
||||
</td></tr>`;
|
||||
}).join('')
|
||||
+ '</tbody></table>';
|
||||
}
|
||||
|
||||
@@ -845,8 +854,10 @@ async function loadMailbox() {
|
||||
}
|
||||
|
||||
async function loadMails() {
|
||||
const r = await GET('/api/v1/offsite-fund/mails', { limit: 20 });
|
||||
const items = r.body?.data?.items || r.body?.data || [];
|
||||
// 该接口的分页参数是 `page` / `page_size`(不是 limit)。
|
||||
const r = await GET('/api/v1/offsite-fund/mails', { page: 1, page_size: 20 });
|
||||
const raw = r.body?.data;
|
||||
const items = Array.isArray(raw) ? raw : (raw?.items || []);
|
||||
$('mails').innerHTML = Array.isArray(items) && items.length
|
||||
? `<table><thead><tr><th>邮件 ID</th><th>主题</th><th>状态</th><th>操作</th></tr></thead><tbody>`
|
||||
+ items.map((m) => `<tr><td><code>${esc(m.mail_id ?? m.id)}</code></td>
|
||||
@@ -926,6 +937,7 @@ function renderAdmin(box) {
|
||||
<h2>审计流水</h2>
|
||||
<p class="hint">谁做了什么、有没有被拒,都记在这里(<code>GET /api/v1/admin/audit-records</code>)。</p>
|
||||
<div class="row"><input class="q" id="audit-limit" value="20" style="width:80px">
|
||||
<span class="muted">1-100</span>
|
||||
<button class="act" onclick="loadAudit()">刷新</button></div>
|
||||
<div id="audit"><div class="muted">加载中…</div></div>
|
||||
</div>
|
||||
@@ -1003,7 +1015,11 @@ async function userRoles() {
|
||||
}
|
||||
|
||||
async function loadAudit() {
|
||||
const limit = $('audit-limit').value.trim() || '20';
|
||||
// 该接口 limit 的取值范围是 1-100;钳一下,免得填大值得到 422。
|
||||
let limit = parseInt($('audit-limit').value.trim() || '20', 10);
|
||||
if (!Number.isFinite(limit)) limit = 20;
|
||||
limit = Math.min(100, Math.max(1, limit));
|
||||
$('audit-limit').value = limit;
|
||||
const r = await GET('/api/v1/admin/audit-records', { limit });
|
||||
const items = r.body?.data?.items || r.body?.data || [];
|
||||
const box = $('audit');
|
||||
|
||||
Reference in New Issue
Block a user