yeg
2026-08-26 9f48020dfd3e29d1c0049a3da9df3203c40bc264
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { ref } from 'vue'
 
export type ExceptionStatus = '待处理' | '已处理'
 
export interface ExceptionRecord {
  id: number
  testId: number
  testName: string
  testTime: string
  exceptionItem: string
  abnormalValue: string
  normalValue: string
  generatedAt: string
  processor: string
  handledAt: string
  status: ExceptionStatus
  handleRemark: string
}
 
const STORAGE_KEY = 'battery_detection_exceptions_v1'
 
const seedRecords: ExceptionRecord[] = [
  { id: 5012, testId: 1024, testName: '高温循环性能测试', testTime: '2026-08-05 09:42', exceptionItem: '壳体温度', abnormalValue: '62.8 ℃', normalValue: '≤ 55 ℃', generatedAt: '2026-08-05 10:18', processor: '', handledAt: '-', status: '待处理', handleRemark: '' },
  { id: 5011, testId: 1023, testName: '电芯容量一致性测试', testTime: '2026-08-05 09:10', exceptionItem: '容量偏差', abnormalValue: '8.6%', normalValue: '≤ 5%', generatedAt: '2026-08-05 09:58', processor: '李工', handledAt: '2026-08-05 11:06', status: '已处理', handleRemark: '复核采样记录后确认单体容量异常,已转入复测。' },
  { id: 5010, testId: 1022, testName: '低温充放电测试', testTime: '2026-08-04 16:22', exceptionItem: '放电电压', abnormalValue: '2.41 V', normalValue: '≥ 2.50 V', generatedAt: '2026-08-04 17:04', processor: '', handledAt: '-', status: '待处理', handleRemark: '' },
  { id: 5009, testId: 1021, testName: '电芯老化寿命测试', testTime: '2026-08-04 14:30', exceptionItem: '容量保持率', abnormalValue: '77.2%', normalValue: '≥ 80%', generatedAt: '2026-08-04 15:36', processor: '王工', handledAt: '2026-08-04 16:12', status: '已处理', handleRemark: '确认达到寿命终止条件,测试已正常结束。' },
  { id: 5008, testId: 1020, testName: '3C倍率放电验证', testTime: '2026-08-04 13:14', exceptionItem: '放电温升', abnormalValue: '31.7 ℃', normalValue: '≤ 25 ℃', generatedAt: '2026-08-04 13:32', processor: '', handledAt: '-', status: '待处理', handleRemark: '' },
  { id: 5007, testId: 1019, testName: '常温容量复测', testTime: '2026-08-03 18:48', exceptionItem: '通道电流', abnormalValue: '12.8 mA', normalValue: '0 ± 5 mA', generatedAt: '2026-08-03 18:50', processor: '李工', handledAt: '2026-08-04 08:42', status: '已处理', handleRemark: '已完成电流零点补偿并复核后续数据。' },
  { id: 5006, testId: 1018, testName: '过充安全边界测试', testTime: '2026-08-03 15:05', exceptionItem: '过充电压', abnormalValue: '4.43 V', normalValue: '≤ 4.40 V', generatedAt: '2026-08-03 15:06', processor: '陈工', handledAt: '2026-08-03 15:28', status: '已处理', handleRemark: '保护装置已触发,复核为预期边界响应。' },
  { id: 5005, testId: 1017, testName: '低温启动能力验证', testTime: '2026-08-03 11:27', exceptionItem: '启动电压', abnormalValue: '8.8 V', normalValue: '≥ 9.0 V', generatedAt: '2026-08-03 11:28', processor: '', handledAt: '-', status: '待处理', handleRemark: '' },
  { id: 5004, testId: 1016, testName: '1C标准循环测试', testTime: '2026-08-02 17:20', exceptionItem: '负极电位', abnormalValue: '0.018 V', normalValue: '≥ 0.020 V', generatedAt: '2026-08-02 17:21', processor: '张工', handledAt: '2026-08-02 18:02', status: '已处理', handleRemark: '降低充电倍率后电位恢复正常,继续测试。' },
  { id: 5003, testId: 1015, testName: '高倍率温升测试', testTime: '2026-08-02 14:48', exceptionItem: '采集器温度', abnormalValue: '48.6 ℃', normalValue: '≤ 45 ℃', generatedAt: '2026-08-02 14:49', processor: '', handledAt: '-', status: '待处理', handleRemark: '' },
  { id: 5002, testId: 1014, testName: '批次容量抽检', testTime: '2026-08-01 16:35', exceptionItem: '容量下限', abnormalValue: '2864 mAh', normalValue: '≥ 2900 mAh', generatedAt: '2026-08-01 16:36', processor: '李工', handledAt: '2026-08-01 17:15', status: '已处理', handleRemark: '异常电芯已移出抽检批次并登记复测。' },
  { id: 5001, testId: 1013, testName: '短路保护响应测试', testTime: '2026-08-01 10:08', exceptionItem: '保护响应时间', abnormalValue: '126 ms', normalValue: '≤ 100 ms', generatedAt: '2026-08-01 10:09', processor: '陈工', handledAt: '2026-08-01 10:46', status: '已处理', handleRemark: '复核高速记录仪数据,确认保护响应超限。' },
]
 
function loadRecords() {
  try {
    const stored = localStorage.getItem(STORAGE_KEY)
    if (stored) return JSON.parse(stored) as ExceptionRecord[]
  } catch {
    localStorage.removeItem(STORAGE_KEY)
  }
  return seedRecords
}
 
const records = ref<ExceptionRecord[]>(loadRecords())
 
function persist() {
  localStorage.setItem(STORAGE_KEY, JSON.stringify(records.value))
}
 
export function useExceptions() {
  function handleRecord(id: number, processor: string, handleRemark: string, handledAt: string) {
    const target = records.value.find(item => item.id === id)
    if (!target) return false
    target.processor = processor
    target.handleRemark = handleRemark
    target.handledAt = handledAt
    target.status = '已处理'
    persist()
    return true
  }
 
  function removeRecord(id: number) {
    records.value = records.value.filter(item => item.id !== id)
    persist()
  }
 
  return { records, handleRecord, removeRecord }
}