feat(web): кнопка «Создать возврат» на проведённой приёмке (п.5 create-based-on)
Some checks are pending
Auto-tag / Create date-tag (push) Waiting to run
CI / Backend (.NET 8) (push) Waiting to run
CI / Web (React + Vite) (push) Waiting to run
CI / POS (WPF, Windows) (push) Waiting to run
Docker Web / Build + push Web (push) Waiting to run
Docker Web / Deploy Web on stage (push) Blocked by required conditions

Проведённая приёмка → «Создать возврат» вызывает from-supply (преднабор строк) и
открывает черновик возврата поставщику. Вместе с секцией оплат приёмки (supply→
payment) и ссылками-основаниями в DTO — развивает «создать на основании».

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
nns 2026-10-09 06:41:03 +05:00
parent 524f8f41b1
commit fd03700a58

View file

@ -1,7 +1,7 @@
import { useState, useEffect, useRef, type FormEvent, type ReactNode } from 'react'
import { useNavigate, useParams, Link } from 'react-router-dom'
import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query'
import { ArrowLeft, Plus, Trash2, Save, CheckCircle } from 'lucide-react'
import { ArrowLeft, Plus, Trash2, Save, CheckCircle, Undo2 } from 'lucide-react'
import { api } from '@/lib/api'
import { Button } from '@/components/Button'
import { Field, TextArea, Select, AsyncSelect, Checkbox, MoneyInput, NumberInput } from '@/components/Field'
@ -216,6 +216,13 @@ export function SupplyEditPage() {
meta: { successMessage: 'Удалено' },
})
// «Создать на основании»: возврат поставщику с преднабором строк приёмки.
const createReturn = useMutation({
mutationFn: async () => (await api.post<{ id: string }>(`/api/purchases/supplier-returns/from-supply/${id}`)).data,
onSuccess: (d) => { if (d?.id) navigate(`/purchases/supplier-returns/${d.id}`) },
onError: (e: Error) => setError((e as { response?: { data?: { error?: string } } }).response?.data?.error ?? e.message),
})
const onSubmit = (e: FormEvent) => { e.preventDefault(); save.mutate() }
const addLineFromProduct = (p: Product) => {
@ -326,6 +333,12 @@ export function SupplyEditPage() {
<Trash2 className="w-4 h-4" /> Удалить
</Button>
)}
{isPosted && (
<Button type="button" variant="secondary" size="sm" disabled={createReturn.isPending}
onClick={() => createReturn.mutate()} title="Создать возврат поставщику на основании этой приёмки">
<Undo2 className="w-4 h-4" /> Создать возврат
</Button>
)}
{isDraft && (
<Button type="submit" disabled={!canSave || save.isPending}>
<Save className="w-4 h-4" /> {save.isPending ? 'Сохраняю…' : 'Сохранить'}