@agentprismform/render-vue 0.0.0-stage → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.mjs +2995 -0
- package/dist/style.css +2 -0
- package/package.json +40 -4
- package/src/components/FormGroup.vue +50 -0
- package/src/components/FormItem.vue +171 -0
- package/src/components/FormRender.vue +127 -0
- package/src/components/PrismForm.vue +608 -0
- package/src/components/controls/AddressControl.vue +255 -0
- package/src/components/controls/AgreementControl.vue +49 -0
- package/src/components/controls/CascaderControl.vue +159 -0
- package/src/components/controls/DateControl.vue +96 -0
- package/src/components/controls/ImageUploadControl.vue +135 -0
- package/src/components/controls/InputControl.vue +80 -0
- package/src/components/controls/ListControl.vue +149 -0
- package/src/components/controls/SearchControl.vue +193 -0
- package/src/components/controls/SelectControl.vue +206 -0
- package/src/components/controls/SliderControl.vue +61 -0
- package/src/components/controls/TaskControl.vue +39 -0
- package/src/components/controls/VerifyCodeControl.vue +135 -0
- package/src/components/controls/task/ApiTask.vue +99 -0
- package/src/components/controls/task/CustomerTask.vue +91 -0
- package/src/components/controls/task/H5JumpTask.vue +125 -0
- package/src/components/controls/task/InlineTask.vue +116 -0
- package/src/components/controls/task/NativeTask.vue +299 -0
- package/src/components/controls/task/SubFormTask.vue +156 -0
- package/src/composables/useFormRender.ts +63 -0
- package/src/composables/useTaskHandler.ts +11 -0
- package/src/helpers.ts +143 -0
- package/src/index.ts +8 -0
- package/src/taskHandlers.ts +4 -0
- package/README.md +0 -3
|
@@ -0,0 +1,608 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
computed,
|
|
4
|
+
onUnmounted,
|
|
5
|
+
provide,
|
|
6
|
+
reactive,
|
|
7
|
+
ref,
|
|
8
|
+
shallowRef,
|
|
9
|
+
watch,
|
|
10
|
+
} from 'vue'
|
|
11
|
+
import { FormCore, type FormSchema, type StorageAdapter } from '@agentprismform/core'
|
|
12
|
+
import { createFormRenderState, type ResolvedFormGroup } from '@agentprismform/render'
|
|
13
|
+
import {
|
|
14
|
+
FORM_UI_HOST_HANDLERS_KEY,
|
|
15
|
+
MODERN_COLLAPSIBLE_KEY,
|
|
16
|
+
MODERN_CUSTOM_CONTROLS_KEY,
|
|
17
|
+
MODERN_KEYBOARD_POLICY_KEY,
|
|
18
|
+
MODERN_LOCALE_KEY,
|
|
19
|
+
MODERN_READONLY_KEY,
|
|
20
|
+
MODERN_SHELL_SKIN_KEY,
|
|
21
|
+
MODERN_TELEMETRY_KEY,
|
|
22
|
+
MODERN_THEME_OVERRIDE_KEY,
|
|
23
|
+
computeFormProgress,
|
|
24
|
+
getModernShellComponents,
|
|
25
|
+
normalizeModernLocale,
|
|
26
|
+
resolveModernThemeVars,
|
|
27
|
+
type FormTelemetryHandler,
|
|
28
|
+
type FormUiHostHandlers,
|
|
29
|
+
type ModernCustomControlsMap,
|
|
30
|
+
type ModernKeyboardPolicy,
|
|
31
|
+
type ModernLocale,
|
|
32
|
+
type ModernShellSkin,
|
|
33
|
+
type ModernThemeOverride,
|
|
34
|
+
} from '@agentprismform/render-ui'
|
|
35
|
+
import FormRender from './FormRender.vue'
|
|
36
|
+
|
|
37
|
+
export interface PrismFormThemeConfig {
|
|
38
|
+
skin?: ModernShellSkin
|
|
39
|
+
override?: ModernThemeOverride | null
|
|
40
|
+
formMode?: 'flat' | 'collapsible' | 'step'
|
|
41
|
+
showProgressBar?: boolean
|
|
42
|
+
readOnly?: boolean
|
|
43
|
+
keyboardPolicy?: ModernKeyboardPolicy
|
|
44
|
+
submitText?: string
|
|
45
|
+
locale?: ModernLocale
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface PrismFormBundle {
|
|
49
|
+
schema: FormSchema
|
|
50
|
+
themeConfig?: PrismFormThemeConfig | null
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const props = withDefaults(
|
|
54
|
+
defineProps<{
|
|
55
|
+
/** Raw FormSchema (optional if `bundle` is provided) */
|
|
56
|
+
schema?: FormSchema | null
|
|
57
|
+
/** Finalized form.bundle.json ({ schema, themeConfig }) from release-export / scaffold-host */
|
|
58
|
+
bundle?: PrismFormBundle | null
|
|
59
|
+
/** Optional ThemeConfigJson overrides */
|
|
60
|
+
themeConfig?: PrismFormThemeConfig | null
|
|
61
|
+
/** Initial field values passed into FormCore.init() */
|
|
62
|
+
initialValues?: Record<string, any>
|
|
63
|
+
/** Visual skin: 'fin-minimal' | 'clean-outline' | 'bank-card' */
|
|
64
|
+
skin?: ModernShellSkin
|
|
65
|
+
/** Brand color / radius / density / trust bar overrides */
|
|
66
|
+
themeOverride?: ModernThemeOverride | null
|
|
67
|
+
/** Layout interaction mode: 'flat' | 'collapsible' | 'step' */
|
|
68
|
+
formMode?: 'flat' | 'collapsible' | 'step'
|
|
69
|
+
/** Show top progress bar & jump-to-first-missing button */
|
|
70
|
+
showProgressBar?: boolean
|
|
71
|
+
/** Review Mode (read-only + sensitive field masking) */
|
|
72
|
+
readOnly?: boolean
|
|
73
|
+
/** Custom numeric/ID keypad policy: 'auto' | 'custom' | 'system' */
|
|
74
|
+
keyboardPolicy?: ModernKeyboardPolicy
|
|
75
|
+
/** UI language: 'zh-CN' | 'en-US' */
|
|
76
|
+
locale?: ModernLocale
|
|
77
|
+
/** Business handlers (sendVerifyCode / uploadFile / searchSuggest / loadAddressChildren / launchTask) */
|
|
78
|
+
hostHandlers?: FormUiHostHandlers | null
|
|
79
|
+
/** Partial widget override or custom control registry (by item.key / item.type) */
|
|
80
|
+
customControls?: ModernCustomControlsMap
|
|
81
|
+
/** Optional telemetry callback */
|
|
82
|
+
onTelemetry?: FormTelemetryHandler
|
|
83
|
+
/** Optional custom StorageAdapter (defaults to in-memory Map) */
|
|
84
|
+
storageAdapter?: StorageAdapter
|
|
85
|
+
/** Submit button text override */
|
|
86
|
+
submitText?: string
|
|
87
|
+
/** Whether to render the built-in submit button (default true) */
|
|
88
|
+
showSubmit?: boolean
|
|
89
|
+
/** Disable submit button externally while parent is submitting */
|
|
90
|
+
submitting?: boolean
|
|
91
|
+
/** Max container width (default '680px') */
|
|
92
|
+
maxWidth?: string
|
|
93
|
+
}>(),
|
|
94
|
+
{
|
|
95
|
+
schema: null,
|
|
96
|
+
bundle: null,
|
|
97
|
+
themeConfig: null,
|
|
98
|
+
initialValues: undefined,
|
|
99
|
+
skin: undefined,
|
|
100
|
+
themeOverride: undefined,
|
|
101
|
+
formMode: undefined,
|
|
102
|
+
showProgressBar: undefined,
|
|
103
|
+
readOnly: undefined,
|
|
104
|
+
keyboardPolicy: undefined,
|
|
105
|
+
locale: undefined,
|
|
106
|
+
hostHandlers: null,
|
|
107
|
+
customControls: undefined,
|
|
108
|
+
onTelemetry: undefined,
|
|
109
|
+
storageAdapter: undefined,
|
|
110
|
+
submitText: undefined,
|
|
111
|
+
showSubmit: true,
|
|
112
|
+
submitting: false,
|
|
113
|
+
maxWidth: '680px',
|
|
114
|
+
},
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
const emit = defineEmits<{
|
|
118
|
+
(e: 'submit', data: Record<string, any>): void
|
|
119
|
+
(e: 'change', payload: { values: Record<string, any>; fields: Record<string, any> }): void
|
|
120
|
+
(e: 'validate-error', payload: { firstErrorKey: string | null; errors: Record<string, string> }): void
|
|
121
|
+
}>()
|
|
122
|
+
|
|
123
|
+
const resolvedSchema = computed<FormSchema | null>(() => props.schema || props.bundle?.schema || null)
|
|
124
|
+
const mergedThemeConfig = computed<PrismFormThemeConfig>(() => ({
|
|
125
|
+
...(props.bundle?.themeConfig || {}),
|
|
126
|
+
...(props.themeConfig || {}),
|
|
127
|
+
}))
|
|
128
|
+
|
|
129
|
+
const effectiveSkin = computed<ModernShellSkin>(
|
|
130
|
+
() => props.skin || mergedThemeConfig.value.skin || 'fin-minimal',
|
|
131
|
+
)
|
|
132
|
+
const effectiveOverride = computed<ModernThemeOverride | null>(
|
|
133
|
+
() => props.themeOverride ?? mergedThemeConfig.value.override ?? null,
|
|
134
|
+
)
|
|
135
|
+
const effectiveFormMode = computed<'flat' | 'collapsible' | 'step'>(
|
|
136
|
+
() => props.formMode || mergedThemeConfig.value.formMode || 'flat',
|
|
137
|
+
)
|
|
138
|
+
const effectiveShowProgress = computed<boolean>(() => {
|
|
139
|
+
if (typeof props.showProgressBar === 'boolean') return props.showProgressBar
|
|
140
|
+
if (typeof mergedThemeConfig.value.showProgressBar === 'boolean') {
|
|
141
|
+
return mergedThemeConfig.value.showProgressBar
|
|
142
|
+
}
|
|
143
|
+
return true
|
|
144
|
+
})
|
|
145
|
+
const effectiveReadOnly = computed<boolean>(() => {
|
|
146
|
+
if (typeof props.readOnly === 'boolean') return props.readOnly
|
|
147
|
+
return Boolean(mergedThemeConfig.value.readOnly)
|
|
148
|
+
})
|
|
149
|
+
const effectiveKeyboardPolicy = computed<ModernKeyboardPolicy>(
|
|
150
|
+
() => props.keyboardPolicy || mergedThemeConfig.value.keyboardPolicy || 'auto',
|
|
151
|
+
)
|
|
152
|
+
const effectiveLocale = computed<ModernLocale>(() =>
|
|
153
|
+
normalizeModernLocale(props.locale || mergedThemeConfig.value.locale || 'zh-CN'),
|
|
154
|
+
)
|
|
155
|
+
const isEn = computed(() => effectiveLocale.value === 'en-US')
|
|
156
|
+
|
|
157
|
+
const themeVars = computed(() => resolveModernThemeVars(effectiveSkin.value, effectiveOverride.value))
|
|
158
|
+
const modernShell = getModernShellComponents()
|
|
159
|
+
|
|
160
|
+
provide(MODERN_SHELL_SKIN_KEY, effectiveSkin)
|
|
161
|
+
provide(MODERN_THEME_OVERRIDE_KEY, effectiveOverride)
|
|
162
|
+
provide(
|
|
163
|
+
MODERN_COLLAPSIBLE_KEY,
|
|
164
|
+
computed(() => effectiveFormMode.value === 'collapsible'),
|
|
165
|
+
)
|
|
166
|
+
provide(MODERN_KEYBOARD_POLICY_KEY, effectiveKeyboardPolicy)
|
|
167
|
+
provide(MODERN_READONLY_KEY, effectiveReadOnly)
|
|
168
|
+
provide(
|
|
169
|
+
MODERN_TELEMETRY_KEY,
|
|
170
|
+
computed(() => props.onTelemetry || null),
|
|
171
|
+
)
|
|
172
|
+
provide(MODERN_LOCALE_KEY, effectiveLocale)
|
|
173
|
+
provide(
|
|
174
|
+
MODERN_CUSTOM_CONTROLS_KEY,
|
|
175
|
+
computed(() => props.customControls || {}),
|
|
176
|
+
)
|
|
177
|
+
provide(
|
|
178
|
+
FORM_UI_HOST_HANDLERS_KEY,
|
|
179
|
+
computed(() => props.hostHandlers ?? null),
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
const rootEl = ref<HTMLElement | null>(null)
|
|
183
|
+
const coreRef = shallowRef<FormCore | null>(null)
|
|
184
|
+
const fields = reactive<Record<string, any>>({})
|
|
185
|
+
const groups = ref<ResolvedFormGroup[]>([])
|
|
186
|
+
const activeStep = ref(0)
|
|
187
|
+
const ready = ref(false)
|
|
188
|
+
let activeCleanup: (() => void) | null = null
|
|
189
|
+
|
|
190
|
+
function createDefaultStorage(): StorageAdapter {
|
|
191
|
+
const mem = new Map<string, any>()
|
|
192
|
+
return {
|
|
193
|
+
get: (k: string) => mem.get(k),
|
|
194
|
+
set: (k: string, v: any) => mem.set(k, v),
|
|
195
|
+
remove: (k: string) => mem.delete(k),
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function cloneSchema(s: FormSchema): FormSchema {
|
|
200
|
+
return JSON.parse(JSON.stringify(s))
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function syncFromCore(core: FormCore, schema: FormSchema) {
|
|
204
|
+
const currentKeys = new Set(Object.keys(core.fields))
|
|
205
|
+
for (const existing of Object.keys(fields)) {
|
|
206
|
+
if (!currentKeys.has(existing)) delete fields[existing]
|
|
207
|
+
}
|
|
208
|
+
const snap: Record<string, any> = {}
|
|
209
|
+
for (const k of currentKeys) {
|
|
210
|
+
const copy = { ...core.fields[k] }
|
|
211
|
+
fields[k] = copy
|
|
212
|
+
snap[k] = copy
|
|
213
|
+
}
|
|
214
|
+
groups.value = createFormRenderState(schema, snap, { excludeTaskAndAgreement: false }).groups
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async function mountCore(schema: FormSchema | null) {
|
|
218
|
+
if (activeCleanup) {
|
|
219
|
+
activeCleanup()
|
|
220
|
+
activeCleanup = null
|
|
221
|
+
}
|
|
222
|
+
ready.value = false
|
|
223
|
+
activeStep.value = 0
|
|
224
|
+
if (!schema) {
|
|
225
|
+
coreRef.value = null
|
|
226
|
+
groups.value = []
|
|
227
|
+
return
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const cloned = cloneSchema(schema)
|
|
231
|
+
const core = new FormCore(cloned, props.storageAdapter || createDefaultStorage())
|
|
232
|
+
coreRef.value = core
|
|
233
|
+
|
|
234
|
+
const onAfterChange = () => {
|
|
235
|
+
syncFromCore(core, cloned)
|
|
236
|
+
emit('change', {
|
|
237
|
+
values: core.collectFormData({ skipVerify: true }),
|
|
238
|
+
fields: { ...fields },
|
|
239
|
+
})
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
await core.init(props.initialValues ? { ...props.initialValues } : {})
|
|
243
|
+
core.on('afterChange', onAfterChange)
|
|
244
|
+
activeCleanup = () => {
|
|
245
|
+
core.off('afterChange', onAfterChange)
|
|
246
|
+
}
|
|
247
|
+
syncFromCore(core, cloned)
|
|
248
|
+
ready.value = true
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
watch(
|
|
252
|
+
resolvedSchema,
|
|
253
|
+
(next) => {
|
|
254
|
+
void mountCore(next)
|
|
255
|
+
},
|
|
256
|
+
{ immediate: true },
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
onUnmounted(() => {
|
|
260
|
+
if (activeCleanup) {
|
|
261
|
+
activeCleanup()
|
|
262
|
+
activeCleanup = null
|
|
263
|
+
}
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
const isStepMode = computed(() => effectiveFormMode.value === 'step' && groups.value.length > 1)
|
|
267
|
+
const safeStep = computed(() => Math.min(activeStep.value, Math.max(0, groups.value.length - 1)))
|
|
268
|
+
const visibleGroups = computed<ResolvedFormGroup[]>(() =>
|
|
269
|
+
isStepMode.value ? [groups.value[safeStep.value]].filter(Boolean) : groups.value,
|
|
270
|
+
)
|
|
271
|
+
const progress = computed(() =>
|
|
272
|
+
effectiveShowProgress.value ? computeFormProgress(groups.value as any, fields) : null,
|
|
273
|
+
)
|
|
274
|
+
const effectiveSubmitText = computed(
|
|
275
|
+
() =>
|
|
276
|
+
props.submitText ||
|
|
277
|
+
mergedThemeConfig.value.submitText ||
|
|
278
|
+
(isEn.value ? 'Submit Form' : '提交表单'),
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
function scrollToField(key: string | null) {
|
|
282
|
+
if (!key || typeof document === 'undefined') return
|
|
283
|
+
if (isStepMode.value) {
|
|
284
|
+
const idx = groups.value.findIndex((g) => (g.items || []).some((it: any) => it.key === key))
|
|
285
|
+
if (idx >= 0) activeStep.value = idx
|
|
286
|
+
}
|
|
287
|
+
const scope = rootEl.value || document
|
|
288
|
+
const el =
|
|
289
|
+
(scope.querySelector(`[data-field-key="${key}"]`) as HTMLElement | null) ||
|
|
290
|
+
(scope.querySelector('[data-has-error="1"], .m-field-error') as HTMLElement | null)
|
|
291
|
+
if (el && typeof el.scrollIntoView === 'function') {
|
|
292
|
+
el.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
|
293
|
+
}
|
|
294
|
+
const focusable = el?.querySelector('input, textarea, select') as HTMLElement | null
|
|
295
|
+
focusable?.focus?.({ preventScroll: true })
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function collectErrors(core: FormCore): { firstErrorKey: string | null; errors: Record<string, string> } {
|
|
299
|
+
const errors: Record<string, string> = {}
|
|
300
|
+
let firstErrorKey: string | null = null
|
|
301
|
+
for (const g of groups.value) {
|
|
302
|
+
for (const item of g.items || []) {
|
|
303
|
+
const msg = core.fields[item.key]?.errMsg
|
|
304
|
+
if (msg) {
|
|
305
|
+
errors[item.key] = String(msg)
|
|
306
|
+
if (!firstErrorKey) firstErrorKey = item.key
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return { firstErrorKey, errors }
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function validate(): boolean {
|
|
314
|
+
const core = coreRef.value
|
|
315
|
+
const schema = resolvedSchema.value
|
|
316
|
+
if (!core || !schema) return false
|
|
317
|
+
const ok = core.validateAll()
|
|
318
|
+
syncFromCore(core, schema)
|
|
319
|
+
if (!ok) {
|
|
320
|
+
const errInfo = collectErrors(core)
|
|
321
|
+
emit('validate-error', errInfo)
|
|
322
|
+
scrollToField(errInfo.firstErrorKey)
|
|
323
|
+
}
|
|
324
|
+
return ok
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function getValues(): Record<string, any> {
|
|
328
|
+
return coreRef.value ? coreRef.value.collectFormData({ skipVerify: true }) : {}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function setValue(key: string, value: any, options?: { skipVerify?: boolean; eventType?: string }) {
|
|
332
|
+
coreRef.value?.setControlData(key, value, options)
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
async function reset(nextInitialValues?: Record<string, any>) {
|
|
336
|
+
const schema = resolvedSchema.value
|
|
337
|
+
if (!schema) return
|
|
338
|
+
if (nextInitialValues !== undefined) {
|
|
339
|
+
const cloned = cloneSchema(schema)
|
|
340
|
+
if (activeCleanup) {
|
|
341
|
+
activeCleanup()
|
|
342
|
+
activeCleanup = null
|
|
343
|
+
}
|
|
344
|
+
const core = new FormCore(cloned, props.storageAdapter || createDefaultStorage())
|
|
345
|
+
coreRef.value = core
|
|
346
|
+
const onAfterChange = () => {
|
|
347
|
+
syncFromCore(core, cloned)
|
|
348
|
+
emit('change', {
|
|
349
|
+
values: core.collectFormData({ skipVerify: true }),
|
|
350
|
+
fields: { ...fields },
|
|
351
|
+
})
|
|
352
|
+
}
|
|
353
|
+
await core.init({ ...nextInitialValues })
|
|
354
|
+
core.on('afterChange', onAfterChange)
|
|
355
|
+
activeCleanup = () => core.off('afterChange', onAfterChange)
|
|
356
|
+
syncFromCore(core, cloned)
|
|
357
|
+
ready.value = true
|
|
358
|
+
return
|
|
359
|
+
}
|
|
360
|
+
await mountCore(schema)
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function handleSubmitClick() {
|
|
364
|
+
if (props.submitting || effectiveReadOnly.value) return
|
|
365
|
+
if (!validate()) return
|
|
366
|
+
emit('submit', getValues())
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
defineExpose({
|
|
370
|
+
validate,
|
|
371
|
+
getValues,
|
|
372
|
+
setValue,
|
|
373
|
+
reset,
|
|
374
|
+
getCore: () => coreRef.value,
|
|
375
|
+
})
|
|
376
|
+
</script>
|
|
377
|
+
|
|
378
|
+
<template>
|
|
379
|
+
<div
|
|
380
|
+
ref="rootEl"
|
|
381
|
+
class="apf-prism-form"
|
|
382
|
+
:data-modern-skin="effectiveSkin"
|
|
383
|
+
:style="{ ...themeVars, maxWidth }"
|
|
384
|
+
>
|
|
385
|
+
<div v-if="resolvedSchema?.title" class="apf-prism-form__header">
|
|
386
|
+
<div class="apf-prism-form__title">{{ resolvedSchema.title }}</div>
|
|
387
|
+
<div v-if="resolvedSchema.description" class="apf-prism-form__desc">
|
|
388
|
+
{{ resolvedSchema.description }}
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
|
|
392
|
+
<div
|
|
393
|
+
v-if="ready && progress && progress.total > 0"
|
|
394
|
+
class="apf-prism-form__progress"
|
|
395
|
+
data-testid="prism-form-progress"
|
|
396
|
+
>
|
|
397
|
+
<div class="apf-prism-form__progress-row">
|
|
398
|
+
<span v-if="isEn">
|
|
399
|
+
Progress <strong>{{ progress.percent }}%</strong> (Required {{ progress.requiredFilled }}/{{ progress.requiredTotal }})
|
|
400
|
+
</span>
|
|
401
|
+
<span v-else>
|
|
402
|
+
填写进度 <strong>{{ progress.percent }}%</strong>(必填 {{ progress.requiredFilled }}/{{ progress.requiredTotal }})
|
|
403
|
+
</span>
|
|
404
|
+
<button
|
|
405
|
+
v-if="progress.firstMissingRequiredKey"
|
|
406
|
+
type="button"
|
|
407
|
+
class="apf-prism-form__jump"
|
|
408
|
+
@click="scrollToField(progress.firstMissingRequiredKey)"
|
|
409
|
+
>
|
|
410
|
+
{{ isEn ? 'Next required ›' : '定位未填 ›' }}
|
|
411
|
+
</button>
|
|
412
|
+
</div>
|
|
413
|
+
<div class="apf-prism-form__bar">
|
|
414
|
+
<div class="apf-prism-form__bar-fill" :style="{ width: `${progress.percent}%` }" />
|
|
415
|
+
</div>
|
|
416
|
+
</div>
|
|
417
|
+
|
|
418
|
+
<div v-if="ready && isStepMode" class="apf-prism-form__steps" data-testid="prism-form-steps">
|
|
419
|
+
<button
|
|
420
|
+
v-for="(grp, idx) in groups"
|
|
421
|
+
:key="grp.key || idx"
|
|
422
|
+
type="button"
|
|
423
|
+
class="apf-prism-form__step-pill"
|
|
424
|
+
:class="{ 'is-active': safeStep === idx }"
|
|
425
|
+
@click="activeStep = idx"
|
|
426
|
+
>
|
|
427
|
+
{{ idx + 1 }}. {{ grp.title || (isEn ? `Step ${idx + 1}` : `第${idx + 1}步`) }}
|
|
428
|
+
</button>
|
|
429
|
+
</div>
|
|
430
|
+
|
|
431
|
+
<FormRender
|
|
432
|
+
v-if="ready && coreRef"
|
|
433
|
+
:groups="visibleGroups"
|
|
434
|
+
:fields="fields"
|
|
435
|
+
:form-core="coreRef"
|
|
436
|
+
:custom-controls="customControls"
|
|
437
|
+
:host-handlers="hostHandlers"
|
|
438
|
+
v-bind="modernShell"
|
|
439
|
+
>
|
|
440
|
+
<template #footer>
|
|
441
|
+
<div v-if="isStepMode" class="apf-prism-form__step-nav">
|
|
442
|
+
<button
|
|
443
|
+
type="button"
|
|
444
|
+
class="apf-prism-form__step-btn"
|
|
445
|
+
:disabled="safeStep <= 0"
|
|
446
|
+
@click="activeStep = Math.max(0, safeStep - 1)"
|
|
447
|
+
>
|
|
448
|
+
{{ isEn ? 'Previous' : '上一步' }}
|
|
449
|
+
</button>
|
|
450
|
+
<span class="apf-prism-form__step-count">{{ safeStep + 1 }} / {{ groups.length }}</span>
|
|
451
|
+
<button
|
|
452
|
+
type="button"
|
|
453
|
+
class="apf-prism-form__step-btn is-primary"
|
|
454
|
+
:disabled="safeStep >= groups.length - 1"
|
|
455
|
+
@click="activeStep = Math.min(groups.length - 1, safeStep + 1)"
|
|
456
|
+
>
|
|
457
|
+
{{ isEn ? 'Next' : '下一步' }}
|
|
458
|
+
</button>
|
|
459
|
+
</div>
|
|
460
|
+
|
|
461
|
+
<slot name="footer" :submit="handleSubmitClick" :validate="validate" :submitting="submitting">
|
|
462
|
+
<div v-if="showSubmit && !effectiveReadOnly" class="apf-prism-form__footer">
|
|
463
|
+
<button
|
|
464
|
+
type="button"
|
|
465
|
+
class="apf-prism-form__submit"
|
|
466
|
+
:disabled="submitting"
|
|
467
|
+
@click="handleSubmitClick"
|
|
468
|
+
>
|
|
469
|
+
{{ submitting ? (isEn ? 'Submitting…' : '提交中…') : effectiveSubmitText }}
|
|
470
|
+
</button>
|
|
471
|
+
</div>
|
|
472
|
+
</slot>
|
|
473
|
+
</template>
|
|
474
|
+
</FormRender>
|
|
475
|
+
</div>
|
|
476
|
+
</template>
|
|
477
|
+
|
|
478
|
+
<style scoped>
|
|
479
|
+
.apf-prism-form {
|
|
480
|
+
width: 100%;
|
|
481
|
+
margin: 0 auto;
|
|
482
|
+
background: var(--fs-page-bg, #f5f6fa);
|
|
483
|
+
box-sizing: border-box;
|
|
484
|
+
padding-bottom: 24px;
|
|
485
|
+
}
|
|
486
|
+
.apf-prism-form :deep(.form-render[data-shell='override']) {
|
|
487
|
+
background: transparent;
|
|
488
|
+
padding-top: 4px;
|
|
489
|
+
}
|
|
490
|
+
.apf-prism-form__header {
|
|
491
|
+
padding: 16px 16px 4px;
|
|
492
|
+
}
|
|
493
|
+
.apf-prism-form__title {
|
|
494
|
+
font-size: 18px;
|
|
495
|
+
font-weight: 600;
|
|
496
|
+
line-height: 26px;
|
|
497
|
+
color: var(--fs-text, #0f172a);
|
|
498
|
+
}
|
|
499
|
+
.apf-prism-form__desc {
|
|
500
|
+
margin-top: 4px;
|
|
501
|
+
font-size: 13px;
|
|
502
|
+
line-height: 20px;
|
|
503
|
+
color: var(--fs-text-sub, #475569);
|
|
504
|
+
}
|
|
505
|
+
.apf-prism-form__progress {
|
|
506
|
+
padding: 8px 16px 4px;
|
|
507
|
+
display: flex;
|
|
508
|
+
flex-direction: column;
|
|
509
|
+
gap: 6px;
|
|
510
|
+
}
|
|
511
|
+
.apf-prism-form__progress-row {
|
|
512
|
+
display: flex;
|
|
513
|
+
align-items: center;
|
|
514
|
+
justify-content: space-between;
|
|
515
|
+
font-size: 12px;
|
|
516
|
+
color: var(--fs-text-sub, #475569);
|
|
517
|
+
}
|
|
518
|
+
.apf-prism-form__jump {
|
|
519
|
+
border: 0;
|
|
520
|
+
border-radius: 999px;
|
|
521
|
+
padding: 2px 9px;
|
|
522
|
+
font-size: 11px;
|
|
523
|
+
font-weight: 600;
|
|
524
|
+
background: var(--fs-brand-soft, #eef4ff);
|
|
525
|
+
color: var(--fs-brand, #0f52ba);
|
|
526
|
+
cursor: pointer;
|
|
527
|
+
}
|
|
528
|
+
.apf-prism-form__bar {
|
|
529
|
+
height: 5px;
|
|
530
|
+
border-radius: 999px;
|
|
531
|
+
background: #e2e8f0;
|
|
532
|
+
overflow: hidden;
|
|
533
|
+
}
|
|
534
|
+
.apf-prism-form__bar-fill {
|
|
535
|
+
height: 100%;
|
|
536
|
+
background: var(--fs-brand, #0f52ba);
|
|
537
|
+
transition: width 0.2s ease;
|
|
538
|
+
}
|
|
539
|
+
.apf-prism-form__steps {
|
|
540
|
+
display: flex;
|
|
541
|
+
gap: 6px;
|
|
542
|
+
padding: 8px 16px 4px;
|
|
543
|
+
overflow-x: auto;
|
|
544
|
+
}
|
|
545
|
+
.apf-prism-form__step-pill {
|
|
546
|
+
border: 1px solid #e2e8f0;
|
|
547
|
+
background: #ffffff;
|
|
548
|
+
color: #475569;
|
|
549
|
+
border-radius: 999px;
|
|
550
|
+
padding: 4px 10px;
|
|
551
|
+
font-size: 12px;
|
|
552
|
+
white-space: nowrap;
|
|
553
|
+
cursor: pointer;
|
|
554
|
+
}
|
|
555
|
+
.apf-prism-form__step-pill.is-active {
|
|
556
|
+
border-color: var(--fs-brand, #0f52ba);
|
|
557
|
+
background: var(--fs-brand, #0f52ba);
|
|
558
|
+
color: #ffffff;
|
|
559
|
+
font-weight: 600;
|
|
560
|
+
}
|
|
561
|
+
.apf-prism-form__step-nav {
|
|
562
|
+
display: flex;
|
|
563
|
+
align-items: center;
|
|
564
|
+
justify-content: space-between;
|
|
565
|
+
padding: 4px 16px 10px;
|
|
566
|
+
}
|
|
567
|
+
.apf-prism-form__step-btn {
|
|
568
|
+
border: 1px solid #cbd5e1;
|
|
569
|
+
background: #ffffff;
|
|
570
|
+
color: #334155;
|
|
571
|
+
border-radius: 8px;
|
|
572
|
+
padding: 6px 14px;
|
|
573
|
+
font-size: 12px;
|
|
574
|
+
cursor: pointer;
|
|
575
|
+
}
|
|
576
|
+
.apf-prism-form__step-btn.is-primary {
|
|
577
|
+
border-color: var(--fs-brand, #0f52ba);
|
|
578
|
+
background: var(--fs-brand, #0f52ba);
|
|
579
|
+
color: #ffffff;
|
|
580
|
+
font-weight: 600;
|
|
581
|
+
}
|
|
582
|
+
.apf-prism-form__step-btn:disabled {
|
|
583
|
+
opacity: 0.45;
|
|
584
|
+
cursor: not-allowed;
|
|
585
|
+
}
|
|
586
|
+
.apf-prism-form__step-count {
|
|
587
|
+
font-size: 12px;
|
|
588
|
+
color: #64748b;
|
|
589
|
+
}
|
|
590
|
+
.apf-prism-form__footer {
|
|
591
|
+
padding: 12px 16px 0;
|
|
592
|
+
}
|
|
593
|
+
.apf-prism-form__submit {
|
|
594
|
+
width: 100%;
|
|
595
|
+
height: 44px;
|
|
596
|
+
border: 0;
|
|
597
|
+
border-radius: 10px;
|
|
598
|
+
background: var(--fs-brand, #0f52ba);
|
|
599
|
+
color: #ffffff;
|
|
600
|
+
font-size: 15px;
|
|
601
|
+
font-weight: 600;
|
|
602
|
+
cursor: pointer;
|
|
603
|
+
}
|
|
604
|
+
.apf-prism-form__submit:disabled {
|
|
605
|
+
opacity: 0.6;
|
|
606
|
+
cursor: not-allowed;
|
|
607
|
+
}
|
|
608
|
+
</style>
|