Aggiunto il filtro per Provincia
This commit is contained in:
@@ -82,6 +82,10 @@ export default defineComponent({
|
||||
sola_lettura: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
withToggle: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
}
|
||||
},
|
||||
components: {},
|
||||
@@ -116,7 +120,8 @@ export default defineComponent({
|
||||
watch(() => props.options, (value: any, oldval: any) => {
|
||||
if (!props.multiselect_by_server) {
|
||||
valori.value = valoriload.value
|
||||
// console.log('@@@ VALORI CHANGED (1)', valori.value)
|
||||
} else {
|
||||
console.log('@@@ VALORI CHANGED (1)', valori.value)
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -170,8 +175,8 @@ export default defineComponent({
|
||||
|
||||
|
||||
function changeval(newval: any) {
|
||||
// console.log(' ½½½½½½½ changeval', newval)
|
||||
if (props.multiselect_by_server) {
|
||||
console.log(' ½½½½½½½ changeval', newval)
|
||||
if (props.multiple || props.multiselect_by_server) {
|
||||
// localStorage.setItem(props.tablesel + '_' + newval, valori.value[newval])
|
||||
myarrvalue.value = newval && newval['arrvalue'] ? newval['arrvalue'] : newval
|
||||
saveOptInCookie(newval)
|
||||
@@ -249,9 +254,9 @@ export default defineComponent({
|
||||
}
|
||||
// }
|
||||
}
|
||||
console.log('@@@ VALORI CHANGED (4)', valori.value)
|
||||
if (!props.multiselect_by_server) {
|
||||
valori.value = valoriload.value
|
||||
console.log('@@@ VALORI CHANGED (4)', valori.value)
|
||||
} else {
|
||||
valori.value = arrtempOpt.value
|
||||
}
|
||||
@@ -260,50 +265,34 @@ export default defineComponent({
|
||||
|
||||
function filterFn(val: any, update: any, abort: any) {
|
||||
update(
|
||||
() => {
|
||||
async () => {
|
||||
console.log('Filter val', val, val.length)
|
||||
let myarr: any = []
|
||||
|
||||
if (val.length <= 1) {
|
||||
valori.value = arrtempOpt.value
|
||||
console.log('@@@ LENGTH <= 1')
|
||||
abort()
|
||||
return
|
||||
}
|
||||
|
||||
let mystr = val.toLocaleLowerCase()
|
||||
|
||||
console.log('props.tablesel', props.tablesel)
|
||||
// console.log('props.tablesel', props.tablesel)
|
||||
|
||||
if (fieldsTable.tableRemotePickup.includes(props.tablesel)) {
|
||||
try {
|
||||
myarr = props.options
|
||||
if (mystr !== '')
|
||||
return globalStore.loadPickup({ table: props.tablesel, search: mystr })
|
||||
.then((ris) => {
|
||||
myarr = props.options
|
||||
if (ris) {
|
||||
if (props.addall) {
|
||||
let myobj: any = {}
|
||||
if (typeof props.optlab === 'string') {
|
||||
myobj[props.optlab] = '(Tutti)'
|
||||
myobj[props.optval] = costanti.FILTER_TUTTI
|
||||
}
|
||||
|
||||
ris = [myobj, ...ris]
|
||||
}
|
||||
valori.value = ris
|
||||
if (props.multiselect_by_server) {
|
||||
console.log('@@@ VALORI CHANGED (2)', valori.value)
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
// myarr = [{_id:1, prov: 'RN', descr: 'Rimini'}]
|
||||
myarr = await globalStore.loadPickup({ table: props.tablesel, search: mystr.trim() })
|
||||
|
||||
if (myarr === null) {
|
||||
console.log('@@@ VALORI VALUE XXX', valori.value)
|
||||
valori.value = arrtempOpt.value
|
||||
return
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('@@@ VALORI VALUE XXX', valori.value)
|
||||
valori.value = arrtempOpt.value
|
||||
return
|
||||
}
|
||||
// const needle = val.toLocaleLowerCase()
|
||||
// optFiltered.value = optFiltered.value.filter((v: any) => v.toLocaleLowerCase().indexOf(needle) > -1)
|
||||
@@ -332,6 +321,7 @@ export default defineComponent({
|
||||
},
|
||||
// "ref" is the Vue reference to the QSelect
|
||||
(ref: any) => {
|
||||
// console.log('ref.options', ref.options)
|
||||
if (val !== '' && ref.options.length > 0) {
|
||||
ref.setOptionIndex(-1) // reset optionIndex in case there is something selected
|
||||
ref.moveOptionSelection(1, true) // focus the first selectable option and do not update the input-value
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
@filter="filterFn"
|
||||
@filter-abort="abortFilterFn"
|
||||
@update:model-value="changeval"
|
||||
input-debounce="300"
|
||||
input-debounce="600"
|
||||
rounded
|
||||
outlined
|
||||
multiple
|
||||
@@ -66,29 +66,7 @@
|
||||
</q-select>
|
||||
|
||||
</div>
|
||||
<div v-else-if="useinput">
|
||||
<q-select
|
||||
:multiple="multiple"
|
||||
rounded
|
||||
outlined
|
||||
v-bind="$attrs"
|
||||
:input-class="myclass"
|
||||
:model-value="myvalue"
|
||||
:use-input="useinput"
|
||||
input-debounce="0"
|
||||
@new-value="newvaluefunc"
|
||||
new-value-mode="add-unique"
|
||||
map-options
|
||||
emit-value
|
||||
:options="valori"
|
||||
:option-value="optval"
|
||||
:option-label="optlab"
|
||||
@update:model-value="changeval"
|
||||
:label="label"
|
||||
:dense="dense">
|
||||
</q-select>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div v-else-if="pickup">
|
||||
<q-select
|
||||
v-if="pickup"
|
||||
filled
|
||||
@@ -126,9 +104,67 @@
|
||||
</q-item>
|
||||
</template>
|
||||
</q-select>
|
||||
</div>
|
||||
<div v-else-if="multiple">
|
||||
<q-select
|
||||
v-else
|
||||
:multiple="multiple"
|
||||
:multiple="true"
|
||||
:model-value="myarrvalue"
|
||||
label-color="primary"
|
||||
:label="label"
|
||||
@update:model-value="changeval"
|
||||
rounded
|
||||
outlined
|
||||
v-bind="$attrs"
|
||||
:input-class="myclass"
|
||||
:use-input="useinput"
|
||||
input-debounce="0"
|
||||
@new-value="newvaluefunc"
|
||||
new-value-mode="add-unique"
|
||||
map-options
|
||||
emit-value
|
||||
stack-label
|
||||
:options="valori"
|
||||
:option-value="optval"
|
||||
:option-label="optlab"
|
||||
:dense="dense">
|
||||
|
||||
<template
|
||||
v-slot:selected-item="scope">
|
||||
<div v-if="scope.opt[optlab]">
|
||||
<q-chip
|
||||
removable
|
||||
dense
|
||||
@remove="scope.removeAtIndex(scope.index)"
|
||||
v-if="checkIfShowRec(scope.opt)"
|
||||
color="white"
|
||||
text-color="mycol"
|
||||
class="q-my-none q-ml-xs q-mr-none"
|
||||
>
|
||||
<q-avatar color="primary" text-color="white" :icon="scope.opt.icon ? scope.opt.icon : ''" size="12px"/>
|
||||
{{ scope.opt[optlab] }}
|
||||
</q-chip>
|
||||
</div>
|
||||
</template>
|
||||
<template
|
||||
v-if="withToggle"
|
||||
v-slot:option="{ itemProps, opt, selected, toggleOption }">
|
||||
<q-item v-bind="itemProps">
|
||||
|
||||
<q-item-section>
|
||||
<q-item-label>{{ opt[optlab] }}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-toggle :model-value="selected" @update:value="toggleOption(opt)"/>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template>
|
||||
|
||||
</q-select>
|
||||
|
||||
</div>
|
||||
<div v-else>
|
||||
<q-select
|
||||
:multiple="false"
|
||||
rounded
|
||||
outlined
|
||||
:dense="dense"
|
||||
|
||||
Reference in New Issue
Block a user