- aggiornamento catalogo: lista titoli del catalogo
- scheda prodotto libro - migliorata tabella prodotto
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
v-model:value="item.value"
|
||||
:addall="item.addall"
|
||||
:addnone="item.addnone"
|
||||
:focus="focus"
|
||||
:addlast="true"
|
||||
:tablesel="item.type === costanti.FieldType.select_by_server ? item.tablesel : ''"
|
||||
:pickup="item.type === costanti.FieldType.select_by_server"
|
||||
@@ -37,7 +38,7 @@
|
||||
:filter="item.filter"
|
||||
:filter_extra="item.filter_extra"
|
||||
:useinput="item.useinput && item.type !== costanti.FieldType.select_by_server"
|
||||
@clear="item.value = ''"
|
||||
@clear="item.value = ''; myproduct = null; saveSearch()"
|
||||
>
|
||||
</CMySelect>
|
||||
</div>
|
||||
@@ -45,7 +46,7 @@
|
||||
<div
|
||||
v-if="myproduct?._id"
|
||||
class="row justify-center"
|
||||
style="text-align: center;"
|
||||
style="text-align: center"
|
||||
>
|
||||
<CContainerCatalogoCard
|
||||
:id="myproduct._id"
|
||||
@@ -59,9 +60,33 @@
|
||||
}"
|
||||
@selauthor="selauthor"
|
||||
:scheda="optcatalogo.arrSchede[0].scheda"
|
||||
@updateproductmodif="updateproductmodif"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column text-center">
|
||||
<div class="row justify-center q-ma-md">
|
||||
<div v-if="visu === shared_consts.VISU_SEARCHPROD_MODE.INSERT">
|
||||
<q-btn
|
||||
rounded
|
||||
class="q-ma-sm"
|
||||
color="secondary"
|
||||
icon="fas fa-plus"
|
||||
label="Inserisci"
|
||||
@click="insertProd"
|
||||
></q-btn>
|
||||
<!-- Button Close window -->
|
||||
<q-btn
|
||||
rounded
|
||||
class="q-ma-sm"
|
||||
color="primary"
|
||||
icon="fas fa-times-circle"
|
||||
label="Chiudi"
|
||||
@click="clickClose"
|
||||
></q-btn>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user