- ГРСИ: {config.registryNumber || "Не указан"}
+ ГРСИ: {config.registryNumber || 'Не указан'}
Максимум: {config.maxItems} эталонов
@@ -36,7 +38,7 @@ export const StandardsPreview: React.FC
= ({ config }) =>
@@ -45,11 +47,11 @@ export const StandardsPreview: React.FC = ({ config }) =>
{config.targetCells && config.targetCells.length > 0 && (
-
+
{config.targetCells.map((target, index) => (
{target.sheet}!{target.cell}
@@ -60,5 +62,5 @@ export const StandardsPreview: React.FC = ({ config }) =>
- );
-};
\ No newline at end of file
+ )
+}
diff --git a/src/component/StandardsElement/StandardsSelector.tsx b/src/component/StandardsElement/StandardsSelector.tsx
index 54f17d8..7056c8e 100644
--- a/src/component/StandardsElement/StandardsSelector.tsx
+++ b/src/component/StandardsElement/StandardsSelector.tsx
@@ -1,214 +1,227 @@
-import { Badge } from "@/components/ui/badge";
-import { Button } from "@/components/ui/button";
-import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
-import { Calendar, Check, FileText, Settings, X } from "lucide-react";
-import { useState } from "react";
+import { Badge } from '@/component/ui/badge'
+import { Button } from '@/component/ui/button'
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+} from '@/component/ui/dialog'
+import { Calendar, Check, FileText, Settings, X } from 'lucide-react'
+import { useState } from 'react'
interface MeasurementStandard {
- id: string;
- name: string;
- shortName: string;
- type: string;
- registryNumber: string;
- range: string;
- accuracy: string;
- certificateNumber: string;
- validUntil: string;
+ id: string
+ name: string
+ shortName: string
+ type: string
+ registryNumber: string
+ range: string
+ accuracy: string
+ certificateNumber: string
+ validUntil: string
}
interface StandardsSelectorProps {
- isOpen: boolean;
- onClose: () => void;
- value: string[];
- onChange: (value: string[]) => void;
- registryNumber?: string;
+ isOpen: boolean
+ onClose: () => void
+ value: string[]
+ onChange: (value: string[]) => void
+ registryNumber?: string
}
// Моковые данные для эталонов
const mockStandards: MeasurementStandard[] = [
{
- id: "1",
- name: "Эталон массы 1 кг",
- shortName: "ЭМ-1кг",
- type: "Масса",
- registryNumber: "ГРСИ 12345-01",
- range: "0.5-2 кг",
- accuracy: "±0.001 г",
- certificateNumber: "СИ-2024-001",
- validUntil: "2025-12-31",
+ id: '1',
+ name: 'Эталон массы 1 кг',
+ shortName: 'ЭМ-1кг',
+ type: 'Масса',
+ registryNumber: 'ГРСИ 12345-01',
+ range: '0.5-2 кг',
+ accuracy: '±0.001 г',
+ certificateNumber: 'СИ-2024-001',
+ validUntil: '2025-12-31',
},
{
- id: "2",
- name: "Эталон длины 1 м",
- shortName: "ЭД-1м",
- type: "Длина",
- registryNumber: "ГРСИ 12345-02",
- range: "0.5-2 м",
- accuracy: "±0.001 мм",
- certificateNumber: "СИ-2024-002",
- validUntil: "2025-06-30",
+ id: '2',
+ name: 'Эталон длины 1 м',
+ shortName: 'ЭД-1м',
+ type: 'Длина',
+ registryNumber: 'ГРСИ 12345-02',
+ range: '0.5-2 м',
+ accuracy: '±0.001 мм',
+ certificateNumber: 'СИ-2024-002',
+ validUntil: '2025-06-30',
},
{
- id: "3",
- name: "Эталон температуры 20°C",
- shortName: "ЭТ-20°C",
- type: "Температура",
- registryNumber: "ГРСИ 12345-03",
- range: "15-25°C",
- accuracy: "±0.01°C",
- certificateNumber: "СИ-2024-003",
- validUntil: "2025-03-15",
+ id: '3',
+ name: 'Эталон температуры 20°C',
+ shortName: 'ЭТ-20°C',
+ type: 'Температура',
+ registryNumber: 'ГРСИ 12345-03',
+ range: '15-25°C',
+ accuracy: '±0.01°C',
+ certificateNumber: 'СИ-2024-003',
+ validUntil: '2025-03-15',
},
{
- id: "4",
- name: "Эталон давления 1 Па",
- shortName: "ЭД-1Па",
- type: "Давление",
- registryNumber: "ГРСИ 12345-04",
- range: "0.5-2 Па",
- accuracy: "±0.001 Па",
- certificateNumber: "СИ-2024-004",
- validUntil: "2025-09-20",
+ id: '4',
+ name: 'Эталон давления 1 Па',
+ shortName: 'ЭД-1Па',
+ type: 'Давление',
+ registryNumber: 'ГРСИ 12345-04',
+ range: '0.5-2 Па',
+ accuracy: '±0.001 Па',
+ certificateNumber: 'СИ-2024-004',
+ validUntil: '2025-09-20',
},
{
- id: "5",
- name: "Эталон времени 1 с",
- shortName: "ЭВ-1с",
- type: "Время",
- registryNumber: "ГРСИ 12345-05",
- range: "0.5-2 с",
- accuracy: "±0.000001 с",
- certificateNumber: "СИ-2024-005",
- validUntil: "2025-12-01",
+ id: '5',
+ name: 'Эталон времени 1 с',
+ shortName: 'ЭВ-1с',
+ type: 'Время',
+ registryNumber: 'ГРСИ 12345-05',
+ range: '0.5-2 с',
+ accuracy: '±0.000001 с',
+ certificateNumber: 'СИ-2024-005',
+ validUntil: '2025-12-01',
},
-];
+]
export function StandardsSelector({
isOpen,
onClose,
value = [],
onChange,
- registryNumber = "ГРСИ 12345"
+ registryNumber = 'ГРСИ 12345',
}: StandardsSelectorProps) {
- const [selectedStandards, setSelectedStandards] = useState
(value);
+ const [selectedStandards, setSelectedStandards] = useState(value)
const toggleStandard = (standardId: string) => {
setSelectedStandards(prev => {
if (prev.includes(standardId)) {
- return prev.filter(id => id !== standardId);
+ return prev.filter(id => id !== standardId)
} else if (prev.length < 7) {
- return [...prev, standardId];
+ return [...prev, standardId]
}
- return prev;
- });
- };
+ return prev
+ })
+ }
const handleSave = () => {
- onChange(selectedStandards);
- onClose();
- };
+ onChange(selectedStandards)
+ onClose()
+ }
const handleClose = () => {
- setSelectedStandards(value); // Сбрасываем к исходному значению
- onClose();
- };
+ setSelectedStandards(value) // Сбрасываем к исходному значению
+ onClose()
+ }
const isExpiringSoon = (validUntil: string) => {
- const expiryDate = new Date(validUntil);
- const now = new Date();
- const monthsUntilExpiry = (expiryDate.getTime() - now.getTime()) / (1000 * 60 * 60 * 24 * 30);
- return monthsUntilExpiry <= 3;
- };
+ const expiryDate = new Date(validUntil)
+ const now = new Date()
+ const monthsUntilExpiry =
+ (expiryDate.getTime() - now.getTime()) / (1000 * 60 * 60 * 24 * 30)
+ return monthsUntilExpiry <= 3
+ }
return (