feat: correcao de deteccao de monopeças no conversor e estilizacao de pecas simples na tabela
This commit is contained in:
@@ -618,11 +618,9 @@
|
||||
}
|
||||
|
||||
if (currentAssembly) {
|
||||
const isSubComp =
|
||||
itemMark === '-' ||
|
||||
itemMark.includes('-100') ||
|
||||
itemMark.includes('-10') ||
|
||||
(itemMark.match(/-\d+$/) && parseInt(itemMark.match(/-(\d+)$/)[1], 10) >= 1000);
|
||||
const lastNumberMatch = itemMark.match(/(?:^|-)(\d+)$/);
|
||||
const itemNum = lastNumberMatch ? parseInt(lastNumberMatch[1], 10) : (parseInt(itemMark, 10) || 0);
|
||||
const isSubComp = itemMark === '-' || itemNum >= 1000;
|
||||
|
||||
if (isSubComp) {
|
||||
currentAssembly.isComposed = 'SIM';
|
||||
|
||||
@@ -618,11 +618,9 @@
|
||||
}
|
||||
|
||||
if (currentAssembly) {
|
||||
const isSubComp =
|
||||
itemMark === '-' ||
|
||||
itemMark.includes('-100') ||
|
||||
itemMark.includes('-10') ||
|
||||
(itemMark.match(/-\d+$/) && parseInt(itemMark.match(/-(\d+)$/)[1], 10) >= 1000);
|
||||
const lastNumberMatch = itemMark.match(/(?:^|-)(\d+)$/);
|
||||
const itemNum = lastNumberMatch ? parseInt(lastNumberMatch[1], 10) : (parseInt(itemMark, 10) || 0);
|
||||
const isSubComp = itemMark === '-' || itemNum >= 1000;
|
||||
|
||||
if (isSubComp) {
|
||||
currentAssembly.isComposed = 'SIM';
|
||||
|
||||
@@ -518,12 +518,12 @@ const AdvanceSteelConverterContent: React.FC = () => {
|
||||
}
|
||||
|
||||
if (currentAssembly) {
|
||||
const isSubComp =
|
||||
itemMark === '-' ||
|
||||
isComponente(itemMark) ||
|
||||
itemMark.includes('-100') ||
|
||||
itemMark.includes('-10') ||
|
||||
(itemMark.match(/-\d+$/) && parseInt(itemMark.match(/-(\d+)$/)![1], 10) >= (labels.faixaComponenteMin || 1000));
|
||||
// Extrai o número final da marca do item (ex: de "B134-13-1" -> 1, de "B134-13-1000" -> 1000, de "B133-13-1015" -> 1015, de "1000" -> 1000)
|
||||
const lastNumberMatch = itemMark.match(/(?:^|-)(\d+)$/);
|
||||
const itemNum = lastNumberMatch ? parseInt(lastNumberMatch[1], 10) : (parseInt(itemMark, 10) || 0);
|
||||
|
||||
// Um item é SUBCOMPONENTE apenas se sua numeração de marca for >= faixaComponenteMin (1000) OU se for explicitamente '-'
|
||||
const isSubComp = itemMark === '-' || itemNum >= (labels.faixaComponenteMin || 1000);
|
||||
|
||||
if (isSubComp) {
|
||||
currentAssembly.isComposed = 'SIM';
|
||||
|
||||
@@ -72,8 +72,8 @@ export function TableHeaderSortable({
|
||||
<SortButton field="prioridade">Prioridade</SortButton>
|
||||
</TableHead>
|
||||
|
||||
<TableHead className="w-16 px-2 text-center">
|
||||
<SortButton field="tem_componentes">Tipo / {labels.componenteLabel}</SortButton>
|
||||
<TableHead className="w-24 px-2 text-center">
|
||||
<SortButton field="tem_componentes">Componentes</SortButton>
|
||||
</TableHead>
|
||||
|
||||
<TableHead className="w-12 px-2 text-right">
|
||||
|
||||
@@ -13,7 +13,8 @@ import {
|
||||
ChevronDown,
|
||||
Layers,
|
||||
Loader2,
|
||||
ExternalLink
|
||||
ExternalLink,
|
||||
Minus
|
||||
} from 'lucide-react';
|
||||
import { Peca } from '@/hooks/usePecas';
|
||||
import { useComponentesPeca } from '@/hooks/useComponentesPeca';
|
||||
@@ -110,11 +111,14 @@ export function TableRow({
|
||||
<PriorityBadge prioridade={peca.prioridade as any} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell className="w-16 px-2 text-center">
|
||||
<div className="flex justify-center">
|
||||
<TableCell className="w-24 px-2 text-center">
|
||||
<div className="flex justify-center items-center">
|
||||
{!peca.tem_componentes ? (
|
||||
<div className="flex items-center justify-center w-5 h-5 bg-green-500 rounded-full shadow-sm" title="Monopeça (sem componentes)">
|
||||
<Check className="h-3 w-3 text-white font-bold" />
|
||||
<div
|
||||
className="flex items-center justify-center w-5 h-5 rounded-full bg-slate-800/90 border border-slate-700 text-slate-400 shadow-sm"
|
||||
title="Peça única (sem componentes)"
|
||||
>
|
||||
<Minus className="h-3 w-3 text-slate-400 font-bold" />
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
|
||||
+12
-4
@@ -567,15 +567,17 @@ export function usePecas() {
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Inserir/Sincronizar Componentes
|
||||
// 4. Inserir/Sincronizar Componentes (Limpa resíduos se a peça virou simples ou foi reimportada)
|
||||
let totalComponentesInseridos = 0;
|
||||
if (componentesMap.size > 0) {
|
||||
console.log('🔧 Inserindo e sincronizando componentes...');
|
||||
|
||||
for (const [pecaKey, componentes] of componentesMap.entries()) {
|
||||
for (const peca of pecasParaProcessar) {
|
||||
const pecaKey = `${peca.of_number || ''}-${peca.etapa_fase || ''}-${peca.marca || ''}`;
|
||||
const pecaId = pecaIdResolvedMap.get(pecaKey);
|
||||
const componentes = componentesMap.get(pecaKey) || [];
|
||||
|
||||
if (pecaId && componentes.length > 0) {
|
||||
if (pecaId) {
|
||||
if (componentes.length > 0) {
|
||||
// Limpar componentes antigos desta peça para atualizar de forma limpa
|
||||
await supabase
|
||||
.from('componentes_peca')
|
||||
@@ -596,6 +598,12 @@ export function usePecas() {
|
||||
} else {
|
||||
totalComponentesInseridos += componentesComPecaId.length;
|
||||
}
|
||||
} else {
|
||||
// Peça simples sem componentes: limpar componentes residuais antigos caso existissem
|
||||
await supabase
|
||||
.from('componentes_peca')
|
||||
.delete()
|
||||
.eq('peca_id', pecaId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user