feat(M08-B): 补联调更新时间

This commit is contained in:
Codex
2026-07-06 08:26:46 +08:00
parent 89b5263352
commit 14fcfc2578
6 changed files with 49 additions and 13 deletions
@@ -6,6 +6,7 @@
<span>通过 <strong>{{ passedCount }}</strong></span>
<span>阻断 <strong>{{ blockedCount }}</strong></span>
<span>待处理 <strong>{{ pendingCount }}</strong></span>
<span>更新 <strong>{{ sessionMeta.updatedAt || '未记录' }}</strong></span>
</div>
<div class="toolbar-actions">
<el-segmented v-model="category" :options="categoryOptions" />
@@ -219,6 +220,7 @@ interface SessionMeta {
site: string;
coordinator: string;
executedAt: string;
updatedAt: string;
}
const storageKey = 'qipai.cleaning.field-handoff';
@@ -340,6 +342,8 @@ function readSavedDraft() {
}
function persistDraft() {
touchSessionMeta();
localStorage.setItem(sessionStorageKey, JSON.stringify(sessionMeta));
localStorage.setItem(storageKey, JSON.stringify(draft));
}
@@ -350,21 +354,28 @@ function readSessionMeta(): SessionMeta {
batchNo: saved.batchNo || '',
site: saved.site || '',
coordinator: saved.coordinator || '',
executedAt: saved.executedAt || ''
executedAt: saved.executedAt || '',
updatedAt: saved.updatedAt || ''
};
} catch {
return { batchNo: '', site: '', coordinator: '', executedAt: '' };
return { batchNo: '', site: '', coordinator: '', executedAt: '', updatedAt: '' };
}
}
function persistSessionMeta() {
touchSessionMeta();
localStorage.setItem(sessionStorageKey, JSON.stringify(sessionMeta));
}
function touchSessionMeta() {
sessionMeta.updatedAt = formatLocalMinute(new Date());
}
function resetDraft() {
for (const item of checklist) {
draft[item.id] = { status: 'PENDING', owner: '', note: '' };
}
touchSessionMeta();
persistDraft();
}
@@ -382,7 +393,8 @@ async function copyBlockedSummary() {
`联调批次:${sessionMeta.batchNo || '未填写'}`,
`现场/门店:${sessionMeta.site || '未填写'}`,
`负责人:${sessionMeta.coordinator || '未填写'}`,
`执行时间:${sessionMeta.executedAt || '未填写'}`
`执行时间:${sessionMeta.executedAt || '未填写'}`,
`最后更新:${sessionMeta.updatedAt || '未记录'}`
].join('\n');
const content = blockedItems.value.map((item) => {
const itemDraft = draft[item.id];
@@ -402,6 +414,7 @@ async function copyVerdict() {
`现场/门店:${sessionMeta.site || '未填写'}`,
`负责人:${sessionMeta.coordinator || '未填写'}`,
`执行时间:${sessionMeta.executedAt || '未填写'}`,
`最后更新:${sessionMeta.updatedAt || '未记录'}`,
`结论:${handoffReady.value ? '可进入现场验收收口' : '仍不可收口'}`,
`统计:通过 ${passedCount.value},阻断 ${blockedCount.value},待处理 ${pendingCount.value}`
].join('\n');
@@ -420,6 +433,7 @@ function exportChecklist() {
['session', '现场/门店', sessionMeta.site, '', '', '', '', ''],
['session', '负责人', sessionMeta.coordinator, '', '', '', '', ''],
['session', '执行时间', sessionMeta.executedAt, '', '', '', '', ''],
['session', '最后更新', sessionMeta.updatedAt, '', '', '', '', ''],
['ID', '类别', '检查项', '期望', '状态', '负责人', '结果记录', '证据'],
...checklist.map((item) => [
item.id,
@@ -470,7 +484,8 @@ async function importSnapshot(event: Event) {
batchNo: payload.sessionMeta?.batchNo || '',
site: payload.sessionMeta?.site || '',
coordinator: payload.sessionMeta?.coordinator || '',
executedAt: payload.sessionMeta?.executedAt || ''
executedAt: payload.sessionMeta?.executedAt || '',
updatedAt: payload.sessionMeta?.updatedAt || ''
});
for (const [id, value] of Object.entries(payload.draft)) {
if (!checklistIds.has(id)) continue;
@@ -481,6 +496,7 @@ async function importSnapshot(event: Event) {
note: value.note || ''
};
}
touchSessionMeta();
persistSessionMeta();
persistDraft();
ElMessage.success('联调快照已导入');
@@ -508,6 +524,15 @@ function downloadText(filename: string, content: string, type: string) {
URL.revokeObjectURL(url);
}
function formatLocalMinute(date: Date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hour = String(date.getHours()).padStart(2, '0');
const minute = String(date.getMinutes()).padStart(2, '0');
return `${year}-${month}-${day} ${hour}:${minute}`;
}
function csvCell(value: string) {
const normalized = value.replace(/\r?\n/g, ' ');
return /[",\r\n]/.test(normalized) ? `"${normalized.replace(/"/g, '""')}"` : normalized;