@@ -0,0 +1,538 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { Printer } from 'lucide-react';
|
||||
import SupplierImprovements from '@/components/supplier-improvements';
|
||||
import type { ImprovementData } from '@/components/supplier-improvements';
|
||||
import SupplierResponses from '@/components/supplier-responses';
|
||||
import type { ResponseData } from '@/components/supplier-responses';
|
||||
import { PageTitle, Panel, controlClass } from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import SupplierEvaluationFields, {
|
||||
evaluationStates,
|
||||
criterionStates,
|
||||
} from '@/components/supplier-evaluation-fields';
|
||||
import type {
|
||||
EvaluationPayload,
|
||||
EvaluationOrder,
|
||||
} from '@/components/supplier-evaluation-fields';
|
||||
|
||||
type Evaluation = {
|
||||
id: number;
|
||||
supplier_id: number;
|
||||
revision: number;
|
||||
version: number;
|
||||
status: string;
|
||||
previous_id: number | null;
|
||||
created_by: number;
|
||||
contributors: number[];
|
||||
supplier_snapshot: { id: number; name: string; nuit: string };
|
||||
payload: EvaluationPayload;
|
||||
review_reason: string | null;
|
||||
reviewed_at: string | null;
|
||||
};
|
||||
type History = {
|
||||
id: number;
|
||||
action: string;
|
||||
user_id: number;
|
||||
after: Evaluation;
|
||||
created_at: string;
|
||||
};
|
||||
const actions: Record<string, string> = {
|
||||
created: 'Criação',
|
||||
updated: 'Alteração',
|
||||
submit: 'Submissão',
|
||||
approve: 'Aprovação',
|
||||
return: 'Devolução',
|
||||
revised: 'Nova revisão',
|
||||
};
|
||||
export default function SupplierEvaluation({
|
||||
evaluation: e,
|
||||
orders,
|
||||
canEdit,
|
||||
canReview,
|
||||
canRevise,
|
||||
reportOnly,
|
||||
nextRevisionId,
|
||||
history,
|
||||
people,
|
||||
notice,
|
||||
generatedAt,
|
||||
improvements,
|
||||
responses,
|
||||
}: {
|
||||
evaluation: Evaluation;
|
||||
orders: EvaluationOrder[];
|
||||
canEdit: boolean;
|
||||
canReview: boolean;
|
||||
canRevise: boolean;
|
||||
reportOnly: boolean;
|
||||
nextRevisionId: number | null;
|
||||
history: {
|
||||
data: History[];
|
||||
total: number;
|
||||
prev_page_url: string | null;
|
||||
next_page_url: string | null;
|
||||
};
|
||||
people: Record<number, string>;
|
||||
notice?: string;
|
||||
generatedAt: string;
|
||||
improvements: ImprovementData;
|
||||
responses: ResponseData;
|
||||
}) {
|
||||
const form = useForm({ version: e.version, payload: e.payload });
|
||||
const command = useForm({ version: e.version, reason: '' });
|
||||
const base = `/fornecedores/avaliacoes/${e.id}`;
|
||||
const dirty =
|
||||
JSON.stringify(form.data.payload) !== JSON.stringify(e.payload);
|
||||
const waiting = e.payload.criteria.filter((row) =>
|
||||
['pending', 'insufficient'].includes(row.result),
|
||||
).length;
|
||||
const submit = (action: string) =>
|
||||
command.post(`${base}/${action}`, {
|
||||
preserveScroll: true,
|
||||
preserveState: 'errors',
|
||||
});
|
||||
const errors = [
|
||||
...Object.values(form.errors),
|
||||
...Object.values(command.errors),
|
||||
];
|
||||
return (
|
||||
<>
|
||||
<Head title={`AVF-${e.id} · Avaliação de fornecedor`} />
|
||||
<style>{`@media print { @page {size:A4;margin:14mm} .evaluation-report {font-size:11px;max-width:none;padding:0} .evaluation-report section {box-shadow:none} .evaluation-report h2,.evaluation-report h3 {break-after:avoid} .evaluation-report article {break-inside:avoid} }`}</style>
|
||||
<div className="evaluation-report mx-auto max-w-5xl space-y-6 px-5 py-8 lg:px-8">
|
||||
<PageTitle
|
||||
eyebrow={`AVF-${e.id} · Revisão ${e.revision} · Versão ${e.version}`}
|
||||
title={e.payload.title}
|
||||
description={`${e.supplier_snapshot.name} · ${evaluationStates[e.status] ?? e.status}`}
|
||||
action={
|
||||
<div className="flex flex-wrap gap-3 print:hidden">
|
||||
<Button asChild variant="outline">
|
||||
<Link href="/fornecedores/avaliacoes">
|
||||
Avaliações
|
||||
</Link>
|
||||
</Button>
|
||||
{!reportOnly && (
|
||||
<Button asChild variant="outline">
|
||||
<Link href={`${base}/relatorio`}>
|
||||
Abrir relatório
|
||||
</Link>
|
||||
</Button>
|
||||
)}
|
||||
{reportOnly && (
|
||||
<>
|
||||
<Button asChild variant="outline">
|
||||
<Link href={base}>
|
||||
Voltar à avaliação
|
||||
</Link>
|
||||
</Button>
|
||||
<Button onClick={() => window.print()}>
|
||||
<Printer className="size-4" />
|
||||
Imprimir
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
{notice && (
|
||||
<p
|
||||
role="status"
|
||||
className="rounded border border-teal-300 p-3 print:hidden"
|
||||
>
|
||||
{notice}
|
||||
</p>
|
||||
)}
|
||||
<div className="flex flex-wrap gap-4 text-sm">
|
||||
<span>
|
||||
Autor: {people[e.created_by] ?? `#${e.created_by}`}
|
||||
</span>
|
||||
<span>NUIT preservado: {e.supplier_snapshot.nuit}</span>
|
||||
{e.previous_id && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/fornecedores/avaliacoes/${e.previous_id}/relatorio`}
|
||||
>
|
||||
Revisão anterior preservada
|
||||
</Link>
|
||||
)}
|
||||
{nextRevisionId && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/fornecedores/avaliacoes/${nextRevisionId}`}
|
||||
>
|
||||
Abrir revisão posterior
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
{e.status !== 'approved' && (
|
||||
<p className="rounded border border-amber-300 p-3 text-sm">
|
||||
{evaluationStates[e.status]} — este documento ainda não
|
||||
contém uma aprovação independente.
|
||||
</p>
|
||||
)}
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Registo qualitativo da prestação da entidade fornecedora.
|
||||
Sem pontuação ou classificação automática; não altera por si
|
||||
só a qualificação, suspensão ou elegibilidade do fornecedor.
|
||||
</p>
|
||||
{canEdit ? (
|
||||
<Panel title="Preparar e conservar evidências">
|
||||
<form
|
||||
className="space-y-5"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
form.put(base, {
|
||||
preserveScroll: true,
|
||||
preserveState: 'errors',
|
||||
});
|
||||
}}
|
||||
>
|
||||
<SupplierEvaluationFields
|
||||
payload={form.data.payload}
|
||||
orders={orders}
|
||||
disabled={form.processing || command.processing}
|
||||
onChange={(payload) =>
|
||||
form.setData('payload', payload)
|
||||
}
|
||||
/>
|
||||
{errors.map((error, index) => (
|
||||
<p
|
||||
key={index}
|
||||
role="alert"
|
||||
className="text-sm text-red-700"
|
||||
>
|
||||
{error}
|
||||
</p>
|
||||
))}
|
||||
<div className="flex flex-wrap gap-3">
|
||||
<Button
|
||||
disabled={
|
||||
form.processing || command.processing
|
||||
}
|
||||
>
|
||||
Guardar rascunho
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
type="button"
|
||||
disabled={
|
||||
form.processing ||
|
||||
command.processing ||
|
||||
dirty
|
||||
}
|
||||
onClick={() => submit('submit')}
|
||||
>
|
||||
Submeter para revisão
|
||||
</Button>
|
||||
</div>
|
||||
{dirty && (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Guarde as alterações antes de submeter. A
|
||||
revisão compara os dados efectivamente
|
||||
guardados.
|
||||
</p>
|
||||
)}
|
||||
</form>
|
||||
</Panel>
|
||||
) : (
|
||||
<>
|
||||
<Panel title="Âmbito e evidências">
|
||||
<div className="space-y-4 text-sm">
|
||||
<p>
|
||||
Componente:{' '}
|
||||
{e.payload.nature === 'goods'
|
||||
? 'Bens'
|
||||
: 'Serviços'}{' '}
|
||||
· Período:{' '}
|
||||
{e.payload.period_start ?? 'Por indicar'} —{' '}
|
||||
{e.payload.period_end ?? 'Por indicar'}.
|
||||
</p>
|
||||
<p className="whitespace-pre-wrap">
|
||||
{e.payload.scope ||
|
||||
'Âmbito ainda não indicado.'}
|
||||
</p>
|
||||
<div>
|
||||
Ordens abrangidas:{' '}
|
||||
{e.payload.order_ids.length
|
||||
? e.payload.order_ids.map((id) => (
|
||||
<Link
|
||||
key={id}
|
||||
className="mr-3 underline"
|
||||
href={`/ordens/${id}`}
|
||||
>
|
||||
{orders.find(
|
||||
(order) =>
|
||||
order.id === id,
|
||||
)?.number ?? `#${id}`}
|
||||
</Link>
|
||||
))
|
||||
: 'Sem ordens associadas; conferir as referências declaradas no âmbito.'}
|
||||
</div>
|
||||
<p>
|
||||
{e.payload.criteria.length} critérios ·{' '}
|
||||
{waiting} por analisar ou com evidência
|
||||
insuficiente.
|
||||
</p>
|
||||
{e.payload.criteria.map((row, index) => (
|
||||
<article
|
||||
key={index}
|
||||
className="space-y-2 rounded border p-3"
|
||||
>
|
||||
<h3 className="font-medium">
|
||||
{index + 1}.{' '}
|
||||
{row.label ||
|
||||
'Critério por identificar'}
|
||||
</h3>
|
||||
<p>{criterionStates[row.result]}</p>
|
||||
<p className="whitespace-pre-wrap">
|
||||
Justificação:{' '}
|
||||
{row.reason || 'Por completar'}
|
||||
</p>
|
||||
<p className="whitespace-pre-wrap">
|
||||
Evidência declarada:{' '}
|
||||
{row.evidence || 'Não indicada'}
|
||||
</p>
|
||||
</article>
|
||||
))}
|
||||
<h3 className="font-medium">Conclusão</h3>
|
||||
<p className="whitespace-pre-wrap">
|
||||
{e.payload.conclusion ||
|
||||
'Ainda não registada.'}
|
||||
</p>
|
||||
<h3 className="font-medium">
|
||||
Ocorrências críticas
|
||||
</h3>
|
||||
<p className="whitespace-pre-wrap">
|
||||
{e.payload.critical_occurrences ||
|
||||
'Sem informação registada neste campo; não equivale a uma declaração de ausência de ocorrências.'}
|
||||
</p>
|
||||
{e.payload.critical_evidence && (
|
||||
<p className="whitespace-pre-wrap">
|
||||
Evidência: {e.payload.critical_evidence}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</Panel>
|
||||
</>
|
||||
)}
|
||||
{e.review_reason && (
|
||||
<Panel title="Última decisão documentada">
|
||||
<p className="text-sm whitespace-pre-wrap">
|
||||
{e.review_reason}
|
||||
</p>
|
||||
<p className="mt-2 text-xs text-muted-foreground">
|
||||
{e.reviewed_at}
|
||||
</p>
|
||||
</Panel>
|
||||
)}
|
||||
{canReview && (
|
||||
<Panel title="Conferência independente">
|
||||
<form
|
||||
className="space-y-4"
|
||||
onSubmit={(event) => event.preventDefault()}
|
||||
>
|
||||
<p className="text-sm">
|
||||
Confirme âmbito, atribuição das ocorrências,
|
||||
aplicabilidade e referências. Evidências
|
||||
pendentes não são convertidas em notas nem
|
||||
ignoradas.
|
||||
</p>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Fundamento da decisão
|
||||
<textarea
|
||||
className={
|
||||
controlClass + ' h-auto min-h-24 py-2'
|
||||
}
|
||||
value={command.data.reason}
|
||||
minLength={10}
|
||||
maxLength={4000}
|
||||
onChange={(event) =>
|
||||
command.setData(
|
||||
'reason',
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
{errors.map((error, index) => (
|
||||
<p
|
||||
key={index}
|
||||
role="alert"
|
||||
className="text-sm text-red-700"
|
||||
>
|
||||
{error}
|
||||
</p>
|
||||
))}
|
||||
<div className="flex flex-wrap gap-3">
|
||||
<Button
|
||||
type="button"
|
||||
disabled={command.processing || waiting > 0}
|
||||
onClick={() => submit('approve')}
|
||||
>
|
||||
Aprovar avaliação
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
disabled={command.processing}
|
||||
onClick={() => submit('return')}
|
||||
>
|
||||
Devolver para correcção
|
||||
</Button>
|
||||
</div>
|
||||
{waiting > 0 && (
|
||||
<p className="text-sm text-amber-800">
|
||||
Existem {waiting} critérios pendentes.
|
||||
Devolva para completar as evidências antes
|
||||
de aprovar.
|
||||
</p>
|
||||
)}
|
||||
</form>
|
||||
</Panel>
|
||||
)}
|
||||
{e.status === 'review' && !canReview && !reportOnly && (
|
||||
<p className="text-sm">
|
||||
Aguarda conferência por outra pessoa autorizada que não
|
||||
tenha elaborado ou submetido esta revisão.
|
||||
</p>
|
||||
)}
|
||||
{canRevise && (
|
||||
<Panel title="Rectificar sem apagar a avaliação aprovada">
|
||||
<p className="mb-3 text-sm">
|
||||
A rectificação cria outro rascunho, com número de
|
||||
revisão próprio. A versão aprovada anterior mantém o
|
||||
seu relatório e histórico.
|
||||
</p>
|
||||
<Button
|
||||
disabled={command.processing}
|
||||
onClick={() => submit('rever')}
|
||||
>
|
||||
Preparar nova revisão
|
||||
</Button>
|
||||
{errors.map((error, index) => (
|
||||
<p
|
||||
key={index}
|
||||
role="alert"
|
||||
className="mt-2 text-sm text-red-700"
|
||||
>
|
||||
{error}
|
||||
</p>
|
||||
))}
|
||||
</Panel>
|
||||
)}
|
||||
{!reportOnly && (
|
||||
<Panel title="Histórico de alterações e decisões">
|
||||
<p className="mb-3 text-sm">
|
||||
{history.total} registos preservados. Cada alteração
|
||||
conserva a sua fotografia; versões aprovadas não são
|
||||
reescritas.
|
||||
</p>
|
||||
<div className="space-y-3">
|
||||
{history.data.map((event) => (
|
||||
<details
|
||||
key={event.id}
|
||||
className="rounded border p-3 text-sm"
|
||||
>
|
||||
<summary className="cursor-pointer">
|
||||
{actions[
|
||||
event.action.split('.').at(-1) ?? ''
|
||||
] ?? event.action}{' '}
|
||||
· Versão {event.after.version} ·{' '}
|
||||
{people[event.user_id] ??
|
||||
`#${event.user_id}`}{' '}
|
||||
·{' '}
|
||||
{new Date(
|
||||
event.created_at,
|
||||
).toLocaleString('pt-MZ')}
|
||||
</summary>
|
||||
<div className="mt-3 space-y-2">
|
||||
<p>
|
||||
{
|
||||
evaluationStates[
|
||||
event.after.status
|
||||
]
|
||||
}{' '}
|
||||
· {event.after.payload.title}
|
||||
</p>
|
||||
<p className="whitespace-pre-wrap">
|
||||
{event.after.payload.scope}
|
||||
</p>
|
||||
{event.after.payload.criteria.map(
|
||||
(row, index) => (
|
||||
<p
|
||||
key={index}
|
||||
className="whitespace-pre-wrap"
|
||||
>
|
||||
{row.label} ·{' '}
|
||||
{
|
||||
criterionStates[
|
||||
row.result
|
||||
]
|
||||
}{' '}
|
||||
· {row.reason} · Evidência:{' '}
|
||||
{row.evidence ||
|
||||
'Não indicada'}
|
||||
</p>
|
||||
),
|
||||
)}
|
||||
<p className="whitespace-pre-wrap">
|
||||
{event.after.payload.conclusion}
|
||||
</p>
|
||||
{event.after.review_reason && (
|
||||
<p className="whitespace-pre-wrap">
|
||||
Decisão:{' '}
|
||||
{event.after.review_reason}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</details>
|
||||
))}
|
||||
</div>
|
||||
<nav
|
||||
aria-label="Paginação do histórico"
|
||||
className="mt-4 flex gap-4 text-sm"
|
||||
>
|
||||
{history.prev_page_url && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={history.prev_page_url}
|
||||
>
|
||||
Anterior
|
||||
</Link>
|
||||
)}
|
||||
{history.next_page_url && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={history.next_page_url}
|
||||
>
|
||||
Seguinte
|
||||
</Link>
|
||||
)}
|
||||
</nav>
|
||||
</Panel>
|
||||
)}
|
||||
<SupplierImprovements
|
||||
data={improvements}
|
||||
evaluationId={e.id}
|
||||
names={people}
|
||||
reportOnly={reportOnly}
|
||||
generatedAt={generatedAt}
|
||||
/>
|
||||
<SupplierResponses
|
||||
data={responses}
|
||||
evaluationId={e.id}
|
||||
names={people}
|
||||
reportOnly={reportOnly}
|
||||
generatedAt={generatedAt}
|
||||
/>
|
||||
<footer className="border-t pt-4 text-xs text-muted-foreground">
|
||||
SGC · AVF-{e.id} · Revisão {e.revision} ·{' '}
|
||||
{evaluationStates[e.status]} · Consulta de{' '}
|
||||
{new Date(generatedAt).toLocaleString('pt-MZ')}. As
|
||||
referências são declarações documentadas, não verificação
|
||||
automática do conteúdo.
|
||||
</footer>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,39 +1,349 @@
|
||||
import { Head } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import { PageTitle, Panel } from '@/components/procurement';
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { PageTitle, Panel, controlClass } from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import SupplierEvaluationFields, {
|
||||
emptyEvaluation,
|
||||
evaluationStates,
|
||||
} from '@/components/supplier-evaluation-fields';
|
||||
import type { EvaluationOrder } from '@/components/supplier-evaluation-fields';
|
||||
import proposal from './evaluation-proposal';
|
||||
|
||||
const areas = [
|
||||
['Avaliações planeadas', 'Definir fornecedor, período, âmbito e responsáveis pela avaliação.'],
|
||||
['Nova avaliação', 'Identificar contratos e ordens abrangidas, escolher a grelha de bens ou serviços e reunir notas, justificações e evidências.'],
|
||||
['Rascunhos', 'Preparar a avaliação e completar evidências antes de submeter para revisão.'],
|
||||
['Avaliações em revisão', 'Conferência independente, com devolução para correcção ou aprovação documentada.'],
|
||||
['Avaliações aprovadas', 'Consultar versões aprovadas; rectificações devem gerar revisão identificável.'],
|
||||
['Histórico por fornecedor', 'Consultar a evolução, observações e contestações com decisão documentada. Comparar apenas âmbitos e grelhas equivalentes.'],
|
||||
['Planos de melhoria', 'Acompanhar acções, responsáveis, prazos, evidências de conclusão e validação de eficácia.'],
|
||||
['Relatórios de avaliação', 'Ficha por fornecedor e período, resultados por critério, ocorrências críticas e cobertura de evidências.'],
|
||||
];
|
||||
export default function SupplierEvaluations() {
|
||||
const [selected, setSelected] = useState(0);
|
||||
return <>
|
||||
<Head title="Avaliação de fornecedores" />
|
||||
<div className="space-y-6 p-4 md:p-8">
|
||||
<PageTitle eyebrow="Fornecedores" title="Avaliação de fornecedores" description="Acompanhamento da prestação da entidade fornecedora durante ou após o fornecimento." />
|
||||
<div className="rounded-xl border border-amber-300 bg-amber-50 p-4 text-sm text-amber-950">
|
||||
Proposta funcional para validação da organização. As áreas abaixo descrevem o circuito previsto; o registo e a aprovação de avaliações ainda não estão disponíveis. Pesos, escala e limiares são ilustrativos.
|
||||
</div>
|
||||
<nav aria-label="Áreas da avaliação de fornecedores" className="flex flex-wrap gap-2">
|
||||
{areas.map(([label], index) => <button key={label} type="button" aria-pressed={selected === index} onClick={() => setSelected(index)} className={`rounded-lg border px-4 py-2 text-sm ${selected === index ? 'bg-primary text-primary-foreground' : 'bg-card hover:bg-muted'}`}>{label}</button>)}
|
||||
</nav>
|
||||
<Panel title={areas[selected][0]} description={areas[selected][1]}>
|
||||
<p className="text-sm text-muted-foreground">Área prevista na proposta. Não são apresentados resultados de fornecedores reais.</p>
|
||||
</Panel>
|
||||
<Panel title="Proposta funcional completa" description="Qualificação verifica elegibilidade; avaliação analisa o cumprimento efectivo. Uma pontuação não suspende nem exclui automaticamente um fornecedor.">
|
||||
<details><summary className="cursor-pointer font-medium">Consultar campos, grelhas, evidências e regras propostas</summary>
|
||||
<div className="mt-4 whitespace-pre-wrap text-sm leading-7">{proposal}</div>
|
||||
type Row = {
|
||||
id: number;
|
||||
revision: number;
|
||||
version: number;
|
||||
status: string;
|
||||
supplier: string;
|
||||
title: string;
|
||||
period_start: string | null;
|
||||
period_end: string | null;
|
||||
};
|
||||
export default function SupplierEvaluations({
|
||||
ready,
|
||||
records,
|
||||
filters,
|
||||
suppliers,
|
||||
orders,
|
||||
notice,
|
||||
}: {
|
||||
ready: boolean;
|
||||
records: {
|
||||
data: Row[];
|
||||
total: number;
|
||||
current_page: number;
|
||||
last_page: number;
|
||||
prev_page_url: string | null;
|
||||
next_page_url: string | null;
|
||||
} | null;
|
||||
filters: { supplier_id?: number; status?: string };
|
||||
suppliers: { id: number; name: string; nuit: string }[];
|
||||
orders: EvaluationOrder[];
|
||||
notice?: string;
|
||||
}) {
|
||||
const form = useForm({
|
||||
supplier_id: '',
|
||||
operation_key: crypto.randomUUID(),
|
||||
payload: emptyEvaluation(),
|
||||
});
|
||||
const filter = useForm({
|
||||
supplier_id: String(filters.supplier_id ?? ''),
|
||||
status: filters.status ?? '',
|
||||
});
|
||||
const supplierOrders = orders.filter(
|
||||
(order) => order.supplier_id === Number(form.data.supplier_id),
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<Head title="Avaliação de fornecedores" />
|
||||
<div className="mx-auto max-w-7xl space-y-6 px-5 py-8 lg:px-8">
|
||||
<PageTitle
|
||||
eyebrow="Fornecedores"
|
||||
title="Avaliação de fornecedores"
|
||||
description="Prepare a avaliação qualitativa, reúna evidências, submeta para revisão independente e consulte o histórico e o relatório de cada revisão."
|
||||
action={
|
||||
<Button asChild variant="outline">
|
||||
<Link href="/relatorios/medidas-fornecedores">
|
||||
Acompanhar medidas de melhoria
|
||||
</Link>
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
{notice && (
|
||||
<p
|
||||
role="status"
|
||||
className="rounded border border-teal-300 p-3 text-sm"
|
||||
>
|
||||
{notice}
|
||||
</p>
|
||||
)}
|
||||
{!ready && (
|
||||
<p
|
||||
role="status"
|
||||
className="rounded border border-amber-300 p-3"
|
||||
>
|
||||
O módulo está a ser instalado. O cadastro de
|
||||
fornecedores e os processos existentes permanecem
|
||||
disponíveis.
|
||||
</p>
|
||||
)}
|
||||
<Panel title="Avaliações e histórico por fornecedor">
|
||||
<form
|
||||
className="mb-5 flex flex-wrap items-end gap-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
filter.get('/fornecedores/avaliacoes', {
|
||||
preserveState: true,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Fornecedor
|
||||
<select
|
||||
className={controlClass}
|
||||
value={filter.data.supplier_id}
|
||||
onChange={(event) =>
|
||||
filter.setData(
|
||||
'supplier_id',
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todos os autorizados</option>
|
||||
{suppliers.map((supplier) => (
|
||||
<option
|
||||
key={supplier.id}
|
||||
value={supplier.id}
|
||||
>
|
||||
{supplier.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Estado
|
||||
<select
|
||||
className={controlClass}
|
||||
value={filter.data.status}
|
||||
onChange={(event) =>
|
||||
filter.setData('status', event.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{Object.entries(evaluationStates).map(
|
||||
([value, label]) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
</option>
|
||||
),
|
||||
)}
|
||||
</select>
|
||||
</label>
|
||||
<Button disabled={filter.processing}>
|
||||
Aplicar filtros
|
||||
</Button>
|
||||
<Link
|
||||
className="py-2 text-sm underline"
|
||||
href="/fornecedores/avaliacoes"
|
||||
>
|
||||
Limpar
|
||||
</Link>
|
||||
</form>
|
||||
{records && (
|
||||
<>
|
||||
<p className="mb-3 text-sm">
|
||||
{records.total} avaliações/revisões no âmbito
|
||||
autorizado.
|
||||
</p>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full min-w-180 text-left text-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="p-2">Avaliação</th>
|
||||
<th className="p-2">
|
||||
Fornecedor / período
|
||||
</th>
|
||||
<th className="p-2">Estado</th>
|
||||
<th className="p-2">Consultar</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{records.data.map((row) => (
|
||||
<tr
|
||||
key={row.id}
|
||||
className="border-t"
|
||||
>
|
||||
<td className="p-2">
|
||||
AVF-{row.id} · Revisão{' '}
|
||||
{row.revision}
|
||||
<span className="block font-medium">
|
||||
{row.title}
|
||||
</span>
|
||||
</td>
|
||||
<td className="p-2">
|
||||
{row.supplier}
|
||||
<span className="block text-muted-foreground">
|
||||
{row.period_start ??
|
||||
'Início por indicar'}{' '}
|
||||
—{' '}
|
||||
{row.period_end ??
|
||||
'Fim por indicar'}
|
||||
</span>
|
||||
</td>
|
||||
<td className="p-2">
|
||||
{evaluationStates[
|
||||
row.status
|
||||
] ?? row.status}
|
||||
</td>
|
||||
<td className="space-y-2 p-2">
|
||||
<Link
|
||||
className="block underline"
|
||||
href={`/fornecedores/avaliacoes/${row.id}`}
|
||||
>
|
||||
Abrir avaliação
|
||||
</Link>
|
||||
<Link
|
||||
className="block underline"
|
||||
href={`/fornecedores/avaliacoes/${row.id}/relatorio`}
|
||||
>
|
||||
Relatório
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{records.data.length === 0 && (
|
||||
<p className="py-4 text-sm">
|
||||
Sem avaliações nos filtros e no âmbito
|
||||
autorizado.
|
||||
</p>
|
||||
)}
|
||||
<nav
|
||||
aria-label="Paginação das avaliações"
|
||||
className="mt-4 flex flex-wrap justify-between gap-3 text-sm"
|
||||
>
|
||||
<span>
|
||||
Página {records.current_page} de{' '}
|
||||
{records.last_page}
|
||||
</span>
|
||||
<div className="flex gap-4">
|
||||
{records.prev_page_url && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={records.prev_page_url}
|
||||
>
|
||||
Anterior
|
||||
</Link>
|
||||
)}
|
||||
{records.next_page_url && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={records.next_page_url}
|
||||
>
|
||||
Seguinte
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</nav>
|
||||
</>
|
||||
)}
|
||||
</Panel>
|
||||
<Panel
|
||||
title="Preparar nova avaliação"
|
||||
description="Bens e serviços são avaliados separadamente. O relatório regista o âmbito escolhido e não calcula médias entre componentes."
|
||||
>
|
||||
<form
|
||||
className="space-y-5"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
form.post('/fornecedores/avaliacoes', {
|
||||
preserveState: 'errors',
|
||||
preserveScroll: true,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Fornecedor
|
||||
<select
|
||||
className={controlClass}
|
||||
disabled={!ready || form.processing}
|
||||
value={form.data.supplier_id}
|
||||
onChange={(event) =>
|
||||
form.setData({
|
||||
...form.data,
|
||||
supplier_id: event.target.value,
|
||||
payload: {
|
||||
...form.data.payload,
|
||||
order_ids: [],
|
||||
},
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">Escolher fornecedor</option>
|
||||
{suppliers.map((supplier) => (
|
||||
<option
|
||||
key={supplier.id}
|
||||
value={supplier.id}
|
||||
>
|
||||
{supplier.name} · {supplier.nuit}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<SupplierEvaluationFields
|
||||
payload={form.data.payload}
|
||||
orders={supplierOrders}
|
||||
disabled={!ready || form.processing}
|
||||
onChange={(payload) =>
|
||||
form.setData('payload', payload)
|
||||
}
|
||||
/>
|
||||
{Object.entries(form.errors).map(([key, error]) => (
|
||||
<p
|
||||
key={key}
|
||||
role="alert"
|
||||
className="text-sm text-red-700"
|
||||
>
|
||||
{error}
|
||||
</p>
|
||||
))}
|
||||
<Button
|
||||
disabled={
|
||||
!ready ||
|
||||
form.processing ||
|
||||
!form.data.supplier_id
|
||||
}
|
||||
>
|
||||
Guardar rascunho
|
||||
</Button>
|
||||
</form>
|
||||
</Panel>
|
||||
<details className="rounded-lg border p-4 text-sm">
|
||||
<summary className="cursor-pointer font-medium">
|
||||
Proposta de grelhas quantitativas e evoluções previstas
|
||||
</summary>
|
||||
<p className="my-3">
|
||||
O ciclo disponível é qualitativo. Pesos, limiares,
|
||||
pontuações, planos de melhoria acompanhados e
|
||||
contestação mantêm-se distintos desta entrega; os
|
||||
valores ilustrativos abaixo não foram activados como
|
||||
política.
|
||||
</p>
|
||||
<div className="whitespace-pre-wrap text-muted-foreground">
|
||||
{proposal}
|
||||
</div>
|
||||
</details>
|
||||
</Panel>
|
||||
</div>
|
||||
</>;
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
SupplierEvaluations.layout = { breadcrumbs: [{ title: 'Fornecedores', href: '/fornecedores' }, { title: 'Avaliação de fornecedores', href: '/fornecedores/avaliacoes' }] };
|
||||
SupplierEvaluations.layout = {
|
||||
breadcrumbs: [
|
||||
{ title: 'Fornecedores', href: '/fornecedores' },
|
||||
{
|
||||
title: 'Avaliação de fornecedores',
|
||||
href: '/fornecedores/avaliacoes',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user