FILTRO CITTA Sopra ogni pagina !

This commit is contained in:
Surya Paolo
2022-12-01 16:55:22 +01:00
parent 9010c0ff37
commit bf1e9fc982
26 changed files with 900 additions and 74 deletions

View File

@@ -102,6 +102,11 @@ export default defineComponent({
required: false,
default: false
},
addlast: {
type: Boolean,
required: false,
default: false
},
dense: {
type: Boolean,
required: false,
@@ -163,25 +168,26 @@ export default defineComponent({
})
watch(() => props.options, (value: any, oldval: any) => {
if (!props.multiselect_by_server) {
valori.value = valoriload.value
} else {
// console.log('@@@ VALORI CHANGED (1)', valori.value)
}
},
if (!props.multiselect_by_server) {
valori.value = valoriload.value
} else {
// console.log('@@@ VALORI CHANGED (1)', valori.value)
}
},
)
watch(() => props.value, (value: any, oldval: any) => {
update()
},
update()
},
)
watch(() => props.arrvalue, (value: any, oldval: any) => {
// console.log(' MODIF props.arrvalue', props.arrvalue)
update()
},
// console.log(' MODIF props.arrvalue', props.arrvalue)
update()
},
)
function saveOptInCookie(arrval: any) {
console.log('saveOptInCookie')
if (arrval) {
for (const id of arrval) {
@@ -208,7 +214,10 @@ export default defineComponent({
// console.log('----------- arrtempOpt.value', arrtempOpt.value)
tools.localStSetItem(props.tablesel + num + props.optval, id)
tools.localStSetItem(props.tablesel + num + props.optlab, tools.getValueByFunzOrVal(rec, props.optlab))
let mysaved = tools.getValueByFunzOrVal(rec, props.optlab)
tools.localStSetItem(props.tablesel + num + props.optlab, mysaved)
console.log(' SAVED: ', props.tablesel + num + props.optlab, '=', mysaved)
num += 1
tools.localStSetItem(props.tablesel + 'NUM', num.toString())
@@ -220,7 +229,7 @@ export default defineComponent({
function changeval(newval: any) {
// console.log(' ½½½½½½½ changeval', newval)
console.log(' ½½½½½½½ changeval', newval)
if (props.multiple || props.multiselect_by_server) {
// tools.localStSetItem(props.tablesel + '_' + newval, valori.value[newval])
@@ -248,6 +257,7 @@ export default defineComponent({
} else {
if (props.tablesel === shared_consts.TAB_COUNTRY)
myvalue.value = newval && newval['value'] ? newval['value'] : newval
else if (props.tablesel === shared_consts.TAB_CITIES)
@@ -257,11 +267,45 @@ export default defineComponent({
else
myvalue.value = newval
// console.log('Myselect changeval', myvalue.value)
if (myvalue.value && JSON.stringify(myvalue.value)) {
saveLastOpt(props.optval, JSON.stringify(myvalue.value))
}
emit('update:value', myvalue.value)
emit('changeval', myvalue.value)
}
}
function saveLastOpt(key: string, myval: any) {
let ind = 9
// get free number
for (let i = 0; i < 10; i++) {
let myoldval = tools.getItemLS(props.tablesel + 'last_VAL' + i.toString())
myoldval = tools.strToObj(myoldval)
if (myoldval && myoldval[key]) {
if (myoldval[key] === myval) {
// already exist
return
}
// if (myoldval[key] !== myval) {
if (!myoldval[key]) {
ind = i
break
}
} else {
ind = i
break
}
}
// console.log('saveLastOpt', ind, 'key', key, 'myval', myval)
tools.localStSetItem(props.tablesel + 'last_OPT' + ind.toString(), key)
tools.localStSetItem(props.tablesel + 'last_VAL' + ind.toString(), myval)
}
function mounted() {
optionsreal.value = props.options
update()
@@ -320,7 +364,7 @@ export default defineComponent({
for (const myrec of myarrremote) {
let myidkey = myrec[props.col.remote_key]
if (!arrtempOpt.value.includes(myidkey)){
if (!arrtempOpt.value.includes(myidkey)) {
let myobj: any = {}
myobj[props.col.remote_key] = myidkey
if (props.col.remote_field === 'comune' && !!myrec['prov']) {
@@ -333,7 +377,7 @@ export default defineComponent({
}
}
}catch (e){}
} catch (e) { }
}
}
@@ -467,10 +511,35 @@ export default defineComponent({
myarr = [myobj, ...myarr]
}
if (props.addlast) {
myarr = getLastInserted(myarr)
}
// console.log(' myarr: ', myarr)
return myarr
}
function getLastInserted(myarr: any) {
for (let ind = 0; ind < 10; ind++) {
let optlab = tools.getItemLS(props.tablesel + 'last_OPT' + ind.toString())
let optval = tools.getItemLS(props.tablesel + 'last_VAL' + ind.toString())
if (optval)
optval = JSON.parse(optval)
// console.log(ind, '¶¶¶¶¶¶¶¶¶¶ optlab', optlab, 'optval', optval)
let myobj2: any = {}
if (typeof props.optlab === 'string') {
if (optval && !!optval['comune']) {
myobj2[props.optlab] = optval['comune']
myobj2[props.optval] = optval[optlab]
myarr = [...myarr, myobj2]
}
}
}
return myarr
}
function filterFn(val: any, update: any, abort: any) {
update(
async () => {
@@ -505,7 +574,7 @@ export default defineComponent({
}
if (val.length <= 1 && !(fieldsTable.tableRemotePickup.includes(props.tablesel) && props.filter_extra )) {
if (val.length <= 1 && !(fieldsTable.tableRemotePickup.includes(props.tablesel) && props.filter_extra)) {
console.log('@@@ LENGTH <= 1')
abort()
return
@@ -527,11 +596,9 @@ export default defineComponent({
myarr.push({ _id: 1, comune: 'PROVA 2', prov: 'AL' })
myarr.push({ _id: 2, comune: 'PROVA 2B', prov: 'AL' })
}*/
{ // @ts-ignore
myarr = await globalStore.loadPickup({ table: props.tablesel, search: mystr.trim(), filter: props.filter_extra })
}
}*/ { // @ts-ignore
myarr = await globalStore.loadPickup({ table: props.tablesel, search: mystr.trim(), filter: props.filter_extra })
}
@@ -563,6 +630,10 @@ export default defineComponent({
myarr = [myobj, ...myarr]
}
if (props.addlast) {
myarr = getLastInserted(myarr)
}
}
if (myarr && myarr.length > 0) {