- aggiornamento catalogo: lista titoli del catalogo

- scheda prodotto libro
- migliorata tabella prodotto
This commit is contained in:
Surya Paolo
2025-04-04 18:15:14 +02:00
parent 79d1c5fe1d
commit 9cfc308d09
49 changed files with 1760 additions and 934 deletions

View File

@@ -4,4 +4,20 @@
.drag-handle:active {
cursor: grabbing; /* Cambia la manina quando l'utente sta trascinando */
}
}
.etichetta{
margin-top: 5px;
margin-bottom: 5px;
padding-top: 5px;
padding-bottom: 5px;
font-weight: bold;
font-size: 1.15rem;
}
.boxtitleval{
padding: 10px;
vertical-align: middle;
}

View File

@@ -1,10 +1,11 @@
import { defineComponent, onMounted, ref, watch } from "vue";
import { PropType, computed, defineComponent, onMounted, ref, watch } from "vue";
import draggable from 'vuedraggable'
import { tools } from '@tools'
import { useGlobalStore } from '@src/store/globalStore'
import { CMyValueDb } from '@src/components/CMyValueDb'
import { CSearchProduct } from '@src/components/CSearchProduct'
import { CMyDialog } from '@src/components/CMyDialog'
@@ -12,33 +13,82 @@ import { costanti } from '@costanti'
import { IAuthor, ICatProd } from "app/src/model";
import type {
IMyScheda,
IOptCatalogo,
IProduct
} from '@src/model';
import { shared_consts } from "app/src/common/shared_vuejs";
import { useProducts } from "app/src/store/Products";
import { CViewTable } from "../CViewTable";
import { CLabel } from "../CLabel";
import { useI18n } from "vue-i18n";
export default defineComponent({
name: "CProductTable",
emits: ["update:lista_prodotti", "update:optcatalogo"],
components: {
draggable, CSearchProduct, CMyDialog,
draggable, CSearchProduct, CMyDialog, CMyValueDb, CViewTable, CLabel,
},
props: {
lista_prodotti: {
type: Array,
required: true,
},
optcatalogo: {
type: Object as PropType<IOptCatalogo>,
required: false,
default: null,
},
scheda: {
type: Object as PropType<IMyScheda>,
required: false,
default: () => ({
}),
},
},
emits: ["update:lista_prodotti"],
setup(props, { emit }) {
// Copia locale della lista_prodotti per manipolazione interna
const internalProducts = ref([...props.lista_prodotti]);
const { t } = useI18n()
const globalStore = useGlobalStore()
const products = useProducts()
const showProd = ref(false)
const selProd = ref(<IProduct>{})
const selProd = ref(<IProduct | null>null)
const cmd = ref(shared_consts.SCHEDA_PRODOTTO.CMD_NONE)
const showQtaDisponibile = ref(false)
const loading = ref(false)
const visufromgm = ref(false)
const updatefromgm = ref(false)
const field_updated_fromGM = ref('')
const modifOn = ref(false)
const endload = ref(false)
const optionscatalogo = ref(<any>{maxlength: 0})
const editOn = computed({
get(): boolean {
return globalStore.editOn ? globalStore.editOn : false
},
set(value: boolean) {
return tools.updateEditOn(value)
}
})
async function mounted() {
optionscatalogo.value = {
maxlength: props.scheda?.testo_bottom?.maxlength
}
}
// Aggiorna la copia locale quando il prop cambia
@@ -51,17 +101,27 @@ export default defineComponent({
// Colonne della tabella
const allColumns = [
{ name: "drag", label: "Ordinamento", field: "", align: "left", style: "width: 50px" },
{ name: "image", label: "Copertina", field: "image", align: "center" },
{ name: "name", label: "Titolo", field: "name", align: "left" },
{ name: "drag", label: "Ordinam.", field: "", align: "left", style: "width: 50px" },
{ name: "image", label: "Foto", field: "image", align: "center" },
{ name: "name", label: "Titolo del Libro", field: "name", align: "left" },
{ name: "authors", label: "Autore", field: "authors", align: "left" },
{ name: "trafiletto", label: "Trafiletto", field: "trafiletto", align: "left" },
{ name: "catprods", label: "Argomento", field: "catprods", align: "left" },
{ name: "quantity", label: "Disponibilità", field: "quantity", align: "left" },
{ name: "date_pub", label: "Pubblicato", field: "date_pub", align: "left" },
{ name: "ranking", label: "Class.", field: "ranking", align: "right" },
{ name: "rank3M", label: "Class. 3M", field: "rank3M", align: "right" },
{ name: "rank6M", label: "Class. 6M", field: "rank6M", align: "right" },
{ name: "rank1Y", label: "Class. 1Y", field: "rank1Y", align: "right" },
{ name: "pagine", label: "Pag.", field: "pagine", align: "right" },
{ name: "totVen", label: "Venduti", field: "totVen", align: "right" },
{ name: "totFat", label: "Fattur.", field: "totFat", align: "right" },
{ name: "ult_ord", label: "Ult. Ordine", field: "ult_ord", align: "left" },
{ name: "quantity", label: "Magazz.", field: "quantity", align: "right" },
{ name: "isbn", label: "ISBN", field: "isbn", align: "left" },
{ name: "actions", label: "Azioni", field: "", align: "center" },
];
let cookieValue: string | null = null;
let cookieValue: [] | null = null;
try {
cookieValue = tools.getCookie("selColCat");
// Se il cookie esiste e contiene una stringa JSON valida
@@ -139,6 +199,70 @@ export default defineComponent({
showProd.value = true
}
function modifyProduct(element: any) {
if (element) {
selProd.value = element
cmd.value = shared_consts.SCHEDA_PRODOTTO.CMD_MODIFICA
modifOn.value = true
}
}
function updateProduct(element: any) {
selProd.value = element
// Aggiorna l'elemento nella lista interna
internalProducts.value = internalProducts.value.map((prod: any) => {
if (prod._id === selProd.value._id) {
return selProd.value;
}
return prod;
});
emit("update:lista_prodotti", internalProducts.value); // Notifica il parent del cambiamento
}
async function updateproductmodif(element: any) {
console.log('PRODUCT TABLE: updateproductmodif')
try {
if (element?._id) {
selProd.value = await products.getProductById(element?._id)
} else {
selProd.value = await products.getProductById(selProd.value?._id)
}
// update record inside internalProducts
internalProducts.value = internalProducts.value.map((prod: any) => {
if (prod._id === selProd.value._id) {
return selProd.value;
}
return prod;
});
} catch (e) {
console.error('err', e)
}
}
async function refreshDataFromGM() {
}
async function refreshFieldFromGM(field: string) {
if (selProd.value) {
loading.value = true
updatefromgm.value = true
field_updated_fromGM.value = ''
field_updated_fromGM.value = await globalStore.getGM_FieldOf_T_Web_Articoli(selProd.value.productInfo.sku!, field, shared_consts.CmdQueryMs.GET)
loading.value = false
}
}
onMounted(mounted)
return {
allColumns,
selectedColumns,
@@ -147,6 +271,7 @@ export default defineComponent({
formatAuthors,
formatCatProds,
removeProduct,
modifyProduct,
tools,
globalStore,
costanti,
@@ -154,6 +279,22 @@ export default defineComponent({
showProduct,
showProd,
selProd,
cmd,
shared_consts,
updateProduct,
field_updated_fromGM,
refreshFieldFromGM,
refreshDataFromGM,
updatefromgm,
visufromgm,
loading,
showQtaDisponibile,
modifOn,
endload,
updateproductmodif,
optionscatalogo,
t,
products,
}
},
}
})

View File

@@ -73,11 +73,67 @@
<!-- Autore -->
<td v-if="isColumnVisible('authors')">{{ formatAuthors(element.productInfo?.authors) }}</td>
<td
v-if="isColumnVisible('trafiletto')"
style="text-align: center"
:class="element.productInfo?.descr_trafiletto_catalogo?.length > 100 ? 'text-green' : 'text-red'"
>
{{ element.productInfo?.descr_trafiletto_catalogo?.length > 100 ? 'SI' : 'NO' }}
</td>
<!-- Argomento -->
<td v-if="isColumnVisible('catprods')">{{ formatCatProds(element.productInfo?.catprods) }}</td>
<td v-if="isColumnVisible('date_pub')">{{ tools.getstrDate(element.productInfo?.date_pub) }}</td>
<td v-if="isColumnVisible('ranking')">{{ element.indiceRanking }}</td>
<td
v-if="isColumnVisible('rank3M')"
style="text-align: right"
>
{{ element.productInfo?.rank3M }}
</td>
<td
v-if="isColumnVisible('rank6M')"
style="text-align: right"
>
{{ element.productInfo?.rank6M }}
</td>
<td
v-if="isColumnVisible('rank1Y')"
style="text-align: right"
>
{{ element.productInfo?.rank1Y }}
</td>
<td
v-if="isColumnVisible('pagine')"
style="text-align: right"
>
{{ element.arrvariazioni[0].pagine }}
</td>
<td
v-if="isColumnVisible('totVen')"
style="text-align: right"
>
{{ element.productInfo?.totVen }}
</td>
<td
v-if="isColumnVisible('totFat')"
style="text-align: right"
>
{{ element.productInfo?.totFat }}
</td>
<td v-if="isColumnVisible('ult_ord')">{{ tools.getstrDate(element.productInfo?.dataUltimoOrdine) }}</td>
<!-- Quantità -->
<td v-if="isColumnVisible('quantity')">{{ element.arrvariazioni[0].quantita }}</td>
<td
v-if="isColumnVisible('quantity')"
style="text-align: right"
>
{{ element.arrvariazioni[0].quantita }}
</td>
<!-- ISBN -->
<td v-if="isColumnVisible('isbn')">{{ element.isbn }}</td>
@@ -90,6 +146,15 @@
flat
>
<q-list>
<q-item
clickable
v-close-popup
@click="modifyProduct(element)"
>
<q-item-section>
<q-item-label>Modifica</q-item-label>
</q-item-section>
</q-item>
<q-item
clickable
v-close-popup
@@ -112,8 +177,100 @@
title="Prodotto"
class="q-ma-md"
>
<CSearchProduct v-if="selProd" :idprodtoshow="selProd._id" nameLinkTemplate="SEARCH_Prima"> </CSearchProduct>
<CSearchProduct
:idprodtoshow="selProd?._id"
nameLinkTemplate="SEARCH_Prima"
@updateproductmodif="updateproductmodif"
>
</CSearchProduct>
</CMyDialog>
<q-dialog
v-model="modifOn"
maximized
>
<q-spinner
v-if="!endload"
color="primary"
size="3em"
:thickness="2"
/>
<div v-if="!!selProd && !!selProd.productInfo">
</div>
</q-dialog>
<q-dialog
v-if="visufromgm"
v-model="visufromgm"
@hide="visufromgm = false"
>
<q-card class="dialog_card">
<q-toolbar class="bg-primary text-white">
<q-toolbar-title> Visu </q-toolbar-title>
<q-btn
flat
round
color="white"
icon="close"
v-close-popup
></q-btn>
</q-toolbar>
<q-card-section class="q-pa-xs inset-shadow">
<q-spinner
v-if="!endload"
color="primary"
size="3em"
:thickness="2"
/>
<div v-if="visufromgm && selProd">
<CViewTable
:options="{
nameTable: 'T_Web_Articoli',
campispeciali: true,
numrec: 100,
where: 'T.IdArticolo =' + selProd.productInfo.sku,
showQtaDisponibile,
outhtml: true,
}"
>
</CViewTable>
</div>
</q-card-section>
</q-card>
</q-dialog>
<q-dialog
v-if="updatefromgm && selProd"
v-model="updatefromgm"
@hide="updatefromgm = false"
>
<q-card class="dialog_card">
<q-toolbar class="bg-primary text-white">
<q-toolbar-title> Aggiorna da GM: </q-toolbar-title>
<q-btn
flat
round
color="white"
icon="close"
v-close-popup
></q-btn>
</q-toolbar>
<q-card-section class="q-pa-xs inset-shadow">
<q-inner-loading
id="spinner"
:showing="loading"
>
<q-spinner-tail
color="primary"
size="4em"
>
</q-spinner-tail>
</q-inner-loading>
<br />
Valore: {{ field_updated_fromGM }}
<br />
</q-card-section>
</q-card>
</q-dialog>
</template>
<script lang="ts" src="./CProductTable.ts"></script>