Aggiungere Filtro Regione
This commit is contained in:
@@ -194,7 +194,7 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function getFilterCitiesByProvince(recCities: any, index: number, arr: any) {
|
||||
/*function getFilterCitiesByProvince(recCities: any, index: number, arr: any) {
|
||||
const recprov: any = searchList.value.find((rec) => rec.table === 'provinces')
|
||||
// console.log('recSubSkill', recSubSkill, 'recskills', recskills)
|
||||
if (recprov) {
|
||||
@@ -204,6 +204,17 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
function getFilterProvinceByRegion(recProvince: any, index: number, arr: any) {
|
||||
const recreg: any = searchList.value.find((rec) => rec.table === 'regions')
|
||||
if (recreg) {
|
||||
return recProvince.reg === recreg.value
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
searchList_Servizi.value = [
|
||||
{
|
||||
@@ -219,16 +230,17 @@ export default defineComponent({
|
||||
icon: 'mood',
|
||||
filteradv: true,
|
||||
},
|
||||
/*{
|
||||
{
|
||||
label: 'Regione',
|
||||
table: 'regions',
|
||||
key: 'idReg',
|
||||
value: 0,
|
||||
type: costanti.FieldType.select,
|
||||
arrvalue: tools.getCookie(tools.COOK_SEARCH + 'regions', [costanti.FILTER_TUTTI]),
|
||||
value: tools.getCookie(tools.COOK_SEARCH + 'regions', costanti.FILTER_TUTTI),
|
||||
addall: true,
|
||||
arrvalue: [],
|
||||
filter: null,
|
||||
useinput: true,
|
||||
},*/
|
||||
useinput: false,
|
||||
},
|
||||
{
|
||||
label: 'Provincia',
|
||||
table: 'provinces',
|
||||
@@ -237,9 +249,10 @@ export default defineComponent({
|
||||
value: tools.getCookie(tools.COOK_SEARCH + 'provinces', costanti.FILTER_TUTTI),
|
||||
addall: true,
|
||||
arrvalue: [],
|
||||
filter: null,
|
||||
filter: getFilterProvinceByRegion,
|
||||
useinput: true,
|
||||
icon: 'flag',
|
||||
tablesel: 'provinces',
|
||||
},
|
||||
{
|
||||
label: 'Comune',
|
||||
@@ -370,16 +383,28 @@ export default defineComponent({
|
||||
icon: 'mood',
|
||||
filteradv: true,
|
||||
},
|
||||
/*{
|
||||
{
|
||||
label: 'Regione',
|
||||
table: 'regions',
|
||||
key: 'idReg',
|
||||
value: 0,
|
||||
type: costanti.FieldType.select,
|
||||
arrvalue: tools.getCookie(tools.COOK_SEARCH + 'regions', [costanti.FILTER_TUTTI]),
|
||||
value: tools.getCookie(tools.COOK_SEARCH + 'regions', costanti.FILTER_TUTTI),
|
||||
addall: true,
|
||||
arrvalue: [],
|
||||
filter: null,
|
||||
useinput: true,
|
||||
},*/
|
||||
useinput: false,
|
||||
},
|
||||
{
|
||||
label: 'Regione',
|
||||
table: 'regions',
|
||||
key: 'idReg',
|
||||
type: costanti.FieldType.select,
|
||||
value: tools.getCookie(tools.COOK_SEARCH + 'regions', costanti.FILTER_TUTTI),
|
||||
addall: true,
|
||||
arrvalue: [],
|
||||
filter: null,
|
||||
useinput: false,
|
||||
},
|
||||
{
|
||||
label: 'Provincia',
|
||||
table: 'provinces',
|
||||
@@ -388,7 +413,7 @@ export default defineComponent({
|
||||
value: tools.getCookie(tools.COOK_SEARCH + 'provinces', costanti.FILTER_TUTTI),
|
||||
addall: true,
|
||||
arrvalue: [],
|
||||
filter: null,
|
||||
filter: getFilterProvinceByRegion,
|
||||
useinput: true,
|
||||
icon: 'flag',
|
||||
},
|
||||
@@ -469,16 +494,17 @@ export default defineComponent({
|
||||
]
|
||||
|
||||
searchList_Beni.value = [
|
||||
/*{
|
||||
{
|
||||
label: 'Regione',
|
||||
table: 'regions',
|
||||
key: 'idReg',
|
||||
value: 0,
|
||||
type: costanti.FieldType.select,
|
||||
arrvalue: tools.getCookie(tools.COOK_SEARCH + 'regions', [costanti.FILTER_TUTTI]),
|
||||
value: tools.getCookie(tools.COOK_SEARCH + 'regions', costanti.FILTER_TUTTI),
|
||||
addall: true,
|
||||
arrvalue: [],
|
||||
filter: null,
|
||||
useinput: true,
|
||||
},*/
|
||||
useinput: false,
|
||||
},
|
||||
{
|
||||
label: 'Provincia',
|
||||
table: 'provinces',
|
||||
@@ -487,7 +513,7 @@ export default defineComponent({
|
||||
value: tools.getCookie(tools.COOK_SEARCH + 'provinces', costanti.FILTER_TUTTI),
|
||||
addall: true,
|
||||
arrvalue: [],
|
||||
filter: null,
|
||||
filter: getFilterProvinceByRegion,
|
||||
useinput: true,
|
||||
icon: 'flag',
|
||||
},
|
||||
@@ -615,6 +641,17 @@ export default defineComponent({
|
||||
]
|
||||
|
||||
searchList_MyGroups.value = [
|
||||
{
|
||||
label: 'Regione',
|
||||
table: 'regions',
|
||||
key: 'idReg',
|
||||
type: costanti.FieldType.select,
|
||||
value: tools.getCookie(tools.COOK_SEARCH + 'regions', costanti.FILTER_TUTTI),
|
||||
addall: true,
|
||||
arrvalue: [],
|
||||
filter: null,
|
||||
useinput: false,
|
||||
},
|
||||
{
|
||||
label: 'Provincia',
|
||||
table: 'provinces',
|
||||
@@ -623,7 +660,7 @@ export default defineComponent({
|
||||
value: tools.getCookie(tools.COOK_SEARCH + 'provinces', costanti.FILTER_TUTTI),
|
||||
addall: true,
|
||||
arrvalue: [],
|
||||
filter: null,
|
||||
filter: getFilterProvinceByRegion,
|
||||
useinput: true,
|
||||
icon: 'flag',
|
||||
},
|
||||
|
||||
@@ -405,16 +405,19 @@ export default defineComponent({
|
||||
let filtersearch: any[] = []
|
||||
let filtersearch2: any[] = []
|
||||
let filtersearch3or: any[] = []
|
||||
let filtersearch3and: any[] = []
|
||||
let filtercustom: any[] = [...props.filtercustom]
|
||||
|
||||
let recSector = null
|
||||
let recSectorGood = null
|
||||
let recCities = null
|
||||
let recRegion = null
|
||||
let recProvince = null
|
||||
let recSkill = null
|
||||
let idSector = 0
|
||||
let idSectorGood = 0
|
||||
let idProvince = 0
|
||||
let idRegion = 0
|
||||
let idSkill = 0
|
||||
if (searchList.value) {
|
||||
recSector = searchList.value.find((item: ISearchList) => item.table === 'sectors')
|
||||
@@ -428,6 +431,10 @@ export default defineComponent({
|
||||
recProvince = searchList.value.find((item: ISearchList) => item.table === 'provinces')
|
||||
idProvince = recProvince ? recProvince.value : 0
|
||||
}
|
||||
if (searchList.value) {
|
||||
recRegion = searchList.value.find((item: ISearchList) => item.table === 'regions')
|
||||
idRegion = recRegion ? recRegion.value : 0
|
||||
}
|
||||
if (searchList.value) {
|
||||
recCities = searchList.value.find((item: ISearchList) => item.table === 'cities')
|
||||
}
|
||||
@@ -437,6 +444,9 @@ export default defineComponent({
|
||||
idSkill = recSkill ? recSkill.value : 0
|
||||
}
|
||||
|
||||
let arrfilter_cities: any = []
|
||||
let arrfilter_provices: any = []
|
||||
|
||||
// console.table(searchList.value)
|
||||
|
||||
if (searchList.value) {
|
||||
@@ -448,15 +458,26 @@ export default defineComponent({
|
||||
// console.log(' item ', item)
|
||||
let obj: any = {}
|
||||
|
||||
if (item.table === 'provinces') {
|
||||
if (item.table === 'regions') {
|
||||
|
||||
obj['mycities.reg'] = item.value
|
||||
if (item.value !== '' && item.value !== costanti.FILTER_TUTTI) {
|
||||
filtersearch3and.push(obj)
|
||||
}
|
||||
|
||||
if (item.value && recProvince && idRegion !== costanti.FILTER_TUTTI) {
|
||||
arrfilter_provices.push({key: 'reg', value: idRegion })
|
||||
}
|
||||
|
||||
} else if (item.table === 'provinces') {
|
||||
|
||||
obj['mycities.prov'] = item.value
|
||||
if (item.value !== '' && item.value !== costanti.FILTER_TUTTI) {
|
||||
filtersearch3or.push(obj)
|
||||
filtersearch3and.push(obj)
|
||||
}
|
||||
|
||||
if (item.value && recCities && idProvince !== costanti.FILTER_TUTTI) {
|
||||
recCities.filter_extra = {prov: idProvince}
|
||||
arrfilter_cities.push({key: 'prov', value: idProvince })
|
||||
}
|
||||
|
||||
} else if (item.table === 'cities') {
|
||||
@@ -464,7 +485,7 @@ export default defineComponent({
|
||||
if (item.value && item.value.hasOwnProperty('_id')) {
|
||||
obj['idCity'] = item.value._id
|
||||
if (item.value && item.value !== '' && item.value._id !== costanti.FILTER_TUTTI) {
|
||||
filtersearch3or.push(obj)
|
||||
filtersearch3and.push(obj)
|
||||
}
|
||||
}
|
||||
} else if (shared_consts.TABLES_WITH_FILTER_FIELD.includes(item.table)) {
|
||||
@@ -539,6 +560,23 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
if (arrfilter_cities.length > 0 && recCities) {
|
||||
let myobjfilt: any = {}
|
||||
for (const myrec of arrfilter_cities) {
|
||||
myobjfilt[myrec.key] = myrec.value
|
||||
}
|
||||
recCities.filter_extra = myobjfilt
|
||||
}
|
||||
|
||||
if (arrfilter_provices.length > 0 && recProvince) {
|
||||
let myobjfilt: any = {}
|
||||
for (const myrec of arrfilter_provices) {
|
||||
myobjfilt[myrec.key] = myrec.value
|
||||
}
|
||||
recProvince.filter_extra = myobjfilt
|
||||
}
|
||||
|
||||
|
||||
// console.log('filtersearch', filtersearch)
|
||||
|
||||
if (props.prop_search) {
|
||||
@@ -579,6 +617,7 @@ export default defineComponent({
|
||||
// @ts-ignore
|
||||
filtersearch2: filtersearch2,
|
||||
filtersearch3or: filtersearch3or,
|
||||
filtersearch3and: filtersearch3and,
|
||||
// @ts-ignore
|
||||
filtercustom: filtercustom,
|
||||
sortBy: myobj,
|
||||
|
||||
@@ -428,6 +428,8 @@ export default defineComponent({
|
||||
update(
|
||||
async () => {
|
||||
console.log('Filter val', val, val.length)
|
||||
console.log('props.filter_extra', props.filter_extra)
|
||||
|
||||
|
||||
let myarr: any = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user