Sistemato il filtro per Provincia

This commit is contained in:
paoloar77
2022-01-24 23:48:52 +01:00
parent 030523c8ee
commit d3eee69aa7
2 changed files with 59 additions and 31 deletions

View File

@@ -129,18 +129,18 @@ export default defineComponent({
arrvalue: tools.getCookie(tools.COOK_SEARCH + 'provinces', [costanti.FILTER_TUTTI]), arrvalue: tools.getCookie(tools.COOK_SEARCH + 'provinces', [costanti.FILTER_TUTTI]),
filter: null, filter: null,
useinput: true, useinput: true,
notinsearch: true,
}, },
{ {
label: 'Città', label: 'Città',
table: 'cities', table: 'cities',
key: 'idProvince', key: 'idCity',
type: costanti.FieldType.multiselect_by_server, type: costanti.FieldType.multiselect_by_server,
value: 0, value: 0,
addall: true, addall: true,
arrvalue: tools.getCookie(tools.COOK_SEARCH + 'cities', [costanti.FILTER_TUTTI]), arrvalue: tools.getCookie(tools.COOK_SEARCH + 'cities', [costanti.FILTER_TUTTI]),
useinput: true, useinput: true,
filter: getFilterCitiesByProvince, filter: null,
// filter: getFilterCitiesByProvince,
// param1: shared_consts.PARAM_SHOW_PROVINCE, // param1: shared_consts.PARAM_SHOW_PROVINCE,
tablesel: 'cities', tablesel: 'cities',
}, },
@@ -252,6 +252,7 @@ export default defineComponent({
name: 1, name: 1,
surname: 1, surname: 1,
comune: 1, comune: 1,
mycities: 1,
'profile.img': 1, 'profile.img': 1,
'profile.qualifica': 1, 'profile.qualifica': 1,
} }
@@ -271,10 +272,10 @@ export default defineComponent({
af_objId_tab: '', af_objId_tab: '',
}, },
lookup5: { lookup5: {
lk_tab: 'provinces', lk_tab: 'cities',
lk_LF: 'idProvince', lk_LF: 'idCity',
lk_FF: 'prov', lk_FF: '_id',
lk_as: 'descr', lk_as: 'mycities',
af_objId_tab: '', af_objId_tab: '',
}, },
} }

View File

@@ -182,7 +182,7 @@ export default defineComponent({
const globalStore = useGlobalStore() const globalStore = useGlobalStore()
const isfinishLoading = computed(() => globalStore.finishLoading) const isfinishLoading = computed(() => globalStore.finishLoading)
const pagination = ref(<IPagination> { sortBy: 'desc', descending: false, page: 1, rowsNumber: 10, rowsPerPage: 10 }) const pagination = ref(<IPagination>{ sortBy: 'desc', descending: false, page: 1, rowsNumber: 10, rowsPerPage: 10 })
const addRow = ref('Aggiungi') const addRow = ref('Aggiungi')
@@ -246,12 +246,12 @@ export default defineComponent({
return lab return lab
}) })
watch(() => searchList.value, (to: any, from: any) => { watch(() => searchList.value, (to: any, from: any) => {
console.log('watch searchlist', to) console.log('watch searchlist', to)
refresh() refresh()
}) })
watch(() => props.filtercustom, (to: any, from: any) => { watch(() => props.filtercustom, (to: any, from: any) => {
console.log('filtercustom', to) console.log('filtercustom', to)
refresh() refresh()
}) })
@@ -343,15 +343,22 @@ export default defineComponent({
let filtersearch: any[] = [] let filtersearch: any[] = []
let filtersearch2: any[] = [] let filtersearch2: any[] = []
let filtersearch3or: any[] = []
let recSector = null; let recSector = null
let recSkill = null; let recProvince = null
let idSector = 0; let recSkill = null
let idSkill = 0; let idSector = 0
let idProvince = 0
let idSkill = 0
if (searchList.value) { if (searchList.value) {
recSector = searchList.value.find((item: ISearchList) => item.table === 'sectors') recSector = searchList.value.find((item: ISearchList) => item.table === 'sectors')
idSector = recSector ? recSector.value : 0 idSector = recSector ? recSector.value : 0
} }
if (searchList.value) {
recProvince = searchList.value.find((item: ISearchList) => item.table === 'provinces')
idProvince = recProvince ? recProvince.value : 0
}
if (searchList.value) { if (searchList.value) {
recSkill = searchList.value.find((item: ISearchList) => item.table === 'skills') recSkill = searchList.value.find((item: ISearchList) => item.table === 'skills')
@@ -362,33 +369,51 @@ export default defineComponent({
if (searchList.value) { if (searchList.value) {
for (const item of searchList.value) { for (const item of searchList.value) {
//searchList.value.forEach((item: ISearchList) => { //searchList.value.forEach((item: ISearchList) => {
if (!item.notinsearch) { if (!item.notinsearch) {
let objitem: any = {} let objitem: any = {}
// console.log(' item ', item)
if (item.value > 0) { if (item.value > 0) {
objitem[item.key] = item.value objitem[item.key] = item.value
filtersearch.push(objitem) filtersearch.push(objitem)
} else if (item.arrvalue.length > 0) { } else if (item.arrvalue.length > 0) {
const myarr = item.arrvalue.filter((value: any) => { const myarr = item.arrvalue.filter((value: any) => {
if (typeof value === 'number') { if (typeof value === 'number') {
return value > 0; return value > 0
} }
return true; return true
}) })
let arr2: any = [] let arr2: any = []
myarr.forEach((myval: any) => { if (item.table === 'provinces') {
let objitem2: any = {} arr2 = []
objitem2[item.key] = myval myarr.forEach((myval: any) => {
arr2.push(objitem2) let objitem3: any = {}
}) objitem3['mycities.prov'] = myval
arr2.push(objitem3)
})
let obj2: any = {
$or: arr2
}
if (arr2.length > 0) {
filtersearch3or = arr2
}
} else {
myarr.forEach((myval: any) => {
let objitem2: any = {}
objitem2[item.key] = myval
arr2.push(objitem2)
})
let obj2: any = { let obj2: any = {
$or: arr2 $or: arr2
}
if (arr2.length > 0) {
filtersearch.push(obj2)
}
} }
if (arr2.length > 0)
filtersearch.push(obj2)
} else { } else {
if ((item.table === 'skills') && item.value === costanti.FILTER_TUTTI) { if ((item.table === 'skills') && item.value === costanti.FILTER_TUTTI) {
let obj2: any = {} let obj2: any = {}
@@ -447,6 +472,7 @@ export default defineComponent({
filtersearch: filtersearch, filtersearch: filtersearch,
// @ts-ignore // @ts-ignore
filtersearch2: filtersearch2, filtersearch2: filtersearch2,
filtersearch3or: filtersearch3or,
// @ts-ignore // @ts-ignore
filtercustom: props.filtercustom, filtercustom: props.filtercustom,
sortBy: myobj, sortBy: myobj,
@@ -527,7 +553,7 @@ export default defineComponent({
// else // else
try { try {
serverData.value = [...returnedData.value] serverData.value = [...returnedData.value]
}catch (e) { } catch (e) {
serverData.value = [] serverData.value = []
} }
} }
@@ -934,6 +960,7 @@ export default defineComponent({
return '' return ''
} }
} }
function visuIntestazCol(col: IColGridTable) { function visuIntestazCol(col: IColGridTable) {
if (col.fieldtype === costanti.FieldType.html || col.fieldtype === costanti.FieldType.listimages) { if (col.fieldtype === costanti.FieldType.html || col.fieldtype === costanti.FieldType.listimages) {
return false return false
@@ -942,7 +969,7 @@ export default defineComponent({
} }
} }
function checkIfColShow(field: string|undefined) { function checkIfColShow(field: string | undefined) {
let vis = true let vis = true
if (props.prop_mytable === 'myskills' && !props.prop_search) { if (props.prop_mytable === 'myskills' && !props.prop_search) {
if (field === 'username') { if (field === 'username') {
@@ -1111,7 +1138,7 @@ export default defineComponent({
async function saveNewRecord() { async function saveNewRecord() {
// check if the field are setted // check if the field are setted
if (!enableSaveNewRec()){ if (!enableSaveNewRec()) {
return false return false
} }
@@ -1125,7 +1152,7 @@ export default defineComponent({
//++ Eliminare eventuali campi ? //++ Eliminare eventuali campi ?
mycolumns.value.forEach((col:IColGridTable) => { mycolumns.value.forEach((col: IColGridTable) => {
if (col.notsave) { if (col.notsave) {
delete myobj[col.name] delete myobj[col.name]
} }
@@ -1175,7 +1202,7 @@ export default defineComponent({
editRecordBool.value = false editRecordBool.value = false
const indrec = serverData.value.findIndex((rec: IMySkill) => rec._id === ris._id) const indrec = serverData.value.findIndex((rec: IMySkill) => rec._id === ris._id)
console.log('indrec', indrec, serverData.value[indrec]) console.log('indrec', indrec, serverData.value[indrec])
mycolumns.value.forEach((col:IColGridTable) => { mycolumns.value.forEach((col: IColGridTable) => {
if (!col.foredit) { if (!col.foredit) {
ris[col.name] = oldrec[col.name] ris[col.name] = oldrec[col.name]
} }