- Generazione della Raccolta dei Cataloghi (web e Stampa), e creazione del PDF Online.
- Lista Raccolta Cataloghi, aggiungi/togli catalogo.
This commit is contained in:
@@ -1,28 +1,25 @@
|
||||
import type { PropType } from 'vue';
|
||||
import { defineComponent, onMounted, ref, watch, computed } from 'vue'
|
||||
import { tools } from '@tools'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { useProducts } from '@store/Products'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { toolsext } from '@store/Modules/toolsext'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { costanti } from '@costanti'
|
||||
import { defineComponent, onMounted, ref, watch, computed } from 'vue';
|
||||
import { tools } from '@tools';
|
||||
import { useUserStore } from '@store/UserStore';
|
||||
import { useCatalogStore } from '@store/CatalogStore'
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useGlobalStore } from '@store/globalStore';
|
||||
import { useProducts } from '@store/Products';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { toolsext } from '@store/Modules/toolsext';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { costanti } from '@costanti';
|
||||
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
import { CProductCard } from '@src/components/CProductCard'
|
||||
import { shared_consts } from '@src/common/shared_vuejs';
|
||||
import { CProductCard } from '@src/components/CProductCard';
|
||||
|
||||
import { CMySelect } from '@src/components/CMySelect'
|
||||
import { CContainerCatalogoCard } from '@src/components/CContainerCatalogoCard'
|
||||
import { CSelectUserActive } from '@src/components/CSelectUserActive'
|
||||
import type {
|
||||
IOptCatalogo,
|
||||
IProduct, ISearchList
|
||||
} from 'model';
|
||||
import { CMySelect } from '@src/components/CMySelect';
|
||||
import { CContainerCatalogoCard } from '@src/components/CContainerCatalogoCard';
|
||||
import { CSelectUserActive } from '@src/components/CSelectUserActive';
|
||||
import type { IOptCatalogo, IProduct, ISearchList } from 'model';
|
||||
|
||||
|
||||
import { fieldsTable } from '@store/Modules/fieldsTable'
|
||||
import { fieldsTable } from '@store/Modules/fieldsTable';
|
||||
import Products from 'app/src/rootgen/admin/products/products.vue';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -35,6 +32,10 @@ export default defineComponent({
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
table: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
idprodtoshow: {
|
||||
type: String,
|
||||
required: false,
|
||||
@@ -57,124 +58,155 @@ export default defineComponent({
|
||||
},
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
const productStore = useProducts()
|
||||
const router = useRouter()
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore();
|
||||
const globalStore = useGlobalStore();
|
||||
const productStore = useProducts();
|
||||
const catalogStore = useCatalogStore();
|
||||
const router = useRouter();
|
||||
const $q = useQuasar();
|
||||
const { t } = useI18n();
|
||||
|
||||
const search = ref('')
|
||||
const focus = ref(false)
|
||||
const search = ref('');
|
||||
const focus = ref(false);
|
||||
|
||||
const loadpage = ref(false)
|
||||
const refreshpage = ref(false)
|
||||
const show_hide = ref(false)
|
||||
const loadpage = ref(false);
|
||||
const refreshpage = ref(false);
|
||||
const show_hide = ref(false);
|
||||
|
||||
const mycolumns = ref([])
|
||||
const mycolumns = ref([]);
|
||||
|
||||
const idPage = ref('')
|
||||
const selauthor = ref('')
|
||||
const where = ref('')
|
||||
|
||||
const searchList = ref(<ISearchList[]>[])
|
||||
const idPage = ref('');
|
||||
const selauthor = ref('');
|
||||
|
||||
const searchList = ref(<ISearchList[]>[]);
|
||||
|
||||
const optcatalogo = ref<IOptCatalogo | null>(null);
|
||||
|
||||
const myproduct = ref(<IProduct>{})
|
||||
const myproduct = ref(<IProduct>{});
|
||||
|
||||
const addstr = ref('')
|
||||
|
||||
const labelcombo = computed(() => (item: any) => {
|
||||
let lab = item.label
|
||||
if (item.showcount)
|
||||
lab += ' (' + valoriopt.value(item, false, false).length + ')'
|
||||
return lab
|
||||
})
|
||||
let lab = item.label;
|
||||
if (item.showcount) lab += ' (' + valoriopt.value(item, false, false).length + ')';
|
||||
return lab;
|
||||
});
|
||||
|
||||
const listaRicerca = computed(() => {
|
||||
const mylist = searchList.value.find((rec: any) => rec.table === 'products' && rec.key === 'titolo')
|
||||
|
||||
return mylist
|
||||
})
|
||||
let key = ''
|
||||
if (props.table === shared_consts.TABLES_CATALOG) {
|
||||
key = 'title'
|
||||
} else {
|
||||
key = 'titolo'
|
||||
}
|
||||
const mylist = searchList.value.find((rec: any) => rec.table === props.table && rec.key === key);
|
||||
|
||||
return mylist;
|
||||
});
|
||||
|
||||
const searchText = computed(() => {
|
||||
const lista = listaRicerca.value
|
||||
return lista && lista.value && tools.existProp(lista.value, 'name') ? lista.value.name : ''
|
||||
})
|
||||
const lista = listaRicerca.value;
|
||||
let key = ''
|
||||
if (props.table === shared_consts.TABLES_CATALOG) {
|
||||
key = 'title'
|
||||
} else {
|
||||
key = 'name'
|
||||
}
|
||||
return lista && lista.value && tools.existProp(lista.value, key) ? lista.value[key] : '';
|
||||
});
|
||||
|
||||
const valoriopt = computed(() => (item: any, addall: boolean, addnone: boolean = false) => {
|
||||
// console.log('valoriopt', item.table)
|
||||
return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter)
|
||||
})
|
||||
return globalStore.getTableJoinByName(item.table, addall, addnone, item.filter);
|
||||
});
|
||||
|
||||
watch(() => searchText.value, (newval, oldval) => {
|
||||
console.log('searchText=', searchText.value)
|
||||
const id = getSearchId()
|
||||
loadProduct(id)
|
||||
|
||||
})
|
||||
watch(() => myproduct.value, (newval, oldval) => {
|
||||
console.log('myproduct', myproduct.value)
|
||||
// loadProduct(myproduct.value._id)
|
||||
updateproductmodif(myproduct.value)
|
||||
})
|
||||
watch(
|
||||
() => searchText.value,
|
||||
(newval, oldval) => {
|
||||
console.log('searchText=', searchText.value);
|
||||
const id = getSearchId();
|
||||
loadProduct(id);
|
||||
}
|
||||
);
|
||||
watch(
|
||||
() => myproduct.value,
|
||||
(newval, oldval) => {
|
||||
console.log('myproduct', myproduct.value);
|
||||
// loadProduct(myproduct.value._id)
|
||||
updateproductmodif(myproduct.value);
|
||||
}
|
||||
);
|
||||
|
||||
async function loadProduct(id: string) {
|
||||
// Carica il prodotto
|
||||
console.log('loadProduct', id)
|
||||
console.log('loadProduct', id);
|
||||
|
||||
if (id) {
|
||||
myproduct.value = await productStore.loadProductById(id)
|
||||
} else {
|
||||
myproduct.value = null
|
||||
if (props.table === 'products') {
|
||||
if (id) {
|
||||
myproduct.value = await productStore.loadProductById(id);
|
||||
} else {
|
||||
myproduct.value = null;
|
||||
}
|
||||
|
||||
} else if (props.table === 'catalogs') {
|
||||
if (id) {
|
||||
myproduct.value = await catalogStore.getCatalogById(id);
|
||||
} else {
|
||||
myproduct.value = null;
|
||||
}
|
||||
}
|
||||
saveSearch();
|
||||
|
||||
saveSearch()
|
||||
|
||||
console.log('myproduct.value', myproduct.value)
|
||||
|
||||
console.log('myproduct.value', myproduct.value);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => where.value,
|
||||
(newval, oldval) => {
|
||||
tools.setCookie(addstr.value + 'WHE', newval);
|
||||
}
|
||||
);
|
||||
|
||||
function saveSearch() {
|
||||
if (!props.idprodtoshow && !props.empty) {
|
||||
if (myproduct.value) {
|
||||
tools.setCookie(tools.COOK_LAST_PROD_SEARCH, myproduct.value._id.toString())
|
||||
tools.setCookie(addstr.value + tools.COOK_LAST_PROD_SEARCH, myproduct.value._id.toString());
|
||||
} else {
|
||||
tools.setCookie(tools.COOK_LAST_PROD_SEARCH, '')
|
||||
tools.setCookie(addstr.value + tools.COOK_LAST_PROD_SEARCH, '');
|
||||
}
|
||||
}
|
||||
|
||||
if (!myproduct.value) {
|
||||
tools.setCookie(tools.COOK_LAST_PROD_SEARCH, '')
|
||||
tools.setCookie(addstr.value + tools.COOK_LAST_PROD_SEARCH, '');
|
||||
}
|
||||
}
|
||||
|
||||
function resetSearch() {
|
||||
const mialista = listaRicerca.value
|
||||
const mialista = listaRicerca.value;
|
||||
if (mialista && mialista.value && tools.existProp(mialista.value, 'name')) {
|
||||
mialista.value = null
|
||||
mialista.value = null;
|
||||
}
|
||||
search.value = ''
|
||||
search.value = '';
|
||||
}
|
||||
|
||||
|
||||
function getSearchId(): string {
|
||||
const lista = listaRicerca.value
|
||||
return lista && lista.value && lista.value._id ? lista.value._id : ''
|
||||
const lista = listaRicerca.value;
|
||||
return lista && lista.value && lista.value._id ? lista.value._id : '';
|
||||
}
|
||||
|
||||
function populateDataWithlinkIdTemplate() {
|
||||
// console.log('populateDataWithlinkIdTemplate')
|
||||
|
||||
if (optcatalogo.value) {
|
||||
|
||||
for (const recscheda of optcatalogo.value.arrSchede!) {
|
||||
if (recscheda.scheda?.linkIdTemplate) {
|
||||
// ricopia da Template:
|
||||
const myscheda = globalStore.sovrascriviSchedaFromTemplate(recscheda.scheda?.linkIdTemplate, recscheda)
|
||||
const myscheda = globalStore.sovrascriviSchedaFromTemplate(recscheda.scheda?.linkIdTemplate, recscheda);
|
||||
if (myscheda) {
|
||||
recscheda.scheda = { ...myscheda }
|
||||
recscheda.scheda = { ...myscheda };
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,139 +214,164 @@ export default defineComponent({
|
||||
// console.log(' FINE - populateDataWithlinkIdTemplate')
|
||||
}
|
||||
|
||||
function isProductLibro() {
|
||||
return props.table === 'products';
|
||||
}
|
||||
|
||||
async function mounted() {
|
||||
// console.log('mounted Catalogo')
|
||||
|
||||
addstr.value = tools.addstrCookie(props.table)
|
||||
|
||||
where.value = tools.getCookie(addstr.value + 'WHE', shared_consts.WHERE_INSERT.ONTOP);
|
||||
|
||||
if (props.modelValue) {
|
||||
optcatalogo.value = props.modelValue
|
||||
optcatalogo.value = props.modelValue;
|
||||
} else {
|
||||
optcatalogo.value = globalStore.createCatalogoVuoto()
|
||||
productStore.addNewScheda(optcatalogo.value)
|
||||
optcatalogo.value = globalStore.createCatalogoVuoto();
|
||||
productStore.addNewScheda(optcatalogo.value);
|
||||
|
||||
if (props.nameLinkTemplate) {
|
||||
const linkIdTemplate = globalStore.getLinkIdTemplateByName(props.nameLinkTemplate)
|
||||
if (linkIdTemplate)
|
||||
optcatalogo.value.arrSchede[0].scheda.linkIdTemplate = linkIdTemplate
|
||||
const linkIdTemplate = globalStore.getLinkIdTemplateByName(props.nameLinkTemplate);
|
||||
if (linkIdTemplate) optcatalogo.value.arrSchede[0].scheda.linkIdTemplate = linkIdTemplate;
|
||||
} else {
|
||||
optcatalogo.value.arrSchede[0].scheda.name = 'SEARCH_NEW'
|
||||
optcatalogo.value.arrSchede[0].scheda.name = 'SEARCH_NEW';
|
||||
}
|
||||
}
|
||||
|
||||
const id = props.idprodtoshow || (!props.empty ? tools.getCookie(tools.COOK_LAST_PROD_SEARCH, '') : '')
|
||||
let id = null;
|
||||
if (props.table === 'products') {
|
||||
id = props.idprodtoshow || (!props.empty ? tools.getCookie(addstr.value + tools.COOK_LAST_PROD_SEARCH, '') : '');
|
||||
}
|
||||
|
||||
if (props.nameLinkTemplate) {
|
||||
populateDataWithlinkIdTemplate()
|
||||
populateDataWithlinkIdTemplate();
|
||||
}
|
||||
|
||||
if (props.visu === shared_consts.VISU_SEARCHPROD_MODE.INSERT) {
|
||||
focus.value = true
|
||||
focus.value = true;
|
||||
}
|
||||
|
||||
loadpage.value = false
|
||||
loadpage.value = false;
|
||||
|
||||
if (id) {
|
||||
await loadProduct(id)
|
||||
await loadProduct(id);
|
||||
}
|
||||
|
||||
mycolumns.value = fieldsTable.getArrColsByTable(props.table);
|
||||
|
||||
mycolumns.value = fieldsTable.getArrColsByTable('products')
|
||||
if (isProductLibro()) {
|
||||
searchList.value = [
|
||||
{
|
||||
visible: true,
|
||||
label: 'Cerca un Titolo o un Autore',
|
||||
table: 'products',
|
||||
key: 'titolo',
|
||||
type: costanti.FieldType.select_by_server,
|
||||
value: myproduct.value,
|
||||
collabel: collabel,
|
||||
arrvalue: [],
|
||||
useinput: true,
|
||||
filter: null,
|
||||
tablesel: 'products',
|
||||
dense: false,
|
||||
},
|
||||
];
|
||||
} else {
|
||||
searchList.value = [
|
||||
{
|
||||
visible: true,
|
||||
label: 'Cerca un Catalogo',
|
||||
table: 'catalogs',
|
||||
key: 'title',
|
||||
type: costanti.FieldType.select_by_server,
|
||||
value: myproduct.value,
|
||||
collabel: 'title',
|
||||
arrvalue: [],
|
||||
useinput: true,
|
||||
filter: null,
|
||||
tablesel: 'catalogs',
|
||||
dense: false,
|
||||
},
|
||||
];
|
||||
|
||||
searchList.value = [
|
||||
{
|
||||
visible: true,
|
||||
label: 'Cerca un Titolo o un Autore',
|
||||
table: 'products',
|
||||
key: 'titolo',
|
||||
type: costanti.FieldType.select_by_server,
|
||||
value: myproduct.value,
|
||||
collabel: collabel,
|
||||
arrvalue: [],
|
||||
useinput: true,
|
||||
filter: null,
|
||||
tablesel: 'products',
|
||||
dense: false,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// Inizializza
|
||||
loadpage.value = true
|
||||
|
||||
loadpage.value = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function naviga(path: string) {
|
||||
router.push(path)
|
||||
router.push(path);
|
||||
}
|
||||
|
||||
function collabel(rec: any) {
|
||||
|
||||
let label = ''
|
||||
if (rec && rec.productInfo) {
|
||||
if (productStore.isNovitaById(rec.productInfo.date_pub))
|
||||
label += `🌟 `
|
||||
let label = '';
|
||||
if (rec && rec.productInfo && props.table === 'products') {
|
||||
if (productStore.isNovitaById(rec.productInfo.date_pub)) label += `🌟 `;
|
||||
|
||||
label += `${rec.productInfo.name}`;
|
||||
if (Array.isArray(rec.productInfo.authors)) {
|
||||
const authors = rec.productInfo.authors.map((a: any) => `${a.name} ${a.surname}`).join(', ');
|
||||
label += ` - (${authors})`;
|
||||
} else {
|
||||
label += rec.productInfo.authors ? ` - (${rec.productInfo.authors.name} ${rec.productInfo.authors.surname}) ` : '';
|
||||
label += rec.productInfo.authors
|
||||
? ` - (${rec.productInfo.authors.name} ${rec.productInfo.authors.surname}) `
|
||||
: '';
|
||||
}
|
||||
if (rec.productInfo.idStatoProdotto) {
|
||||
if (!productStore.isPubblicatoById(rec.productInfo.idStatoProdotto))
|
||||
label += ' (' + productStore.getDescrStatiProdottoByIdStatoProdotto(rec.productInfo.idStatoProdotto || '') + ')'
|
||||
label +=
|
||||
' (' + productStore.getDescrStatiProdottoByIdStatoProdotto(rec.productInfo.idStatoProdotto || '') + ')';
|
||||
}
|
||||
if (productStore.isEsaurito(rec)) {
|
||||
label += ' (Attualmente non disponibile)'
|
||||
label += ' (Attualmente non disponibile)';
|
||||
}
|
||||
// console.log('Computed label:', label)
|
||||
} else {
|
||||
if (rec && rec.name) label = rec.name;
|
||||
else label = '';
|
||||
}
|
||||
return label
|
||||
return label;
|
||||
}
|
||||
|
||||
function insertProd() {
|
||||
// console.log('insertProd')
|
||||
emit('insert', myproduct.value)
|
||||
console.log('insertProd', myproduct.value)
|
||||
emit('insert', myproduct.value, where.value);
|
||||
}
|
||||
|
||||
function clickClose() {
|
||||
searchList.value[0].value = ''
|
||||
myproduct.value = null
|
||||
emit('close')
|
||||
searchList.value[0].value = '';
|
||||
myproduct.value = null;
|
||||
emit('close');
|
||||
}
|
||||
|
||||
function updateproductmodif(element: IProduct) {
|
||||
console.log('CSEARCHPRODUCT: updateproductmodif')
|
||||
emit('updateproductmodif', element)
|
||||
console.log('CSEARCHPRODUCT: updateproductmodif');
|
||||
emit('updateproductmodif', element);
|
||||
}
|
||||
|
||||
async function searchOnGM(mystr: string) {
|
||||
// refreshSingleBookFromGM({usaDBGMLocale: false})
|
||||
const options = {
|
||||
|
||||
}
|
||||
const ris = await globalStore.updateAllBookFromGM_T_Web_Articoli({ sku: '', isbn: mystr, ...options })
|
||||
const options = {};
|
||||
const ris = await globalStore.updateAllBookFromGM_T_Web_Articoli({ sku: '', isbn: mystr, ...options });
|
||||
if (ris) {
|
||||
|
||||
const id = getSearchId()
|
||||
loadProduct(id)
|
||||
updateproductmodif(myproduct.value)
|
||||
const id = getSearchId();
|
||||
loadProduct(id);
|
||||
updateproductmodif(myproduct.value);
|
||||
|
||||
// await updateproduct(false)
|
||||
if (ris.error) {
|
||||
tools.showNegativeNotif($q, ris.error)
|
||||
tools.showNegativeNotif($q, ris.error);
|
||||
} else {
|
||||
tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK'))
|
||||
tools.showPositiveNotif($q, t('dbgm.updateLocalDb_OK'));
|
||||
}
|
||||
|
||||
// updatefromgm.value = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
onMounted(mounted);
|
||||
|
||||
return {
|
||||
userStore,
|
||||
@@ -345,7 +402,7 @@ export default defineComponent({
|
||||
saveSearch,
|
||||
updateproductmodif,
|
||||
searchOnGM,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
where,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user