commit21
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Head, useForm } from '@inertiajs/react';
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import {
|
||||
FormErrors,
|
||||
PageTitle,
|
||||
@@ -6,6 +6,9 @@ import {
|
||||
controlClass,
|
||||
} from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import SupplyPagination, {
|
||||
type SupplyPageInfo,
|
||||
} from '@/components/supply-pagination';
|
||||
|
||||
type Analysis = {
|
||||
days: number;
|
||||
@@ -26,6 +29,9 @@ type Analysis = {
|
||||
}[];
|
||||
};
|
||||
type HistoryRecord = {
|
||||
canApprove?: boolean;
|
||||
canReturn?: boolean;
|
||||
canSuspend?: boolean;
|
||||
id: number;
|
||||
record_key: string;
|
||||
version: number;
|
||||
@@ -50,6 +56,9 @@ type HistoryRecord = {
|
||||
};
|
||||
};
|
||||
type Props = {
|
||||
recordPagination?: SupplyPageInfo | null;
|
||||
focusRecordId?: number | null;
|
||||
focusChanged?: boolean;
|
||||
ready: boolean;
|
||||
actorId: number;
|
||||
canPrepare: boolean;
|
||||
@@ -399,7 +408,6 @@ function Decision({
|
||||
reason: '',
|
||||
data: { confirm_scope: false },
|
||||
});
|
||||
const independent = !r.snapshot.contributors.includes(props.actorId);
|
||||
return (
|
||||
<div className="mt-4 space-y-4">
|
||||
{props.canPrepare && ['draft', 'returned'].includes(r.state) && (
|
||||
@@ -410,7 +418,7 @@ function Decision({
|
||||
<Prepare props={props} old={r} />
|
||||
</details>
|
||||
)}
|
||||
{props.canReview && independent && r.state !== 'suspended' && (
|
||||
{(r.canApprove || r.canReturn || r.canSuspend) && (
|
||||
<>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Decisão da minha responsabilidade
|
||||
@@ -422,19 +430,20 @@ function Decision({
|
||||
}
|
||||
>
|
||||
<option value="">Seleccionar acção</option>
|
||||
{r.state === 'approved' ? (
|
||||
{r.canSuspend && (
|
||||
<option value="suspend">
|
||||
Suspender reutilização
|
||||
</option>
|
||||
) : (
|
||||
<>
|
||||
<option value="approve">
|
||||
Conferir e aprovar análise
|
||||
</option>
|
||||
<option value="return">
|
||||
Devolver para correcção
|
||||
</option>
|
||||
</>
|
||||
)}
|
||||
{r.canApprove && (
|
||||
<option value="approve">
|
||||
Conferir e aprovar análise
|
||||
</option>
|
||||
)}
|
||||
{r.canReturn && (
|
||||
<option value="return">
|
||||
Devolver para correcção
|
||||
</option>
|
||||
)}
|
||||
</select>
|
||||
</label>
|
||||
@@ -515,7 +524,24 @@ export default function History(props: Props) {
|
||||
{!props.ready && (
|
||||
<p role="status">Instalação do fornecimento pendente.</p>
|
||||
)}
|
||||
{props.canPrepare && (
|
||||
{props.focusRecordId && (
|
||||
<div className="space-y-2 text-sm">
|
||||
<Link
|
||||
href="/compras/fornecimento?view=history"
|
||||
className="underline"
|
||||
>
|
||||
Ver todas as análises
|
||||
</Link>
|
||||
{props.focusChanged && (
|
||||
<p role="status">
|
||||
Esta análise foi actualizada. Está a consultar a
|
||||
versão actual; as versões anteriores permanecem
|
||||
no histórico.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{props.canPrepare && !props.focusRecordId && (
|
||||
<Panel title="Analisar período existente">
|
||||
<details>
|
||||
<summary className="cursor-pointer font-medium">
|
||||
@@ -540,6 +566,7 @@ export default function History(props: Props) {
|
||||
title={`${r.snapshot.item.code} · ${r.snapshot.item.name}`}
|
||||
description={`${r.snapshot.warehouse.name} · ${states[r.state]} · Versão ${r.version}`}
|
||||
>
|
||||
<div id={`supply-record-${r.id}`} />
|
||||
<Facts record={r} series />
|
||||
<p className="mt-3 text-sm">{r.reason}</p>
|
||||
<Decision props={props} record={r} />
|
||||
@@ -569,6 +596,7 @@ export default function History(props: Props) {
|
||||
</details>
|
||||
</Panel>
|
||||
))}
|
||||
<SupplyPagination page={props.recordPagination} />
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Uma análise conferida pode ser seleccionada pelo responsável
|
||||
pelas políticas. A consulta do razão e a configuração de
|
||||
|
||||
Reference in New Issue
Block a user