fix filtro multiselect
This commit is contained in:
@@ -207,6 +207,20 @@ export default defineComponent({
|
||||
refresh()
|
||||
}
|
||||
|
||||
function canModifyThisRec(rec: any) {
|
||||
// console.log('rec', rec)
|
||||
if (rec.hasOwnProperty('userId')) {
|
||||
let userId = rec.userId
|
||||
if (userId === userStore.my._id) {
|
||||
// E' il mio, quindi modificalo
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
// if (userStore.isAdmin || userStore.isManager)
|
||||
// return true
|
||||
}
|
||||
|
||||
// emulate 'SELECT count(*) FROM ...WHERE...'
|
||||
function getRowsNumberCount(myfilter?: any) {
|
||||
|
||||
@@ -244,11 +258,27 @@ export default defineComponent({
|
||||
|
||||
if (searchList.value) {
|
||||
searchList.value.forEach((item: ISearchList) => {
|
||||
let myarr: ISearchList
|
||||
let objitem: any = {}
|
||||
if (item.value > 0) {
|
||||
let myarr: ISearchList
|
||||
let objitem: any = {}
|
||||
objitem[item.key] = item.value
|
||||
filtersearch.push(objitem)
|
||||
} else if (item.arrvalue.length > 0) {
|
||||
const myarr = item.arrvalue.filter((value) => value > 0)
|
||||
|
||||
let arr2: any = []
|
||||
|
||||
myarr.forEach((myval) => {
|
||||
let objitem2: any = {}
|
||||
objitem2[item.key] = myval
|
||||
arr2.push(objitem2)
|
||||
})
|
||||
|
||||
let obj2: any = {
|
||||
$or: arr2
|
||||
}
|
||||
if (arr2.length > 0)
|
||||
filtersearch.push(obj2)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -272,7 +302,7 @@ export default defineComponent({
|
||||
params.codeId = mycodeid.value
|
||||
|
||||
// console.log('params', params)
|
||||
console.log('props.extraparams', props.extraparams)
|
||||
// console.log('props.extraparams', props.extraparams)
|
||||
|
||||
params = { ...params, ...props.extraparams }
|
||||
|
||||
@@ -1029,6 +1059,7 @@ export default defineComponent({
|
||||
globalStore,
|
||||
searchList,
|
||||
searchval,
|
||||
canModifyThisRec,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -146,7 +146,8 @@
|
||||
|
||||
<q-select
|
||||
v-if="item.type === costanti.FieldType.multiselect"
|
||||
v-model="item.value"
|
||||
v-model="item.arrvalue"
|
||||
@update:model-value="searchval"
|
||||
rounded
|
||||
outlined
|
||||
multiple
|
||||
@@ -158,7 +159,7 @@
|
||||
:options="globalStore.getTableJoinByName(item.table)"
|
||||
style="min-width: 150px"
|
||||
:option-value="fieldsTable.getKeyByTable(item.table)"
|
||||
@update:model-value="searchval">
|
||||
>
|
||||
|
||||
<template v-slot:option="{ itemProps, opt, selected, toggleOption }">
|
||||
<q-item v-bind="itemProps">
|
||||
@@ -167,7 +168,7 @@
|
||||
<q-item-label>{{ opt[fieldsTable.getLabelByTable(item.table)] }}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-toggle :model-value="selected" @update:value="toggleOption(opt)"/>
|
||||
<q-toggle :model-value="selected" @update:model-value="toggleOption(opt)"/>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template>
|
||||
@@ -230,9 +231,11 @@
|
||||
<span class="ellipsis"> {{ props.row[col_title] }} </span>
|
||||
<q-space/>
|
||||
<q-btn
|
||||
v-if="canModifyThisRec(props.row)"
|
||||
flat round color="white" icon="fas fa-pencil-alt" size="sm"
|
||||
@click="clickFunz(props.row, prop_mycolumns.find((rec) => rec.action === lists.MenuAction.CAN_EDIT_TABLE))"></q-btn>
|
||||
<q-btn
|
||||
v-if="canModifyThisRec(props.row)"
|
||||
flat round color="white" icon="fas fa-trash-alt" size="sm"
|
||||
@click="clickFunz(props.row, prop_mycolumns.find((rec) => rec.action === lists.MenuAction.DELETE_RECTABLE))"></q-btn>
|
||||
</q-bar>
|
||||
@@ -255,6 +258,7 @@
|
||||
<CMyPopupEdit
|
||||
:table="mytable"
|
||||
:canEdit="canEdit"
|
||||
:canModify="canModifyThisRec(props.row)"
|
||||
:disable="disabilita()"
|
||||
:mycol="col"
|
||||
v-model:row="props.row"
|
||||
|
||||
Reference in New Issue
Block a user