- 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

@@ -1,5 +1,5 @@
import type { PropType } from 'vue';
import { defineComponent, onMounted, ref, watch, computed, onBeforeUnmount, nextTick } from 'vue'
import { defineComponent, onMounted, ref, watch, computed} from 'vue'
import { tools } from '@tools'
import { useUserStore } from '@store/UserStore'
import { useRouter } from 'vue-router'
@@ -17,18 +17,17 @@ import { CMySelect } from '@src/components/CMySelect'
import { CContainerCatalogoCard } from '@src/components/CContainerCatalogoCard'
import { CSelectUserActive } from '@src/components/CSelectUserActive'
import type {
IOptCatalogo, IDimensioni, IFilterCatalogo,
IMyScheda, IProdView, IProduct, ISchedaSingola, ISearchList, ICatalog, IImg
IOptCatalogo,
IProduct, ISearchList
} from 'model';
import { fieldsTable } from '@store/Modules/fieldsTable'
import { useCatalogStore } from '@src/store/CatalogStore'
export default defineComponent({
name: 'CSearchProduct',
components: { CContainerCatalogoCard, CProductCard, CSelectUserActive, CMySelect },
emits: [],
emits: ['insert', 'close', 'updateproductmodif'],
props: {
modelValue: {
type: Object as PropType<IOptCatalogo>,
@@ -40,11 +39,21 @@ export default defineComponent({
required: false,
default : '',
},
empty: {
type: Boolean,
required: false,
default: false,
},
nameLinkTemplate: {
type: String,
required: false,
default : '',
},
visu: {
type: Number,
required: false,
default: shared_consts.VISU_SEARCHPROD_MODE.VISU,
},
},
setup(props, { emit }) {
const userStore = useUserStore()
@@ -55,6 +64,7 @@ export default defineComponent({
const { t } = useI18n()
const search = ref('')
const focus = ref(false)
const loadpage = ref(false)
const refreshpage = ref(false)
@@ -99,6 +109,12 @@ export default defineComponent({
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) {
@@ -110,9 +126,14 @@ export default defineComponent({
myproduct.value = null
}
saveSearch()
console.log('myproduct.value', myproduct.value)
if (!props.idprodtoshow) {
}
function saveSearch() {
if (!props.idprodtoshow && !props.empty) {
if (myproduct.value) {
tools.setCookie(tools.COOK_LAST_PROD_SEARCH, myproduct.value._id.toString())
} else {
@@ -120,6 +141,9 @@ export default defineComponent({
}
}
if (!myproduct.value) {
tools.setCookie(tools.COOK_LAST_PROD_SEARCH, '')
}
}
function resetSearch() {
@@ -137,7 +161,7 @@ export default defineComponent({
}
function populateDataWithlinkIdTemplate() {
console.log('populateDataWithlinkIdTemplate')
// console.log('populateDataWithlinkIdTemplate')
if (optcatalogo.value) {
@@ -174,12 +198,16 @@ export default defineComponent({
}
}
const id = props.idprodtoshow || tools.getCookie(tools.COOK_LAST_PROD_SEARCH, '')
const id = props.idprodtoshow || (!props.empty ? tools.getCookie(tools.COOK_LAST_PROD_SEARCH, '') : '')
if (props.nameLinkTemplate) {
populateDataWithlinkIdTemplate()
}
if (props.visu === shared_consts.VISU_SEARCHPROD_MODE.INSERT) {
focus.value = true
}
loadpage.value = false
if (id) {
@@ -216,15 +244,30 @@ export default defineComponent({
}
function collabel (rec: any) {
console.log('Record:', rec)
// console.log('Record:', rec)
let label = ''
if (rec && rec.productInfo) {
label = `${rec.productInfo.name} - ${rec.productInfo.authors.map((a: any) => a.name + ' ' + a.surname).join(', ')}`
console.log('Computed label:', label)
// console.log('Computed label:', label)
}
return label
}
function insertProd() {
// console.log('insertProd')
emit('insert', myproduct.value)
}
function clickClose() {
searchList.value[0].value = ''
myproduct.value = null
emit('close')
}
function updateproductmodif(element: IProduct) {
emit('updateproductmodif', element)
}
onMounted(mounted)
return {
@@ -250,6 +293,11 @@ export default defineComponent({
valoriopt,
labelcombo,
searchText,
insertProd,
focus,
clickClose,
saveSearch,
updateproductmodif,
}
}
})