From 054638ed0d30e55416f8d01368e445bfed2341d4 Mon Sep 17 00:00:00 2001 From: romanskijdev Date: Thu, 27 Aug 2026 17:27:50 +0300 Subject: [PATCH] Add znzt module --- src/pages/OrdersPage.tsx | 142 ++++++++++++++++++++++++--------------- 1 file changed, 89 insertions(+), 53 deletions(-) diff --git a/src/pages/OrdersPage.tsx b/src/pages/OrdersPage.tsx index 1f70381..d603a63 100644 --- a/src/pages/OrdersPage.tsx +++ b/src/pages/OrdersPage.tsx @@ -4,9 +4,13 @@ import { LoadingOverlay, Select, TextInput, HoverCard, ActionIcon, Stack, Textarea, Checkbox } from '@mantine/core' import { notifications } from '@mantine/notifications' -import { IconDeviceFloppy, IconLock, IconSettings, IconSearch, IconFilter, IconUserSearch, IconRefresh, IconArrowLeft } from '@tabler/icons-react' +import { + IconDeviceFloppy, IconLock, IconSettings, IconSearch, + IconFilter, IconUserSearch, IconRefresh, IconArrowLeft, + IconFileExport, IconPaperclip, IconExternalLink +} from '@tabler/icons-react' import { useVirtualizer } from '@tanstack/react-virtual' -import { useNavigate, useParams } from 'react-router-dom' // πŸ‘ˆ Π”ΠΎΠ±Π°Π²ΠΈΠ»ΠΈ для Ρ€ΠΎΡƒΡ‚ΠΈΠ½Π³Π° +import { useNavigate, useParams } from 'react-router-dom' import { monthlyOrdersApi } from "../api/monthlyOrders.ts" import type { FrontendOrderMatrix, MonthlyOrderClient, NomenclatureItem } from "../types/orders.ts" @@ -56,16 +60,16 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void const tableContainerRef = useRef(null); - // 🟒 Π›ΠΎΠ³ΠΈΠΊΠ° Аналитика + // Π›ΠΎΠ³ΠΈΠΊΠ° Аналитика const navigate = useNavigate(); const { id } = useParams(); const targetManagerId = id ? Number(id) : undefined; - const isReadOnly = !!targetManagerId; // Если смотрим Ρ‡ΡƒΠΆΡƒΡŽ, Ρ‚ΠΎ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Ρ‡Ρ‚Π΅Π½ΠΈΠ΅ + const isReadOnly = !!targetManagerId; const loadData = async (ignoreDraft = false) => { try { setLoading(true) - const res = await monthlyOrdersApi.getMatrix(targetManagerId) // πŸ‘ˆ ΠŸΠ΅Ρ€Π΅Π΄Π°Π΅ΠΌ ID, Ссли Π΅ΡΡ‚ΡŒ + const res = await monthlyOrdersApi.getMatrix(targetManagerId) const matrix = res.data setData(matrix) @@ -84,7 +88,6 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void } }) - // Π§Π΅Ρ€Π½ΠΎΠ²ΠΈΠΊ Π½Π΅ Π·Π°Π³Ρ€ΡƒΠΆΠ°Π΅ΠΌ, Ссли ΠΌΡ‹ Аналитик (isReadOnly = true) const draft = localStorage.getItem(DRAFT_KEY); const draftTime = localStorage.getItem(DRAFT_TIME_KEY); @@ -103,8 +106,6 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void } } catch (err: any) { const errorMsg = err.response?.data?.error_description || 'Ошибка Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠΈ'; - - // 🟒 Если бэкСнд Ρ‚Ρ€Π΅Π±ΡƒΠ΅Ρ‚ ID ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ€Π°, Π·Π½Π°Ρ‡ΠΈΡ‚ зашСл Π°Π½Π°Π»ΠΈΡ‚ΠΈΠΊ -> Π Π΅Π΄ΠΈΡ€Π΅ΠΊΡ‚ Π½Π° Π΄Π°ΡˆΠ±ΠΎΡ€Π΄! if (errorMsg.includes('Π°Π½Π°Π»ΠΈΡ‚ΠΈΠΊΡƒ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ΠΏΠ΅Ρ€Π΅Π΄Π°Ρ‚ΡŒ manager_id')) { navigate('/analyst'); return; @@ -115,9 +116,8 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void } } - useEffect(() => { loadData() }, [targetManagerId]) // πŸ‘ˆ ΠŸΠ΅Ρ€Π΅Π·Π°Π³Ρ€ΡƒΠΆΠ°Π΅ΠΌ ΠΏΡ€ΠΈ смСнС ID + useEffect(() => { loadData() }, [targetManagerId]) - // АвтосохранСниС Ρ‡Π΅Ρ€Π½ΠΎΠ²ΠΈΠΊΠ° (Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Ссли Π½Π΅ Π°Π½Π°Π»ΠΈΡ‚ΠΈΠΊ!) useEffect(() => { if (loading || saving || isReadOnly) return; @@ -130,7 +130,7 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void }, [editableOrders, data, loading, saving, isReadOnly]); const handleQuantityChange = useCallback((clientName: string, nom: NomenclatureItem, qty: number | null) => { - if (isReadOnly) return; // Π‘Π»ΠΎΠΊΠΈΡ€ΠΎΠ²ΠΊΠ° + if (isReadOnly) return; setEditableOrders(prev => { const currentOrder = prev[clientName]; const items = [...(currentOrder.items || [])]; @@ -147,17 +147,18 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void }, [isReadOnly]); const updateClientMeta = useCallback((clientName: string, field: keyof MonthlyOrderClient, value: string | null) => { - if (isReadOnly) return; // Π‘Π»ΠΎΠΊΠΈΡ€ΠΎΠ²ΠΊΠ° + if (isReadOnly) return; setEditableOrders(prev => ({ ...prev, [clientName]: { ...prev[clientName], [field]: value } })) }, [isReadOnly]); + const handleSave = async () => { if (isReadOnly) return; for (const [clientName, order] of Object.entries(editableOrders)) { - if (order.items && order.items.length > 0 && !order.manager_comment?.trim()) { - return notifications.show({ title: 'Π’Π½ΠΈΠΌΠ°Π½ΠΈΠ΅', message: `Π£ΠΊΠ°ΠΆΠΈΡ‚Π΅ ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ для ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π° "${clientName}"!`, color: 'yellow' }) + if (!order.manager_comment || order.manager_comment.trim() === '') { + return notifications.show({ title: 'Π’Π½ΠΈΠΌΠ°Π½ΠΈΠ΅', message: `ΠšΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ обязатСлСн для ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π° "${clientName}"!`, color: 'yellow' }) } } try { @@ -243,13 +244,11 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void if (loading) return if (!data) return НСт Π΄Π°Π½Π½Ρ‹Ρ… - // ΠžΠ±Ρ‰ΠΈΠΉ Ρ„Π»Π°Π³ ΠΎΡ‚ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΡ элСмСнтов const inputsDisabled = data.is_locked || isReadOnly; return ( - {/* 🟒 Кнопка Π²ΠΎΠ·Π²Ρ€Π°Ρ‚Π° для Π°Π½Π°Π»ΠΈΡ‚ΠΈΠΊΠ° */} {isReadOnly && ( - - - ) - )} + + {!isReadOnly && ( + data.is_locked ? ( + }>ΠŸΡ€ΠΈΠ΅ΠΌ Π·Π°ΠΊΡ€Ρ‹Ρ‚ + ) : ( + <> + {draftSavedAt && ( + + Π›ΠΎΠΊΠ°Π»ΡŒΠ½Ρ‹ΠΉ Ρ‡Π΅Ρ€Π½ΠΎΠ²ΠΈΠΊ:
+ {formatMSKTime(draftSavedAt)} (МБК) +
+ )} + + + + ) + )} +
@@ -349,21 +349,47 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void const clientName = c.google_data.name; const branch = c.google_data.branch; const order = editableOrders[clientName]; - const hasOrderItems = order?.items && order.items.length > 0; - const isCommentMissing = hasOrderItems && (!order.manager_comment || order.manager_comment.trim() === ''); + + // ΠŸΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° ΠΎΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½ΠΎΡΡ‚ΠΈ коммСнтария + const hasComment = !!order?.manager_comment && order.manager_comment.trim() !== ''; return ( - - + + {clientName} - + + + {/* Π‘ΠΊΡ€Ρ‹Ρ‚Ρ‹ΠΉ ΠΈΠ½ΠΏΡƒΡ‚ для прикрСплСния Ρ„Π°ΠΉΠ»Π°-скрина */} + { + const file = e.target.files?.[0]; + if (file) { + notifications.show({ title: 'Π€Π°ΠΉΠ» Π²Ρ‹Π±Ρ€Π°Π½', message: `Π‘ΠΊΡ€ΠΈΠ½ для ${clientName}: ${file.name}`, color: 'blue' }); + } + }} + /> + 0 ? "teal" : "gray"} + size="sm" + title="ΠŸΡ€ΠΈΠΊΡ€Π΅ΠΏΠΈΡ‚ΡŒ скрин подтвСрТдСния Π·Π°ΠΊΠ°Π·Π°" + onClick={() => document.getElementById(`file-${clientName}`)?.click()} + > + + + + + {branch && ( @@ -380,15 +406,20 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void