import products dinamically

This commit is contained in:
Surya Paolo
2024-02-06 20:13:06 +01:00
parent dbcd2aee63
commit 3c0f040d92
53 changed files with 1847 additions and 325 deletions

View File

@@ -32,7 +32,7 @@ export default defineComponent({
const incaricamento = ref(false)
const checkAggiornaQta = ref(false)
const cosafare = ref(shared_consts.Cmd.PRODUCTS)
const cosafare = ref(shared_consts.Cmd.PRODUCTS_V2)
const inputfile = ref('')
const risultato = ref('')
@@ -46,6 +46,10 @@ export default defineComponent({
label: 'Importa Prodotti',
value: shared_consts.Cmd.PRODUCTS
},
{
label: 'Importa Prodotti Versione 2',
value: shared_consts.Cmd.PRODUCTS_V2
},
{
label: 'Importa Inventario',
value: shared_consts.Cmd.INVENTARIO
@@ -375,10 +379,14 @@ export default defineComponent({
let arrCols: any = []
if (skipfirstrow.value) {
arrCols = myarr[0].split(',');
arrCols = myarr[0]
}
console.log('arrCols', arrCols)
if (cmd === shared_consts.Cmd.PRODUCTS_V2) {
skipfirstrow.value = false
}
for (const rec of myarr) {
if (skipfirstrow.value) {
@@ -425,10 +433,12 @@ export default defineComponent({
strris += addfield(col, 'weight', rec, { isnumero: true }); col++;
strris += addfield(col, 'unit', rec, {}); col++;
strris += addfield(col, 'link', rec, {}); col++;
strris += addfield(col, 'perc_iva', rec, {}); col++;
strris += addfield(col, 'price_acquistato', rec, { isnumero: true }); col++;
strris += addfield(col, 'minBuyQty', rec, { isnumero: true }); col++;
strris += addfield(col, 'minStepQty', rec, { isnumero: true }); col++;
strris += addfield(col, 'cat_name', rec, {}); col++;
strris += addfield(col, 'subcat_name', rec, {}); col++;
strris += addfield(col, 'producer_name', rec, {}); col++;
@@ -442,6 +452,20 @@ export default defineComponent({
strris += addfield(col, 'note', rec, {}); col++;
strris += '} '
} else if (cmd === shared_consts.Cmd.PRODUCTS_V2) {
if (!primo) {
strris += ', '
}
strris += '{ '
let col = 0;
strris += addfield(col, 'idapp', rec, { strinput: tools.appid(), primo: true });
for (const mycol of arrCols) {
strris += addfield(col, mycol, rec, {}); col++;
}
strris += '} '
} else if (cmd === shared_consts.Cmd.INVENTARIO) {
if (!primo) {
strris += ', '
@@ -453,7 +477,9 @@ export default defineComponent({
for (const mycol of arrCols) {
strris += addfield(col, mycol, rec, {}); col++;
}
strris += '} '
} else if (cmd === shared_consts.Cmd.CITIES_SERVER) {
strris += '{ \n'
strris += ' _id :' + ind + ',\n'
@@ -474,7 +500,7 @@ export default defineComponent({
if (cmd === shared_consts.Cmd.CITIES_SERVER) {
userStore.importToServerCmd($q, t, cmd, null)
} else if (cmd === shared_consts.Cmd.PRODUCTS) {
} else if ((cmd === shared_consts.Cmd.PRODUCTS) || (cmd === shared_consts.Cmd.PRODUCTS_V2)) {
let options = { aggiornaStockQty: checkAggiornaQta.value }
if (importasulserver.value)
userStore.importToServerCmd($q, t, cmd, { arrdata: strris, options })
@@ -485,19 +511,34 @@ export default defineComponent({
return risultato
}
function reset() {
risultato.value = ''
risraw.value = ''
inputfile.value = ''
}
function loadTextFromFile(ev: any) {
console.log('ev', ev)
const file = ev.target.files[0]
const reader = new FileReader()
try {
console.log('ev', ev)
reset()
if (ev.target && ev.target.files) {
const file = ev.target.files[0]
const reader = new FileReader()
reader.onload = (e: any) => {
reader.onload = (e: any) => {
const testo = e.target.result
const testo = e.target.result
risultato.value = importCmd(cosafare.value, testo)
risultato.value = importCmd(cosafare.value, testo)
}
if (file)
reader.readAsText(file)
}
} catch (e) {
risultato.value = ''
}
reader.readAsText(file)
}
function eseguiCmd() {
@@ -508,11 +549,13 @@ export default defineComponent({
function eseguiCmdProduct() {
let options = { aggiornaStockQty: checkAggiornaQta.value }
userStore.importToServerCmd($q, t, cosafare.value, { arrdata: risultato.value, options })
risultato.value = ''
}
function eseguiCmdInventario() {
let options = { aggiornaStockQty: checkAggiornaQta.value }
userStore.importToServerCmd($q, t, cosafare.value, { arrdata: risultato.value, options })
risultato.value = ''
}
function createProvLink() {