diff --git a/src/pages/BandoEdit/components/BandoEditFormStep3/index.js b/src/pages/BandoEdit/components/BandoEditFormStep3/index.js index d5c40ea..80e1b6f 100644 --- a/src/pages/BandoEdit/components/BandoEditFormStep3/index.js +++ b/src/pages/BandoEdit/components/BandoEditFormStep3/index.js @@ -95,12 +95,13 @@ const BandoEditFormStep3 = forwardRef(function () { const getFormsCallback = (resp) => { if (resp.status === 'SUCCESS') { const EXCLUDED_TYPES = new Set(['fileupload', 'fileselect', 'table', 'criteria_table', 'spreadsheet']); + console.log('resp.data', resp.data) const raw = (resp.data ?? []).flatMap(form => (form.content ?? []) .filter(f => !EXCLUDED_TYPES.has(f.name)) .map(f => ({ id: f.id, - label: f.label, + label: f.settings?.find(s => s.name === 'label')?.value ?? f.label, placeholder: f.settings?.find(s => s.name === 'placeholder')?.value ?? '' })) ); @@ -109,6 +110,7 @@ const BandoEditFormStep3 = forwardRef(function () { if (!byLabel.has(f.label)) byLabel.set(f.label, { label: f.label, ids: [], placeholder: f.placeholder }); byLabel.get(f.label).ids.push(f.id); }); + console.log('byLabel', Array.from(byLabel.values())) storeSet('callFormFields', Array.from(byLabel.values())); } } diff --git a/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSettingSpreadsheet/index.js b/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSettingSpreadsheet/index.js index b5752c5..e03d5d9 100644 --- a/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSettingSpreadsheet/index.js +++ b/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSettingSpreadsheet/index.js @@ -162,10 +162,16 @@ const ElementSettingSpreadsheet = ({ value, name, setDataFn }) => { }, []); // refs are stable - // Keep formFieldsRef in sync with store value + // Keep formFieldsRef in sync with store value; rebuild Univer (and its context menu) + // once fields arrive, because the menu is constructed at init time from formFieldsRef.current. useEffect(() => { + console.log('callFormFields', callFormFields) formFieldsRef.current = callFormFields; - }, [callFormFields]); + if (callFormFields.length > 0 && univerAPIRef.current) { + const currentWorkbook = univerAPIRef.current.getActiveWorkbook()?.save() ?? null; + initializeUniver(currentWorkbook); + } + }, [callFormFields, initializeUniver]); // Initialize Univer on mount useEffect(() => {