import { Store } from 'unistore'; import { IStoreState, ID } from '../../index.data'; import FormulaManager from '../FormulaManager'; import { idFormula2LabelFormula, labelFormula2IdFormula, id2Label } from './helper'; import { FormulaManagerConfig } from '../index.data'; class PositionedFormulaManager extends FormulaManager { // {{11}}+1 => A1+1 // 假设B2表.id===22, 则: // {{id22!11}} + 1 => B2!A1+1 transformToUser(internalFormula: string): string { return idFormula2LabelFormula(this.store.getState(), internalFormula, this.config); } // A1+1 => {{id11}}+1 // 假设B2表.id===22, 则: // B2!A1+1 => {{id22!11}} + 1 transformToInternal(userFormula: string): string { return labelFormula2IdFormula(this.store.getState(), userFormula, this.config); } // 11 => A1 // id22!11 => B2!A1 // 用于用户pick, 此时仅返回id, 不返回{{}}号 transformCellToUser(internalCellId: ID): string { return id2Label(this.store.getState(), internalCellId, this.config); } } export default PositionedFormulaManager;