Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/pages/price-analysis/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,17 @@ export default function PriceAnalysisPage() {
{ value: 12, label: '12 месяцев' },
]}
/>
<Button onClick={() => setManualModalOpen(true)} icon={<PlusOutlined />}>
<Button
style={{ flex: '1 1 auto' }}
onClick={() => setManualModalOpen(true)}
icon={<PlusOutlined />}
>
Добавить цену вручную
</Button>
</Flex>
{region ? (
<PriceTable
parentId={pricesQuery.data?.cteDto.cteId}
prices={priceRows}
manualPrices={manualPrices}
selectedIds={definedPrices}
Expand Down Expand Up @@ -468,6 +473,12 @@ export default function PriceAnalysisPage() {
.price-row-manual:hover > td {
background-color: #bae0ff !important;
}
.price-row-same {
background-color: #f6ffed !important;
}
.price-row-same:hover > td {
background-color: #d9f7be !important;
}
.cte-info-card .ant-card-head-wrapper {
gap: 8px;
padding-top: 8px;
Expand Down
18 changes: 16 additions & 2 deletions src/widgets/price-table/ui/price-card-list.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WarningOutlined } from '@ant-design/icons'
import { InfoCircleOutlined, WarningOutlined } from '@ant-design/icons'
import { Card, Checkbox, Empty, List, Skeleton, Tooltip, Typography } from 'antd'
import dayjs from 'dayjs'

Expand All @@ -20,6 +20,7 @@ interface TableRow {
isOutlier: boolean
reason?: string
isManual: boolean
isSame: boolean
manualIndex?: number
}

Expand All @@ -34,6 +35,7 @@ interface PriceCardListProps {
manualSelectedIndices: Set<number>
onToggleManual: (idx: number) => void
loading: boolean
parentId?: string
}

export function PriceCardList({
Expand All @@ -47,6 +49,7 @@ export function PriceCardList({
manualSelectedIndices,
onToggleManual,
loading,
parentId,
}: PriceCardListProps) {
if (loading) {
return <Skeleton active paragraph={{ rows: 4 }} />
Expand All @@ -62,6 +65,7 @@ export function PriceCardList({
isOutlier: p.isOutlier ?? false,
reason: p.reason ?? undefined,
isManual: false,
isSame: !!parentId && p.cteId === parentId,
})),
...manualPrices.map((mp, idx) => ({
key: `manual:${idx}`,
Expand All @@ -70,6 +74,7 @@ export function PriceCardList({
date: null,
source: mp.reason,
isOutlier: false,
isSame: false,
isManual: true,
manualIndex: idx,
})),
Expand Down Expand Up @@ -103,7 +108,9 @@ export function PriceCardList({
? '3px solid #DB2B21'
: row.isManual
? '3px solid #1677ff'
: undefined,
: row.isSame
? '3px solid #52c41a'
: undefined,
}}
>
<div style={{ display: 'flex', alignItems: 'flex-start', gap: 12 }}>
Expand All @@ -128,6 +135,13 @@ export function PriceCardList({
<WarningOutlined style={{ color: '#faad14', fontSize: 14, flexShrink: 0 }} />
</Tooltip>
)}
{row.isSame && !row.isOutlier && (
<Tooltip title="Полностью соответствует выбранной СТЕ">
<InfoCircleOutlined
style={{ color: '#52c41a', fontSize: 14, flexShrink: 0 }}
/>
</Tooltip>
)}
</div>
<Typography.Text strong style={{ fontSize: 16 }}>
{formatPrice(row.price)}
Expand Down
16 changes: 14 additions & 2 deletions src/widgets/price-table/ui/price-table.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WarningOutlined } from '@ant-design/icons'
import { InfoCircleOutlined, WarningOutlined } from '@ant-design/icons'
import { Checkbox, Table, Tooltip } from 'antd'
import type { ColumnsType } from 'antd/es/table'
import dayjs from 'dayjs'
Expand Down Expand Up @@ -27,6 +27,7 @@ interface TableRow {
isOutlier: boolean
reason?: string
isManual: boolean
isSame: boolean
manualIndex?: number
}

Expand All @@ -39,6 +40,7 @@ interface PriceTableProps {
manualSelectedIndices: Set<number>
onToggleManual: (idx: number) => void
loading: boolean
parentId?: string
}

export function PriceTable({
Expand All @@ -50,6 +52,7 @@ export function PriceTable({
manualSelectedIndices,
onToggleManual,
loading,
parentId,
}: PriceTableProps) {
const isMobile = useIsMobile()

Expand All @@ -63,6 +66,7 @@ export function PriceTable({
isOutlier: p.isOutlier ?? false,
reason: p.reason ?? undefined,
isManual: false,
isSame: !!parentId && p.cteId === parentId,
}))

const manualRows: TableRow[] = manualPrices.map((mp, idx) => ({
Expand All @@ -72,12 +76,13 @@ export function PriceTable({
date: null,
source: mp.reason,
isOutlier: false,
isSame: false,
isManual: true,
manualIndex: idx,
}))

return [...apiRows, ...manualRows]
}, [prices, manualPrices])
}, [prices, manualPrices, parentId])

const totalCount = prices.length + manualPrices.length
const selectedCount = selectedIds.size + manualSelectedIndices.size
Expand All @@ -97,6 +102,7 @@ export function PriceTable({
manualSelectedIndices={manualSelectedIndices}
onToggleManual={onToggleManual}
loading={loading}
parentId={parentId}
/>
)
}
Expand Down Expand Up @@ -138,6 +144,11 @@ export function PriceTable({
<WarningOutlined style={{ color: '#faad14', fontSize: 14 }} />
</Tooltip>
)}
{record.isSame && !record.isOutlier && (
<Tooltip title="Полностью соответствует выбранной СТЕ">
<InfoCircleOutlined style={{ color: '#52c41a', fontSize: 14 }} />
</Tooltip>
)}
</span>
),
},
Expand Down Expand Up @@ -177,6 +188,7 @@ export function PriceTable({
rowClassName={(record) => {
if (record.isOutlier && !record.isManual) return 'price-row-outlier'
if (record.isManual) return 'price-row-manual'
if (record.isSame) return 'price-row-same'
return ''
}}
style={{ marginTop: 16 }}
Expand Down
Loading