2025-04-04 18:15:14 +02:00
|
|
|
import { PropType, computed, defineComponent, onMounted, ref, watch } from "vue";
|
|
|
|
|
import draggable from 'vuedraggable'
|
|
|
|
|
|
|
|
|
|
import { tools } from '@tools'
|
|
|
|
|
|
|
|
|
|
import { useGlobalStore } from '@src/store/globalStore'
|
|
|
|
|
|
|
|
|
|
import { CTableCupleLabelValue } from '@src/components/CTableCupleLabelValue'
|
|
|
|
|
|
|
|
|
|
import { costanti } from '@costanti'
|
|
|
|
|
|
|
|
|
|
import type {
|
|
|
|
|
IMyScheda,
|
|
|
|
|
IProduct,
|
|
|
|
|
IRecFields
|
|
|
|
|
} from '@src/model';
|
|
|
|
|
import { shared_consts } from "app/src/common/shared_vuejs";
|
|
|
|
|
import { useProducts } from "app/src/store/Products";
|
|
|
|
|
import { useI18n } from "vue-i18n";
|
2025-04-11 18:49:42 +02:00
|
|
|
import { useQuasar } from "quasar";
|
2025-04-04 18:15:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
name: "CSchedaProdotto",
|
2025-04-11 18:49:42 +02:00
|
|
|
emits: ['updateproductmodif'],
|
2025-04-04 18:15:14 +02:00
|
|
|
components: {
|
|
|
|
|
CTableCupleLabelValue
|
|
|
|
|
},
|
|
|
|
|
props: {
|
|
|
|
|
modelValue: {
|
|
|
|
|
type: Object as PropType<IProduct>,
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
scheda: {
|
|
|
|
|
type: Object as PropType<IMyScheda>,
|
|
|
|
|
required: false,
|
|
|
|
|
default: () => ({
|
|
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
setup(props, { emit }) {
|
|
|
|
|
// Copia locale della lista_prodotti per manipolazione interna
|
2025-04-11 18:49:42 +02:00
|
|
|
const $q = useQuasar()
|
2025-04-04 18:15:14 +02:00
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
|
|
|
const globalStore = useGlobalStore()
|
|
|
|
|
const products = useProducts()
|
|
|
|
|
|
|
|
|
|
const mytab = ref('scheda')
|
|
|
|
|
|
2025-04-11 18:49:42 +02:00
|
|
|
const loading = ref(false)
|
|
|
|
|
|
|
|
|
|
const updatetogm = ref(false)
|
|
|
|
|
const field_updated_toGM = ref('')
|
|
|
|
|
|
2025-04-04 18:15:14 +02:00
|
|
|
const myproduct = ref<IProduct>({ ...props.modelValue })
|
|
|
|
|
|
|
|
|
|
watch(() => props.modelValue, (newVal) => {
|
|
|
|
|
myproduct.value = { ...newVal };
|
|
|
|
|
}, { deep: false });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function mounted() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
// Aggiorna la copia locale quando il prop cambia
|
|
|
|
|
watch(
|
|
|
|
|
() => props.lista_prodotti,
|
|
|
|
|
(newVal) => {
|
|
|
|
|
internalProducts.value = [...newVal];
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function getArrListStat(): IRecFields[] {
|
|
|
|
|
const arrlist: IRecFields[] = [
|
|
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Fatturati",
|
|
|
|
|
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: "totFat",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.number,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Fatturati ultimi 3 Mesi",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
|
|
|
|
mykey: "fatLast3M",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.number,
|
|
|
|
|
},
|
2025-04-11 18:49:42 +02:00
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
|
},
|
2025-04-30 13:27:47 +02:00
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Fatturati ultimo Anno",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
|
|
|
|
mykey: "fatLast1Y",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.number,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Fatturati ultimi 2 Anni",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
|
|
|
|
mykey: "fatLast2Y",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.number,
|
|
|
|
|
},
|
2025-04-04 18:15:14 +02:00
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Venduti",
|
|
|
|
|
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: "totVen",
|
|
|
|
|
debounce: "1000", type: costanti.FieldType.number,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Venduti Ultimi 3 Mesi",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
|
|
|
|
mykey: "vLast3M",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.number,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Venduti Ultimi 6 Mesi",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
|
|
|
|
mykey: "vLast6M",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.number,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Venduti Ultimo Anno",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
2025-04-30 13:27:47 +02:00
|
|
|
mykey: "vLast1Y",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.number,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Venduti Ultimi 2 Anni",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
|
|
|
|
mykey: "vLast2Y",
|
2025-04-04 18:15:14 +02:00
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.number,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// SEZIONE RANKING (FATTURATI)
|
2025-04-30 13:27:47 +02:00
|
|
|
/*{
|
2025-04-04 18:15:14 +02:00
|
|
|
editOn: false,
|
|
|
|
|
label: "Ranking 3 Mesi",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
|
|
|
|
mykey: "rank3M",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.number,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Ranking 6 Mesi",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
|
|
|
|
mykey: "rank6M",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.number,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Ranking 1 Anno",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
|
|
|
|
mykey: "rank1Y",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.number,
|
2025-04-30 13:27:47 +02:00
|
|
|
},*/
|
2025-04-04 18:15:14 +02:00
|
|
|
];
|
|
|
|
|
return arrlist
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getArrListDescrizioni(): IRecFields[] {
|
|
|
|
|
const arrlist: IRecFields[] = [
|
|
|
|
|
{
|
|
|
|
|
editOn: true,
|
2025-04-11 18:49:42 +02:00
|
|
|
label: "Descrizione Trafiletto per Catalogo",
|
2025-04-30 13:27:47 +02:00
|
|
|
title: myproduct.value?.productInfo?.name,
|
2025-04-04 18:15:14 +02:00
|
|
|
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
|
2025-04-11 18:49:42 +02:00
|
|
|
mykey: "descr_trafiletto_catalogo",
|
2025-04-04 18:15:14 +02:00
|
|
|
debounce: "1000",
|
2025-04-30 13:27:47 +02:00
|
|
|
type: costanti.FieldType.editor_nohtml,
|
2025-04-04 18:15:14 +02:00
|
|
|
dense: true,
|
2025-04-11 18:49:42 +02:00
|
|
|
showall: true,
|
2025-04-04 18:15:14 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: true,
|
2025-04-11 18:49:42 +02:00
|
|
|
label: "Descrizione breve macro",
|
2025-04-30 13:27:47 +02:00
|
|
|
title: myproduct.value?.productInfo?.name,
|
2025-04-04 18:15:14 +02:00
|
|
|
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
|
2025-04-11 18:49:42 +02:00
|
|
|
mykey: "descrizione_breve_macro",
|
2025-04-30 13:27:47 +02:00
|
|
|
maxlength: 650,
|
2025-04-04 18:15:14 +02:00
|
|
|
debounce: "1000",
|
2025-04-30 13:27:47 +02:00
|
|
|
type: costanti.FieldType.editor_nohtml,
|
2025-04-04 18:15:14 +02:00
|
|
|
dense: true,
|
2025-04-11 18:49:42 +02:00
|
|
|
showall: true,
|
2025-04-04 18:15:14 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: true,
|
|
|
|
|
label: "Descrizione Estesa",
|
|
|
|
|
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_completa_macro",
|
|
|
|
|
maxlength: props.scheda?.testo_bottom?.maxlength ? props.scheda?.testo_bottom?.maxlength : 10000,
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.string,
|
|
|
|
|
dense: true,
|
2025-04-11 18:49:42 +02:00
|
|
|
showall: true,
|
2025-04-04 18:15:14 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: true,
|
|
|
|
|
label: "Link a gruppomacro.com",
|
|
|
|
|
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: "link_macro",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.string,
|
|
|
|
|
dense: true,
|
2025-04-11 18:49:42 +02:00
|
|
|
showall: true,
|
2025-04-04 18:15:14 +02:00
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
return arrlist
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getArrListScheda(): IRecFields[] {
|
|
|
|
|
const arrlist: IRecFields[] = [
|
|
|
|
|
{
|
|
|
|
|
editOn: true,
|
|
|
|
|
label: "Titolo",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo, // Oggetto dinamico, da sostituire con il valore reale
|
|
|
|
|
mykey: "name",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.string,
|
|
|
|
|
dense: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: true,
|
|
|
|
|
label: "SottoTitolo",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
|
|
|
|
mykey: "sottotitolo",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.string,
|
|
|
|
|
dense: true,
|
|
|
|
|
},
|
2025-05-01 00:20:02 +02:00
|
|
|
/*{
|
|
|
|
|
editOn: true,
|
|
|
|
|
label: "Pagine",
|
|
|
|
|
table: "arrvariazioni",
|
|
|
|
|
id: myproduct.value._id,
|
|
|
|
|
rec: myproduct.value,
|
|
|
|
|
mykey: "data_verifica",
|
|
|
|
|
debounce: "0",
|
|
|
|
|
type: costanti.FieldType.date,
|
|
|
|
|
dense: true,
|
|
|
|
|
},*/
|
2025-04-04 18:15:14 +02:00
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Pubblicazione",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
|
|
|
|
mykey: "date_pub",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.onlydate,
|
|
|
|
|
dense: true,
|
|
|
|
|
},
|
2025-04-24 01:03:20 +02:00
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Stato",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
|
|
|
|
mykey: "idStatoProdotto",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.select,
|
|
|
|
|
jointable: 't_web_statiprodottos',
|
|
|
|
|
dense: true,
|
|
|
|
|
},
|
2025-04-11 18:49:42 +02:00
|
|
|
{
|
|
|
|
|
editOn: true,
|
|
|
|
|
label: "Argomento",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo?._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
|
|
|
|
mykey: "idCatProds",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.multiselect,
|
2025-04-30 13:27:47 +02:00
|
|
|
jointable: 'catprtotali',
|
2025-04-11 18:49:42 +02:00
|
|
|
dense: true,
|
|
|
|
|
},
|
2025-04-04 18:15:14 +02:00
|
|
|
{
|
|
|
|
|
editOn: true,
|
|
|
|
|
label: "Pagine",
|
|
|
|
|
table: "arrvariazioni",
|
|
|
|
|
id: myproduct.value._id,
|
|
|
|
|
rec: myproduct.value,
|
|
|
|
|
mykey: "pagine",
|
|
|
|
|
debounce: "0",
|
|
|
|
|
|
|
|
|
|
type: costanti.FieldType.number,
|
|
|
|
|
dense: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: true,
|
|
|
|
|
label: "Misure",
|
|
|
|
|
table: "arrvariazioni",
|
|
|
|
|
id: myproduct.value._id,
|
|
|
|
|
rec: myproduct.value,
|
|
|
|
|
mykey: "misure",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.string,
|
|
|
|
|
dense: true,
|
|
|
|
|
},
|
2025-04-24 01:03:20 +02:00
|
|
|
{
|
2025-04-24 19:31:34 +02:00
|
|
|
editOn: true,
|
|
|
|
|
label: "Edizione",
|
2025-04-24 01:03:20 +02:00
|
|
|
table: "arrvariazioni",
|
|
|
|
|
id: myproduct.value._id,
|
|
|
|
|
rec: myproduct.value,
|
2025-04-24 19:31:34 +02:00
|
|
|
mykey: "edizione",
|
2025-04-24 01:03:20 +02:00
|
|
|
debounce: "1000",
|
2025-04-24 19:31:34 +02:00
|
|
|
type: costanti.FieldType.string,
|
2025-04-24 01:03:20 +02:00
|
|
|
dense: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: false,
|
2025-04-24 19:31:34 +02:00
|
|
|
label: "Tipologia",
|
2025-04-24 01:03:20 +02:00
|
|
|
table: "arrvariazioni",
|
|
|
|
|
id: myproduct.value._id,
|
|
|
|
|
rec: myproduct.value,
|
2025-04-24 19:31:34 +02:00
|
|
|
mykey: "idTipologia",
|
2025-04-24 01:03:20 +02:00
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.select,
|
2025-04-24 19:31:34 +02:00
|
|
|
jointable: 't_web_tipologies',
|
2025-04-24 01:03:20 +02:00
|
|
|
dense: true,
|
|
|
|
|
},
|
2025-04-04 18:15:14 +02:00
|
|
|
{
|
|
|
|
|
editOn: true,
|
|
|
|
|
label: "Formato",
|
|
|
|
|
table: "arrvariazioni",
|
|
|
|
|
id: myproduct.value._id,
|
|
|
|
|
rec: myproduct.value,
|
2025-04-24 19:31:34 +02:00
|
|
|
mykey: "idTipoFormato",
|
2025-04-04 18:15:14 +02:00
|
|
|
debounce: "1000",
|
2025-04-24 19:31:34 +02:00
|
|
|
type: costanti.FieldType.select,
|
|
|
|
|
jointable: 't_web_tipiformatos',
|
2025-04-04 18:15:14 +02:00
|
|
|
dense: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: true,
|
|
|
|
|
label: "Prezzo",
|
|
|
|
|
table: "arrvariazioni",
|
|
|
|
|
id: myproduct.value._id,
|
|
|
|
|
rec: myproduct.value,
|
|
|
|
|
mykey: "price",
|
|
|
|
|
debounce: "0",
|
|
|
|
|
|
|
|
|
|
type: costanti.FieldType.number,
|
|
|
|
|
dense: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: true,
|
|
|
|
|
label: "Prezzo Scontato",
|
|
|
|
|
table: "arrvariazioni",
|
|
|
|
|
id: myproduct.value._id,
|
|
|
|
|
rec: myproduct.value,
|
|
|
|
|
mykey: "sale_price",
|
|
|
|
|
debounce: "0",
|
|
|
|
|
|
|
|
|
|
type: costanti.FieldType.number,
|
|
|
|
|
dense: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Magazzino",
|
|
|
|
|
table: "arrvariazioni",
|
|
|
|
|
id: myproduct.value._id,
|
|
|
|
|
rec: myproduct.value,
|
|
|
|
|
mykey: "quantita",
|
|
|
|
|
debounce: "0",
|
|
|
|
|
|
|
|
|
|
type: costanti.FieldType.number,
|
|
|
|
|
dense: true,
|
|
|
|
|
},
|
2025-04-24 19:31:34 +02:00
|
|
|
{
|
|
|
|
|
editOn: false,
|
|
|
|
|
label: "Aggiornato (da GM) il",
|
|
|
|
|
table: "productinfos",
|
|
|
|
|
id: myproduct.value.productInfo._id,
|
|
|
|
|
rec: myproduct.value.productInfo,
|
|
|
|
|
mykey: "date_updated_fromGM",
|
|
|
|
|
debounce: "1000",
|
|
|
|
|
type: costanti.FieldType.onlydate,
|
|
|
|
|
dense: true,
|
|
|
|
|
},
|
2025-04-04 18:15:14 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
return arrlist
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-11 18:49:42 +02:00
|
|
|
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) {
|
2025-04-24 01:03:20 +02:00
|
|
|
myproduct.value = await products.getProductById(myproduct.value._id, load)
|
2025-04-11 18:49:42 +02:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-24 01:03:20 +02:00
|
|
|
/*async function refreshDataFromGM() {
|
2025-04-11 18:49:42 +02:00
|
|
|
if (myproduct.value) {
|
|
|
|
|
loading.value = true
|
2025-04-18 13:23:52 +02:00
|
|
|
const ris = await globalStore.updateLocalDbFromGM_T_Web_Articoli(myproduct.value.productInfo.sku!, myproduct.value.isbn)
|
2025-04-11 18:49:42 +02:00
|
|
|
if (ris) {
|
|
|
|
|
|
|
|
|
|
await updateproduct(false)
|
|
|
|
|
|
|
|
|
|
tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK'))
|
|
|
|
|
}
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-24 01:03:20 +02:00
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
async function refreshSingleBookFromGM(options: any) {
|
|
|
|
|
if (myproduct.value) {
|
|
|
|
|
loading.value = true
|
|
|
|
|
await globalStore.updateAllBookFromGM_T_Web_Articoli({ sku: myproduct.value.productInfo.sku!, isbn: myproduct.value.productInfo.code, ...options })
|
|
|
|
|
.then((ris) => {
|
|
|
|
|
if (ris) {
|
|
|
|
|
if (ris.error) {
|
|
|
|
|
tools.showNegativeNotif($q, ris.error)
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
updateproduct(false)
|
|
|
|
|
// console.log('product AGGIORNATO:', myproduct.value)
|
|
|
|
|
tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK'))
|
|
|
|
|
}
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-11 18:49:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-04-24 01:03:20 +02:00
|
|
|
|
2025-04-04 18:15:14 +02:00
|
|
|
onMounted(mounted)
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
tools,
|
|
|
|
|
globalStore,
|
|
|
|
|
costanti,
|
|
|
|
|
shared_consts,
|
|
|
|
|
t,
|
|
|
|
|
products,
|
|
|
|
|
getArrListScheda,
|
|
|
|
|
getArrListDescrizioni,
|
|
|
|
|
getArrListStat,
|
|
|
|
|
mytab,
|
|
|
|
|
myproduct,
|
2025-04-11 18:49:42 +02:00
|
|
|
updateproductmodif,
|
|
|
|
|
updatetogm,
|
|
|
|
|
field_updated_toGM,
|
|
|
|
|
loading,
|
|
|
|
|
updateRecordToGM,
|
2025-04-24 01:03:20 +02:00
|
|
|
refreshSingleBookFromGM,
|
|
|
|
|
// refreshDataFromGM,
|
2025-04-04 18:15:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|