- posso fare upload dell'immagine del prodotto dalla lista

- corretto import dati
This commit is contained in:
Surya Paolo
2024-03-02 22:53:29 +01:00
parent 1017a3dfe2
commit 789e3fde41
6 changed files with 78 additions and 37 deletions

View File

@@ -151,11 +151,11 @@ function extractArrayDataFromCSV(idapp, rec) {
arrcampi_product = getValoriAndIndice_Product(null);
for (const campoobj of arrcampi_productInfo) {
if (rec.hasOwnProperty(campoobj)) {
let myval = rec[campoobj];
productInfo[campoobj] = myval === 'TRUE' ? true : (myval === 'FALSE' ? false : myval);
if (rec.hasOwnProperty(campoobj.name)) {
let myval = tools.ripulisciCampo(rec[campoobj.name]);
productInfo[campoobj.name] = (myval === 'TRUE' || myval.toUpperCase() === 'SI') ? true : ((myval === 'FALSE' || myval.toUpperCase() === 'NO') ? false : myval);
}
}
for (const campoobj of arrcampi_product) {
@@ -198,13 +198,14 @@ router.post('/import', authenticate, async (req, res) => {
try {
const liste = require('../data/liste');
let dataObjects = null;
if (cmd === shared_consts.Cmd.CITIES_SERVER) {
return await City.insertMany(liste.Comuni).then((ris) => {
return res.status(200).send(true);
});
} else if (cmd === shared_consts.Cmd.INVENTARIO) {
let dataObjects = JSON.parse(`[${data.arrdata}]`);
dataObjects = JSON.parse(`[${data.arrdata}]`);
let updated = 0;
let imported = 0;
let errors = 0;
@@ -222,7 +223,7 @@ router.post('/import', authenticate, async (req, res) => {
} else if (cmd === shared_consts.Cmd.PRODUCTS) {
let dataObjects = JSON.parse(`[${data.arrdata}]`);
dataObjects = JSON.parse(`[${data.arrdata}]`);
let updated = 0;
let imported = 0;
@@ -379,8 +380,15 @@ router.post('/import', authenticate, async (req, res) => {
}
} else if (cmd === shared_consts.Cmd.PRODUCTS_V2) {
let mydata = `[${data.arrdata}]`;
let cleanmydata = mydata.replace(/\n/g, '');
let arrrec = JSON.parse(cleanmydata);
dataObjects = mydata.replace(/\n/g, '');
let arrrec = [];
try {
arrrec = JSON.parse(dataObjects);
} catch (e) {
console.error("Errore durante l'analisi del JSON:", e);
arrrec = [];
}
let updated = 0;
let imported = 0;
let errors = 0;