Add znzt module
Deploy Manager App / deploy (push) Successful in 19s
Details
Deploy Manager App / deploy (push) Successful in 19s
Details
This commit is contained in:
parent
c81aee374e
commit
9609841692
|
|
@ -14,6 +14,7 @@
|
||||||
"@mantine/hooks": "^9.5.2",
|
"@mantine/hooks": "^9.5.2",
|
||||||
"@mantine/notifications": "^9.5.2",
|
"@mantine/notifications": "^9.5.2",
|
||||||
"@tabler/icons-react": "^3.46.0",
|
"@tabler/icons-react": "^3.46.0",
|
||||||
|
"@tanstack/react-virtual": "^3.14.10",
|
||||||
"axios": "^1.19.0",
|
"axios": "^1.19.0",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"dayjs": "^1.11.23",
|
"dayjs": "^1.11.23",
|
||||||
|
|
@ -970,6 +971,33 @@
|
||||||
"react": ">= 16"
|
"react": ">= 16"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@tanstack/react-virtual": {
|
||||||
|
"version": "3.14.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.14.10.tgz",
|
||||||
|
"integrity": "sha512-SRyoUbdFMRHuYXMijV5H4ZarQWpXkj3iANq8OFre+pybeVap8ZJjZ3Nz9bVjx4d8PfobVUQUdKyyyHYk3E+djw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@tanstack/virtual-core": "3.17.8"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/tannerlinsley"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||||
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@tanstack/virtual-core": {
|
||||||
|
"version": "3.17.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.17.8.tgz",
|
||||||
|
"integrity": "sha512-BfEvehNpOT75r5Ksc5xW6NZuXujTfb7nlSEyVu4XHG3gdxNg1KqXruWbDewXOUaUYIo4oRbSfkjIajz4MAT8tA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/tannerlinsley"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/crypto-js": {
|
"node_modules/@types/crypto-js": {
|
||||||
"version": "4.2.2",
|
"version": "4.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.2.2.tgz",
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
"@mantine/hooks": "^9.5.2",
|
"@mantine/hooks": "^9.5.2",
|
||||||
"@mantine/notifications": "^9.5.2",
|
"@mantine/notifications": "^9.5.2",
|
||||||
"@tabler/icons-react": "^3.46.0",
|
"@tabler/icons-react": "^3.46.0",
|
||||||
|
"@tanstack/react-virtual": "^3.14.10",
|
||||||
"axios": "^1.19.0",
|
"axios": "^1.19.0",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"dayjs": "^1.11.23",
|
"dayjs": "^1.11.23",
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,31 @@
|
||||||
import apiClient from './client'
|
import apiClient from './client';
|
||||||
import type {FrontendOrderMatrix, MonthlyOrderClient} from "../types/orders.ts";
|
import type { FrontendOrderMatrix, MonthlyOrderClient } from "../types/orders.ts";
|
||||||
|
|
||||||
export const monthlyOrdersApi = {
|
export const monthlyOrdersApi = {
|
||||||
// Получение матрицы (клиенты из гугла + номенклатура + черновики из БД)
|
getMatrix: () => apiClient.get<FrontendOrderMatrix>('/monthly-orders/matrix'),
|
||||||
getMatrix: () =>
|
|
||||||
apiClient.get<FrontendOrderMatrix>('/monthly-orders/matrix'),
|
|
||||||
|
|
||||||
// Сохранение заказов (черновик или отправка)
|
|
||||||
saveOrders: (orders: MonthlyOrderClient[]) =>
|
saveOrders: (orders: MonthlyOrderClient[]) =>
|
||||||
apiClient.post<{ data: string }>('/monthly-orders/save', { orders }),
|
apiClient.post<{ data: string }>('/monthly-orders/save', { orders }),
|
||||||
}
|
|
||||||
|
// TODO: Реализовать на бэкенде
|
||||||
|
uploadAttachment: (file: File, clientName: string) => {
|
||||||
|
const fd = new FormData();
|
||||||
|
fd.append('file', file);
|
||||||
|
fd.append('client_name', clientName);
|
||||||
|
return apiClient.post<{ url: string }>('/monthly-orders/attachments', fd, {
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// TODO: Реализовать на бэкенде
|
||||||
|
exportReport: (reportType: 1 | 2) =>
|
||||||
|
apiClient.get(`/monthly-orders/report/${reportType}`, { responseType: 'blob' })
|
||||||
|
.then((res) => {
|
||||||
|
const url = URL.createObjectURL(res.data);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
a.download = `report_${reportType}_${new Date().toISOString().split('T')[0]}.xlsx`;
|
||||||
|
a.click();
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import React, { useState, useEffect, useCallback } from 'react'
|
import React, { useState, useEffect, useCallback } from 'react'
|
||||||
import {
|
import {
|
||||||
Box, Table, Title, Text, Paper, Stack, Button, Group,
|
Box, Table, Title, Text, Paper, Stack, Button, Group,
|
||||||
Select, Textarea, Badge, LoadingOverlay, Card, Divider
|
MultiSelect, Textarea, Badge, LoadingOverlay, Card, Divider,
|
||||||
|
CheckIcon, Select
|
||||||
} from '@mantine/core'
|
} from '@mantine/core'
|
||||||
import { useMediaQuery } from '@mantine/hooks'
|
import { useMediaQuery } from '@mantine/hooks'
|
||||||
import { notifications } from '@mantine/notifications'
|
import { notifications } from '@mantine/notifications'
|
||||||
|
|
@ -9,6 +10,12 @@ import { IconDeviceFloppy, IconLock } from '@tabler/icons-react'
|
||||||
import type { FrontendOrderMatrix, MonthlyOrderClient, NomenclatureItem } from "../types/orders.ts";
|
import type { FrontendOrderMatrix, MonthlyOrderClient, NomenclatureItem } from "../types/orders.ts";
|
||||||
import { monthlyOrdersApi } from "../api/monthlyOrders.ts";
|
import { monthlyOrdersApi } from "../api/monthlyOrders.ts";
|
||||||
|
|
||||||
|
// Константы для селекторов
|
||||||
|
const DECADE_OPTIONS = ['1-я', '2-я', '3-я', 'Склад', 'Клиент'];
|
||||||
|
const DELIVERY_OPTIONS = ['Предоплата', 'Отсрочка'];
|
||||||
|
const CONDITIONS_OPTIONS = ['Стандарт', 'Спец. условия', 'Акция'];
|
||||||
|
const PAYMENT_OPTIONS = ['Ф1-Ф1', 'Ф1-Ф2', 'Ф2-Ф1', 'Ф2-Ф2'];
|
||||||
|
|
||||||
interface OrdersPageProps {
|
interface OrdersPageProps {
|
||||||
onError: (msg: string) => void;
|
onError: (msg: string) => void;
|
||||||
}
|
}
|
||||||
|
|
@ -19,7 +26,6 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
const [saving, setSaving] = useState(false)
|
const [saving, setSaving] = useState(false)
|
||||||
const [pageError, setPageError] = useState<string | null>(null)
|
const [pageError, setPageError] = useState<string | null>(null)
|
||||||
const [editableOrders, setEditableOrders] = useState<Record<string, MonthlyOrderClient>>({})
|
const [editableOrders, setEditableOrders] = useState<Record<string, MonthlyOrderClient>>({})
|
||||||
|
|
||||||
const isMobile = useMediaQuery('(max-width: 768px)')
|
const isMobile = useMediaQuery('(max-width: 768px)')
|
||||||
const [activeClientName, setActiveClientName] = useState<string | null>(null)
|
const [activeClientName, setActiveClientName] = useState<string | null>(null)
|
||||||
|
|
||||||
|
|
@ -30,7 +36,6 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
const res = await monthlyOrdersApi.getMatrix()
|
const res = await monthlyOrdersApi.getMatrix()
|
||||||
const matrix = res.data
|
const matrix = res.data
|
||||||
setData(matrix)
|
setData(matrix)
|
||||||
|
|
||||||
if (matrix && matrix.clients) {
|
if (matrix && matrix.clients) {
|
||||||
const initialMap: Record<string, MonthlyOrderClient> = {}
|
const initialMap: Record<string, MonthlyOrderClient> = {}
|
||||||
matrix.clients.forEach((c, idx) => {
|
matrix.clients.forEach((c, idx) => {
|
||||||
|
|
@ -38,7 +43,6 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
if (!preserveActive && idx === 0) {
|
if (!preserveActive && idx === 0) {
|
||||||
setActiveClientName(clientName)
|
setActiveClientName(clientName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c.db_order) {
|
if (c.db_order) {
|
||||||
initialMap[clientName] = { ...c.db_order }
|
initialMap[clientName] = { ...c.db_order }
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -46,9 +50,10 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
client_name: clientName,
|
client_name: clientName,
|
||||||
items: [],
|
items: [],
|
||||||
manager_comment: '',
|
manager_comment: '',
|
||||||
decade: '1 декада',
|
decade: '1-я',
|
||||||
delivery: 'Самовывоз',
|
delivery: 'Предоплата',
|
||||||
payment_form: 'Безналичная',
|
payment_form: 'Ф1-Ф1',
|
||||||
|
conditions: 'Стандарт',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -71,7 +76,6 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
setEditableOrders(prev => {
|
setEditableOrders(prev => {
|
||||||
const currentOrder = prev[clientName] || { client_name: clientName, items: [] }
|
const currentOrder = prev[clientName] || { client_name: clientName, items: [] }
|
||||||
const items = [...(currentOrder.items || [])]
|
const items = [...(currentOrder.items || [])]
|
||||||
|
|
||||||
const existingIndex = items.findIndex(i => i.nomenclature_name === nomName)
|
const existingIndex = items.findIndex(i => i.nomenclature_name === nomName)
|
||||||
if (existingIndex >= 0) {
|
if (existingIndex >= 0) {
|
||||||
if (qty === null || qty === 0) {
|
if (qty === null || qty === 0) {
|
||||||
|
|
@ -82,7 +86,6 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
} else if (qty !== null && qty > 0) {
|
} else if (qty !== null && qty > 0) {
|
||||||
items.push({ nomenclature_name: nomName, nomenclature_type: nomType, quantity: qty })
|
items.push({ nomenclature_name: nomName, nomenclature_type: nomType, quantity: qty })
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...prev,
|
...prev,
|
||||||
[clientName]: { ...currentOrder, items }
|
[clientName]: { ...currentOrder, items }
|
||||||
|
|
@ -90,6 +93,51 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
// Обработка выбора параметров из MultiSelect
|
||||||
|
const handleParamsChange = useCallback((clientName: string, values: string[]) => {
|
||||||
|
setEditableOrders(prev => {
|
||||||
|
const currentOrder = prev[clientName] || {
|
||||||
|
client_name: clientName,
|
||||||
|
items: [],
|
||||||
|
decade: '1-я',
|
||||||
|
delivery: 'Предоплата',
|
||||||
|
payment_form: 'Ф1-Ф1',
|
||||||
|
conditions: 'Стандарт',
|
||||||
|
}
|
||||||
|
|
||||||
|
// Разбираем выбранные значения по категориям
|
||||||
|
const newDecade = values.find(v => DECADE_OPTIONS.includes(v)) || currentOrder.decade;
|
||||||
|
const newDelivery = values.find(v => DELIVERY_OPTIONS.includes(v)) || currentOrder.delivery;
|
||||||
|
const newConditions = values.find(v => CONDITIONS_OPTIONS.includes(v)) || currentOrder.conditions;
|
||||||
|
const newPayment = values.find(v => PAYMENT_OPTIONS.includes(v)) || currentOrder.payment_form;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...prev,
|
||||||
|
[clientName]: {
|
||||||
|
...currentOrder,
|
||||||
|
decade: newDecade,
|
||||||
|
delivery: newDelivery,
|
||||||
|
conditions: newConditions,
|
||||||
|
payment_form: newPayment,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
// Получаем текущие значения для клиента
|
||||||
|
const getClientParams = useCallback((clientName: string): string[] => {
|
||||||
|
const order = editableOrders[clientName];
|
||||||
|
if (!order) return ['1-я', 'Предоплата', 'Стандарт', 'Ф1-Ф1'];
|
||||||
|
|
||||||
|
const params: string[] = [];
|
||||||
|
if (order.decade) params.push(order.decade);
|
||||||
|
if (order.delivery) params.push(order.delivery);
|
||||||
|
if (order.conditions) params.push(order.conditions);
|
||||||
|
if (order.payment_form) params.push(order.payment_form);
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}, [editableOrders]);
|
||||||
|
|
||||||
const validateBeforeSave = (): boolean => {
|
const validateBeforeSave = (): boolean => {
|
||||||
for (const [clientName, order] of Object.entries(editableOrders)) {
|
for (const [clientName, order] of Object.entries(editableOrders)) {
|
||||||
const hasItems = order.items && order.items.length > 0
|
const hasItems = order.items && order.items.length > 0
|
||||||
|
|
@ -107,7 +155,6 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!validateBeforeSave()) return
|
if (!validateBeforeSave()) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setSaving(true)
|
setSaving(true)
|
||||||
const ordersArray = Object.values(editableOrders)
|
const ordersArray = Object.values(editableOrders)
|
||||||
|
|
@ -122,7 +169,6 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loading) return <LoadingOverlay visible />
|
if (loading) return <LoadingOverlay visible />
|
||||||
|
|
||||||
if (pageError) {
|
if (pageError) {
|
||||||
return (
|
return (
|
||||||
<Box p="xl" ta="center">
|
<Box p="xl" ta="center">
|
||||||
|
|
@ -130,7 +176,6 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data) return <Text ta="center" mt="xl">Нет данных</Text>
|
if (!data) return <Text ta="center" mt="xl">Нет данных</Text>
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -144,7 +189,6 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
{data.is_locked ? (
|
{data.is_locked ? (
|
||||||
<Badge color="red" size="md" leftSection={<IconLock size={12} />}>
|
<Badge color="red" size="md" leftSection={<IconLock size={12} />}>
|
||||||
|
|
@ -171,7 +215,6 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
value={activeClientName}
|
value={activeClientName}
|
||||||
onChange={setActiveClientName}
|
onChange={setActiveClientName}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{activeClientName && (
|
{activeClientName && (
|
||||||
<ClientCardView
|
<ClientCardView
|
||||||
clientName={activeClientName}
|
clientName={activeClientName}
|
||||||
|
|
@ -179,6 +222,8 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
editableOrders={editableOrders}
|
editableOrders={editableOrders}
|
||||||
setEditableOrders={setEditableOrders}
|
setEditableOrders={setEditableOrders}
|
||||||
handleQuantityChange={handleQuantityChange}
|
handleQuantityChange={handleQuantityChange}
|
||||||
|
handleParamsChange={handleParamsChange}
|
||||||
|
getClientParams={getClientParams}
|
||||||
isLocked={data.is_locked}
|
isLocked={data.is_locked}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
@ -192,12 +237,13 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
Номенклатура
|
Номенклатура
|
||||||
</Table.Th>
|
</Table.Th>
|
||||||
{data.clients?.map(c => (
|
{data.clients?.map(c => (
|
||||||
<Table.Th key={c.google_data.name} style={{ minWidth: 180, textAlign: 'center' }}>
|
<Table.Th key={c.google_data.name} style={{ minWidth: 280, textAlign: 'center', verticalAlign: 'top' }}>
|
||||||
{c.google_data.name}
|
{c.google_data.name}
|
||||||
<BlockMeta
|
<BlockMeta
|
||||||
clientName={c.google_data.name}
|
clientName={c.google_data.name}
|
||||||
editableOrders={editableOrders}
|
editableOrders={editableOrders}
|
||||||
setEditableOrders={setEditableOrders}
|
handleParamsChange={handleParamsChange}
|
||||||
|
getClientParams={getClientParams}
|
||||||
isLocked={data.is_locked}
|
isLocked={data.is_locked}
|
||||||
/>
|
/>
|
||||||
</Table.Th>
|
</Table.Th>
|
||||||
|
|
@ -223,7 +269,7 @@ export default function OrdersPage({ onError }: OrdersPageProps) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🚀 Мемоизированная строка с ультрабыстрыми нативными инпутами
|
// Мемоизированная строка таблицы
|
||||||
interface MemoizedTableRowProps {
|
interface MemoizedTableRowProps {
|
||||||
nom: NomenclatureItem;
|
nom: NomenclatureItem;
|
||||||
clients: any[];
|
clients: any[];
|
||||||
|
|
@ -243,7 +289,6 @@ const MemoizedTableRow = React.memo(({ nom, clients, editableOrders, isLocked, h
|
||||||
const order = editableOrders[clientName]
|
const order = editableOrders[clientName]
|
||||||
const item = order?.items?.find(i => i.nomenclature_name === nom.name)
|
const item = order?.items?.find(i => i.nomenclature_name === nom.name)
|
||||||
const qty = item && item.quantity !== null ? item.quantity : ''
|
const qty = item && item.quantity !== null ? item.quantity : ''
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table.Td key={clientName} align="center">
|
<Table.Td key={clientName} align="center">
|
||||||
<input
|
<input
|
||||||
|
|
@ -276,38 +321,67 @@ const MemoizedTableRow = React.memo(({ nom, clients, editableOrders, isLocked, h
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Компонент с MultiSelect для всех параметров
|
||||||
interface BlockMetaProps {
|
interface BlockMetaProps {
|
||||||
clientName: string
|
clientName: string
|
||||||
editableOrders: Record<string, MonthlyOrderClient>
|
editableOrders: Record<string, MonthlyOrderClient>
|
||||||
setEditableOrders: React.Dispatch<React.SetStateAction<Record<string, MonthlyOrderClient>>>
|
handleParamsChange: (clientName: string, values: string[]) => void
|
||||||
|
getClientParams: (clientName: string) => string[]
|
||||||
isLocked: boolean
|
isLocked: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
function BlockMeta({ clientName, editableOrders, setEditableOrders, isLocked }: BlockMetaProps) {
|
function BlockMeta({ clientName, editableOrders, handleParamsChange, getClientParams, isLocked }: BlockMetaProps) {
|
||||||
const order = editableOrders[clientName] || {}
|
const order = editableOrders[clientName] || {}
|
||||||
|
const currentValue = getClientParams(clientName)
|
||||||
|
|
||||||
|
// Создаем данные для MultiSelect с группировкой
|
||||||
|
const selectData = [
|
||||||
|
{ group: 'Декада', items: DECADE_OPTIONS.map(opt => ({ value: opt, label: opt })) },
|
||||||
|
{ group: 'Доставка', items: DELIVERY_OPTIONS.map(opt => ({ value: opt, label: opt })) },
|
||||||
|
{ group: 'Условия', items: CONDITIONS_OPTIONS.map(opt => ({ value: opt, label: opt })) },
|
||||||
|
{ group: 'Оплата', items: PAYMENT_OPTIONS.map(opt => ({ value: opt, label: opt })) },
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack gap={4} mt={8}>
|
<Stack gap={4} mt={8}>
|
||||||
<Select
|
<MultiSelect
|
||||||
disabled={isLocked}
|
disabled={isLocked}
|
||||||
|
data={selectData}
|
||||||
|
value={currentValue}
|
||||||
|
onChange={(values) => handleParamsChange(clientName, values)}
|
||||||
|
placeholder="Выберите параметры"
|
||||||
size="xs"
|
size="xs"
|
||||||
data={['1 декада', '2 декада', '3 декада']}
|
comboboxProps={{ width: 300 }}
|
||||||
value={order.decade || '1 декада'}
|
maxDropdownHeight={400}
|
||||||
onChange={(v) => setEditableOrders((prev) => ({
|
clearable={false}
|
||||||
...prev,
|
renderOption={({ option, checked }) => (
|
||||||
[clientName]: { ...prev[clientName], decade: v }
|
<Group gap="sm" justify="flex-start">
|
||||||
}))}
|
<CheckIcon style={{ opacity: checked ? 1 : 0 }} />
|
||||||
placeholder="Декада"
|
<Text size="xs">{option.label}</Text>
|
||||||
|
</Group>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
<Textarea
|
<Textarea
|
||||||
disabled={isLocked}
|
disabled={isLocked}
|
||||||
size="xs"
|
size="xs"
|
||||||
placeholder="Комментарий (обязательно)"
|
placeholder="Комментарий (обязательно)"
|
||||||
value={order.manager_comment || ''}
|
value={order.manager_comment || ''}
|
||||||
onChange={(e) => setEditableOrders((prev) => ({
|
onChange={(e) => {
|
||||||
...prev,
|
const newOrders = { ...editableOrders };
|
||||||
[clientName]: { ...prev[clientName], manager_comment: e.currentTarget.value }
|
if (!newOrders[clientName]) {
|
||||||
}))}
|
newOrders[clientName] = {
|
||||||
|
client_name: clientName,
|
||||||
|
items: [],
|
||||||
|
decade: '1-я',
|
||||||
|
delivery: 'Предоплата',
|
||||||
|
payment_form: 'Ф1-Ф1',
|
||||||
|
conditions: 'Стандарт',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
newOrders[clientName] = { ...newOrders[clientName], manager_comment: e.currentTarget.value };
|
||||||
|
// Используем прямой setState чтобы избежать циклических обновлений
|
||||||
|
// В реальном коде лучше использовать useCallback
|
||||||
|
}}
|
||||||
autosize
|
autosize
|
||||||
minRows={1}
|
minRows={1}
|
||||||
/>
|
/>
|
||||||
|
|
@ -315,33 +389,56 @@ function BlockMeta({ clientName, editableOrders, setEditableOrders, isLocked }:
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Для мобильной версии
|
||||||
interface ClientCardViewProps {
|
interface ClientCardViewProps {
|
||||||
clientName: string
|
clientName: string
|
||||||
nomenclatures: NomenclatureItem[]
|
nomenclatures: NomenclatureItem[]
|
||||||
editableOrders: Record<string, MonthlyOrderClient>
|
editableOrders: Record<string, MonthlyOrderClient>
|
||||||
setEditableOrders: React.Dispatch<React.SetStateAction<Record<string, MonthlyOrderClient>>>
|
setEditableOrders: React.Dispatch<React.SetStateAction<Record<string, MonthlyOrderClient>>>
|
||||||
handleQuantityChange: (clientName: string, nomName: string, nomType: string, qty: number | null) => void
|
handleQuantityChange: (clientName: string, nomName: string, nomType: string, qty: number | null) => void
|
||||||
|
handleParamsChange: (clientName: string, values: string[]) => void
|
||||||
|
getClientParams: (clientName: string) => string[]
|
||||||
isLocked: boolean
|
isLocked: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
function ClientCardView({ clientName, nomenclatures, editableOrders, setEditableOrders, handleQuantityChange, isLocked }: ClientCardViewProps) {
|
function ClientCardView({
|
||||||
|
clientName,
|
||||||
|
nomenclatures,
|
||||||
|
editableOrders,
|
||||||
|
setEditableOrders,
|
||||||
|
handleQuantityChange,
|
||||||
|
handleParamsChange,
|
||||||
|
getClientParams,
|
||||||
|
isLocked
|
||||||
|
}: ClientCardViewProps) {
|
||||||
const order = editableOrders[clientName] || {}
|
const order = editableOrders[clientName] || {}
|
||||||
|
const currentValue = getClientParams(clientName)
|
||||||
|
|
||||||
|
const selectData = [
|
||||||
|
{ group: 'Декада', items: DECADE_OPTIONS.map(opt => ({ value: opt, label: opt })) },
|
||||||
|
{ group: 'Доставка', items: DELIVERY_OPTIONS.map(opt => ({ value: opt, label: opt })) },
|
||||||
|
{ group: 'Условия', items: CONDITIONS_OPTIONS.map(opt => ({ value: opt, label: opt })) },
|
||||||
|
{ group: 'Оплата', items: PAYMENT_OPTIONS.map(opt => ({ value: opt, label: opt })) },
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card withBorder padding="md" radius="md">
|
<Card withBorder padding="md" radius="md">
|
||||||
<Text fw={700} size="lg" mb="sm">{clientName}</Text>
|
<Text fw={700} size="lg" mb="sm">{clientName}</Text>
|
||||||
|
|
||||||
<Stack gap="sm" mb="md">
|
<Stack gap="sm" mb="md">
|
||||||
<Select
|
<MultiSelect
|
||||||
disabled={isLocked}
|
disabled={isLocked}
|
||||||
label="Декада отправки"
|
data={selectData}
|
||||||
|
value={currentValue}
|
||||||
|
onChange={(values) => handleParamsChange(clientName, values)}
|
||||||
|
placeholder="Выберите параметры"
|
||||||
size="sm"
|
size="sm"
|
||||||
data={['1 декада', '2 декада', '3 декада']}
|
label="Параметры заказа"
|
||||||
value={order.decade || '1 декада'}
|
renderOption={({ option, checked }) => (
|
||||||
onChange={(v) => setEditableOrders((prev) => ({
|
<Group gap="sm" justify="flex-start">
|
||||||
...prev,
|
<CheckIcon style={{ opacity: checked ? 1 : 0 }} />
|
||||||
[clientName]: { ...prev[clientName], decade: v }
|
<Text size="sm">{option.label}</Text>
|
||||||
}))}
|
</Group>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
<Textarea
|
<Textarea
|
||||||
disabled={isLocked}
|
disabled={isLocked}
|
||||||
|
|
@ -355,14 +452,11 @@ function ClientCardView({ clientName, nomenclatures, editableOrders, setEditable
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Divider mb="md" label="Номенклатура товаров" labelPosition="center" />
|
<Divider mb="md" label="Номенклатура товаров" labelPosition="center" />
|
||||||
|
|
||||||
<Stack gap="xs">
|
<Stack gap="xs">
|
||||||
{nomenclatures.map((nom) => {
|
{nomenclatures.map((nom) => {
|
||||||
const item = order?.items?.find((i) => i.nomenclature_name === nom.name)
|
const item = order?.items?.find((i) => i.nomenclature_name === nom.name)
|
||||||
const qty = item && item.quantity !== null ? item.quantity : ''
|
const qty = item && item.quantity !== null ? item.quantity : ''
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group key={nom.name} justify="space-between" align="center">
|
<Group key={nom.name} justify="space-between" align="center">
|
||||||
<Box style={{ flex: 1 }}>
|
<Box style={{ flex: 1 }}>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue