2026-04-17-23-12-52 - 修复时间字段24h脏数据、格式选项分类过滤、字段管理编辑面板滚动对齐
This commit is contained in:
@@ -952,6 +952,7 @@ export default function ReportEditor() {
|
||||
|
||||
const formatTimeDisplay = (timeStr: string, fmt?: string): string => {
|
||||
if (!timeStr || !fmt) return timeStr || '';
|
||||
if (fmt === '24h') fmt = 'HH:mm';
|
||||
const [h24str, mstr] = timeStr.split(':');
|
||||
const h24 = parseInt(h24str) || 0;
|
||||
const isPM = h24 >= 12;
|
||||
|
||||
@@ -86,7 +86,8 @@ export default function TemplateManage() {
|
||||
|
||||
const savedFormats = storage.get<string[]>('customTimeFormats', []);
|
||||
const defaultFormats = ['YYYY-MM-DD', 'YYYY年MM月DD日', 'MM-DD', 'MM月DD日', 'HH:mm', 'hh:mm A'];
|
||||
setCustomTimeFormats(Array.from(new Set([...defaultFormats, ...savedFormats])));
|
||||
const cleanedSaved = savedFormats.filter(f => f !== '24h' && f !== '12h');
|
||||
setCustomTimeFormats(Array.from(new Set([...defaultFormats, ...cleanedSaved])));
|
||||
|
||||
const savedTemplates = storage.get<Template[]>('templates', []);
|
||||
if (savedTemplates.length === 0) {
|
||||
@@ -878,13 +879,17 @@ export default function TemplateManage() {
|
||||
<div
|
||||
key={field.key}
|
||||
id={`sidebar-field-${field.key}`}
|
||||
onClick={() => {
|
||||
onClick={(e) => {
|
||||
setEditingFieldKey(field.key);
|
||||
setEditFieldLabel(field.label);
|
||||
setEditFieldOptions((field.options || []).join(', '));
|
||||
setEditFieldTimeFormat(field.timeFormat || '');
|
||||
setEditFieldTimeDefault(field.timeDefault || 'specific');
|
||||
setEditFieldFixedTimeValue(field.fixedTimeValue || '');
|
||||
const target = e.currentTarget;
|
||||
setTimeout(() => {
|
||||
target.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
||||
}, 50);
|
||||
}}
|
||||
className={`cursor-pointer rounded border p-2 transition-all ${activeFieldKey === field.key ? 'border-accent bg-blue-50 ring-1 ring-accent' : 'border-slate-100 bg-slate-50 hover:border-slate-200'}`}
|
||||
>
|
||||
@@ -954,7 +959,15 @@ export default function TemplateManage() {
|
||||
placeholder="输入格式,如 YYYY-MM-DD"
|
||||
/>
|
||||
<datalist id={`edit-format-list-${field.key}`}>
|
||||
{customTimeFormats.map(fmt => <option key={fmt} value={fmt} />)}
|
||||
{customTimeFormats
|
||||
.filter(fmt => {
|
||||
const isDateFormat = /YYYY|MM|DD/.test(fmt);
|
||||
const isTimeFormat = /HH|hh|mm|A/.test(fmt);
|
||||
if (field.type === 'date') return isDateFormat;
|
||||
if (field.type === 'time') return isTimeFormat;
|
||||
return true;
|
||||
})
|
||||
.map(fmt => <option key={fmt} value={fmt} />)}
|
||||
</datalist>
|
||||
</div>
|
||||
)}
|
||||
@@ -1114,7 +1127,15 @@ export default function TemplateManage() {
|
||||
placeholder="输入格式,如 YYYY-MM-DD"
|
||||
/>
|
||||
<datalist id="new-format-list">
|
||||
{customTimeFormats.map(fmt => <option key={fmt} value={fmt} />)}
|
||||
{customTimeFormats
|
||||
.filter(fmt => {
|
||||
const isDateFormat = /YYYY|MM|DD/.test(fmt);
|
||||
const isTimeFormat = /HH|hh|mm|A/.test(fmt);
|
||||
if (newFieldForm.type === 'date') return isDateFormat;
|
||||
if (newFieldForm.type === 'time') return isTimeFormat;
|
||||
return true;
|
||||
})
|
||||
.map(fmt => <option key={fmt} value={fmt} />)}
|
||||
</datalist>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -127,8 +127,8 @@ export const DEFAULT_FORM_FIELDS: FormField[] = [
|
||||
{ key: 'department', label: '科别', category: '填空', type: 'text', visibleInForm: true, isSystemLocked: false },
|
||||
{ key: 'bedNumber', label: '床号', category: '填空', type: 'text', visibleInForm: true, isSystemLocked: false },
|
||||
{ key: 'surgeryDate', label: '手术日期', category: '时间', type: 'date', visibleInForm: true, isSystemLocked: true, timeFormat: 'YYYY-MM-DD', timeDefault: 'specific' },
|
||||
{ key: 'startTime', label: '手术开始时间', category: '时间', type: 'time', visibleInForm: true, isSystemLocked: true, timeFormat: '24h', timeDefault: 'specific' },
|
||||
{ key: 'endTime', label: '手术终止时间', category: '时间', type: 'time', visibleInForm: true, isSystemLocked: true, timeFormat: '24h', timeDefault: 'specific' },
|
||||
{ key: 'startTime', label: '手术开始时间', category: '时间', type: 'time', visibleInForm: true, isSystemLocked: true, timeFormat: 'HH:mm', timeDefault: 'specific' },
|
||||
{ key: 'endTime', label: '手术终止时间', category: '时间', type: 'time', visibleInForm: true, isSystemLocked: true, timeFormat: 'HH:mm', timeDefault: 'specific' },
|
||||
{ key: 'reportDate', label: '撰写时间', category: '时间', type: 'date', visibleInForm: true, isSystemLocked: true, timeFormat: 'YYYY年MM月DD日', timeDefault: 'current' },
|
||||
{ key: 'surgeon', label: '手术者', category: '多选', type: 'multi_select', visibleInForm: true, isSystemLocked: true, options: ['张医生', '李医生', '王医生'] },
|
||||
{ key: 'assistant', label: '助手', category: '多选', type: 'multi_select', visibleInForm: true, isSystemLocked: true, options: ['赵医生', '钱医生', '孙医生'] },
|
||||
|
||||
Reference in New Issue
Block a user