переименования папок
This commit is contained in:
57
src/component/StandardsElement/definition.tsx
Normal file
57
src/component/StandardsElement/definition.tsx
Normal file
@@ -0,0 +1,57 @@
|
||||
import { ElementDefinition } from '@/lib/element-registry'
|
||||
import { parseCellAddress } from '@/lib/utils'
|
||||
import { CellTarget } from '@/type/template'
|
||||
import { Weight } from 'lucide-react'
|
||||
import { StandardsEditor } from './StandardsEditor'
|
||||
import { StandardsPreview } from './StandardsPreview'
|
||||
|
||||
interface StandardsConfig {
|
||||
registryNumber: string // ГРСИ
|
||||
sheet: string // Лист Excel
|
||||
startCell: string // Первая ячейка (например "A10")
|
||||
maxItems: number // Обычно 7
|
||||
targetCells: CellTarget[]
|
||||
}
|
||||
|
||||
export const standardsDefinition: ElementDefinition<StandardsConfig, string[]> =
|
||||
{
|
||||
type: 'standards',
|
||||
label: 'Измерительные эталоны',
|
||||
icon: <Weight className="h-4 w-4" />,
|
||||
defaultConfig: {
|
||||
registryNumber: '',
|
||||
sheet: 'Report',
|
||||
startCell: 'A1',
|
||||
maxItems: 7,
|
||||
targetCells: [],
|
||||
},
|
||||
Editor: StandardsEditor,
|
||||
Preview: StandardsPreview,
|
||||
Render: () => {
|
||||
// Здесь нужно создать обертку для StandardsDialog
|
||||
// Пока возвращаем null, так как StandardsDialog требует дополнительные пропсы
|
||||
return null
|
||||
},
|
||||
mapToCells: cfg => {
|
||||
const res: CellTarget[] = []
|
||||
const parsed = parseCellAddress(cfg.startCell)
|
||||
|
||||
if (!parsed) {
|
||||
// Если не удалось распарсить, возвращаем пустой массив
|
||||
return res
|
||||
}
|
||||
|
||||
const { column, row } = parsed
|
||||
|
||||
// Генерируем ячейки вертикально (A1, A2, A3...)
|
||||
for (let i = 0; i < cfg.maxItems; i++) {
|
||||
res.push({
|
||||
sheet: cfg.sheet,
|
||||
cell: `${column}${row + i}`,
|
||||
displayName: `Эталон ${i + 1}`,
|
||||
})
|
||||
}
|
||||
|
||||
return res
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user