Aggiornamento cataloghi...
This commit is contained in:
@@ -17,11 +17,12 @@ import type {
|
||||
import { shared_consts } from "app/src/common/shared_vuejs";
|
||||
import { useProducts } from "app/src/store/Products";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
name: "CSchedaProdotto",
|
||||
emits: [],
|
||||
emits: ['updateproductmodif'],
|
||||
components: {
|
||||
CTableCupleLabelValue
|
||||
},
|
||||
@@ -37,14 +38,10 @@ export default defineComponent({
|
||||
|
||||
}),
|
||||
},
|
||||
updateproductmodif: {
|
||||
type: Function as PropType<(element: any) => void>,
|
||||
required: false,
|
||||
default: () => () => { },
|
||||
},
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
// Copia locale della lista_prodotti per manipolazione interna
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
|
||||
const globalStore = useGlobalStore()
|
||||
@@ -52,6 +49,11 @@ export default defineComponent({
|
||||
|
||||
const mytab = ref('scheda')
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
const updatetogm = ref(false)
|
||||
const field_updated_toGM = ref('')
|
||||
|
||||
const myproduct = ref<IProduct>({ ...props.modelValue })
|
||||
|
||||
watch(() => props.modelValue, (newVal) => {
|
||||
@@ -95,6 +97,16 @@ export default defineComponent({
|
||||
debounce: "1000",
|
||||
type: costanti.FieldType.number,
|
||||
},
|
||||
{
|
||||
editOn: false,
|
||||
label: "Fatturati ultimi 6 Mesi",
|
||||
table: "productinfos",
|
||||
id: myproduct.value.productInfo._id,
|
||||
rec: myproduct.value.productInfo,
|
||||
mykey: "fatLast6M",
|
||||
debounce: "1000",
|
||||
type: costanti.FieldType.number,
|
||||
},
|
||||
{
|
||||
editOn: false,
|
||||
label: "Venduti",
|
||||
@@ -172,17 +184,6 @@ export default defineComponent({
|
||||
|
||||
function getArrListDescrizioni(): IRecFields[] {
|
||||
const arrlist: IRecFields[] = [
|
||||
{
|
||||
editOn: true,
|
||||
label: "Descrizione breve macro",
|
||||
table: "productinfos",
|
||||
id: myproduct.value.productInfo._id, // ID dinamico, da sostituire con il valore reale
|
||||
rec: myproduct.value.productInfo, // Oggetto dinamico, da sostituire con il valore reale
|
||||
mykey: "descrizione_breve_macro",
|
||||
debounce: "1000",
|
||||
type: costanti.FieldType.string,
|
||||
dense: true,
|
||||
},
|
||||
{
|
||||
editOn: true,
|
||||
label: "Descrizione Trafiletto per Catalogo",
|
||||
@@ -193,6 +194,19 @@ export default defineComponent({
|
||||
debounce: "1000",
|
||||
type: costanti.FieldType.string,
|
||||
dense: true,
|
||||
showall: true,
|
||||
},
|
||||
{
|
||||
editOn: true,
|
||||
label: "Descrizione breve macro",
|
||||
table: "productinfos",
|
||||
id: myproduct.value.productInfo._id, // ID dinamico, da sostituire con il valore reale
|
||||
rec: myproduct.value.productInfo, // Oggetto dinamico, da sostituire con il valore reale
|
||||
mykey: "descrizione_breve_macro",
|
||||
debounce: "1000",
|
||||
type: costanti.FieldType.string,
|
||||
dense: true,
|
||||
showall: true,
|
||||
},
|
||||
{
|
||||
editOn: true,
|
||||
@@ -205,6 +219,7 @@ export default defineComponent({
|
||||
debounce: "1000",
|
||||
type: costanti.FieldType.string,
|
||||
dense: true,
|
||||
showall: true,
|
||||
},
|
||||
{
|
||||
editOn: true,
|
||||
@@ -216,6 +231,7 @@ export default defineComponent({
|
||||
debounce: "1000",
|
||||
type: costanti.FieldType.string,
|
||||
dense: true,
|
||||
showall: true,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -258,6 +274,18 @@ export default defineComponent({
|
||||
type: costanti.FieldType.onlydate,
|
||||
dense: true,
|
||||
},
|
||||
{
|
||||
editOn: true,
|
||||
label: "Argomento",
|
||||
table: "productinfos",
|
||||
id: myproduct.value.productInfo?._id,
|
||||
rec: myproduct.value.productInfo,
|
||||
mykey: "idCatProds",
|
||||
debounce: "1000",
|
||||
type: costanti.FieldType.multiselect,
|
||||
jointable: 'catprods',
|
||||
dense: true,
|
||||
},
|
||||
{
|
||||
editOn: true,
|
||||
label: "Pagine",
|
||||
@@ -334,6 +362,76 @@ export default defineComponent({
|
||||
|
||||
}
|
||||
|
||||
function updateproductmodif(element: any) {
|
||||
console.log('CSCHEDAPRODOTTO updateproductmodif ', element)
|
||||
emit('updateproductmodif', element)
|
||||
}
|
||||
|
||||
async function updateFieldsDataToGM(data: any) {
|
||||
if (myproduct.value) {
|
||||
try {
|
||||
loading.value = true; // Attiva lo stato di caricamento
|
||||
updatetogm.value = true; // Indica che l'aggiornamento è in corso
|
||||
|
||||
// Ottieni lo SKU del prodotto corrente
|
||||
const sku = myproduct.value.productInfo.sku;
|
||||
|
||||
if (!sku) {
|
||||
throw new Error("SKU non disponibile per il prodotto.");
|
||||
}
|
||||
|
||||
// Aggiorna il campo nel database utilizzando setGM_FieldOf_T_Web_Articoli
|
||||
const result = await globalStore.setGM_FieldOf_T_Web_Articoli(
|
||||
sku, // SKU del prodotto
|
||||
data, // Nuovo valore per il campo
|
||||
shared_consts.CmdQueryMs.SET // Comando per l'aggiornamento
|
||||
);
|
||||
|
||||
console.log(`Record aggiornato con successo. Risultato:`, result);
|
||||
} catch (error) {
|
||||
console.error(`Errore durante l'aggiornamento del record:`, error.message);
|
||||
throw new Error(`Errore durante l'aggiornamento del record: ${error.message}`);
|
||||
} finally {
|
||||
loading.value = false; // Disattiva lo stato di caricamento
|
||||
updatetogm.value = false; // Indica che l'aggiornamento è terminato
|
||||
}
|
||||
} else {
|
||||
console.warn("Nessun prodotto selezionato per l'aggiornamento.");
|
||||
}
|
||||
}
|
||||
|
||||
function updateRecordToGM() {
|
||||
|
||||
console.log('myproduct.value.productInfo.catprods', myproduct.value.productInfo.catprods)
|
||||
|
||||
let mydata = {
|
||||
ListaArgomenti: products.getArrayidArgomentoByArridCatProds(myproduct.value.productInfo.idCatProds)
|
||||
}
|
||||
console.log('devo salvare mydata', mydata)
|
||||
updateFieldsDataToGM(mydata)
|
||||
}
|
||||
|
||||
async function updateproduct(load?: boolean) {
|
||||
myproduct.value = await products.getProductById(myproduct.value._id, true)
|
||||
|
||||
}
|
||||
|
||||
async function refreshDataFromGM() {
|
||||
if (myproduct.value) {
|
||||
loading.value = true
|
||||
const ris = await globalStore.updateLocalDbFromGM_T_Web_Articoli(myproduct.value.productInfo.sku!)
|
||||
if (ris) {
|
||||
|
||||
await updateproduct(false)
|
||||
|
||||
tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK'))
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
@@ -348,6 +446,12 @@ export default defineComponent({
|
||||
getArrListStat,
|
||||
mytab,
|
||||
myproduct,
|
||||
updateproductmodif,
|
||||
updatetogm,
|
||||
field_updated_toGM,
|
||||
loading,
|
||||
updateRecordToGM,
|
||||
refreshDataFromGM,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user