Barton0708's picture
Промт:
8058d85 verified
class EmployeeDatabase {
constructor() {
this.db = JSON.parse(window.localStorage.getItem('employeeDB')) || {
employees: [],
lastUpdate: new Date().toISOString()
};
}
save() {
window.localStorage.setItem('employeeDB', JSON.stringify(this.db));
}
addEmployee(employeeData) {
// Process 1C data
const employee = {
id: this.generateId(),
fullName: employeeData.B,
birthDate: employeeData.N,
hireDate: employeeData.H,
terminationDate: employeeData.I,
tabNumber: employeeData.A,
position: employeeData.C,
rank: employeeData.D,
territory: employeeData.E,
organization: employeeData.F,
department: employeeData.G,
// Add all other fields from the specification
// ...
updatedAt: new Date().toISOString()
};
this.db.employees.push(employee);
this.save();
return employee;
}
updateEmployee(tabNumber, newData) {
const index = this.db.employees.findIndex(e => e.tabNumber === tabNumber);
if (index !== -1) {
this.db.employees[index] = {
...this.db.employees[index],
...newData,
updatedAt: new Date().toISOString()
};
this.save();
return true;
}
return false;
}
findEmployee(tabNumber) {
return this.db.employees.find(e => e.tabNumber === tabNumber);
}
getAllEmployees() {
return this.db.employees;
}
generateId() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
// Add methods for processing different file types
process1CData(workbook) {
// Implementation for processing 1C data
}
processFlightData(workbook) {
// Implementation for processing flight data
}
processPositionData(workbook) {
// Implementation for processing position data
}
}
// Export for use in other files
if (typeof module !== 'undefined' && module.exports) {
module.exports = EmployeeDatabase;
} else {
window.EmployeeDatabase = EmployeeDatabase;
}