Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f1385c301 | |||
| 1797168047 | |||
| 842b9ad678 | |||
| 2591d94414 | |||
| 2eaa75e876 | |||
| eaef011b73 | |||
| 99c720f26c |
@@ -1 +1 @@
|
|||||||
@tnsu:registry=http://git.tnsu.kz/api/packages/timur.gorodetskiy/npm/
|
@tnsu:registry=https://git.tnsu.kz/api/packages/tansu/npm/
|
||||||
|
|||||||
@@ -13,6 +13,10 @@
|
|||||||
и оставляет на шаге, чтобы правки не пропали при закрытии вкладки. (#8)
|
и оставляет на шаге, чтобы правки не пропали при закрытии вкладки. (#8)
|
||||||
- СТ ОМТС, Шаг 3: незаполненное подсвечивается сразу. Красная рамка — то, без чего дальше не
|
- СТ ОМТС, Шаг 3: незаполненное подсвечивается сразу. Красная рамка — то, без чего дальше не
|
||||||
пустит (победитель, километраж, условия оплаты); бледная заливка — пустая цена. (#9)
|
пустит (победитель, километраж, условия оплаты); бледная заливка — пустая цена. (#9)
|
||||||
|
- СТ ОМТС, Шаг 3: у логистики и доп. расходов можно вписать свою единицу измерения — у логистики
|
||||||
|
вместо «рейс» может быть «тонна», «машина» и т.п. (#11)
|
||||||
|
- СТ ОМТС, Шаг 3: добавить потенциального поставщика проще найти — блок над таблицей с заголовком
|
||||||
|
и активной кнопкой, и кнопка «+ Добавить поставщика» прямо в шапке таблицы. (#12)
|
||||||
|
|
||||||
### Изменено
|
### Изменено
|
||||||
|
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ Info "Подключаем @tnsu/ui-kit..."
|
|||||||
# .npmrc: адрес registry для скоупа @tnsu (НЕ секрет, можно коммитить).
|
# .npmrc: адрес registry для скоупа @tnsu (НЕ секрет, можно коммитить).
|
||||||
# Токен на чтение — у каждого разработчика свой, в ~/.npmrc (в проект не кладём).
|
# Токен на чтение — у каждого разработчика свой, в ~/.npmrc (в проект не кладём).
|
||||||
$npmrc = @'
|
$npmrc = @'
|
||||||
@tnsu:registry=http://git.tnsu.kz/api/packages/timur.gorodetskiy/npm/
|
@tnsu:registry=https://git.tnsu.kz/api/packages/tansu/npm/
|
||||||
'@
|
'@
|
||||||
$npmrc | Set-Content -Encoding UTF8 ".npmrc"
|
$npmrc | Set-Content -Encoding UTF8 ".npmrc"
|
||||||
Success ".npmrc создан (адрес registry @tnsu)."
|
Success ".npmrc создан (адрес registry @tnsu)."
|
||||||
@@ -282,7 +282,7 @@ try {
|
|||||||
} catch {
|
} catch {
|
||||||
Warn "Не удалось поставить @tnsu/ui-kit. Скорее всего нет токена @tnsu в ~/.npmrc."
|
Warn "Не удалось поставить @tnsu/ui-kit. Скорее всего нет токена @tnsu в ~/.npmrc."
|
||||||
Warn "Создай токен (Gitea → Настройки → Приложения → package: Read) и пропиши в ~/.npmrc:"
|
Warn "Создай токен (Gitea → Настройки → Приложения → package: Read) и пропиши в ~/.npmrc:"
|
||||||
Warn " //git.tnsu.kz/api/packages/timur.gorodetskiy/npm/:_authToken=ТВОЙ_ТОКЕН"
|
Warn " //git.tnsu.kz/api/packages/tansu/npm/:_authToken=ТВОЙ_ТОКЕН"
|
||||||
Warn "Потом выполни: npm install @tnsu/ui-kit"
|
Warn "Потом выполни: npm install @tnsu/ui-kit"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Generated
+4
-4
@@ -15,7 +15,7 @@
|
|||||||
"@microsoft/sp-office-ui-fabric-core": "1.22.1",
|
"@microsoft/sp-office-ui-fabric-core": "1.22.1",
|
||||||
"@microsoft/sp-property-pane": "1.22.1",
|
"@microsoft/sp-property-pane": "1.22.1",
|
||||||
"@microsoft/sp-webpart-base": "1.22.1",
|
"@microsoft/sp-webpart-base": "1.22.1",
|
||||||
"@tnsu/ui-kit": "^0.11.0",
|
"@tnsu/ui-kit": "^0.14.0",
|
||||||
"ncalayer-js-client": "^1.6.0",
|
"ncalayer-js-client": "^1.6.0",
|
||||||
"react": "17.0.1",
|
"react": "17.0.1",
|
||||||
"react-dom": "17.0.1",
|
"react-dom": "17.0.1",
|
||||||
@@ -6269,9 +6269,9 @@
|
|||||||
"license": "0BSD"
|
"license": "0BSD"
|
||||||
},
|
},
|
||||||
"node_modules/@tnsu/ui-kit": {
|
"node_modules/@tnsu/ui-kit": {
|
||||||
"version": "0.11.0",
|
"version": "0.14.0",
|
||||||
"resolved": "http://git.tnsu.kz/api/packages/timur.gorodetskiy/npm/%40tnsu%2Fui-kit/-/0.11.0/ui-kit-0.11.0.tgz",
|
"resolved": "https://git.tnsu.kz/api/packages/tansu/npm/%40tnsu%2Fui-kit/-/0.14.0/ui-kit-0.14.0.tgz",
|
||||||
"integrity": "sha512-Yv4hUmCsDNvGMj32ygNhBZiurhe5lU0IHvWSZMkG15h+xmCBmsTzgrItmKenKkKiOM2R4cjOo4D2W8SsTNHleQ==",
|
"integrity": "sha512-Vun9AUM9jL8rttbsbKo5Yh6TUz1srkNqxiO6mmzebrSo1JOASNJqNjJPMTS+8Jt3MTrJPklvh0TbeqGQzw7qxQ==",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@fluentui/react": "^8.106.4",
|
"@fluentui/react": "^8.106.4",
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@
|
|||||||
"@microsoft/sp-office-ui-fabric-core": "1.22.1",
|
"@microsoft/sp-office-ui-fabric-core": "1.22.1",
|
||||||
"@microsoft/sp-property-pane": "1.22.1",
|
"@microsoft/sp-property-pane": "1.22.1",
|
||||||
"@microsoft/sp-webpart-base": "1.22.1",
|
"@microsoft/sp-webpart-base": "1.22.1",
|
||||||
"@tnsu/ui-kit": "^0.11.0",
|
"@tnsu/ui-kit": "^0.14.0",
|
||||||
"ncalayer-js-client": "^1.6.0",
|
"ncalayer-js-client": "^1.6.0",
|
||||||
"react": "17.0.1",
|
"react": "17.0.1",
|
||||||
"react-dom": "17.0.1",
|
"react-dom": "17.0.1",
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ export function AddExtraRow({ matrix, isRestrictedView, colSpan }: Props): JSX.E
|
|||||||
{suppliersWithOffer.map(s => (
|
{suppliersWithOffer.map(s => (
|
||||||
<td key={s.id} colSpan={getSubCols(supplierCurrencies[s.id] ?? 'KZT', isRestrictedView)} />
|
<td key={s.id} colSpan={getSubCols(supplierCurrencies[s.id] ?? 'KZT', isRestrictedView)} />
|
||||||
))}
|
))}
|
||||||
|
{/* Под колонкой «+ Добавить поставщика» (видна там же, где эта строка, — не в режиме просмотра). */}
|
||||||
|
<td className={styles.addSupplierFillerCell} />
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { Button, Dialog, Icon, TextInput } from '@tnsu/ui-kit';
|
||||||
|
import styles from './Step3ComparisonTable.module.scss';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
currencyOptions: string[];
|
||||||
|
onAddManual: (name: string, currency: string) => void;
|
||||||
|
onOpenDatabase: () => void;
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DEFAULT_CURRENCY = 'KZT';
|
||||||
|
|
||||||
|
// Окно кнопки «+ Добавить поставщика» в шапке таблицы: вручную (название и валюта) или из базы
|
||||||
|
// поставщиков. Добавление — те же функции, что у блока над таблицей.
|
||||||
|
export const AddSupplierDialog: React.FC<Props> = ({ currencyOptions, onAddManual, onOpenDatabase, onClose }) => {
|
||||||
|
const [name, setName] = useState('');
|
||||||
|
const [currency, setCurrency] = useState(DEFAULT_CURRENCY);
|
||||||
|
const canAdd = name.trim().length > 0;
|
||||||
|
|
||||||
|
const handleAdd = (): void => {
|
||||||
|
if (!canAdd) return;
|
||||||
|
onAddManual(name, currency);
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open
|
||||||
|
title="Добавить потенциального поставщика"
|
||||||
|
subText="Поставщик, у которого нет загруженного КП: цены вносятся в таблицу вручную."
|
||||||
|
onDismiss={onClose}
|
||||||
|
footer={<Button variant="secondary" onClick={onClose}>Отмена</Button>}
|
||||||
|
>
|
||||||
|
<div className={styles.addSupplierDialogBody}>
|
||||||
|
<div className={styles.addSupplierRow}>
|
||||||
|
<div className={styles.addInput}>
|
||||||
|
<TextInput
|
||||||
|
value={name}
|
||||||
|
onChange={setName}
|
||||||
|
placeholder="Наименование поставщика"
|
||||||
|
ariaLabel="Наименование поставщика"
|
||||||
|
autoFocus
|
||||||
|
onKeyDown={e => { if (e.key === 'Enter') handleAdd(); }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<select
|
||||||
|
className={styles.currencySelect}
|
||||||
|
value={currency}
|
||||||
|
onChange={e => setCurrency(e.target.value)}
|
||||||
|
aria-label="Валюта поставщика"
|
||||||
|
>
|
||||||
|
{currencyOptions.map(c => <option key={c} value={c}>{c}</option>)}
|
||||||
|
</select>
|
||||||
|
<Button variant="accent" onClick={handleAdd} disabled={!canAdd}>
|
||||||
|
<Icon name="plus" size="sm" />
|
||||||
|
Добавить
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className={styles.addSupplierDivider}>или</div>
|
||||||
|
<Button variant="secondary" onClick={() => { onClose(); onOpenDatabase(); }}>
|
||||||
|
<Icon name="building" size="sm" />
|
||||||
|
Выбрать из базы поставщиков
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
};
|
||||||
+82
@@ -0,0 +1,82 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { Button, Icon, TextInput } from '@tnsu/ui-kit';
|
||||||
|
import styles from './Step3ComparisonTable.module.scss';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
name: string;
|
||||||
|
currency: string;
|
||||||
|
currencyOptions: string[];
|
||||||
|
onNameChange: (value: string) => void;
|
||||||
|
onCurrencyChange: (value: string) => void;
|
||||||
|
onAdd: () => void;
|
||||||
|
onOpenDatabase: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NAME_INPUT_ID = 'step3-new-supplier-name';
|
||||||
|
|
||||||
|
// Блок «Потенциальные поставщики» над таблицей. Раньше это были поле, выпадашка и серая кнопка без
|
||||||
|
// подписи — их не замечали: заблокированная кнопка читалась как «не работает». Теперь у блока есть
|
||||||
|
// заголовок, кнопка не блокируется: с пустым названием подсказывает, что ввести.
|
||||||
|
export const AddSupplierToolbar: React.FC<Props> = ({
|
||||||
|
name, currency, currencyOptions, onNameChange, onCurrencyChange, onAdd, onOpenDatabase,
|
||||||
|
}) => {
|
||||||
|
const [isNameMissing, setIsNameMissing] = useState(false);
|
||||||
|
|
||||||
|
const handleAdd = (): void => {
|
||||||
|
if (!name.trim()) {
|
||||||
|
setIsNameMissing(true);
|
||||||
|
// Поле — в ui-kit, ref он не отдаёт; id задаём сами.
|
||||||
|
document.getElementById(NAME_INPUT_ID)?.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setIsNameMissing(false);
|
||||||
|
onAdd();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleNameChange = (value: string): void => {
|
||||||
|
if (value.trim()) setIsNameMissing(false);
|
||||||
|
onNameChange(value);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className={styles.addSupplierBlock}>
|
||||||
|
<div className={styles.addSupplierHeading}>
|
||||||
|
<h4 className={styles.addSupplierTitle}>Потенциальные поставщики</h4>
|
||||||
|
<span className={styles.addSupplierHint}>
|
||||||
|
Добавьте поставщика, у которого нет загруженного КП, — вручную или из базы поставщиков
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.addSupplierRow}>
|
||||||
|
<div className={styles.addInput}>
|
||||||
|
<TextInput
|
||||||
|
id={NAME_INPUT_ID}
|
||||||
|
placeholder="Наименование поставщика"
|
||||||
|
value={name}
|
||||||
|
onChange={handleNameChange}
|
||||||
|
ariaLabel="Наименование нового потенциального поставщика"
|
||||||
|
onKeyDown={e => { if (e.key === 'Enter') handleAdd(); }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<select
|
||||||
|
className={styles.currencySelect}
|
||||||
|
value={currency}
|
||||||
|
onChange={e => onCurrencyChange(e.target.value)}
|
||||||
|
aria-label="Валюта нового потенциального поставщика"
|
||||||
|
>
|
||||||
|
{currencyOptions.map(c => <option key={c} value={c}>{c}</option>)}
|
||||||
|
</select>
|
||||||
|
<Button variant="accent" onClick={handleAdd}>
|
||||||
|
<Icon name="plus" size="sm" />
|
||||||
|
Добавить
|
||||||
|
</Button>
|
||||||
|
<span className={styles.addSupplierOr}>или</span>
|
||||||
|
<Button variant="secondary" onClick={onOpenDatabase}>
|
||||||
|
<Icon name="building" size="sm" />
|
||||||
|
Из базы поставщиков
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
{isNameMissing && <span className={styles.addSupplierError}>Введите наименование поставщика</span>}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
};
|
||||||
+19
-2
@@ -19,12 +19,14 @@ interface Props {
|
|||||||
isRestrictedView: boolean;
|
isRestrictedView: boolean;
|
||||||
adata: UseAdataCheckResult;
|
adata: UseAdataCheckResult;
|
||||||
recommendedId?: string; // победитель формулы 80% цена / 20% условия оплаты (useRecommendedPick)
|
recommendedId?: string; // победитель формулы 80% цена / 20% условия оплаты (useRecommendedPick)
|
||||||
|
// Кнопка «+ Добавить поставщика» в последней колонке шапки.
|
||||||
|
onAddSupplierClick: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Таблица сравнения целиком: шапка (фикс-колонки + заголовки поставщиков) + строки позиций
|
// Таблица сравнения целиком: шапка (фикс-колонки + заголовки поставщиков) + строки позиций
|
||||||
// (MatrixRowView/ExtraPositionRow) + итоговые строки + строка добавления (AddExtraRow).
|
// (MatrixRowView/ExtraPositionRow) + итоговые строки + строка добавления (AddExtraRow).
|
||||||
// Перенесено 1:1 из Step3ComparisonTable (§стайл-гайд: чистая вёрстка, логика — в useStep3Matrix).
|
// Перенесено 1:1 из Step3ComparisonTable (§стайл-гайд: чистая вёрстка, логика — в useStep3Matrix).
|
||||||
export function ComparisonMatrix({ matrix, currencyRates, isRestrictedView, adata, recommendedId }: Props): JSX.Element {
|
export function ComparisonMatrix({ matrix, currencyRates, isRestrictedView, adata, recommendedId, onAddSupplierClick }: Props): JSX.Element {
|
||||||
const {
|
const {
|
||||||
isReadOnly, suppliersWithOffer, supplierCurrencies, selectedSupplierId,
|
isReadOnly, suppliersWithOffer, supplierCurrencies, selectedSupplierId,
|
||||||
supplierStatuses, nameColWidth, regularPositions, extraPositionsRows, allPositions, computedOffers,
|
supplierStatuses, nameColWidth, regularPositions, extraPositionsRows, allPositions, computedOffers,
|
||||||
@@ -37,7 +39,12 @@ export function ComparisonMatrix({ matrix, currencyRates, isRestrictedView, adat
|
|||||||
// Как в проверке перед сохранением (getStep3SaveError): выбор на исключённом — не победитель.
|
// Как в проверке перед сохранением (getStep3SaveError): выбор на исключённом — не победитель.
|
||||||
const hasWinner = suppliersWithOffer.some(s => s.id === selectedSupplierId);
|
const hasWinner = suppliersWithOffer.some(s => s.id === selectedSupplierId);
|
||||||
|
|
||||||
const totalColSpan = FIXED_COLS + suppliersWithOffer.reduce((sum, s) => sum + getSubCols(supplierCurrencies[s.id] ?? 'KZT', isRestrictedView), 0);
|
// Последняя колонка «+ Добавить поставщика» — там, где ищут, как добавить колонку. Во всех строках
|
||||||
|
// под ней пустая ячейка (addSupplierFillerCell), иначе строки таблицы были бы разной длины.
|
||||||
|
const showAddColumn = !isReadOnly;
|
||||||
|
const totalColSpan = FIXED_COLS
|
||||||
|
+ suppliersWithOffer.reduce((sum, s) => sum + getSubCols(supplierCurrencies[s.id] ?? 'KZT', isRestrictedView), 0)
|
||||||
|
+ (showAddColumn ? 1 : 0);
|
||||||
|
|
||||||
// Высота row1 (шапка поставщика) переменная (теги валют, выбор поставщика, состояние Adata),
|
// Высота row1 (шапка поставщика) переменная (теги валют, выбор поставщика, состояние Adata),
|
||||||
// а row2 прибит sticky сразу под ней. Измеряем реальную высоту и отдаём в CSS-переменную,
|
// а row2 прибит sticky сразу под ней. Измеряем реальную высоту и отдаём в CSS-переменную,
|
||||||
@@ -142,6 +149,13 @@ export function ComparisonMatrix({ matrix, currencyRates, isRestrictedView, adat
|
|||||||
</th>
|
</th>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
{showAddColumn && (
|
||||||
|
<th rowSpan={2} className={styles.addSupplierHeaderCell}>
|
||||||
|
<button className={styles.addSupplierHeaderBtn} onClick={onAddSupplierClick} title="Добавить потенциального поставщика">
|
||||||
|
+ Добавить поставщика
|
||||||
|
</button>
|
||||||
|
</th>
|
||||||
|
)}
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{/* Row 2: sub-headers — 4 cols for KZT, 6 cols for foreign currency */}
|
{/* Row 2: sub-headers — 4 cols for KZT, 6 cols for foreign currency */}
|
||||||
@@ -206,6 +220,7 @@ export function ComparisonMatrix({ matrix, currencyRates, isRestrictedView, adat
|
|||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
{showAddColumn && <td className={styles.addSupplierFillerCell} />}
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{/* Доп. расходы positions — single row each (no bundle support needed) */}
|
{/* Доп. расходы positions — single row each (no bundle support needed) */}
|
||||||
@@ -242,6 +257,7 @@ export function ComparisonMatrix({ matrix, currencyRates, isRestrictedView, adat
|
|||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
{showAddColumn && <td className={styles.addSupplierFillerCell} />}
|
||||||
</tr>
|
</tr>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -265,6 +281,7 @@ export function ComparisonMatrix({ matrix, currencyRates, isRestrictedView, adat
|
|||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
{showAddColumn && <td className={styles.addSupplierFillerCell} />}
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{/* Inline add-position row */}
|
{/* Inline add-position row */}
|
||||||
|
|||||||
+21
-4
@@ -25,7 +25,7 @@ export function ExtraPositionRow({ pos, posIndex, regularPositionsCount, matrix,
|
|||||||
isReadOnly, edits, extraPositions, translateUnits, rawValues, deliveryKm, selectedSupplierId, nameColWidth,
|
isReadOnly, edits, extraPositions, translateUnits, rawValues, deliveryKm, selectedSupplierId, nameColWidth,
|
||||||
suppliersWithOffer, supplierCurrencies, computedOffers, minTotalByPosition,
|
suppliersWithOffer, supplierCurrencies, computedOffers, minTotalByPosition,
|
||||||
updateSupplierProductName, updateUnit, updateEdit, updatePriceKzt, handleDeliveryKmChange,
|
updateSupplierProductName, updateUnit, updateEdit, updatePriceKzt, handleDeliveryKmChange,
|
||||||
handleDeleteExtraPosition,
|
handleDeleteExtraPosition, handleExtraPositionUnitChange,
|
||||||
} = matrix;
|
} = matrix;
|
||||||
|
|
||||||
const ep = extraPositions.find(e => e.id === pos.id);
|
const ep = extraPositions.find(e => e.id === pos.id);
|
||||||
@@ -47,7 +47,22 @@ export function ExtraPositionRow({ pos, posIndex, regularPositionsCount, matrix,
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td className={styles.unitCell}>{pos.unit}</td>
|
{/* Единица строки — своя (у логистики по умолчанию «рейс»: бывает «тонна», «машина», «услуга»). */}
|
||||||
|
<td className={styles.unitCell}>
|
||||||
|
{!isReadOnly ? (
|
||||||
|
<div className={styles.offerInput}>
|
||||||
|
<TextInput
|
||||||
|
value={pos.unit}
|
||||||
|
onChange={val => handleExtraPositionUnitChange(pos.id, val)}
|
||||||
|
placeholder="ед. изм."
|
||||||
|
borderless
|
||||||
|
ariaLabel={`Ед. изм. строки ${pos.materialName}`}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
pos.unit
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
<td className={styles.qtyCell}>—</td>
|
<td className={styles.qtyCell}>—</td>
|
||||||
{suppliersWithOffer.map(s => {
|
{suppliersWithOffer.map(s => {
|
||||||
const key = key0(s);
|
const key = key0(s);
|
||||||
@@ -120,9 +135,9 @@ export function ExtraPositionRow({ pos, posIndex, regularPositionsCount, matrix,
|
|||||||
<TextInput
|
<TextInput
|
||||||
value={rawValues[`${s.id}::${pos.id}::0::quantity`] ?? (qty !== undefined ? String(qty) : '')}
|
value={rawValues[`${s.id}::${pos.id}::0::quantity`] ?? (qty !== undefined ? String(qty) : '')}
|
||||||
onChange={val => updateEdit(s.id, pos.id, 0, 'quantity', val)}
|
onChange={val => updateEdit(s.id, pos.id, 0, 'quantity', val)}
|
||||||
placeholder="рейсы"
|
placeholder={pos.unit || 'кол-во'}
|
||||||
borderless
|
borderless
|
||||||
ariaLabel={`Кол-во рейсов ${s.name} ${pos.materialName}`}
|
ariaLabel={`Кол-во (${pos.unit || 'ед.'}) ${s.name} ${pos.materialName}`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@@ -219,6 +234,8 @@ export function ExtraPositionRow({ pos, posIndex, regularPositionsCount, matrix,
|
|||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
{/* Под колонкой «+ Добавить поставщика». */}
|
||||||
|
{!isReadOnly && <td className={styles.addSupplierFillerCell} />}
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,6 +218,8 @@ export function MatrixRowView({ pos, posIndex, matrix, currencyRates, isRestrict
|
|||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
{/* Под колонкой «+ Добавить поставщика»: одна ячейка на позицию, включая строки комплекта. */}
|
||||||
|
{rowIdx === 0 && !isReadOnly && <td className={styles.addSupplierFillerCell} rowSpan={posRowSpan} />}
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+91
-14
@@ -866,20 +866,6 @@ $delivery-km-min-width: 76px;
|
|||||||
color: $text;
|
color: $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
.supplierToolbar {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
padding: 4px 0 8px;
|
|
||||||
max-width: 30%;
|
|
||||||
|
|
||||||
> :first-child {
|
|
||||||
flex: 1 1 0;
|
|
||||||
min-width: 160px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.addRow {
|
.addRow {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
@@ -1369,3 +1355,94 @@ $delivery-km-min-width: 76px;
|
|||||||
border-color: $danger;
|
border-color: $danger;
|
||||||
color: $danger;
|
color: $danger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── Добавление потенциального поставщика ───────────────────────────────────
|
||||||
|
// Блок над таблицей (AddSupplierToolbar): раньше без заголовка и с серой кнопкой — его не замечали.
|
||||||
|
|
||||||
|
.addSupplierBlock {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 12px 16px;
|
||||||
|
border: 1px solid $accent-border;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: $accent-bg;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addSupplierHeading {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 4px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addSupplierTitle {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: $accent-dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addSupplierHint {
|
||||||
|
font-size: 12px;
|
||||||
|
color: $muted;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addSupplierRow {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addSupplierOr {
|
||||||
|
font-size: 12px;
|
||||||
|
color: $muted;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addSupplierError {
|
||||||
|
font-size: 12px;
|
||||||
|
color: $danger;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addSupplierDialogBody {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 12px;
|
||||||
|
|
||||||
|
> .addSupplierRow { align-self: stretch; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.addSupplierDivider {
|
||||||
|
font-size: 12px;
|
||||||
|
color: $muted;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Последняя колонка таблицы «+ Добавить поставщика» — там, где ищут, как добавить колонку.
|
||||||
|
.addSupplierHeaderCell {
|
||||||
|
min-width: 140px;
|
||||||
|
vertical-align: middle;
|
||||||
|
text-align: center;
|
||||||
|
background: $head-bg;
|
||||||
|
border-left: 2px dashed $accent-border !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addSupplierHeaderBtn {
|
||||||
|
padding: 8px 12px;
|
||||||
|
border: 1px dashed $accent;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: $surface;
|
||||||
|
color: $accent;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
white-space: nowrap;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:hover { background: $accent-bg; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.addSupplierFillerCell {
|
||||||
|
border-left: 2px dashed $accent-border !important;
|
||||||
|
}
|
||||||
|
|||||||
+33
-31
@@ -1,6 +1,6 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import { Button, Alert, TextInput, Toggle, Spinner, Dialog, Icon } from '@tnsu/ui-kit';
|
import { Button, Alert, Toggle, Spinner, Dialog, Icon } from '@tnsu/ui-kit';
|
||||||
import { FormStep } from '../types/domain';
|
import { FormStep } from '../types/domain';
|
||||||
import { CtService } from '../../services/CtService';
|
import { CtService } from '../../services/CtService';
|
||||||
import { VendorDatabaseService, IVendorRecord } from '../../services/VendorDatabaseService';
|
import { VendorDatabaseService, IVendorRecord } from '../../services/VendorDatabaseService';
|
||||||
@@ -19,6 +19,8 @@ import { useAdataCheck } from './useAdataCheck';
|
|||||||
import { useRecommendedPick } from './useRecommendedPick';
|
import { useRecommendedPick } from './useRecommendedPick';
|
||||||
import { VendorPickerDialog } from './VendorPickerDialog';
|
import { VendorPickerDialog } from './VendorPickerDialog';
|
||||||
import { ExcludedSuppliersList } from './ExcludedSuppliersList';
|
import { ExcludedSuppliersList } from './ExcludedSuppliersList';
|
||||||
|
import { AddSupplierToolbar } from './AddSupplierToolbar';
|
||||||
|
import { AddSupplierDialog } from './AddSupplierDialog';
|
||||||
import { SaveDraftButton } from '../SaveDraftButton/SaveDraftButton';
|
import { SaveDraftButton } from '../SaveDraftButton/SaveDraftButton';
|
||||||
import { withoutPlaceholders } from '../utils/placeholderKpFile';
|
import { withoutPlaceholders } from '../utils/placeholderKpFile';
|
||||||
|
|
||||||
@@ -58,7 +60,7 @@ export const Step3ComparisonTable: React.FC<Props> = ({
|
|||||||
const matrix = useStep3Matrix({ service, formData, isReadOnly: !canEdit, onSave, onNext, onStepComplete });
|
const matrix = useStep3Matrix({ service, formData, isReadOnly: !canEdit, onSave, onNext, onStepComplete });
|
||||||
const {
|
const {
|
||||||
isReadOnly, newSupplierName, newSupplierCurrency, setNewSupplierName, setNewSupplierCurrency,
|
isReadOnly, newSupplierName, newSupplierCurrency, setNewSupplierName, setNewSupplierCurrency,
|
||||||
handleAddSupplier, handleAddSupplierFromDatabase, translateUnits, setTranslateUnits, isSaving, saveError, setSaveError,
|
addManualSupplier, handleAddSupplier, handleAddSupplierFromDatabase, translateUnits, setTranslateUnits, isSaving, saveError, setSaveError,
|
||||||
validateBeforeSave, handleSave, draftSavedAt,
|
validateBeforeSave, handleSave, draftSavedAt,
|
||||||
extraPositions, suppliersWithOffer, columnDisplayNames, allPositions, computedOffers, selectedSupplierId,
|
extraPositions, suppliersWithOffer, columnDisplayNames, allPositions, computedOffers, selectedSupplierId,
|
||||||
excludedColumns, handleRestoreSupplier,
|
excludedColumns, handleRestoreSupplier,
|
||||||
@@ -70,6 +72,8 @@ export const Step3ComparisonTable: React.FC<Props> = ({
|
|||||||
|
|
||||||
// Модалка выбора поставщика из «База данных поставщиков» (см. VendorPickerDialog).
|
// Модалка выбора поставщика из «База данных поставщиков» (см. VendorPickerDialog).
|
||||||
const [showVendorPicker, setShowVendorPicker] = useState(false);
|
const [showVendorPicker, setShowVendorPicker] = useState(false);
|
||||||
|
// Окно кнопки «+ Добавить поставщика» в шапке таблицы.
|
||||||
|
const [showAddSupplierDialog, setShowAddSupplierDialog] = useState(false);
|
||||||
const vendorDbService = useMemo(() => new VendorDatabaseService(service.webPartContext), [service]);
|
const vendorDbService = useMemo(() => new VendorDatabaseService(service.webPartContext), [service]);
|
||||||
const handleAddVendorFromDatabase = (vendor: IVendorRecord): void => {
|
const handleAddVendorFromDatabase = (vendor: IVendorRecord): void => {
|
||||||
const id = handleAddSupplierFromDatabase(vendor);
|
const id = handleAddSupplierFromDatabase(vendor);
|
||||||
@@ -117,35 +121,17 @@ export const Step3ComparisonTable: React.FC<Props> = ({
|
|||||||
return (
|
return (
|
||||||
<div className={styles.root}>
|
<div className={styles.root}>
|
||||||
|
|
||||||
{/* Toolbar: add supplier — always visible above the table */}
|
{/* Добавление потенциального поставщика: блок над таблицей + кнопка в шапке таблицы. */}
|
||||||
{!isReadOnly && (
|
{!isReadOnly && (
|
||||||
<div className={styles.supplierToolbar}>
|
<AddSupplierToolbar
|
||||||
<div className={styles.addInput}>
|
name={newSupplierName}
|
||||||
<TextInput
|
currency={newSupplierCurrency}
|
||||||
placeholder="Наименование потенциального поставщика"
|
currencyOptions={currencyOptions}
|
||||||
value={newSupplierName}
|
onNameChange={setNewSupplierName}
|
||||||
onChange={setNewSupplierName}
|
onCurrencyChange={setNewSupplierCurrency}
|
||||||
ariaLabel="Наименование нового потенциального поставщика"
|
onAdd={handleAddSupplier}
|
||||||
onKeyDown={e => { if (e.key === 'Enter') handleAddSupplier(); }}
|
onOpenDatabase={() => setShowVendorPicker(true)}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
<select
|
|
||||||
className={styles.currencySelect}
|
|
||||||
value={newSupplierCurrency}
|
|
||||||
onChange={e => setNewSupplierCurrency(e.target.value)}
|
|
||||||
aria-label="Валюта нового потенциального поставщика"
|
|
||||||
>
|
|
||||||
{currencyOptions.map(c => <option key={c} value={c}>{c}</option>)}
|
|
||||||
</select>
|
|
||||||
<Button variant="secondary" onClick={handleAddSupplier} disabled={!newSupplierName.trim()}>
|
|
||||||
<Icon name="plus" size="sm" />
|
|
||||||
Добавить потенциального поставщика
|
|
||||||
</Button>
|
|
||||||
<Button variant="secondary" onClick={() => setShowVendorPicker(true)}>
|
|
||||||
<Icon name="building" size="sm" />
|
|
||||||
Добавить из базы поставщиков
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Тумблер пересчёта единиц измерения поставщика в ед. изм. заявки */}
|
{/* Тумблер пересчёта единиц измерения поставщика в ед. изм. заявки */}
|
||||||
@@ -185,7 +171,14 @@ export const Step3ComparisonTable: React.FC<Props> = ({
|
|||||||
|
|
||||||
{recPick.pickError && <Alert variant="err">{recPick.pickError}</Alert>}
|
{recPick.pickError && <Alert variant="err">{recPick.pickError}</Alert>}
|
||||||
|
|
||||||
<ComparisonMatrix matrix={matrix} currencyRates={currencyRates} isRestrictedView={isRestrictedView} adata={adata} recommendedId={recPick.recommendedId} />
|
<ComparisonMatrix
|
||||||
|
matrix={matrix}
|
||||||
|
currencyRates={currencyRates}
|
||||||
|
isRestrictedView={isRestrictedView}
|
||||||
|
adata={adata}
|
||||||
|
recommendedId={recPick.recommendedId}
|
||||||
|
onAddSupplierClick={() => setShowAddSupplierDialog(true)}
|
||||||
|
/>
|
||||||
|
|
||||||
<CriteriaTable matrix={matrix} />
|
<CriteriaTable matrix={matrix} />
|
||||||
|
|
||||||
@@ -269,6 +262,15 @@ export const Step3ComparisonTable: React.FC<Props> = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{showAddSupplierDialog && (
|
||||||
|
<AddSupplierDialog
|
||||||
|
currencyOptions={currencyOptions}
|
||||||
|
onAddManual={addManualSupplier}
|
||||||
|
onOpenDatabase={() => setShowVendorPicker(true)}
|
||||||
|
onClose={() => setShowAddSupplierDialog(false)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{showVendorPicker && (
|
{showVendorPicker && (
|
||||||
<VendorPickerDialog
|
<VendorPickerDialog
|
||||||
vendorDbService={vendorDbService}
|
vendorDbService={vendorDbService}
|
||||||
|
|||||||
+29
-2
@@ -1,7 +1,34 @@
|
|||||||
import { applyCreatedIds, buildOfferKey, computeOffer, getSubCols, isMinPositionTotal, round2Str, sumPositionTotals } from './matrixHelpers';
|
import { applyCreatedIds, applyPositionUnitChange, buildOfferKey, computeOffer, getSubCols, isMinPositionTotal, round2Str, sumPositionTotals } from './matrixHelpers';
|
||||||
import { ExtraPosition } from './matrixTypes';
|
import { EditableOffers, ExtraPosition } from './matrixTypes';
|
||||||
import { SupplierOffer } from '../types/domain';
|
import { SupplierOffer } from '../types/domain';
|
||||||
|
|
||||||
|
describe('applyPositionUnitChange (единица доп. позиции стала своей вместо «рейс»)', () => {
|
||||||
|
const edits: EditableOffers = {
|
||||||
|
'sup_a::extra_pos_1': [{ supplierId: 'sup_a', positionId: 'extra_pos_1', itemIndex: 0, unit: 'рейс', pricePerUnit: 50000 }],
|
||||||
|
'sup_b::extra_pos_1': [{ supplierId: 'sup_b', positionId: 'extra_pos_1', itemIndex: 0, unit: 'машина' }],
|
||||||
|
'sup_c::extra_pos_1': [{ supplierId: 'sup_c', positionId: 'extra_pos_1', itemIndex: 0 }],
|
||||||
|
'sup_a::pos_1': [{ supplierId: 'sup_a', positionId: 'pos_1', itemIndex: 0, unit: 'рейс' }],
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = applyPositionUnitChange(edits, 'extra_pos_1', 'рейс', 'тонна');
|
||||||
|
|
||||||
|
it('у поставщика с прежней единицей позиции — новая, цена не теряется', () => {
|
||||||
|
expect(result['sup_a::extra_pos_1'][0]).toMatchObject({ unit: 'тонна', pricePerUnit: 50000 });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('у поставщика без своей единицы — новая', () => {
|
||||||
|
expect(result['sup_c::extra_pos_1'][0].unit).toBe('тонна');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('свою единицу поставщика не трогает', () => {
|
||||||
|
expect(result['sup_b::extra_pos_1'][0].unit).toBe('машина');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('другие позиции не трогает, даже с той же единицей', () => {
|
||||||
|
expect(result['sup_a::pos_1'][0].unit).toBe('рейс');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('computeOffer', () => {
|
describe('computeOffer', () => {
|
||||||
it('считает сумму в тенге для КП в тенге', () => {
|
it('считает сумму в тенге для КП в тенге', () => {
|
||||||
const offer = computeOffer(
|
const offer = computeOffer(
|
||||||
|
|||||||
@@ -87,6 +87,25 @@ export function buildOfferKey(supplierId: string, positionId: string): string {
|
|||||||
return `${supplierId}::${positionId}`;
|
return `${supplierId}::${positionId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Поменяли единицу доп. позиции (логистика, доп. расходы): у поставщиков, у которых единица та же,
|
||||||
|
// что была у позиции (её не трогали), — новая. Свою единицу поставщика не меняем. Ячейки без правок
|
||||||
|
// и так показывают единицу позиции.
|
||||||
|
export function applyPositionUnitChange(
|
||||||
|
edits: EditableOffers,
|
||||||
|
positionId: string,
|
||||||
|
oldUnit: string,
|
||||||
|
newUnit: string,
|
||||||
|
): EditableOffers {
|
||||||
|
const next: EditableOffers = {};
|
||||||
|
Object.keys(edits).forEach(key => {
|
||||||
|
const isThisPosition = key.split('::')[1] === positionId;
|
||||||
|
next[key] = isThisPosition
|
||||||
|
? edits[key].map(item => (!item.unit || item.unit === oldUnit ? { ...item, unit: newUnit } : item))
|
||||||
|
: edits[key];
|
||||||
|
});
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ColumnOffersInput {
|
export interface ColumnOffersInput {
|
||||||
columns: Array<{ id: string; isExtraSupplier: boolean }>;
|
columns: Array<{ id: string; isExtraSupplier: boolean }>;
|
||||||
positions: PositionRow[];
|
positions: PositionRow[];
|
||||||
|
|||||||
+29
-6
@@ -4,7 +4,7 @@ import { SupplierOffer, CurrencyRate, FormStep, SupplierExclusion } from '../typ
|
|||||||
import { CtService } from '../../services/CtService';
|
import { CtService } from '../../services/CtService';
|
||||||
import { CTFormData } from '../hooks/useCtForm';
|
import { CTFormData } from '../hooks/useCtForm';
|
||||||
import { ExtraSupplier, ExtraPosition, PositionRow, CellEdit, EditableOffers, CriteriaEntry } from './matrixTypes';
|
import { ExtraSupplier, ExtraPosition, PositionRow, CellEdit, EditableOffers, CriteriaEntry } from './matrixTypes';
|
||||||
import { applyCreatedIds, buildOfferKey, computeColumnsOffers, sumPositionTotals } from './matrixHelpers';
|
import { applyCreatedIds, applyPositionUnitChange, buildOfferKey, computeColumnsOffers, sumPositionTotals } from './matrixHelpers';
|
||||||
import { buildExcludedRecordsForSave } from '../utils/excludedColumns';
|
import { buildExcludedRecordsForSave } from '../utils/excludedColumns';
|
||||||
import { parseNumberInput } from '../utils/parseNumberInput';
|
import { parseNumberInput } from '../utils/parseNumberInput';
|
||||||
import { getStep3SaveError } from './step3Validation';
|
import { getStep3SaveError } from './step3Validation';
|
||||||
@@ -587,16 +587,23 @@ export function useStep3Matrix(args: UseStep3MatrixArgs) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAddSupplier = (): void => {
|
// Поставщик, добавленный на Шаге 3 вручную (без КП). Общая точка для обеих кнопок добавления:
|
||||||
if (!newSupplierName.trim()) return;
|
// блока над таблицей и колонки «+ Добавить поставщика» в самой таблице.
|
||||||
|
const addManualSupplier = (name: string, currency: string): void => {
|
||||||
|
if (isReadOnly || !name.trim()) return;
|
||||||
const id = `extra_sup_${++extraIdCounter}`;
|
const id = `extra_sup_${++extraIdCounter}`;
|
||||||
const newEntry = { id, name: newSupplierName.trim(), currency: newSupplierCurrency };
|
const updated = [...extraSuppliers, { id, name: name.trim(), currency }];
|
||||||
const updated = [...extraSuppliers, newEntry];
|
|
||||||
setExtraSuppliers(updated);
|
setExtraSuppliers(updated);
|
||||||
setSupplierStatuses(prev => ({ ...prev, [id]: '' }));
|
setSupplierStatuses(prev => ({ ...prev, [id]: '' }));
|
||||||
|
onSave({ step3ExtraSuppliers: updated });
|
||||||
|
};
|
||||||
|
|
||||||
|
// Блок над таблицей: добавить из своих полей и очистить их.
|
||||||
|
const handleAddSupplier = (): void => {
|
||||||
|
if (!newSupplierName.trim()) return;
|
||||||
|
addManualSupplier(newSupplierName, newSupplierCurrency);
|
||||||
setNewSupplierName('');
|
setNewSupplierName('');
|
||||||
setNewSupplierCurrency('KZT');
|
setNewSupplierCurrency('KZT');
|
||||||
onSave({ step3ExtraSuppliers: updated });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Добавление поставщика из VendorPickerDialog («База данных поставщиков»): та же механика
|
// Добавление поставщика из VendorPickerDialog («База данных поставщиков»): та же механика
|
||||||
@@ -681,6 +688,17 @@ export function useStep3Matrix(args: UseStep3MatrixArgs) {
|
|||||||
onSave({ step3DeliveryKm: updated });
|
onSave({ step3DeliveryKm: updated });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Своя единица доп. позиции вместо заданной при добавлении (у логистики — «рейс»). Поставщики, у
|
||||||
|
// которых единицу не меняли, получают новую. В SP уходит при «Сохранить» (см. handleSave).
|
||||||
|
const handleExtraPositionUnitChange = (positionId: string, unit: string): void => {
|
||||||
|
if (isReadOnly) return;
|
||||||
|
const oldUnit = extraPositions.find(ep => ep.id === positionId)?.unit ?? '';
|
||||||
|
const updated = extraPositions.map(ep => (ep.id === positionId ? { ...ep, unit } : ep));
|
||||||
|
setExtraPositions(updated);
|
||||||
|
setEdits(prev => applyPositionUnitChange(prev, positionId, oldUnit, unit));
|
||||||
|
onSave({ step3ExtraPositions: updated });
|
||||||
|
};
|
||||||
|
|
||||||
const handleDeleteExtraPosition = (positionId: string): void => {
|
const handleDeleteExtraPosition = (positionId: string): void => {
|
||||||
if (isReadOnly) return;
|
if (isReadOnly) return;
|
||||||
const updated = extraPositions.filter(ep => ep.id !== positionId);
|
const updated = extraPositions.filter(ep => ep.id !== positionId);
|
||||||
@@ -760,6 +778,9 @@ export function useStep3Matrix(args: UseStep3MatrixArgs) {
|
|||||||
if (ep.spId) {
|
if (ep.spId) {
|
||||||
// Already created in SP on a previous save — reuse to avoid duplicate Позиции СТ rows.
|
// Already created in SP on a previous save — reuse to avoid duplicate Позиции СТ rows.
|
||||||
extraPosSpIds[ep.id] = ep.spId;
|
extraPosSpIds[ep.id] = ep.spId;
|
||||||
|
// Единицу могли поменять после создания. Пишем всегда — строк доп. расходов единицы,
|
||||||
|
// а отслеживать «менялась ли» — лишнее состояние.
|
||||||
|
await service.updateCTPositionUnit(ep.spId, ep.unit);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const saved = await service.createCTPositions(ct.id, [{
|
const saved = await service.createCTPositions(ct.id, [{
|
||||||
@@ -986,12 +1007,14 @@ export function useStep3Matrix(args: UseStep3MatrixArgs) {
|
|||||||
handleRemoveCustomCriteria,
|
handleRemoveCustomCriteria,
|
||||||
handleNameColResizeMouseDown,
|
handleNameColResizeMouseDown,
|
||||||
handleStatusChange,
|
handleStatusChange,
|
||||||
|
addManualSupplier,
|
||||||
handleAddSupplier,
|
handleAddSupplier,
|
||||||
handleAddSupplierFromDatabase,
|
handleAddSupplierFromDatabase,
|
||||||
handleAddPosition,
|
handleAddPosition,
|
||||||
handleAddDelivery,
|
handleAddDelivery,
|
||||||
handleDeliveryKmChange,
|
handleDeliveryKmChange,
|
||||||
handleDeleteExtraPosition,
|
handleDeleteExtraPosition,
|
||||||
|
handleExtraPositionUnitChange,
|
||||||
validateBeforeSave,
|
validateBeforeSave,
|
||||||
handleSave,
|
handleSave,
|
||||||
draftSavedAt,
|
draftSavedAt,
|
||||||
|
|||||||
@@ -397,6 +397,21 @@ export class CtService {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Единица доп. позиции Шага 3 (логистика, доп. расходы) — её можно поменять после создания.
|
||||||
|
// MERGE на «Позиции СТ» ресивер не блокирует (блокирует только на «Оценка поставщиков»).
|
||||||
|
async updateCTPositionUnit(positionSpId: number, unit: string): Promise<void> {
|
||||||
|
const res = await this.http.fetch(this._liById(LISTS.CT_POSITIONS, positionSpId), SPHttpClient.configurations.v1, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json;odata=nometadata",
|
||||||
|
"IF-MATCH": "*",
|
||||||
|
"X-HTTP-Method": "MERGE",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ unit }),
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new Error(`Ошибка обновления единицы позиции: ${res.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
// Пакетное создание элементов списка через SharePoint OData $batch: вместо N POST —
|
// Пакетное создание элементов списка через SharePoint OData $batch: вместо N POST —
|
||||||
// один HTTP-запрос (до 100 операций/changeset, при большем числе бьём на чанки).
|
// один HTTP-запрос (до 100 операций/changeset, при большем числе бьём на чанки).
|
||||||
// Возвращает Id созданных элементов В ТОМ ЖЕ порядке, что и bodies. Changeset атомарен:
|
// Возвращает Id созданных элементов В ТОМ ЖЕ порядке, что и bodies. Changeset атомарен:
|
||||||
|
|||||||
Reference in New Issue
Block a user