@@ -0,0 +1,416 @@
|
||||
import { Head, Link, router, useForm } from '@inertiajs/react';
|
||||
import {
|
||||
PageTitle,
|
||||
Panel,
|
||||
FormErrors,
|
||||
controlClass,
|
||||
} from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useProcurementPreparationIdentity } from '@/hooks/use-procurement-preparation-identity';
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
import { hasPreparationChanges } from '@/lib/requisition-history';
|
||||
|
||||
type Order = {
|
||||
id: number;
|
||||
version: number;
|
||||
created_at: string;
|
||||
reason: string;
|
||||
data: {
|
||||
type: string;
|
||||
reference: string;
|
||||
utilisation_location: string;
|
||||
description: string;
|
||||
department_id: number;
|
||||
};
|
||||
snapshot: {
|
||||
author: { name: string };
|
||||
department: { name: string };
|
||||
policy: { data: { mode: string } };
|
||||
};
|
||||
};
|
||||
type LinkRecord = {
|
||||
id: number;
|
||||
version: number;
|
||||
data: { requisition_item_id: number };
|
||||
snapshot: { source: Order };
|
||||
};
|
||||
type Props = {
|
||||
policy: { id: number; version: number; data: { mode: string } } | null;
|
||||
canConfigure: boolean;
|
||||
allowedTypes: string[];
|
||||
departments: { id: number; name: string }[];
|
||||
orders: {
|
||||
data: Order[];
|
||||
prev_page_url: string | null;
|
||||
next_page_url: string | null;
|
||||
};
|
||||
requisition: { id: number; number: string; status: string } | null;
|
||||
items: { id: number; description: string }[];
|
||||
links: LinkRecord[];
|
||||
canLink: boolean;
|
||||
};
|
||||
const labels: Record<string, string> = {
|
||||
production: 'Produção',
|
||||
maintenance: 'Manutenção',
|
||||
};
|
||||
type Field = {
|
||||
name: string;
|
||||
label: string;
|
||||
choices?: { value: string; label: string }[];
|
||||
long?: boolean;
|
||||
};
|
||||
|
||||
export default function OperationalOrders(props: Props) {
|
||||
const identity = useProcurementPreparationIdentity(
|
||||
`operational-orders:${props.policy?.id ?? 0}:${props.policy?.version ?? 0}:${props.allowedTypes.join(',')}:${props.canConfigure}:${props.requisition?.id ?? 0}:${props.canLink}`,
|
||||
);
|
||||
return <Workspace key={identity} {...props} identity={identity} />;
|
||||
}
|
||||
function Workspace(props: Props & { identity: string }) {
|
||||
const base = '/ordens-operacionais';
|
||||
return (
|
||||
<>
|
||||
<Head title="Ordens de produção e manutenção" />
|
||||
<div className="mx-auto flex w-full max-w-6xl flex-col gap-6 p-5 lg:p-8">
|
||||
<PageTitle
|
||||
eyebrow="Compras"
|
||||
title="Ordens de produção e manutenção"
|
||||
description="Registe a necessidade no local de utilização ou através do procurement, conforme a configuração da empresa. A ordem de origem acompanha a compra."
|
||||
/>
|
||||
{props.requisition && (
|
||||
<p>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/requisicoes/${props.requisition.id}`}
|
||||
>
|
||||
Voltar à {props.requisition.number}
|
||||
</Link>{' '}
|
||||
·{' '}
|
||||
<Link className="underline" href={base}>
|
||||
Cadastro das ordens
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
<Panel
|
||||
title="Origem das ordens"
|
||||
description="A configuração altera quem pode registar novas ordens. Preserva as ordens existentes e não atribui competências a pessoas."
|
||||
>
|
||||
<p className="mb-4 text-sm">
|
||||
{!props.policy
|
||||
? 'A empresa ainda não definiu a origem das ordens.'
|
||||
: props.policy.data.mode === 'utilisation'
|
||||
? 'Nos locais de utilização: responsável da produção ou chefe de oficina, com competência atribuída pela empresa.'
|
||||
: 'No procurement: o agente regista as ordens para os locais ainda não abrangidos pela aplicação.'}
|
||||
</p>
|
||||
{props.canConfigure && (
|
||||
<DraftForm
|
||||
identity={`${props.identity}:policy`}
|
||||
url={`${base}/configuracao`}
|
||||
initial={{
|
||||
version: String(props.policy?.version ?? 0),
|
||||
mode: props.policy?.data.mode ?? '',
|
||||
reason: '',
|
||||
}}
|
||||
fields={[
|
||||
{
|
||||
name: 'mode',
|
||||
label: 'Modo de registo',
|
||||
choices: [
|
||||
{
|
||||
value: 'utilisation',
|
||||
label: 'Nos locais de utilização',
|
||||
},
|
||||
{
|
||||
value: 'procurement',
|
||||
label: 'Pelo agente de procurement',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'reason',
|
||||
label: 'Fundamento da configuração',
|
||||
long: true,
|
||||
},
|
||||
]}
|
||||
submit="Guardar origem das novas ordens"
|
||||
/>
|
||||
)}
|
||||
</Panel>
|
||||
{props.allowedTypes.length > 0 && (
|
||||
<Panel
|
||||
title="Registar ordem"
|
||||
description="O autor e o modo de origem são registados automaticamente. O documento original permanece no histórico."
|
||||
>
|
||||
<DraftForm
|
||||
identity={`${props.identity}:new`}
|
||||
url={base}
|
||||
initial={{
|
||||
type:
|
||||
props.allowedTypes.length === 1
|
||||
? props.allowedTypes[0]
|
||||
: '',
|
||||
reference: '',
|
||||
department_id:
|
||||
props.departments.length === 1
|
||||
? String(props.departments[0].id)
|
||||
: '',
|
||||
utilisation_location: '',
|
||||
description: '',
|
||||
reason: '',
|
||||
policy_version: String(
|
||||
props.policy?.version ?? 0,
|
||||
),
|
||||
}}
|
||||
fields={[
|
||||
{
|
||||
name: 'type',
|
||||
label: 'Tipo de ordem',
|
||||
choices: props.allowedTypes.map((type) => ({
|
||||
value: type,
|
||||
label: labels[type],
|
||||
})),
|
||||
},
|
||||
{
|
||||
name: 'reference',
|
||||
label: 'Referência da ordem',
|
||||
},
|
||||
{
|
||||
name: 'department_id',
|
||||
label: 'Departamento de utilização',
|
||||
choices: props.departments.map(
|
||||
(department) => ({
|
||||
value: String(department.id),
|
||||
label: department.name,
|
||||
}),
|
||||
),
|
||||
},
|
||||
{
|
||||
name: 'utilisation_location',
|
||||
label: 'Local de utilização',
|
||||
},
|
||||
{
|
||||
name: 'description',
|
||||
label: 'Trabalho ou produção a executar',
|
||||
long: true,
|
||||
},
|
||||
{
|
||||
name: 'reason',
|
||||
label: 'Fundamento do registo',
|
||||
long: true,
|
||||
},
|
||||
]}
|
||||
submit="Registar ordem"
|
||||
/>
|
||||
</Panel>
|
||||
)}
|
||||
<Panel
|
||||
title="Ordens registadas"
|
||||
description="A lista respeita a empresa e o departamento aplicável. Uma ligação utiliza a versão original seleccionada."
|
||||
>
|
||||
{props.orders.data.length === 0 && (
|
||||
<p>Não há ordens disponíveis neste âmbito.</p>
|
||||
)}
|
||||
<ul className="space-y-4">
|
||||
{props.orders.data.map((order) => (
|
||||
<li className="rounded border p-4" key={order.id}>
|
||||
<p className="font-semibold">
|
||||
{labels[order.data.type]} ·{' '}
|
||||
{order.data.reference}
|
||||
</p>
|
||||
<p className="text-sm">
|
||||
{order.snapshot.department.name} ·{' '}
|
||||
{order.data.utilisation_location} ·{' '}
|
||||
{order.snapshot.author.name}
|
||||
</p>
|
||||
<p className="mt-2 text-sm whitespace-pre-wrap">
|
||||
{order.data.description}
|
||||
</p>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<div className="mt-4 flex gap-4">
|
||||
{props.orders.prev_page_url && (
|
||||
<Link
|
||||
preserveState
|
||||
preserveScroll
|
||||
href={props.orders.prev_page_url}
|
||||
>
|
||||
Anterior
|
||||
</Link>
|
||||
)}
|
||||
{props.orders.next_page_url && (
|
||||
<Link
|
||||
preserveState
|
||||
preserveScroll
|
||||
href={props.orders.next_page_url}
|
||||
>
|
||||
Seguinte
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</Panel>
|
||||
{props.requisition &&
|
||||
props.items.map((item) => {
|
||||
const link = props.links.find(
|
||||
(link) => link.data.requisition_item_id === item.id,
|
||||
);
|
||||
return (
|
||||
<Panel
|
||||
key={item.id}
|
||||
title={item.description}
|
||||
description={
|
||||
link
|
||||
? `Ordem ligada: ${link.snapshot.source.data.reference} · ${labels[link.snapshot.source.data.type]}`
|
||||
: 'Sem ordem de origem ligada.'
|
||||
}
|
||||
>
|
||||
{props.canLink && (
|
||||
<DraftForm
|
||||
key={`${item.id}:${link?.version ?? 0}`}
|
||||
identity={`${props.identity}:link:${item.id}:${link?.version ?? 0}`}
|
||||
url={`/requisicoes/${props.requisition?.id}/ordens-operacionais`}
|
||||
initial={{
|
||||
item_id: String(item.id),
|
||||
order_id: '',
|
||||
version: String(link?.version ?? 0),
|
||||
reason: '',
|
||||
}}
|
||||
fields={[
|
||||
{
|
||||
name: 'order_id',
|
||||
label: 'Ordem de origem',
|
||||
choices: props.orders.data.map(
|
||||
(order) => ({
|
||||
value: String(order.id),
|
||||
label: `${labels[order.data.type]} · ${order.data.reference} · ${order.data.utilisation_location}`,
|
||||
}),
|
||||
),
|
||||
},
|
||||
{
|
||||
name: 'reason',
|
||||
label: 'Fundamento da ligação',
|
||||
long: true,
|
||||
},
|
||||
]}
|
||||
submit="Ligar ordem à linha"
|
||||
/>
|
||||
)}
|
||||
</Panel>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
function DraftForm({
|
||||
identity,
|
||||
url,
|
||||
initial,
|
||||
fields,
|
||||
submit,
|
||||
}: {
|
||||
identity: string;
|
||||
url: string;
|
||||
initial: Record<string, string>;
|
||||
fields: Field[];
|
||||
submit: string;
|
||||
}) {
|
||||
const form = useForm<Record<string, string>>(`${identity}:form`, {
|
||||
...initial,
|
||||
operation_key: crypto.randomUUID(),
|
||||
});
|
||||
const dirty = hasPreparationChanges(
|
||||
{ ...initial, operation_key: '' },
|
||||
{ ...form.data, operation_key: '' },
|
||||
);
|
||||
const ref = usePreparationDirty(dirty);
|
||||
return (
|
||||
<form
|
||||
ref={ref}
|
||||
data-preparation-dirty={dirty ? 'true' : 'false'}
|
||||
className="space-y-4"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
form.post(url, {
|
||||
preserveScroll: true,
|
||||
preserveState: true,
|
||||
onSuccess: () => {
|
||||
const cleared = {
|
||||
...initial,
|
||||
operation_key: crypto.randomUUID(),
|
||||
};
|
||||
form.setData(cleared);
|
||||
form.clearErrors();
|
||||
router.remember(cleared, `${identity}:form:data`);
|
||||
router.remember({}, `${identity}:form:errors`);
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={form.errors} />
|
||||
{fields.map((field) => (
|
||||
<label key={field.name} className="block space-y-1 text-sm">
|
||||
{field.label}
|
||||
{field.choices ? (
|
||||
<select
|
||||
className={controlClass}
|
||||
required
|
||||
value={form.data[field.name] ?? ''}
|
||||
onChange={(event) =>
|
||||
form.setData(field.name, event.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Seleccione</option>
|
||||
{form.data[field.name] &&
|
||||
!field.choices.some(
|
||||
(choice) =>
|
||||
choice.value === form.data[field.name],
|
||||
) && (
|
||||
<option value={form.data[field.name]}>
|
||||
Selecção preservada de outra página —
|
||||
confira a ordem antes de submeter
|
||||
</option>
|
||||
)}
|
||||
{field.choices.map((choice) => (
|
||||
<option key={choice.value} value={choice.value}>
|
||||
{choice.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
) : field.long ? (
|
||||
<textarea
|
||||
className={`${controlClass} h-24 py-3`}
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={4000}
|
||||
value={form.data[field.name] ?? ''}
|
||||
onChange={(event) =>
|
||||
form.setData(field.name, event.target.value)
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<input
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={3}
|
||||
maxLength={field.name === 'reference' ? 120 : 300}
|
||||
value={form.data[field.name] ?? ''}
|
||||
onChange={(event) =>
|
||||
form.setData(field.name, event.target.value)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</label>
|
||||
))}
|
||||
<Button disabled={form.processing}>{submit}</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
OperationalOrders.layout = {
|
||||
breadcrumbs: [
|
||||
{
|
||||
title: 'Ordens de produção e manutenção',
|
||||
href: '/ordens-operacionais',
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -67,6 +67,7 @@ export default function Show({
|
||||
importTariffsReady = false,
|
||||
importEstimatesReady = false,
|
||||
capitalRegisterReady = false,
|
||||
operationalOrdersReady = false,
|
||||
expiryReady = false,
|
||||
accountsReady = false,
|
||||
duplicateHints = null,
|
||||
@@ -81,6 +82,7 @@ export default function Show({
|
||||
} | null;
|
||||
importEstimatesReady?: boolean;
|
||||
capitalRegisterReady?: boolean;
|
||||
operationalOrdersReady?: boolean;
|
||||
expiryReady?: boolean;
|
||||
accountsReady?: boolean;
|
||||
importTariffsReady?: boolean;
|
||||
@@ -195,6 +197,14 @@ export default function Show({
|
||||
</Link>
|
||||
</Button>
|
||||
)}
|
||||
{operationalOrdersReady && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/requisicoes/${r.id}/ordens-operacionais`}
|
||||
>
|
||||
Ligar artigos a ordens de produção ou manutenção
|
||||
</Link>
|
||||
)}
|
||||
{accountsReady && (
|
||||
<Button asChild variant="outline">
|
||||
<Link href={`/requisicoes/${r.id}/contas`}>
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
import { Head, Link, router, useForm } from '@inertiajs/react';
|
||||
import {
|
||||
Panel,
|
||||
PageTitle,
|
||||
FormErrors,
|
||||
controlClass,
|
||||
} from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
ComparisonPolicySummary,
|
||||
type ComparisonPolicy,
|
||||
} from '@/components/comparison-policy-summary';
|
||||
import { useProcurementPreparationIdentity } from '@/hooks/use-procurement-preparation-identity';
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
import { hasPreparationChanges } from '@/lib/requisition-history';
|
||||
|
||||
type Item = {
|
||||
id: number;
|
||||
description: string;
|
||||
catalogue_snapshot?: { stock_item_id?: number } | null;
|
||||
};
|
||||
type Policy = {
|
||||
id: number;
|
||||
version: number;
|
||||
stock_item_id: number;
|
||||
item: { name: string; unit: string };
|
||||
warehouse: { name: string };
|
||||
minimum_stock_milli: number;
|
||||
usage_context: string | null;
|
||||
};
|
||||
type Evidence = {
|
||||
id: number;
|
||||
version: number;
|
||||
reason: string;
|
||||
data: { requisition_item_id: number };
|
||||
snapshot: {
|
||||
stock_policy: {
|
||||
minimum_stock_milli: number;
|
||||
usage_context: string | null;
|
||||
warehouse: { name: string };
|
||||
};
|
||||
availability: { free_milli: number | null };
|
||||
author: { name: string };
|
||||
};
|
||||
};
|
||||
type Props = {
|
||||
requisition: {
|
||||
id: number;
|
||||
number: string;
|
||||
priority: string;
|
||||
justification: string;
|
||||
};
|
||||
cycle: number;
|
||||
canRecord: boolean;
|
||||
items: Item[];
|
||||
comparisonPolicy: ComparisonPolicy;
|
||||
policies: {
|
||||
data: Policy[];
|
||||
prev_page_url: string | null;
|
||||
next_page_url: string | null;
|
||||
};
|
||||
evidence: Evidence[];
|
||||
eligible: Evidence[];
|
||||
};
|
||||
|
||||
export default function UrgentStock(props: Props) {
|
||||
const identity = useProcurementPreparationIdentity(
|
||||
`urgent-stock:${props.requisition.id}:${props.cycle}:${props.comparisonPolicy.revision}`,
|
||||
);
|
||||
const enabled =
|
||||
props.requisition.priority === 'urgent' &&
|
||||
props.comparisonPolicy.urgent_minimum_proposals !== undefined;
|
||||
return (
|
||||
<>
|
||||
<Head title="Stock mínimo e cotações urgentes" />
|
||||
<div className="mx-auto flex w-full max-w-5xl flex-col gap-6 p-5 lg:p-8">
|
||||
<PageTitle
|
||||
eyebrow={props.requisition.number}
|
||||
title="Stock mínimo e cotações urgentes"
|
||||
description="Documente a política de stock aplicável ao artigo e ao local de utilização. O servidor confere se o mínimo foi atingido; orçamento, avaliações e aprovações mantêm-se."
|
||||
/>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/requisicoes/${props.requisition.id}/cotacoes`}
|
||||
>
|
||||
Voltar às cotações
|
||||
</Link>
|
||||
<Panel title="Regra preservada na requisição">
|
||||
<ComparisonPolicySummary policy={props.comparisonPolicy} />
|
||||
<p className="mt-3 text-sm">
|
||||
{!enabled
|
||||
? 'Esta requisição não permite redução urgente de cotações.'
|
||||
: props.eligible.length > 0
|
||||
? 'Stock mínimo documentado para todas as linhas deste ciclo. A comparação pode aplicar o número urgente configurado.'
|
||||
: 'Mantém-se o número normal de propostas enquanto faltar a conferência válida de alguma linha.'}
|
||||
</p>
|
||||
</Panel>
|
||||
{props.items.map((item) => {
|
||||
const previous = props.evidence.find(
|
||||
(record) => record.data.requisition_item_id === item.id,
|
||||
);
|
||||
const policies = props.policies.data.filter(
|
||||
(policy) =>
|
||||
policy.stock_item_id ===
|
||||
item.catalogue_snapshot?.stock_item_id,
|
||||
);
|
||||
return (
|
||||
<Panel title={item.description} key={item.id}>
|
||||
{previous && (
|
||||
<div className="mb-4 space-y-1 text-sm">
|
||||
<p>
|
||||
Conferência #{previous.id} ·{' '}
|
||||
{previous.snapshot.author.name} ·{' '}
|
||||
{
|
||||
previous.snapshot.stock_policy
|
||||
.warehouse.name
|
||||
}
|
||||
</p>
|
||||
<p>
|
||||
Mínimo documentado:{' '}
|
||||
{previous.snapshot.stock_policy
|
||||
.minimum_stock_milli / 1000}
|
||||
; stock livre no momento:{' '}
|
||||
{previous.snapshot.availability
|
||||
.free_milli === null
|
||||
? 'Indeterminado'
|
||||
: previous.snapshot.availability
|
||||
.free_milli / 1000}
|
||||
.
|
||||
</p>
|
||||
{previous.snapshot.stock_policy
|
||||
.usage_context && (
|
||||
<p>
|
||||
{
|
||||
previous.snapshot.stock_policy
|
||||
.usage_context
|
||||
}
|
||||
</p>
|
||||
)}
|
||||
<p>{previous.reason}</p>
|
||||
</div>
|
||||
)}
|
||||
{enabled && props.canRecord && (
|
||||
<EvidenceForm
|
||||
key={`${identity}:${item.id}:${previous?.version ?? 0}`}
|
||||
identity={`${identity}:${item.id}:${previous?.version ?? 0}`}
|
||||
requestId={props.requisition.id}
|
||||
itemId={item.id}
|
||||
version={previous?.version ?? 0}
|
||||
policies={policies}
|
||||
/>
|
||||
)}
|
||||
</Panel>
|
||||
);
|
||||
})}
|
||||
<div className="flex gap-4">
|
||||
{props.policies.prev_page_url && (
|
||||
<Link
|
||||
preserveState
|
||||
preserveScroll
|
||||
href={props.policies.prev_page_url}
|
||||
>
|
||||
Políticas anteriores
|
||||
</Link>
|
||||
)}
|
||||
{props.policies.next_page_url && (
|
||||
<Link
|
||||
preserveState
|
||||
preserveScroll
|
||||
href={props.policies.next_page_url}
|
||||
>
|
||||
Mais políticas
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
function EvidenceForm({
|
||||
identity,
|
||||
requestId,
|
||||
itemId,
|
||||
version,
|
||||
policies,
|
||||
}: {
|
||||
identity: string;
|
||||
requestId: number;
|
||||
itemId: number;
|
||||
version: number;
|
||||
policies: Policy[];
|
||||
}) {
|
||||
const initial = {
|
||||
item_id: itemId,
|
||||
policy_id: policies.length === 1 ? String(policies[0].id) : '',
|
||||
version,
|
||||
reason: '',
|
||||
};
|
||||
const form = useForm(`${identity}:form`, {
|
||||
...initial,
|
||||
operation_key: crypto.randomUUID(),
|
||||
});
|
||||
const dirty = hasPreparationChanges(
|
||||
{ ...initial, operation_key: '' },
|
||||
{ ...form.data, operation_key: '' },
|
||||
);
|
||||
const ref = usePreparationDirty(dirty);
|
||||
return (
|
||||
<form
|
||||
ref={ref}
|
||||
data-preparation-dirty={dirty ? 'true' : 'false'}
|
||||
className="space-y-4"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
form.post(`/requisicoes/${requestId}/urgencia-stock`, {
|
||||
preserveScroll: true,
|
||||
preserveState: true,
|
||||
onSuccess: () => {
|
||||
const cleared = {
|
||||
...initial,
|
||||
operation_key: crypto.randomUUID(),
|
||||
};
|
||||
form.setData(cleared);
|
||||
form.clearErrors();
|
||||
router.remember(cleared, `${identity}:form:data`);
|
||||
router.remember({}, `${identity}:form:errors`);
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={form.errors} />
|
||||
<label className="block space-y-1 text-sm">
|
||||
Política de mínimo aplicável ao artigo/local
|
||||
<select
|
||||
className={controlClass}
|
||||
required
|
||||
value={form.data.policy_id}
|
||||
onChange={(event) =>
|
||||
form.setData('policy_id', event.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Seleccione a política aprovada</option>
|
||||
{form.data.policy_id &&
|
||||
!policies.some(
|
||||
(policy) =>
|
||||
String(policy.id) === form.data.policy_id,
|
||||
) && (
|
||||
<option value={form.data.policy_id}>
|
||||
Política preservada de outra página — confira a
|
||||
fonte
|
||||
</option>
|
||||
)}
|
||||
{policies.map((policy) => (
|
||||
<option key={policy.id} value={policy.id}>
|
||||
{policy.warehouse.name} · mínimo{' '}
|
||||
{policy.minimum_stock_milli / 1000}{' '}
|
||||
{policy.item.unit} ·{' '}
|
||||
{policy.usage_context ?? policy.item.name} · versão{' '}
|
||||
{policy.version}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="block space-y-1 text-sm">
|
||||
Fundamento da urgência e da utilização desta política
|
||||
<textarea
|
||||
className={`${controlClass} h-24 py-3`}
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={4000}
|
||||
value={form.data.reason}
|
||||
onChange={(event) =>
|
||||
form.setData('reason', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<Button
|
||||
disabled={
|
||||
form.processing ||
|
||||
(!form.data.policy_id && policies.length === 0)
|
||||
}
|
||||
>
|
||||
Conferir stock mínimo
|
||||
</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
UrgentStock.layout = {
|
||||
breadcrumbs: [{ title: 'Stock mínimo e cotações urgentes', href: '#' }],
|
||||
};
|
||||
Reference in New Issue
Block a user