// Codul pentru gestionarea comenzilor
class FactoryManagementApp {
constructor() {
this.produse = [
'MBK 70', 'MBK 140', 'MBK 100', 'MBK 200',
'PBK 200', 'PBK 250', 'PBK 300',
'TBK 200', 'TBK 250'
];
this.comenzi = [];
this.comandaCurenta = [];
this.initializareInterfata();
}
initializareInterfata() {
// Creează elementele HTML
const container = document.createElement('div');
container.innerHTML = `
`;
// Adaugă event listeners
container.querySelector('#adaugaProdus').addEventListener('click', () => this.adaugaProdus());
container.querySelector('#verificaComanda').addEventListener('click', () => this.verificaComanda());
container.querySelector('#trimiteFabrica').addEventListener('click', () => this.trimiteFabrica());
// Adaugă containerul în pagină
document.body.appendChild(container);
}
adaugaProdus() {
const produsCurent = document.getElementById('produsCurent').value;
const cantitateCurenta = document.getElementById('cantitateCurenta').value;
if (produsCurent && cantitateCurenta > 0) {
this.comandaCurenta.push({
produs: produsCurent,
cantitate: Number(cantitateCurenta)
});
this.actualizareProduseComanda();
}
}
actualizareProduseComanda() {
const container = document.getElementById('produseComandaCurenta');
container.innerHTML = this.comandaCurenta.map(produs =>
`${produs.produs} - ${produs.cantitate} bucăți
`
).join('');
}
verificaComanda() {
const numeComanda = document.getElementById('numeComanda').value;
if (!numeComanda || this.comandaCurenta.length === 0) {
alert('Completați numele comenzii și adăugați produse');
return;
}
let detaliiComanda = `Comandă: ${numeComanda}\n\n`;
detaliiComanda += this.comandaCurenta.map(produs =>
`${produs.produs} - ${produs.cantitate} bucăți`
).join('\n');
if (confirm(detaliiComanda + '\n\nConfirmați comanda?')) {
this.trimiteFabrica();
}
}
trimiteFabrica() {
const numeComanda = document.getElementById('numeComanda').value;
const comandaNoua = {
id: `CMD-${Math.random().toString(36).substr(2, 9)}`,
numeComanda,
produse: [...this.comandaCurenta],
dataPlasare: new Date()
};
this.comenzi.push(comandaNoua);
// Resetare formular
document.getElementById('numeComanda').value = '';
document.getElementById('produseComandaCurenta').innerHTML = '';
this.comandaCurenta = [];
alert('Comanda a fost trimisă cu succes!');
}
}
// Inițializare aplicație
document.addEventListener('DOMContentLoaded', () => {
new FactoryManagementApp();
});
top of page
bottom of page
Opmerkingen