feat: add Flutter schema-driven form cards

This commit is contained in:
selfrelease
2026-07-18 09:13:27 +08:00
parent e13b6c7778
commit 2105fe3bac
85 changed files with 3141 additions and 3 deletions
@@ -0,0 +1,66 @@
import 'package:aioa_mobile/core/forms/schema/form_schema.dart';
const leaveFormDefinition = DynamicFormDefinition(
dataSchema: JsonFormSchema(
id: 'leave-request-v1',
title: '请假申请',
required: {'type', 'startsAt', 'endsAt', 'reason'},
properties: {
'type': JsonFieldSchema(
type: JsonValueType.string,
enumValues: ['PERSONAL', 'SICK', 'ANNUAL'],
),
'startsAt': JsonFieldSchema(
type: JsonValueType.string,
format: 'date-time',
),
'endsAt': JsonFieldSchema(
type: JsonValueType.string,
format: 'date-time',
),
'reason': JsonFieldSchema(
type: JsonValueType.string,
minLength: 1,
maxLength: 2000,
),
},
),
uiSchema: FormUiSchema(
description: '表单卡片由服务端 Schema 自动生成,字段、顺序、控件和校验均可版本化。',
sections: [
FormSectionSchema(
title: '请假信息',
controls: [
FormControlSchema(
field: 'type',
label: '请假类型',
control: FormControlType.select,
optionLabels: {'PERSONAL': '事假', 'SICK': '病假', 'ANNUAL': '年假'},
),
FormControlSchema(
field: 'startsAt',
label: '开始时间',
control: FormControlType.dateTime,
),
FormControlSchema(
field: 'endsAt',
label: '结束时间',
control: FormControlType.dateTime,
),
],
),
FormSectionSchema(
title: '补充说明',
controls: [
FormControlSchema(
field: 'reason',
label: '请假原因',
control: FormControlType.textArea,
placeholder: '请简要说明请假原因',
helperText: 'AI 可以帮助整理表达,但提交前必须由你确认。',
),
],
),
],
),
);