import { FormulaOpeartingPanel } from '@fui/materials'; import { fetchFormulaConfig } from '../../crud/crud.request'; /** * 打开公式编辑框 */ export function openFormulaPopover(value: T, inserterType: string = BI.RegularFormulaInserter.xtype): Promise { return new Promise((resolve, reject) => { const id = BI.UUID(); let formulaPane: FormulaOpeartingPanel; BI.Popovers.create(id, { type: BI.BarPopover.xtype, width: 900, height: 600, header: BI.i18nText('Plugin-JSON_Function_Definition'), body: { type: BI.FormulaOpeartingPanel.xtype, configLoader: fetchFormulaConfig, ref: (_ref: FormulaOpeartingPanel) => { formulaPane = _ref; }, inserterType, value, }, listeners: [{ eventName: BI.Popover.EVENT_CANCEL, action: () => { reject(); BI.Popovers.remove(id); }, }, { eventName: BI.Popover.EVENT_CONFIRM, action: () => { resolve(formulaPane.getValue() as T); BI.Popovers.remove(id); }, }], }).open(id); }); }