整合审计看板,通过下拉选择机种
This commit is contained in:
parent
3f45dc220c
commit
8a1eda390a
@ -26,8 +26,12 @@ const Dashboard = (() => {
|
|||||||
canvas.onmouseleave = null;
|
canvas.onmouseleave = null;
|
||||||
}
|
}
|
||||||
// 清理日期选择器事件
|
// 清理日期选择器事件
|
||||||
|
const auditDateEl = document.getElementById('audit-date');
|
||||||
|
const platformSelect = document.getElementById('audit-platform-select');
|
||||||
const pddDateEl = document.getElementById('audit-date-pdd');
|
const pddDateEl = document.getElementById('audit-date-pdd');
|
||||||
const ytDateEl = document.getElementById('audit-date-yt');
|
const ytDateEl = document.getElementById('audit-date-yt');
|
||||||
|
if(auditDateEl) auditDateEl.onchange = null;
|
||||||
|
if(platformSelect) platformSelect.onchange = null;
|
||||||
if(pddDateEl) pddDateEl.onchange = null;
|
if(pddDateEl) pddDateEl.onchange = null;
|
||||||
if(ytDateEl) ytDateEl.onchange = null;
|
if(ytDateEl) ytDateEl.onchange = null;
|
||||||
// 清理resize监听器
|
// 清理resize监听器
|
||||||
@ -103,8 +107,10 @@ const Dashboard = (() => {
|
|||||||
// 设置审计框高度
|
// 设置审计框高度
|
||||||
const setAuditHeight = () => {
|
const setAuditHeight = () => {
|
||||||
const height = calculateAuditHeight();
|
const height = calculateAuditHeight();
|
||||||
|
const auditCard = document.getElementById('audit-card');
|
||||||
const pddCard = document.getElementById('audit-pdd-card');
|
const pddCard = document.getElementById('audit-pdd-card');
|
||||||
const ytCard = document.getElementById('audit-yt-card');
|
const ytCard = document.getElementById('audit-yt-card');
|
||||||
|
if(auditCard) auditCard.style.height = height + 'px';
|
||||||
if(pddCard) pddCard.style.height = height + 'px';
|
if(pddCard) pddCard.style.height = height + 'px';
|
||||||
if(ytCard) ytCard.style.height = height + 'px';
|
if(ytCard) ytCard.style.height = height + 'px';
|
||||||
};
|
};
|
||||||
@ -370,6 +376,65 @@ const Dashboard = (() => {
|
|||||||
if(!d) return {};
|
if(!d) return {};
|
||||||
return { start: d + ' 00:00:00', end: d + ' 23:59:59' };
|
return { start: d + ' 00:00:00', end: d + ' 23:59:59' };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 整合的审计看板切换逻辑
|
||||||
|
const platformSelect = q('audit-platform-select');
|
||||||
|
const auditDateEl = q('audit-date');
|
||||||
|
const auditListEl = q('audit-list');
|
||||||
|
|
||||||
|
// 当前选中的平台
|
||||||
|
window.__currentAuditPlatform = 'pdd';
|
||||||
|
|
||||||
|
// 更新整合看板显示
|
||||||
|
const updateAuditDisplay = () => {
|
||||||
|
const platform = window.__currentAuditPlatform;
|
||||||
|
const params = platform === 'pdd' ? window.__pddParams : window.__ytParams;
|
||||||
|
const sTime = toEpoch(params.start);
|
||||||
|
const eTime = toEpoch(params.end);
|
||||||
|
const cacheData = platform === 'pdd' ? window.__auditCache.pdd : window.__auditCache.yt;
|
||||||
|
const filteredData = (cacheData || []).filter(r => {
|
||||||
|
const t = toEpoch(r.ts_cn);
|
||||||
|
if (t == null) return false;
|
||||||
|
return (sTime == null || t >= sTime) && (eTime == null || t <= eTime);
|
||||||
|
});
|
||||||
|
const listHtml = filteredData.slice(0, 100).map(r =>
|
||||||
|
`<li><span>${r.ts_cn||'—'}</span><span class="badge">${r.batch||''}</span><span class="badge">${r.mac||''}</span><span class="badge">${r.note||''}</span></li>`
|
||||||
|
).join('') || '<li>暂无数据</li>';
|
||||||
|
if (auditListEl) auditListEl.innerHTML = listHtml;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 平台切换事件
|
||||||
|
if (platformSelect) {
|
||||||
|
platformSelect.onchange = () => {
|
||||||
|
window.__currentAuditPlatform = platformSelect.value;
|
||||||
|
// 同步日期选择器
|
||||||
|
const otherDateEl = platformSelect.value === 'pdd' ? q('audit-date-pdd') : q('audit-date-yt');
|
||||||
|
if (auditDateEl && otherDateEl) {
|
||||||
|
auditDateEl.value = otherDateEl.value;
|
||||||
|
}
|
||||||
|
updateAuditDisplay();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 整合看板日期筛选
|
||||||
|
if (auditDateEl) {
|
||||||
|
auditDateEl.onchange = () => {
|
||||||
|
const d = auditDateEl.value;
|
||||||
|
const platform = window.__currentAuditPlatform;
|
||||||
|
if (platform === 'pdd') {
|
||||||
|
window.__pddParams = dateToRange(d);
|
||||||
|
const pddDateEl = q('audit-date-pdd');
|
||||||
|
if (pddDateEl) pddDateEl.value = d;
|
||||||
|
} else {
|
||||||
|
window.__ytParams = dateToRange(d);
|
||||||
|
const ytDateEl = q('audit-date-yt');
|
||||||
|
if (ytDateEl) ytDateEl.value = d;
|
||||||
|
}
|
||||||
|
refreshAuditLists();
|
||||||
|
updateAuditDisplay();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const pddDateEl=q('audit-date-pdd');
|
const pddDateEl=q('audit-date-pdd');
|
||||||
const ytDateEl=q('audit-date-yt');
|
const ytDateEl=q('audit-date-yt');
|
||||||
if(pddDateEl){
|
if(pddDateEl){
|
||||||
@ -483,6 +548,26 @@ const Dashboard = (() => {
|
|||||||
const ytEls=ytView.slice(0, 100).map(r=>`<li><span>${r.ts_cn||'—'}</span><span class="badge">${r.batch||''}</span><span class="badge">${r.mac||''}</span><span class="badge">${r.note||''}</span></li>`).join('')||'<li>暂无数据</li>';
|
const ytEls=ytView.slice(0, 100).map(r=>`<li><span>${r.ts_cn||'—'}</span><span class="badge">${r.batch||''}</span><span class="badge">${r.mac||''}</span><span class="badge">${r.note||''}</span></li>`).join('')||'<li>暂无数据</li>';
|
||||||
const p=document.getElementById('audit-pdd'); if(p) p.innerHTML=pddEls;
|
const p=document.getElementById('audit-pdd'); if(p) p.innerHTML=pddEls;
|
||||||
const y=document.getElementById('audit-yt'); if(y) y.innerHTML=ytEls;
|
const y=document.getElementById('audit-yt'); if(y) y.innerHTML=ytEls;
|
||||||
|
|
||||||
|
// 更新整合看板
|
||||||
|
const updateAuditDisplay = () => {
|
||||||
|
const platform = window.__currentAuditPlatform || 'pdd';
|
||||||
|
const params = platform === 'pdd' ? window.__pddParams : window.__ytParams;
|
||||||
|
const sTime = toEpoch(params.start);
|
||||||
|
const eTime = toEpoch(params.end);
|
||||||
|
const cacheData = platform === 'pdd' ? window.__auditCache.pdd : window.__auditCache.yt;
|
||||||
|
const filteredData = (cacheData || []).filter(r => {
|
||||||
|
const t = toEpoch(r.ts_cn);
|
||||||
|
if (t == null) return false;
|
||||||
|
return (sTime == null || t >= sTime) && (eTime == null || t <= eTime);
|
||||||
|
});
|
||||||
|
const listHtml = filteredData.slice(0, 100).map(r =>
|
||||||
|
`<li><span>${r.ts_cn||'—'}</span><span class="badge">${r.batch||''}</span><span class="badge">${r.mac||''}</span><span class="badge">${r.note||''}</span></li>`
|
||||||
|
).join('') || '<li>暂无数据</li>';
|
||||||
|
const auditListEl = document.getElementById('audit-list');
|
||||||
|
if (auditListEl) auditListEl.innerHTML = listHtml;
|
||||||
|
};
|
||||||
|
updateAuditDisplay();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
if(e.name !== 'AbortError'){
|
if(e.name !== 'AbortError'){
|
||||||
@ -512,15 +597,28 @@ const Dashboard = (() => {
|
|||||||
<div id="chart-tooltip" style="position:absolute;background:rgba(0,0,0,0.85);color:#fff;padding:6px 10px;border-radius:4px;font-size:12px;pointer-events:none;display:none;white-space:nowrap"></div>
|
<div id="chart-tooltip" style="position:absolute;background:rgba(0,0,0,0.85);color:#fff;padding:6px 10px;border-radius:4px;font-size:12px;pointer-events:none;display:none;white-space:nowrap"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid cols-2" style="margin-top:12px">
|
<div style="margin-top:12px">
|
||||||
<div id="audit-pdd-card" class="card" style="display:flex;flex-direction:column;height:460px">
|
<div id="audit-card" class="card" style="display:flex;flex-direction:column;height:460px">
|
||||||
|
<div style="font-weight:600;margin-bottom:8px;display:flex;justify-content:space-between;align-items:center;flex-shrink:0;gap:8px">
|
||||||
|
<span>审计看板</span>
|
||||||
|
<div style="display:flex;gap:8px;align-items:center">
|
||||||
|
<select id="audit-platform-select" style="padding:4px 8px;background:var(--surface);border:1px solid var(--border);border-radius:6px;color:var(--text);font-size:13px;outline:none;cursor:pointer">
|
||||||
|
<option value="pdd">拼多多</option>
|
||||||
|
<option value="yt">圆通</option>
|
||||||
|
</select>
|
||||||
|
<input id="audit-date" type="date" style="padding:4px 8px;background:var(--surface);border:1px solid var(--border);border-radius:6px;color:var(--text);font-size:13px;outline:none" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ul id="audit-list" class="list" style="overflow-y:auto;flex:1;min-height:0">${pddList}</ul>
|
||||||
|
</div>
|
||||||
|
<div id="audit-pdd-card" class="card" style="display:none;flex-direction:column;height:460px">
|
||||||
<div style="font-weight:600;margin-bottom:8px;display:flex;justify-content:space-between;align-items:center;flex-shrink:0">
|
<div style="font-weight:600;margin-bottom:8px;display:flex;justify-content:space-between;align-items:center;flex-shrink:0">
|
||||||
<span>拼多多审计</span>
|
<span>拼多多审计</span>
|
||||||
<input id="audit-date-pdd" type="date" style="padding:4px 8px;background:var(--surface);border:1px solid var(--border);border-radius:6px;color:var(--text);font-size:13px;outline:none" />
|
<input id="audit-date-pdd" type="date" style="padding:4px 8px;background:var(--surface);border:1px solid var(--border);border-radius:6px;color:var(--text);font-size:13px;outline:none" />
|
||||||
</div>
|
</div>
|
||||||
<ul id="audit-pdd" class="list" style="overflow-y:auto;flex:1;min-height:0">${pddList}</ul>
|
<ul id="audit-pdd" class="list" style="overflow-y:auto;flex:1;min-height:0">${pddList}</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="audit-yt-card" class="card" style="display:flex;flex-direction:column;height:460px">
|
<div id="audit-yt-card" class="card" style="display:none;flex-direction:column;height:460px">
|
||||||
<div style="font-weight:600;margin-bottom:8px;display:flex;justify-content:space-between;align-items:center;flex-shrink:0">
|
<div style="font-weight:600;margin-bottom:8px;display:flex;justify-content:space-between;align-items:center;flex-shrink:0">
|
||||||
<span>圆通审计</span>
|
<span>圆通审计</span>
|
||||||
<input id="audit-date-yt" type="date" style="padding:4px 8px;background:var(--surface);border:1px solid var(--border);border-radius:6px;color:var(--text);font-size:13px;outline:none" />
|
<input id="audit-date-yt" type="date" style="padding:4px 8px;background:var(--surface);border:1px solid var(--border);border-radius:6px;color:var(--text);font-size:13px;outline:none" />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user