etiquetas.js 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.git.md +486 -0
- package/README.md +38 -0
- package/api/api-labels.json +114 -0
- package/api/api.js +316 -0
- package/api/mock/data-volume-id_680.json +64 -0
- package/api/mock/labels-input.json +96 -0
- package/api/mock/labels-part.json +216 -0
- package/api/mock/labels-scrap.json +76 -0
- package/api/mock/labels-thickened.json +96 -0
- package/api/mock/labels-volume.json +56 -0
- package/api/token.txt +1 -0
- package/package.json +43 -0
- package/services/index.js +28 -0
- package/src/constants.js +247 -0
- package/src/createLabel.js +342 -0
- package/src/etiquetas.js +654 -0
- package/src/formatData.js +96 -0
- package/src/formatDataIntegrated.js +498 -0
- package/src/index.js +86 -0
- package/src/label/services/index.js +1201 -0
- package/src/label/services/sortFunctions.js +158 -0
- package/src/label/services/utils.js +280 -0
- package/src/labelWorker.js +123 -0
- package/src/reducer.js +40 -0
- package/src/store.js +55 -0
- package/src/templates.js +139 -0
- package/src/types.ts +575 -0
- package/src/useLabelData.js +99 -0
- package/src/usePrinterStore.js +115 -0
- package/src/variableManager.js +224 -0
package/README.git.md
ADDED
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
# š·ļø Sistema de Etiquetas - Etiquetas.js
|
|
2
|
+
|
|
3
|
+
Sistema completo para geração de etiquetas de peças, tamponamentos, insumos, retalhos e volumes com suporte a impressão e download de PDFs.
|
|
4
|
+
|
|
5
|
+
## š Ćndice
|
|
6
|
+
|
|
7
|
+
- [Instalação](#instalação)
|
|
8
|
+
- [Configuração Inicial](#configuração-inicial)
|
|
9
|
+
- [API Principal](#api-principal)
|
|
10
|
+
- [Tipos de Etiquetas](#tipos-de-etiquetas)
|
|
11
|
+
- [Exemplos de Uso](#exemplos-de-uso)
|
|
12
|
+
- [Templates](#templates)
|
|
13
|
+
- [Testes](#testes)
|
|
14
|
+
- [Estrutura do Projeto](#estrutura-do-projeto)
|
|
15
|
+
- [Sistema Legacy](#sistema-legacy)
|
|
16
|
+
|
|
17
|
+
## š Instalação
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install etiquetas-js
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## āļø Configuração Inicial
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
import etiquetas from 'etiquetas-js';
|
|
27
|
+
|
|
28
|
+
// Inicializar o sistema
|
|
29
|
+
etiquetas.init({
|
|
30
|
+
printerName: 'Zebra ZT230',
|
|
31
|
+
paperSize: 'A4',
|
|
32
|
+
orientation: 'portrait',
|
|
33
|
+
defaultTemplate: 'template-padrao'
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## š API Principal
|
|
38
|
+
|
|
39
|
+
### Inicialização e Configuração
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
// Inicializar sistema
|
|
43
|
+
etiquetas.init(config);
|
|
44
|
+
|
|
45
|
+
// Configurar impressora
|
|
46
|
+
etiquetas.configurePrinter({
|
|
47
|
+
printerName: 'HP LaserJet Pro',
|
|
48
|
+
paperSize: 'A4',
|
|
49
|
+
orientation: 'landscape'
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Verificar status da impressora
|
|
53
|
+
const status = await etiquetas.getPrinterStatus();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Geração de Etiquetas
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
// Gerar etiqueta de peƧa
|
|
60
|
+
const pdfPeca = await etiquetas.makePartLabel(dadosPeca, 'template-peca-padrao');
|
|
61
|
+
|
|
62
|
+
// Gerar etiqueta de tamponamento
|
|
63
|
+
const pdfTamp = await etiquetas.makeTamponamentoLabel(dadosTamp, 'template-tamponamento-padrao');
|
|
64
|
+
|
|
65
|
+
// Gerar etiqueta de insumo
|
|
66
|
+
const pdfInsumo = await etiquetas.makeInsumoLabel(dadosInsumo, 'template-insumo-padrao');
|
|
67
|
+
|
|
68
|
+
// Gerar etiqueta de retalho
|
|
69
|
+
const pdfRetalho = await etiquetas.makeRetalhoLabel(dadosRetalho, 'template-retalho-padrao');
|
|
70
|
+
|
|
71
|
+
// Gerar etiqueta de volume
|
|
72
|
+
const pdfVolume = await etiquetas.makeVolumeLabel(dadosVolume, 'template-volume-padrao');
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### SaĆda e ImpressĆ£o
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
// Download de PDF
|
|
79
|
+
await etiquetas.downloadPDF(pdfBuffer, 'etiqueta.pdf');
|
|
80
|
+
|
|
81
|
+
// Enviar para impressora
|
|
82
|
+
await etiquetas.sendToPrinter(pdfBuffer);
|
|
83
|
+
|
|
84
|
+
// Envio inteligente (imprime se conectado, senão faz download)
|
|
85
|
+
await etiquetas.sendPartLabel(dadosPeca, 'template-peca-padrao');
|
|
86
|
+
await etiquetas.sendTamponamentoLabel(dadosTamp, 'template-tamponamento-padrao');
|
|
87
|
+
await etiquetas.sendInsumoLabel(dadosInsumo, 'template-insumo-padrao');
|
|
88
|
+
await etiquetas.sendRetalhoLabel(dadosRetalho, 'template-retalho-padrao');
|
|
89
|
+
await etiquetas.sendVolumeLabel(dadosVolume, 'template-volume-padrao');
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Geração em Lote
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
// Gerar mĆŗltiplas etiquetas
|
|
96
|
+
const pdfs = await etiquetas.makeBatchLabels(
|
|
97
|
+
[peca1, peca2, peca3],
|
|
98
|
+
'template-peca-padrao',
|
|
99
|
+
'parts'
|
|
100
|
+
);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## š·ļø Tipos de Etiquetas
|
|
104
|
+
|
|
105
|
+
### 1. Etiquetas de PeƧas (`parts`)
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
const dadosPeca = {
|
|
109
|
+
id: "P001",
|
|
110
|
+
codigo: "PID123",
|
|
111
|
+
nome: "Lateral Esquerda",
|
|
112
|
+
tipo: "cabinet",
|
|
113
|
+
largura: 600,
|
|
114
|
+
altura: 800,
|
|
115
|
+
espessura: 15,
|
|
116
|
+
material: {
|
|
117
|
+
nome: "MDF Branco",
|
|
118
|
+
altura: 2750,
|
|
119
|
+
largura: 1830
|
|
120
|
+
},
|
|
121
|
+
bordas: {
|
|
122
|
+
esquerda: "Branco 0.4",
|
|
123
|
+
direita: "Branco 0.4",
|
|
124
|
+
superior: "Branco 0.4",
|
|
125
|
+
inferior: "Sem borda"
|
|
126
|
+
},
|
|
127
|
+
furacao: {
|
|
128
|
+
codigoA: "A001",
|
|
129
|
+
codigoB: "B002",
|
|
130
|
+
ladoUsinagem: "face"
|
|
131
|
+
},
|
|
132
|
+
projeto: {
|
|
133
|
+
id: "PROJ001",
|
|
134
|
+
nome: "Cozinha Moderna",
|
|
135
|
+
cliente: "João Silva"
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 2. Etiquetas de Tamponamentos (`woodwork`)
|
|
141
|
+
|
|
142
|
+
```javascript
|
|
143
|
+
const dadosTamponamento = {
|
|
144
|
+
id: "TAMP-001",
|
|
145
|
+
name: "Tamponamento Lateral",
|
|
146
|
+
ref: "T001",
|
|
147
|
+
qt: 2,
|
|
148
|
+
weight: 1.5,
|
|
149
|
+
material: "MDF 15mm",
|
|
150
|
+
project_id: "PROJ001",
|
|
151
|
+
project_description: "Cozinha Moderna",
|
|
152
|
+
project_customer_name: "João Silva"
|
|
153
|
+
};
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### 3. Etiquetas de Insumos (`inputs`)
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
const dadosInsumo = {
|
|
160
|
+
id: "INS-001",
|
|
161
|
+
name: "Parafuso Phillips 4x30",
|
|
162
|
+
dimensions: "4x30mm",
|
|
163
|
+
qt: 50,
|
|
164
|
+
weight: 0.1,
|
|
165
|
+
ref: "PAR-001",
|
|
166
|
+
manufacturer: "Fixadores SA",
|
|
167
|
+
project_id: "PROJ001",
|
|
168
|
+
project_description: "Cozinha Moderna",
|
|
169
|
+
project_customer_name: "João Silva"
|
|
170
|
+
};
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 4. Etiquetas de Retalhos (`scraps`)
|
|
174
|
+
|
|
175
|
+
```javascript
|
|
176
|
+
const dadosRetalho = {
|
|
177
|
+
scrapId: "RET-001",
|
|
178
|
+
id: "RET-001",
|
|
179
|
+
name: "Retalho MDF Branco",
|
|
180
|
+
ref: "R001",
|
|
181
|
+
qt: 1,
|
|
182
|
+
weight: 2.3,
|
|
183
|
+
date: "2024-01-15T10:30:00Z",
|
|
184
|
+
material: "MDF Branco 15mm",
|
|
185
|
+
project_id: "PROJ001",
|
|
186
|
+
project_description: "Cozinha Moderna",
|
|
187
|
+
project_customer_name: "João Silva"
|
|
188
|
+
};
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 5. Etiquetas de Volumes (`volumes`)
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
const dadosVolume = {
|
|
195
|
+
volume_id: "VOL-001",
|
|
196
|
+
volume_name: "Volume Cozinha - Módulo 1",
|
|
197
|
+
volume_weight: 45.8,
|
|
198
|
+
volume_date: "2024-01-15T10:30:00Z",
|
|
199
|
+
project_id: "PROJ001",
|
|
200
|
+
project_description: "Cozinha Moderna",
|
|
201
|
+
project_customer_name: "João Silva"
|
|
202
|
+
};
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## šØ Templates
|
|
206
|
+
|
|
207
|
+
### Templates DisponĆveis
|
|
208
|
+
|
|
209
|
+
- **PeƧas**: `template-peca-padrao`, `template-peca-compacto`
|
|
210
|
+
- **Tamponamentos**: `template-tamponamento-padrao`
|
|
211
|
+
- **Insumos**: `template-insumo-padrao`
|
|
212
|
+
- **Retalhos**: `template-retalho-padrao`
|
|
213
|
+
- **Volumes**: `template-volume-padrao`
|
|
214
|
+
|
|
215
|
+
### VariƔveis de Template
|
|
216
|
+
|
|
217
|
+
O sistema suporta 44+ variƔveis organizadas por categoria:
|
|
218
|
+
|
|
219
|
+
#### Projeto (5 variƔveis)
|
|
220
|
+
- `{{PROJETO_ID}}`, `{{PROJETO_NOME}}`, `{{PROJETO_OBS}}`
|
|
221
|
+
- `{{CLIENTE_ID}}`, `{{CLIENTE_NOME}}`
|
|
222
|
+
|
|
223
|
+
#### PeƧa (7 variƔveis)
|
|
224
|
+
- `{{PECA_ID}}`, `{{PECA_CODIGO}}`, `{{PECA_NOME}}`, `{{PECA_TIPO}}`
|
|
225
|
+
- `{{LARGURA}}`, `{{ALTURA}}`, `{{ESPESSURA}}`
|
|
226
|
+
|
|
227
|
+
#### Material (3 variƔveis)
|
|
228
|
+
- `{{MN}}` (Nome), `{{MA}}` (Altura), `{{ML}}` (Largura)
|
|
229
|
+
|
|
230
|
+
#### Bordas (4 variƔveis)
|
|
231
|
+
- `{{FE}}` (Esquerda), `{{FD}}` (Direita), `{{FS}}` (Superior), `{{FI}}` (Inferior)
|
|
232
|
+
|
|
233
|
+
#### Furação (3 variÔveis)
|
|
234
|
+
- `{{FURO_A}}`, `{{FURO_B}}`, `{{LADO_USINAGEM}}`
|
|
235
|
+
|
|
236
|
+
#### Volume (4 variƔveis)
|
|
237
|
+
- `{{VOLUME_ID}}`, `{{VOLUME_NOME}}`, `{{VOLUME_PESO}}`, `{{VOLUME_DATA}}`
|
|
238
|
+
|
|
239
|
+
#### Insumo (7 variƔveis)
|
|
240
|
+
- `{{INSUMO_NOME}}`, `{{INSUMO_ID}}`, `{{INSUMO_DIMENSOES}}`
|
|
241
|
+
- `{{INSUMO_QTD}}`, `{{INSUMO_PESO}}`, `{{INSUMO_REF}}`, `{{INSUMO_MARCA}}`
|
|
242
|
+
|
|
243
|
+
#### Tamponamento (5 variƔveis)
|
|
244
|
+
- `{{TAMPONAMENTO_ID}}`, `{{TAMPONAMENTO_REF}}`, `{{TAMPONAMENTO_QT}}`
|
|
245
|
+
- `{{TAMPONAMENTO_PESO}}`, `{{TAMPONAMENTO_NOME}}`
|
|
246
|
+
|
|
247
|
+
#### Retalho (3 variƔveis)
|
|
248
|
+
- `{{RETALHO_ID}}`, `{{DATA_CRIACAO}}`, `{{RETALHO_INDICE}}`
|
|
249
|
+
|
|
250
|
+
## š§Ŗ Testes
|
|
251
|
+
|
|
252
|
+
Execute os testes do sistema:
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# Executar testes completos
|
|
256
|
+
node mock/testes.js
|
|
257
|
+
|
|
258
|
+
# Teste rÔpido - apenas geração de todos os tipos
|
|
259
|
+
node mock/executar-teste-completo.js
|
|
260
|
+
|
|
261
|
+
# Teste especĆfico de todos os tipos
|
|
262
|
+
node mock/teste-todos-tipos.js
|
|
263
|
+
|
|
264
|
+
# Teste otimizado (recomendado para evitar problemas de memória)
|
|
265
|
+
node mock/executar-teste-otimizado.js
|
|
266
|
+
|
|
267
|
+
# Ou importar funƧƵes especĆficas
|
|
268
|
+
import { executarTodosTestes, gerarEtiquetasDeTodosOsTipos } from './mock/testes.js';
|
|
269
|
+
import { gerarEtiquetasOtimizado } from './mock/teste-todos-tipos-otimizado.js';
|
|
270
|
+
|
|
271
|
+
await executarTodosTestes();
|
|
272
|
+
await gerarEtiquetasDeTodosOsTipos();
|
|
273
|
+
await gerarEtiquetasOtimizado(); // Versão otimizada
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Testes IncluĆdos
|
|
277
|
+
|
|
278
|
+
- ā
Status da Impressora
|
|
279
|
+
- ā
Configuração de Impressora
|
|
280
|
+
- ā
Geração de Etiquetas (todos os 5 tipos)
|
|
281
|
+
- ā
Download de PDF
|
|
282
|
+
- ā
Envio Inteligente
|
|
283
|
+
- ā
Geração em Lote
|
|
284
|
+
- š **Teste Completo - Todos os Tipos** (novo!)
|
|
285
|
+
|
|
286
|
+
### Novo Teste: Todos os Tipos de Etiquetas
|
|
287
|
+
|
|
288
|
+
O novo teste `gerarEtiquetasDeTodosOsTipos()` gera uma etiqueta de cada tipo disponĆvel:
|
|
289
|
+
|
|
290
|
+
```javascript
|
|
291
|
+
import { gerarEtiquetasDeTodosOsTipos } from './mock/teste-todos-tipos.js';
|
|
292
|
+
|
|
293
|
+
const resultados = await gerarEtiquetasDeTodosOsTipos();
|
|
294
|
+
console.log(`Sucessos: ${resultados.sucessos}/5`);
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### š Teste Otimizado (Recomendado)
|
|
298
|
+
|
|
299
|
+
Para evitar problemas de memória e heap overflow, use a versão otimizada:
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
# Execução rÔpida
|
|
303
|
+
node mock/executar-teste-otimizado.js
|
|
304
|
+
|
|
305
|
+
# Com mais memória (se necessÔrio)
|
|
306
|
+
node --max-old-space-size=4096 mock/executar-teste-otimizado.js
|
|
307
|
+
|
|
308
|
+
# Com garbage collection
|
|
309
|
+
node --expose-gc mock/executar-teste-otimizado.js
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**Melhorias da versão otimizada:**
|
|
313
|
+
- ā” Timeouts para evitar travamentos
|
|
314
|
+
- 𧹠Limpeza automÔtica de memória
|
|
315
|
+
- š Processamento sequencial com pausas
|
|
316
|
+
- š Dados simplificados para melhor performance
|
|
317
|
+
- ā Tratamento robusto de erros
|
|
318
|
+
|
|
319
|
+
**Tipos testados:**
|
|
320
|
+
- š Etiqueta de PeƧa
|
|
321
|
+
- š§ Etiqueta de Tamponamento
|
|
322
|
+
- š© Etiqueta de Insumo
|
|
323
|
+
- ā»ļø Etiqueta de Retalho
|
|
324
|
+
- š¦ Etiqueta de Volume
|
|
325
|
+
|
|
326
|
+
**Recursos do teste:**
|
|
327
|
+
- ā±ļø Medição de tempo de geração
|
|
328
|
+
- š Relatório detalhado de resultados
|
|
329
|
+
- š¾ Salvamento automĆ”tico dos PDFs em `mock/output/`
|
|
330
|
+
- š EstatĆsticas de performance
|
|
331
|
+
|
|
332
|
+
## š Estrutura do Projeto
|
|
333
|
+
|
|
334
|
+
```
|
|
335
|
+
etiquetas.js/
|
|
336
|
+
āāā src/
|
|
337
|
+
ā āāā etiquetas.js # API principal reorganizada
|
|
338
|
+
ā āāā index.js # ExportaƧƵes principais
|
|
339
|
+
ā āāā constants.js # Constantes e configuraƧƵes
|
|
340
|
+
ā āāā templates.js # Templates de etiquetas
|
|
341
|
+
ā āāā types.ts # DefiniƧƵes TypeScript
|
|
342
|
+
ā āāā formatData.js # Formatação de dados
|
|
343
|
+
ā āāā labelWorker.js # Worker para geração
|
|
344
|
+
ā āāā createLabel.jsx # Geração de PDFs
|
|
345
|
+
āāā mock/
|
|
346
|
+
ā āāā testes.js # Testes completos
|
|
347
|
+
ā āāā exemplo de dados... # Dados de exemplo
|
|
348
|
+
āāā GITHUB_ISSUE.md # Documentação tĆ©cnica
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## š§ ConfiguraƧƵes AvanƧadas
|
|
352
|
+
|
|
353
|
+
### Configuração Personalizada
|
|
354
|
+
|
|
355
|
+
```javascript
|
|
356
|
+
etiquetas.init({
|
|
357
|
+
printerName: 'Zebra ZT230',
|
|
358
|
+
paperSize: 'A4',
|
|
359
|
+
orientation: 'portrait',
|
|
360
|
+
defaultTemplate: 'template-personalizado',
|
|
361
|
+
autoDownloadOnPrinterError: true,
|
|
362
|
+
maxBatchSize: 100,
|
|
363
|
+
cacheEnabled: true,
|
|
364
|
+
debugMode: false
|
|
365
|
+
});
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Tratamento de Erros
|
|
369
|
+
|
|
370
|
+
```javascript
|
|
371
|
+
try {
|
|
372
|
+
const pdf = await etiquetas.makePartLabel(dados, template);
|
|
373
|
+
await etiquetas.sendToPrinter(pdf);
|
|
374
|
+
} catch (error) {
|
|
375
|
+
console.error('Erro:', error.message);
|
|
376
|
+
// Fallback para download
|
|
377
|
+
await etiquetas.downloadPDF(pdf, 'etiqueta-backup.pdf');
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
## š Status e Monitoramento
|
|
382
|
+
|
|
383
|
+
```javascript
|
|
384
|
+
// Verificar status completo
|
|
385
|
+
const status = await etiquetas.getPrinterStatus();
|
|
386
|
+
console.log('Impressora:', status.connected ? 'Conectada' : 'Desconectada');
|
|
387
|
+
console.log('Nome:', status.printerName);
|
|
388
|
+
console.log('Papel:', status.paperSize);
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## š Sistema Legacy
|
|
394
|
+
|
|
395
|
+
### Label Viewer Without UI (Sistema Anterior)
|
|
396
|
+
|
|
397
|
+
Este projeto evoluiu de um fork do `labelViewer` que removia componentes de UI. O sistema legacy ainda estĆ” disponĆvel para compatibilidade:
|
|
398
|
+
|
|
399
|
+
#### Exemplo bƔsico com hook e worker (Legacy)
|
|
400
|
+
|
|
401
|
+
```javascript
|
|
402
|
+
import { useLabelData, createLabelWorker } from './src';
|
|
403
|
+
|
|
404
|
+
function MyComponent() {
|
|
405
|
+
const { getLabelData, config, userPrefs } = useLabelData();
|
|
406
|
+
|
|
407
|
+
const generateLabels = async () => {
|
|
408
|
+
const labelData = getLabelData('parts');
|
|
409
|
+
const worker = createLabelWorker();
|
|
410
|
+
|
|
411
|
+
const params = {
|
|
412
|
+
dataSource: labelData.data,
|
|
413
|
+
labels: labelData.label,
|
|
414
|
+
userPrefs: labelData.userPrefs,
|
|
415
|
+
cacheKey: labelData.cacheKey,
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
try {
|
|
419
|
+
const result = await worker.generateLabels(params, (progress) => {
|
|
420
|
+
console.log(`Progresso: ${progress.percentage}%`);
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
console.log('Labels gerados:', result);
|
|
424
|
+
} catch (error) {
|
|
425
|
+
console.error('Erro ao gerar labels:', error);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
return (
|
|
430
|
+
<button onClick={generateLabels}>
|
|
431
|
+
Gerar Labels
|
|
432
|
+
</button>
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
#### Usando o store (Legacy)
|
|
438
|
+
|
|
439
|
+
```javascript
|
|
440
|
+
import { useLabelStore } from './src';
|
|
441
|
+
|
|
442
|
+
function MyComponent() {
|
|
443
|
+
const {
|
|
444
|
+
pdfInstance,
|
|
445
|
+
isGenerating,
|
|
446
|
+
progress,
|
|
447
|
+
setPDFInstance,
|
|
448
|
+
setGenerating
|
|
449
|
+
} = useLabelStore();
|
|
450
|
+
|
|
451
|
+
// Use o store para gerenciar estado...
|
|
452
|
+
}
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
### Migração do Sistema Legacy
|
|
456
|
+
|
|
457
|
+
Para migrar do sistema legacy para a nova API:
|
|
458
|
+
|
|
459
|
+
```javascript
|
|
460
|
+
// Antes (Legacy)
|
|
461
|
+
import { useLabelData, createLabelWorker } from './src';
|
|
462
|
+
const labelData = getLabelData('parts');
|
|
463
|
+
const worker = createLabelWorker();
|
|
464
|
+
const result = await worker.generateLabels(params);
|
|
465
|
+
|
|
466
|
+
// Depois (Nova API)
|
|
467
|
+
import etiquetas from './src/etiquetas.js';
|
|
468
|
+
etiquetas.init(config);
|
|
469
|
+
const pdf = await etiquetas.makePartLabel(dadosPeca, template);
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
## š¤ Contribuição
|
|
473
|
+
|
|
474
|
+
1. Fork o projeto
|
|
475
|
+
2. Crie uma branch para sua feature (`git checkout -b feature/nova-feature`)
|
|
476
|
+
3. Commit suas mudanƧas (`git commit -am 'Adiciona nova feature'`)
|
|
477
|
+
4. Push para a branch (`git push origin feature/nova-feature`)
|
|
478
|
+
5. Abra um Pull Request
|
|
479
|
+
|
|
480
|
+
## š LicenƧa
|
|
481
|
+
|
|
482
|
+
Este projeto estƔ sob a licenƧa MIT. Veja o arquivo [LICENSE](LICENSE) para mais detalhes.
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
**Desenvolvido com ā¤ļø para facilitar a geração de etiquetas industriais**
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# š·ļø Sistema de Etiquetas - Etiquetas.js
|
|
2
|
+
|
|
3
|
+
Sistema completo para geração de etiquetas de peças, tamponamentos, insumos, retalhos e volumes com suporte a impressão e download de PDFs.
|
|
4
|
+
|
|
5
|
+
## š Recursos Principais
|
|
6
|
+
|
|
7
|
+
- Geração de 5 tipos de etiquetas: Peças, Tamponamentos, Insumos, Retalhos e Volumes
|
|
8
|
+
- Suporte para impressão direta
|
|
9
|
+
- Download em formato PDF
|
|
10
|
+
- Templates personalizƔveis
|
|
11
|
+
- Integração com API para busca de modelos de etiquetas
|
|
12
|
+
|
|
13
|
+
## š Instalação
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install etiquetas.js
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## āļø Uso BĆ”sico
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
import { etiquetas } from 'etiquetas.js';
|
|
23
|
+
|
|
24
|
+
// Inicializar o sistema
|
|
25
|
+
etiquetas.init({
|
|
26
|
+
token:'<jwt-token>'
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Gerar etiqueta de peƧa
|
|
30
|
+
const pdfPeca = await etiquetas.makePartLabel(dadosPeca, '<id-etiqueta>');
|
|
31
|
+
|
|
32
|
+
// Download ou impressão
|
|
33
|
+
await etiquetas.downloadPDF(pdfPeca, '<nome-etiqueta>.pdf');
|
|
34
|
+
// ou
|
|
35
|
+
await etiquetas.sendToPrinter(pdfPeca);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
{
|
|
2
|
+
"namespace":"v1",
|
|
3
|
+
"routes":{
|
|
4
|
+
"\/v1\/labels":{
|
|
5
|
+
"namespace":"v1",
|
|
6
|
+
"methods":[
|
|
7
|
+
"GET"
|
|
8
|
+
],
|
|
9
|
+
"endpoints":[
|
|
10
|
+
{
|
|
11
|
+
"methods":[
|
|
12
|
+
"GET"
|
|
13
|
+
],
|
|
14
|
+
"args":{
|
|
15
|
+
"p":{
|
|
16
|
+
"description":"Page",
|
|
17
|
+
"type":"integer",
|
|
18
|
+
"required":false
|
|
19
|
+
},
|
|
20
|
+
"s":{
|
|
21
|
+
"description":"Search",
|
|
22
|
+
"type":"string",
|
|
23
|
+
"required":false
|
|
24
|
+
},
|
|
25
|
+
"label_id":{
|
|
26
|
+
"description":"ID",
|
|
27
|
+
"type":"integer",
|
|
28
|
+
"required":false
|
|
29
|
+
},
|
|
30
|
+
"label_type":{
|
|
31
|
+
"description":"Tipo",
|
|
32
|
+
"type":"string",
|
|
33
|
+
"enum":[
|
|
34
|
+
"part",
|
|
35
|
+
"scrap",
|
|
36
|
+
"thickened",
|
|
37
|
+
"input",
|
|
38
|
+
"volume"
|
|
39
|
+
],
|
|
40
|
+
"required":false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"_links":{
|
|
46
|
+
"self":[
|
|
47
|
+
{
|
|
48
|
+
"href":"https:\/\/www.dinabox.app\/api\/v1\/labels"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"\/v1\/label":{
|
|
54
|
+
"namespace":"v1",
|
|
55
|
+
"methods":[
|
|
56
|
+
"GET",
|
|
57
|
+
"POST",
|
|
58
|
+
"DELETE"
|
|
59
|
+
],
|
|
60
|
+
"endpoints":[
|
|
61
|
+
{
|
|
62
|
+
"methods":[
|
|
63
|
+
"GET",
|
|
64
|
+
"POST",
|
|
65
|
+
"DELETE"
|
|
66
|
+
],
|
|
67
|
+
"args":{
|
|
68
|
+
"label_id":{
|
|
69
|
+
"description":"ID",
|
|
70
|
+
"type":"integer",
|
|
71
|
+
"required":false
|
|
72
|
+
},
|
|
73
|
+
"label_type":{
|
|
74
|
+
"description":"Tipo",
|
|
75
|
+
"type":"string",
|
|
76
|
+
"enum":[
|
|
77
|
+
"part",
|
|
78
|
+
"scrap",
|
|
79
|
+
"thickened",
|
|
80
|
+
"input",
|
|
81
|
+
"volume"
|
|
82
|
+
],
|
|
83
|
+
"required":false
|
|
84
|
+
},
|
|
85
|
+
"label_name":{
|
|
86
|
+
"description":"Nome",
|
|
87
|
+
"type":"string",
|
|
88
|
+
"required":false
|
|
89
|
+
},
|
|
90
|
+
"label_content":{
|
|
91
|
+
"description":"Conte\u00fado",
|
|
92
|
+
"type":"textarea",
|
|
93
|
+
"required":false
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
"_links":{
|
|
99
|
+
"self":[
|
|
100
|
+
{
|
|
101
|
+
"href":"https:\/\/www.dinabox.app\/api\/v1\/label"
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"_links":{
|
|
108
|
+
"up":[
|
|
109
|
+
{
|
|
110
|
+
"href":"https:\/\/www.dinabox.app\/api\/"
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
}
|