- Catalogo: Aggiunta di Schede
This commit is contained in:
@@ -2,7 +2,7 @@ import {
|
||||
defineComponent, onMounted, PropType, computed, ref, toRef, watch,
|
||||
} from 'vue'
|
||||
|
||||
import { IColGridTable, IElemText, IImgGallery, ILabelValue, IMyCard, IMyElem, IMyPage, IOperators } from '@src/model'
|
||||
import { IColGridTable, IElemText, IImgGallery, ILabelValue, IMyCard, IMyElem, IMyPage, IMyScheda, IOperators, ISchedaSingola } from '@src/model'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
|
||||
import { CImgTitle } from '@/components/CImgTitle'
|
||||
@@ -40,7 +40,7 @@ export default defineComponent({
|
||||
CCardCarousel, COpenStreetMap, CMyPage, CMyPageIntro, CMyEditor, CMyFieldRec,
|
||||
CSelectColor, CSelectFontSize, CSelectImage, CImgPoster, CSelectAnimation, CMySlider
|
||||
},
|
||||
emits: ['saveElem', 'selElemClick', 'toggleSize', 'deleteElem'],
|
||||
emits: ['saveElem', 'selElemClick', 'toggleSize', 'deleteElem', 'dupPage'],
|
||||
props: {
|
||||
myelem: {
|
||||
type: Object as PropType<IMyElem>,
|
||||
@@ -51,6 +51,11 @@ export default defineComponent({
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
IdPath: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
editOn: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
@@ -72,10 +77,16 @@ export default defineComponent({
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
|
||||
const posizTextOptions = ref([
|
||||
{ label: 'In basso', value: costanti.POSIZ_TESTO.IN_BASSO },
|
||||
{ label: 'A Destra', value: costanti.POSIZ_TESTO.A_DESTRA },
|
||||
])
|
||||
|
||||
const animare = ref(0)
|
||||
const slide = ref(0)
|
||||
const slide2 = ref(0)
|
||||
const tabCard = ref('card0')
|
||||
const tabCard = ref(0)
|
||||
const tabScheda = ref(0)
|
||||
const tabElemsText = ref('elem0')
|
||||
const arrPages = ref([] as any[])
|
||||
const disableSave = ref(true)
|
||||
@@ -161,6 +172,9 @@ export default defineComponent({
|
||||
// emit('updateAll', newrec)
|
||||
}
|
||||
|
||||
async function dupPage() {
|
||||
emit('dupPage', null)
|
||||
}
|
||||
async function dupElem(order?: number) {
|
||||
|
||||
const newrec: IMyElem = { ...props.myelem }
|
||||
@@ -246,6 +260,77 @@ export default defineComponent({
|
||||
|
||||
|
||||
}
|
||||
function addNewScheda() {
|
||||
|
||||
let maxorder = 0
|
||||
myel.value.catalogo!.arrSchede?.forEach(scheda => {
|
||||
if (scheda.order > maxorder) {
|
||||
maxorder = scheda.order
|
||||
}
|
||||
})
|
||||
|
||||
let newscheda: IMyScheda = {
|
||||
_id: objectId(),
|
||||
idapp: tools.appid()!,
|
||||
isTemplate: false,
|
||||
name: 'Scheda Nuova',
|
||||
widthscheda: '360px',
|
||||
line_height: 100,
|
||||
widthpag: 800,
|
||||
width: 150,
|
||||
height: 234,
|
||||
numschede_perRiga: 2,
|
||||
numschede_perCol: 2,
|
||||
margine_top: 12,
|
||||
margine_pagina: '92px',
|
||||
margine_riga: '41px',
|
||||
text: '',
|
||||
posiz_text: costanti.POSIZ_TESTO.A_DESTRA,
|
||||
|
||||
productTypes: [],
|
||||
excludeproductTypes: [],
|
||||
editore: [],
|
||||
author: '',
|
||||
sort: costanti.SORT_PUBDATE,
|
||||
arrProdottiSpeciali: [],
|
||||
}
|
||||
|
||||
if (!myel.value.catalogo!.arrSchede)
|
||||
myel.value.catalogo!.arrSchede = []
|
||||
|
||||
myel.value.catalogo!.arrSchede.push(
|
||||
{
|
||||
_id: objectId(),
|
||||
scheda: { ...newscheda },
|
||||
order: maxorder + 10,
|
||||
numSchede: 1,
|
||||
}
|
||||
)
|
||||
// console.log('arrschede', myel.value.catalogo!.arrSchede)
|
||||
|
||||
modifElem()
|
||||
|
||||
}
|
||||
function dupNewScheda(id: string) {
|
||||
if (!myel.value.catalogo!.arrSchede)
|
||||
return
|
||||
|
||||
const myfindscheda = myel.value.catalogo!.arrSchede.find((scheda: ISchedaSingola) => scheda._id === id)
|
||||
|
||||
if (myfindscheda) {
|
||||
let myscheda = { ...myfindscheda }
|
||||
delete myscheda._id
|
||||
myscheda._id = objectId()
|
||||
|
||||
const bakscheda = [...myel.value.catalogo!.arrSchede]
|
||||
|
||||
myel.value.catalogo!.arrSchede = []
|
||||
myel.value.catalogo!.arrSchede = [...bakscheda, myscheda]
|
||||
modifElem()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function dupNewCard() {
|
||||
if (!myel.value.listcards)
|
||||
@@ -306,10 +391,17 @@ export default defineComponent({
|
||||
myel.elemsText = myel.elemsText.filter((rec: IElemText) => rec._id !== id)
|
||||
}
|
||||
|
||||
}
|
||||
function delRecScheda(id: string, myel: IMyElem) {
|
||||
//
|
||||
myel.catalogo!.arrSchede = myel.catalogo!.arrSchede!.filter((scheda: ISchedaSingola) => scheda._id !== id)
|
||||
|
||||
modifElem()
|
||||
|
||||
}
|
||||
|
||||
function saveFieldElem(rec: any, newval: any, col: IColGridTable) {
|
||||
console.log('saveFieldElem', rec, 'newval', newval, 'col', col)
|
||||
//console.log('saveFieldElem', rec, 'newval', newval, 'col', col)
|
||||
|
||||
let iscatalogo = costanti.CATALOGO_FIELDS.includes(col.name)
|
||||
|
||||
@@ -366,7 +458,7 @@ export default defineComponent({
|
||||
|
||||
}
|
||||
modifElem()
|
||||
|
||||
|
||||
}
|
||||
|
||||
function showAnimation() {
|
||||
@@ -399,6 +491,20 @@ export default defineComponent({
|
||||
return options;
|
||||
}
|
||||
|
||||
function SchedeOpt() {
|
||||
const arrschede = globalStore.getMySchede()
|
||||
|
||||
let arr: any = []
|
||||
|
||||
if (arrschede) {
|
||||
arrschede.forEach(scheda => {
|
||||
arr.push({ label: scheda.name, value: scheda._id })
|
||||
});
|
||||
}
|
||||
|
||||
return arr
|
||||
}
|
||||
|
||||
function updateSizeWidth(value: any) {
|
||||
// Gestisce l'input dell'utente per un nuovo valore
|
||||
myel.value.widthimg = value; // Aggiorna widthimg con il nuovo valore
|
||||
@@ -409,36 +515,6 @@ export default defineComponent({
|
||||
myel.value.catalogo!.width = value // Aggiorna widthimg con il nuovo valore
|
||||
modifElem()
|
||||
}
|
||||
function updateCatalogoNumSchedePerCol(value: any) {
|
||||
// Gestisce l'input dell'utente per un nuovo valore
|
||||
myel.value.catalogo!.numschede_perCol = value // Aggiorna widthimg con il nuovo valore
|
||||
modifElem()
|
||||
}
|
||||
function updateCatalogoNumSchedePerRiga(value: any) {
|
||||
// Gestisce l'input dell'utente per un nuovo valore
|
||||
myel.value.catalogo!.numschede_perRiga = value // Aggiorna widthimg con il nuovo valore
|
||||
modifElem()
|
||||
}
|
||||
function updateCatalogoSizeWidthScheda(value: any) {
|
||||
// Gestisce l'input dell'utente per un nuovo valore
|
||||
myel.value.catalogo!.widthscheda = value // Aggiorna widthimg con il nuovo valore
|
||||
modifElem()
|
||||
}
|
||||
function updateCatalogoSizeWidthPag(value: any) {
|
||||
// Gestisce l'input dell'utente per un nuovo valore
|
||||
myel.value.catalogo!.widthpag = value // Aggiorna widthimg con il nuovo valore
|
||||
modifElem()
|
||||
}
|
||||
function updateCatalogoSizeWidthPagPrintable(value: any) {
|
||||
// Gestisce l'input dell'utente per un nuovo valore
|
||||
myel.value.catalogo!.widthpagPrintable = value // Aggiorna widthimg con il nuovo valore
|
||||
modifElem()
|
||||
}
|
||||
function updateCatalogoSizeHeight(value: any) {
|
||||
myel.value.catalogo!.height = value
|
||||
modifElem()
|
||||
}
|
||||
|
||||
function updateSizeHeight(value: any) {
|
||||
myel.value.heightimg = value; // Aggiorna widthimg con il nuovo valore
|
||||
modifElem()
|
||||
@@ -466,10 +542,14 @@ export default defineComponent({
|
||||
neworder.value = rec
|
||||
}
|
||||
|
||||
function addProdSpeciale(rec: any) {
|
||||
neworder.value = rec
|
||||
}
|
||||
|
||||
async function moveElem(direz: any) {
|
||||
let myelem = props.myelem
|
||||
|
||||
const elemprec = globalStore.getMyElemPrecThisElemId(props.path, myelem._id)
|
||||
const elemprec = globalStore.getMyElemPrecThisElemId(props.path, myelem._id!)
|
||||
const elemnext = globalStore.getMyElemNextThisElemId(props.path, myelem._id!)
|
||||
|
||||
let neworder = 0
|
||||
@@ -589,12 +669,14 @@ export default defineComponent({
|
||||
classiImmagineOptions,
|
||||
saveFieldElem,
|
||||
updateCatalogoSizeWidth,
|
||||
updateCatalogoSizeHeight,
|
||||
updateCatalogoSizeWidthScheda,
|
||||
updateCatalogoSizeWidthPag,
|
||||
updateCatalogoSizeWidthPagPrintable,
|
||||
updateCatalogoNumSchedePerCol,
|
||||
updateCatalogoNumSchedePerRiga,
|
||||
dupPage,
|
||||
posizTextOptions,
|
||||
tabScheda,
|
||||
addNewScheda,
|
||||
dupNewScheda,
|
||||
delRecScheda,
|
||||
SchedeOpt,
|
||||
addProdSpeciale,
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user