- Creazione di un Nuovo Catalogo (e la sua relativa pagina), a partire da un modello ed un catalogo esistente.

- Aggiunta dei bottoni sul Ccatalogocard
This commit is contained in:
Surya Paolo
2025-06-12 23:49:13 +02:00
parent 2dac04fb16
commit 286cc4e3a7
23 changed files with 286736 additions and 1889 deletions

View File

@@ -19,11 +19,13 @@ import { useUserStore } from '@store/UserStore';
import { CTitlePage } from '@src/components/CTitlePage';
import { CGridTableRec } from '@src/components/CGridTableRec';
import type { ICatalog, IColGridTable, ISearchList } from 'model';
import type { ICatalog, IColGridTable, INewCatalog, ISearchList } from 'model';
import { useI18n } from 'vue-i18n';
import { toolsext } from '@store/Modules/toolsext';
import { fieldsTable } from '@store/Modules/fieldsTable';
import { useQuasar } from 'quasar';
import { useRouter } from 'vue-router';
import { useCatalogStore } from 'app/src/store/CatalogStore';
export default defineComponent({
name: 'CCatalogList',
@@ -85,8 +87,11 @@ export default defineComponent({
const $q = useQuasar();
const globalStore = useGlobalStore();
const userStore = useUserStore();
const catalogStore = useCatalogStore();
const $router = useRouter();
const table = ref('catalogs');
const caricamentodati = ref(false);
const arrfilterand: any = ref([]);
const filtercustom: any = ref([]);
@@ -99,9 +104,12 @@ export default defineComponent({
const col_footer = ref('');
const col_tabfooter = ref('');
const cataloghi = ref(<any[]>[]);
const modelli = ref(<any[]>[]);
const strextra = ref('');
const myoptions = ref(<any>[]);
const newCatalog = ref(<any>{});
const newCatalog = ref(<INewCatalog>{});
const col = ref(<IColGridTable[]>[]);
@@ -171,6 +179,17 @@ export default defineComponent({
filtercustom.value = [];
col.value = fieldsTable.getArrColsByTable(table.value);
modelli.value = globalStore.getMyPagesOptionsTemplate();
cataloghi.value = catalogStore.getCatalogsList();
if (modelli.value && modelli.value.length > 0) {
newCatalog.value.idPageTemplate = modelli.value[0].value;
}
if (cataloghi.value && cataloghi.value.length > 0) {
newCatalog.value.idCatalogToCopy = cataloghi.value[1].value;
}
}
function mySortFieldsAvailable() {
@@ -198,22 +217,41 @@ export default defineComponent({
showFormAddNewCatalog.value = true;
}
function addNewCatalogSave() {
async function addNewCatalogSave() {
// Salva catalogo
caricamentodati.value = true;
const ris = await globalStore.addNewCatalog(newCatalog.value, $router);
if (ris.page) {
const newPagePath = ris.page.path;
const confirmNavigation = $q
.dialog({
message: t(t('mypages.catalogo_new', { title: ris.page.title })),
ok: { label: t('Sì'), push: true },
cancel: { label: t('No') },
title: t('mypages.confirm_nav'),
})
.onOk(() => {
$router.push({ path: `/${newPagePath}` });
});
} else {
tools.showNegativeNotif($q, t('mypages.catalogo_err'));
}
caricamentodati.value = false;
}
function checkPathExist() {
function checkPathAlreadyExist(path: string) {
const mypageexist = globalStore.mypage.find(
(myrec) => myrec.path.toLowerCase() === newCatalog.path.toLowerCase()
(myrec) => myrec?.path?.toLowerCase() === path?.toLowerCase()
);
if (mypageexist) {
$q.notify({
message: `La pagina ${newCatalog.path} esiste già`,
color: 'red',
position: 'top',
});
return;
}
return mypageexist;
}
function checkNameAlreadyExist(title: string) {
const mypageexist = globalStore.mypage.find(
(myrec) => myrec?.title?.toLowerCase() === title?.toLowerCase()
);
return mypageexist;
}
onMounted(mounted);
@@ -247,8 +285,12 @@ export default defineComponent({
showFormAddNewCatalog,
addNewCatalogSave,
newCatalog,
checkPathExist,
checkPathAlreadyExist,
checkNameAlreadyExist,
globalStore,
caricamentodati,
cataloghi,
modelli,
};
},
});

View File

@@ -65,32 +65,59 @@
filled
v-model="newCatalog.title"
label="Titolo del catalogo *"
autofocus
@update:model-value="
newCatalog.path = tools.convertTitleToFileName(newCatalog.title)
"
lazy-rules
:rules="[(val) => (val && val.length > 0) || 'Inserire il titolo']"
:rules="[
(val) => (val && val.length > 0) || 'Inserire il titolo',
(val) =>
!checkNameAlreadyExist(val) || 'Il titolo della pagina esiste già ',
]"
/>
<q-input
filled
v-model="newCatalog.path"
label="Nome della pagina *"
@update:model-value="checkPathExist"
lazy-rules
:rules="[(val) => (val && val.length > 0) || 'Inserire il nome della pagina']"
:rules="[
(val) => (val && val.length > 0) || 'Inserire il nome della pagina',
(val) => !checkPathAlreadyExist(val) || 'Il nome della pagina esiste già ',
]"
/>
<q-select
filled
v-model="newCatalog.template"
:options="globalStore.getMyPagesOptionsTemplate()"
v-model="newCatalog.idPageTemplate"
:options="modelli"
label="Modello *"
emit-value
map-options
:rules="[(val) => (val && val.length > 0) || 'Selezionare un modello']"
/>
<q-select
filled
v-model="newCatalog.idCatalogToCopy"
:options="cataloghi"
label="Catalogo da copiare *"
emit-value
map-options
/>
<div class="row justify-center">
<q-btn
label="Aggiungi"
type="submit"
:disable="
!(
newCatalog.title &&
newCatalog.path &&
newCatalog.idPageTemplate &&
!checkPathAlreadyExist(newCatalog.path)
)
"
color="primary"
/>
<q-btn
@@ -103,6 +130,15 @@
</div>
</q-form>
</q-card-section>
<div
v-if="caricamentodati"
class="overlay"
>
<q-spinner-hourglass
color="primary"
size="50px"
/>
</div>
</q-card>
</q-dialog>
</template>

View File

@@ -141,7 +141,17 @@
>
</q-img>
</a>
<div class="row no-wrap q-col-gutter-x-xs items-center semi-transparent" style="position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); z-index: 10">
<div
v-if="globalStore.showHeader"
class="row no-wrap q-col-gutter-x-xs items-center semi-transparent"
style="
position: absolute;
bottom: -5px;
left: 50%;
transform: translateX(-50%);
z-index: 10;
"
>
<div v-if="!optcatalogo.generazionePDFInCorso">
<q-btn
icon="fas fa-external-link-alt"

View File

@@ -7,10 +7,12 @@ import { useProducts } from '@store/Products';
import { CCopyBtn } from '@src/components/CCopyBtn';
import { CSingleCart } from '@src/components/CSingleCart';
import { CTitleBanner } from '@src/components/CTitleBanner';
import { tools } from '@store/Modules/tools';
import { useI18n } from 'vue-i18n';
import MixinUsers from '../../mixins/mixin-users';
import { useQuasar } from 'quasar';
export default defineComponent({
name: 'CMyCart',
@@ -21,9 +23,14 @@ export default defineComponent({
const globalStore = useGlobalStore();
const productStore = useProducts();
const { t } = useI18n();
const $q = useQuasar();
const { getnumItemsCart } = MixinUsers();
const codice_sconto = ref('')
const descr_sconto = ref('')
const caricamentodati = ref(false)
const myCart = computed(() => productStore.cart);
const myTotalPrice = computed(() => {
if (productStore.cart) {
@@ -69,6 +76,43 @@ export default defineComponent({
return productStore.getNumOrders() > 0;
}
async function applicaSconto(codice: string) {
try {
caricamentodati.value = true;
const rissconto = await productStore.ApplicaSconto({
cart_id: myCart.value._id,
codice_sconto: codice,
});
if (rissconto) {
if (rissconto.msg) {
tools.showNeutralNotif($q, `${rissconto.msg}`);
} else if (rissconto.valido && rissconto.mycart) {
tools.showPositiveNotif($q, 'Sconto Applicato!');
} else {
tools.showNegativeNotif($q, `${rissconto.errmsg}`);
}
codice_sconto.value = '';
descr_sconto.value = '';
if (rissconto.mycart) {
recOrderCart.value = rissconto.mycart
};
}
} catch (error) {
console.log('error ApplicaSconto', error);
tools.showNegativeNotif($q, `Sconto Non Applicato! ${error.message}`);
codice_sconto.value = '';
descr_sconto.value = '';
} finally {
caricamentodati.value = false;
}
}
async function confermaCodiceSconto() {
await applicaSconto(codice_sconto.value);
}
onMounted(mounted);
return {
@@ -82,6 +126,10 @@ export default defineComponent({
existsOrders,
globalStore,
t,
codice_sconto,
confermaCodiceSconto,
caricamentodati,
descr_sconto,
};
},
});

View File

@@ -136,6 +136,15 @@
</q-btn>
</div>
</div>
<div
v-if="caricamentodati"
class="overlay"
>
<q-spinner-hourglass
color="primary"
size="50px"
/>
</div>
</div>
</template>

View File

@@ -226,6 +226,7 @@ export default defineComponent({
showexportPage,
showimportPage,
hideHeader,
myidPage,
};
},
});

View File

@@ -27,7 +27,7 @@ import { CModifTrafiletto } from '@src/components/CModifTrafiletto';
import { costanti } from '@costanti';
import { IAuthor, ICatProd } from 'app/src/model';
import type { IMyScheda, IOptCatalogo, IProduct } from '@src/model';
import type { IMyScheda, IOptCatalogo, IOrderCart, IProduct } from '@src/model';
import { shared_consts } from 'app/src/common/shared_vuejs';
import { CViewTable } from '../CViewTable';
import { CLabel } from '../CLabel';
@@ -35,7 +35,7 @@ import { useI18n } from 'vue-i18n';
export default defineComponent({
name: 'CProductTable',
emits: ['update:lista_prodotti', 'update:optcatalogo', 'rigenera'],
emits: ['update:lista_prodotti', 'update:optcatalogo', 'rigenera', 'addtolist'],
components: {
draggable,
CSearchProduct,
@@ -70,6 +70,11 @@ export default defineComponent({
required: false,
default: () => ({}),
},
options: {
type: Object,
required: false,
default: () => ({}),
}
},
setup(props, { emit }) {
// Copia locale della lista_prodotti per manipolazione interna
@@ -106,7 +111,6 @@ export default defineComponent({
const addstr = ref('');
const optionscatalogo = ref(<any>{ maxlength: 0 });
function handleUpdate(newList) {
@@ -136,7 +140,6 @@ export default defineComponent({
internalProducts.value.forEach((p: IProduct) => {
p.myorder = ProductStore.createMyOrder();
});
}
),
{ deep: true };
@@ -264,6 +267,15 @@ export default defineComponent({
style: 'width: 50px',
notsortable: true,
},
{
name: 'addtolist',
label: 'Add',
field: 'addtolist',
align: 'center',
noexp: true,
notsortable: true,
visu: costanti.VISUCAMPI.PER_EDITORE,
},
{
name: 'edit',
label: 'Mod',
@@ -555,6 +567,7 @@ export default defineComponent({
case 'data_online_stampa':
return tools.getstrDate(catalog.data_online_stampa);
case 'addtocart':
case 'addtolist':
return true;
case 'image':
return catalog.foto_collana?.imagefile
@@ -809,6 +822,7 @@ export default defineComponent({
? cookieValue
: [
'pos',
'addtolist',
'drag',
'edit',
'validato',
@@ -852,8 +866,13 @@ export default defineComponent({
const selectedColumns = ref([]);
function isEditColumn(name: string): boolean {
const column = allColumns.value.find((col) => col.name === name);
return column ? column.edit : false;
};
// 3. Funzione per verificare se una colonna è visibile (isColumnVisible)
const isColumnVisible = (column, real?: boolean) => {
const isColumnVisible = (column: string, real?: boolean) => {
if (column === 'actions' && !real) {
return false;
}
@@ -862,10 +881,20 @@ export default defineComponent({
return false;
}
}
const ok =
let ok =
allColumns.value.some((col) => col.name === column) &&
(!props.optcatalogo.showListaArgomenti ||
(props.optcatalogo.showListaArgomenti && !column.edit));
(props.optcatalogo.showListaArgomenti && !isEditColumn(column)));
if (props.options?.showbuttAdd && column === 'addtolist') {
if (tools.isCollaboratore())
ok = true
}
if (!props.options?.showbuttAdd && column === 'addtolist') {
ok = false
}
return selectedColumns.value.includes(column) && ok;
};
@@ -873,9 +902,8 @@ export default defineComponent({
const column = allColumns.value.find((col) => col.name === name);
return column ? column.label : '';
};
// Funzione per eliminare un prodotto
const removeProduct = (product) => {
const removeProduct = (product: IProduct) => {
return $q
.dialog({
message: t('scheda.removeProduct'),
@@ -1082,6 +1110,10 @@ export default defineComponent({
emit('rigenera');
}
function addtolist(element) {
emit('addtolist', element)
}
function getFieldClick(element: any, field: any): (() => void) | null {
switch (field.field) {
case 'trafiletto':
@@ -1147,7 +1179,7 @@ export default defineComponent({
);
}
function getImageByElement(element) {
function getImageByElement(element: any) {
let image = '';
if (props.table === shared_consts.TABLES_CATALOG) {
image = element.foto_collana?.imagefile;
@@ -1252,6 +1284,7 @@ export default defineComponent({
allColumnsComputed,
addtoCart,
arrordersCart,
addtolist,
};
},
});

View File

@@ -160,6 +160,17 @@
>
</q-btn>
</td>
<td v-else-if="field.name === 'addtolist' && isColumnVisible('addtolist')">
<q-btn
icon="fas fa-plus"
color="primary"
rounded
dense
size="sm"
@click="addtolist(element)"
>
</q-btn>
</td>
<!-- Immagine Piccola -->
<td v-else-if="field.name === 'image' && isColumnVisible('image')">