87f97a2f9b
build / build (push) Successful in 1m7s
详情使用共享主表字典,稀疏修改所选字段并保留原始问答及旧复核审计。 月周统计提供文本和下拉双入口;每租户每周一份持久草稿,按技能六节双语模板真实预填。 加入幂等自动保存、冲突保留、未知响应重试、切周及离开保护和schema58非破坏降级保护。 验证:完整make verify、隔离PostgreSQL全mirror竞态回归、真实恢复库浏览器验收通过。 浏览器实测字段精确读回、月周双输入、模板预填、MD/CSV、自动保存、冲突、失败重试与API重启恢复。 未连接或改写DobotAI生产源库,未运行付费模型;提交时尚未部署。
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { qaWeek, currentQAWeek, qaWeekValue } from './qaWeeks'
|
|
export type QAPeriodKind = 'month' | 'week'
|
|
export function validPeriodInput(kind: QAPeriodKind, value: string, max?: string): boolean {
|
|
const pattern = kind === 'month' ? /^[0-9]{4}-[0-9]{2}$/ : /^[0-9]{4}-W[0-9]{2}$/
|
|
if (!pattern.test(value)) return false
|
|
const year = Number(value.slice(0, 4))
|
|
if (year < 2000 || year > 9998) return false
|
|
if (kind === 'month') {
|
|
const month = Number(value.slice(5))
|
|
if (month < 1 || month > 12) return false
|
|
} else {
|
|
try {
|
|
qaWeek(year, Number(value.slice(6)))
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|
|
return !max || (validPeriodInput(kind, max) && value <= max)
|
|
}
|
|
export function periodInputOptions(kind: QAPeriodKind, max: string): string[] {
|
|
if (!validPeriodInput(kind, max)) return []
|
|
const result: string[] = []
|
|
if (kind === 'month') {
|
|
let year = Number(max.slice(0, 4)),
|
|
month = Number(max.slice(5))
|
|
for (let i = 0; i < 36 && year >= 2000; i++) {
|
|
result.push(`${year}-${String(month).padStart(2, '0')}`)
|
|
month--
|
|
if (month === 0) {
|
|
year--
|
|
month = 12
|
|
}
|
|
}
|
|
} else {
|
|
const start = qaWeek(Number(max.slice(0, 4)), Number(max.slice(6))).start
|
|
const monday = Date.parse(`${start}:00Z`)
|
|
for (let i = 0; i < 156; i++) {
|
|
const p = currentQAWeek(new Date(monday - i * 7 * 86400000))
|
|
if (p.year < 2000) break
|
|
result.push(qaWeekValue(p))
|
|
}
|
|
}
|
|
return result
|
|
}
|