2021-12-11 00:25:35 +01:00
|
|
|
import {
|
2022-01-28 00:57:28 +01:00
|
|
|
computed,
|
2021-12-11 00:25:35 +01:00
|
|
|
defineComponent, onBeforeMount, onBeforeUnmount, onMounted, ref, toRef, toRefs, watch,
|
|
|
|
|
} from 'vue'
|
|
|
|
|
|
|
|
|
|
import { tools } from '@store/Modules/tools'
|
|
|
|
|
import { CMyFieldDb } from '@/components/CMyFieldDb'
|
|
|
|
|
import { costanti } from '@costanti'
|
|
|
|
|
import { useGlobalStore } from '@store/globalStore'
|
|
|
|
|
import { useUserStore } from '@store/UserStore'
|
|
|
|
|
import { colmySkills } from '@store/Modules/fieldsTable'
|
|
|
|
|
import { CGridTableRec } from '@/components/CGridTableRec'
|
|
|
|
|
import { IMySkill, ISearchList, ISkill } from 'model'
|
|
|
|
|
import { shared_consts } from '@/common/shared_vuejs'
|
2022-02-10 19:43:42 +01:00
|
|
|
import { useI18n } from '@/boot/i18n'
|
2021-12-11 00:25:35 +01:00
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
name: 'CFinder',
|
|
|
|
|
props: {
|
|
|
|
|
defaultnewrec: {
|
|
|
|
|
type: Function,
|
|
|
|
|
required: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
components: {
|
|
|
|
|
CMyFieldDb, CGridTableRec,
|
|
|
|
|
},
|
|
|
|
|
setup(props, { attrs, slots, emit }) {
|
|
|
|
|
const mytable = 'users'
|
2022-02-10 19:43:42 +01:00
|
|
|
const { t } = useI18n();
|
2021-12-11 00:25:35 +01:00
|
|
|
const globalStore = useGlobalStore()
|
|
|
|
|
const userStore = useUserStore()
|
|
|
|
|
|
|
|
|
|
const arrfilterand: any = ref([])
|
|
|
|
|
const filtercustom: any = ref([])
|
|
|
|
|
const searchList = ref(<ISearchList[]>[])
|
|
|
|
|
|
2022-02-10 19:43:42 +01:00
|
|
|
const search = ref('')
|
|
|
|
|
|
2022-01-28 00:57:28 +01:00
|
|
|
const idSector = computed(() => {
|
2022-01-28 18:15:46 +01:00
|
|
|
let myval: any = null
|
|
|
|
|
myval = searchList.value.find((rec) => (rec.table === 'sectors'))
|
|
|
|
|
if (myval) {
|
|
|
|
|
const ris = myval.value || 0
|
2022-02-08 23:06:22 +01:00
|
|
|
console.log('idSector=', ris)
|
2022-01-28 18:15:46 +01:00
|
|
|
return ris
|
|
|
|
|
} else {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2022-01-28 00:57:28 +01:00
|
|
|
})
|
|
|
|
|
|
2021-12-11 00:25:35 +01:00
|
|
|
function mounted() {
|
|
|
|
|
/*arrfilterand.value = [
|
|
|
|
|
{
|
|
|
|
|
label: 'Competenze',
|
|
|
|
|
value: shared_consts.FILTER_MYSKILL_SKILL
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
]*/
|
|
|
|
|
|
2021-12-16 10:56:57 +01:00
|
|
|
function getFilterSkills(recSkill: any, index: number, arr: any) {
|
|
|
|
|
const recsectors:any = searchList.value.find((rec) => rec.table === 'sectors')
|
2021-12-31 01:44:16 +01:00
|
|
|
// console.log('getFilterSkills', recSkill.idSector, recsectors.value)
|
2021-12-16 10:56:57 +01:00
|
|
|
if (recsectors) {
|
|
|
|
|
return recSkill.idSector.includes(recsectors.value)
|
|
|
|
|
} else {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 01:44:16 +01:00
|
|
|
function getFilterSubSkills(recSubSkill: any, index: number, arr: any) {
|
|
|
|
|
const recskills:any = searchList.value.find((rec) => rec.table === 'skills')
|
|
|
|
|
// console.log('recSubSkill', recSubSkill, 'recskills', recskills)
|
|
|
|
|
if (recskills) {
|
|
|
|
|
return recSubSkill.idSkill === recskills.value
|
|
|
|
|
} else {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-23 23:25:19 +01:00
|
|
|
function getFilterCitiesByProvince(recSubSkill: any, index: number, arr: any) {
|
|
|
|
|
const recprov:any = searchList.value.find((rec) => rec.table === 'provinces')
|
|
|
|
|
// console.log('recSubSkill', recSubSkill, 'recskills', recskills)
|
|
|
|
|
if (recprov) {
|
|
|
|
|
return recSubSkill.idSkill === recprov.value
|
|
|
|
|
} else {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-16 10:56:57 +01:00
|
|
|
|
2021-12-11 00:25:35 +01:00
|
|
|
searchList.value = [
|
|
|
|
|
{
|
|
|
|
|
label: 'Settore',
|
|
|
|
|
table: 'sectors',
|
|
|
|
|
key: 'idSector',
|
2022-02-10 01:04:17 +01:00
|
|
|
value: tools.getCookie(tools.COOK_SEARCH + 'sectors', 0),
|
2021-12-11 22:12:44 +01:00
|
|
|
arrvalue: [],
|
2021-12-11 00:25:35 +01:00
|
|
|
type: costanti.FieldType.select,
|
2021-12-16 10:56:57 +01:00
|
|
|
filter: null,
|
2022-02-10 21:16:56 +01:00
|
|
|
addall: true,
|
2021-12-16 10:56:57 +01:00
|
|
|
notinsearch: true,
|
2022-01-20 00:38:49 +01:00
|
|
|
useinput: false,
|
2021-12-11 00:25:35 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Competenza',
|
|
|
|
|
table: 'skills',
|
|
|
|
|
key: 'idSkill',
|
2021-12-31 01:44:16 +01:00
|
|
|
value: tools.getCookie(tools.COOK_SEARCH + 'skills' + '_' + tools.getCookie(tools.COOK_SEARCH + 'sectors', costanti.FILTER_TUTTI), costanti.FILTER_TUTTI),
|
2021-12-11 22:12:44 +01:00
|
|
|
arrvalue: [],
|
2021-12-11 00:25:35 +01:00
|
|
|
type: costanti.FieldType.select,
|
2021-12-31 01:44:16 +01:00
|
|
|
addall: true,
|
2021-12-16 10:56:57 +01:00
|
|
|
filter: getFilterSkills,
|
2021-12-31 01:44:16 +01:00
|
|
|
showcount: true,
|
2022-01-28 18:15:46 +01:00
|
|
|
useinput: false,
|
2021-12-31 01:44:16 +01:00
|
|
|
},
|
|
|
|
|
{
|
2022-01-28 00:57:28 +01:00
|
|
|
label: 'Specializzazione',
|
2021-12-31 01:44:16 +01:00
|
|
|
table: 'subskills',
|
|
|
|
|
key: 'idSubSkill',
|
2022-02-10 19:43:42 +01:00
|
|
|
value: tools.getCookie(tools.COOK_SEARCH + 'subskills' + '_' + tools.getCookie(tools.COOK_SEARCH + 'skills', costanti.FILTER_TUTTI), costanti.FILTER_TUTTI),
|
|
|
|
|
type: costanti.FieldType.select,
|
|
|
|
|
arrvalue: [],
|
2021-12-31 01:44:16 +01:00
|
|
|
addall: true,
|
|
|
|
|
filter: getFilterSubSkills,
|
|
|
|
|
showcount: true,
|
2022-01-20 00:38:49 +01:00
|
|
|
useinput: false,
|
2022-01-28 18:15:46 +01:00
|
|
|
icon: 'far fa-id-card',
|
2022-01-20 00:38:49 +01:00
|
|
|
},
|
2022-01-20 01:17:21 +01:00
|
|
|
/*{
|
2022-01-20 00:38:49 +01:00
|
|
|
label: 'Regione',
|
|
|
|
|
table: 'regions',
|
|
|
|
|
key: 'idReg',
|
|
|
|
|
value: 0,
|
|
|
|
|
type: costanti.FieldType.select,
|
|
|
|
|
arrvalue: tools.getCookie(tools.COOK_SEARCH + 'regions', [costanti.FILTER_TUTTI]),
|
|
|
|
|
filter: null,
|
|
|
|
|
useinput: true,
|
2022-01-20 01:17:21 +01:00
|
|
|
},*/
|
2021-12-11 00:25:35 +01:00
|
|
|
{
|
2022-01-23 23:25:19 +01:00
|
|
|
label: 'Provincia',
|
|
|
|
|
table: 'provinces',
|
|
|
|
|
key: 'idProvince',
|
|
|
|
|
type: costanti.FieldType.multiselect,
|
|
|
|
|
value: 0,
|
|
|
|
|
addall: true,
|
|
|
|
|
arrvalue: tools.getCookie(tools.COOK_SEARCH + 'provinces', [costanti.FILTER_TUTTI]),
|
|
|
|
|
filter: null,
|
|
|
|
|
useinput: true,
|
2022-01-28 18:15:46 +01:00
|
|
|
icon: 'flag',
|
2022-01-23 23:25:19 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Città',
|
2021-12-11 00:25:35 +01:00
|
|
|
table: 'cities',
|
2022-01-24 23:48:52 +01:00
|
|
|
key: 'idCity',
|
2022-01-20 00:38:49 +01:00
|
|
|
type: costanti.FieldType.multiselect_by_server,
|
2021-12-16 10:56:57 +01:00
|
|
|
value: 0,
|
2022-01-20 01:42:33 +01:00
|
|
|
addall: true,
|
2021-12-16 10:56:57 +01:00
|
|
|
arrvalue: tools.getCookie(tools.COOK_SEARCH + 'cities', [costanti.FILTER_TUTTI]),
|
2022-01-20 00:38:49 +01:00
|
|
|
useinput: true,
|
2022-01-24 23:48:52 +01:00
|
|
|
filter: null,
|
|
|
|
|
// filter: getFilterCitiesByProvince,
|
2022-01-23 23:25:19 +01:00
|
|
|
// param1: shared_consts.PARAM_SHOW_PROVINCE,
|
2022-01-20 00:38:49 +01:00
|
|
|
tablesel: 'cities',
|
2021-12-11 00:25:35 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Livello',
|
|
|
|
|
table: 'levels',
|
|
|
|
|
key: 'numLevel',
|
2021-12-16 10:56:57 +01:00
|
|
|
value: tools.getCookie(tools.COOK_SEARCH + 'levels', costanti.FILTER_TUTTI),
|
2021-12-11 22:12:44 +01:00
|
|
|
arrvalue: [],
|
2022-02-10 01:04:17 +01:00
|
|
|
addall: true,
|
2021-12-11 00:25:35 +01:00
|
|
|
type: costanti.FieldType.select,
|
2021-12-16 10:56:57 +01:00
|
|
|
filter: null,
|
2022-01-20 00:38:49 +01:00
|
|
|
useinput: false,
|
2021-12-11 00:25:35 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Stato',
|
|
|
|
|
table: 'statusSkills',
|
|
|
|
|
key: 'idStatusSkill',
|
2021-12-16 10:56:57 +01:00
|
|
|
value: 0,
|
2022-02-10 01:04:17 +01:00
|
|
|
arrvalue: tools.getCookie(tools.COOK_SEARCH + 'statusSkills', []),
|
2021-12-11 00:25:35 +01:00
|
|
|
type: costanti.FieldType.multiselect,
|
2021-12-16 10:56:57 +01:00
|
|
|
filter: null,
|
2022-01-20 00:38:49 +01:00
|
|
|
useinput: false,
|
2022-01-28 18:15:46 +01:00
|
|
|
icon: 'mood',
|
2021-12-11 00:25:35 +01:00
|
|
|
},
|
2021-12-17 18:30:18 +01:00
|
|
|
{
|
|
|
|
|
label: 'Contributo',
|
|
|
|
|
table: 'contribtypes',
|
|
|
|
|
key: 'idContribType',
|
|
|
|
|
value: 0,
|
2022-02-10 01:04:17 +01:00
|
|
|
arrvalue: tools.getCookie(tools.COOK_SEARCH + 'contribtypes', []),
|
2021-12-17 18:30:18 +01:00
|
|
|
type: costanti.FieldType.multiselect,
|
|
|
|
|
filter: null,
|
2022-01-20 00:38:49 +01:00
|
|
|
useinput: false,
|
2022-01-28 18:15:46 +01:00
|
|
|
icon: 'currency_exchange',
|
|
|
|
|
//icon: 'swap_horizontal_circle',
|
2021-12-17 18:30:18 +01:00
|
|
|
},
|
2021-12-11 00:25:35 +01:00
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
filtercustom.value = []
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-16 10:56:57 +01:00
|
|
|
|
2021-12-11 00:25:35 +01:00
|
|
|
async function createNewRecordInUserTable() {
|
|
|
|
|
console.log('createNewRecordInUserTable')
|
|
|
|
|
|
|
|
|
|
let mydata = {
|
|
|
|
|
table: mytable,
|
|
|
|
|
data: {
|
|
|
|
|
userId: userStore.my._id,
|
|
|
|
|
data: {},
|
|
|
|
|
field: 'myskills'
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (props.defaultnewrec) {
|
|
|
|
|
|
|
|
|
|
mydata.data.data = props.defaultnewrec
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log('mydata', mydata)
|
|
|
|
|
const data = await globalStore.saveSubRec(mydata)
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-17 18:30:18 +01:00
|
|
|
function getdefaultnewrec(): IMySkill {
|
2021-12-11 00:25:35 +01:00
|
|
|
return {
|
|
|
|
|
_id: 0,
|
2022-01-28 00:57:28 +01:00
|
|
|
idSector: 0,
|
2021-12-11 00:25:35 +01:00
|
|
|
idSkill: 0,
|
2021-12-31 01:44:16 +01:00
|
|
|
idSubSkill: [],
|
2021-12-11 00:25:35 +01:00
|
|
|
idStatusSkill: [],
|
2021-12-17 18:30:18 +01:00
|
|
|
idContribType: [],
|
2021-12-11 00:25:35 +01:00
|
|
|
idCity: [],
|
|
|
|
|
NumLevel: 0,
|
|
|
|
|
photos: [],
|
|
|
|
|
note: '',
|
|
|
|
|
subTitle: '',
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function extraparams() {
|
|
|
|
|
return {
|
2021-12-16 10:56:57 +01:00
|
|
|
lookup1: {
|
|
|
|
|
lk_tab: 'users',
|
|
|
|
|
lk_LF: 'userId',
|
|
|
|
|
lk_FF: '_id',
|
|
|
|
|
lk_as: 'user',
|
|
|
|
|
af_objId_tab: 'myId',
|
|
|
|
|
},
|
|
|
|
|
lookup2: {
|
2021-12-17 18:30:18 +01:00
|
|
|
lk_tab: 'skills',
|
2021-12-16 10:56:57 +01:00
|
|
|
lk_LF: 'idSkill',
|
|
|
|
|
lk_FF: '_id',
|
2021-12-17 18:30:18 +01:00
|
|
|
lk_as: 'recSkill',
|
2021-12-16 10:56:57 +01:00
|
|
|
af_objId_tab: '',
|
|
|
|
|
lk_proj: {
|
2021-12-17 18:30:18 +01:00
|
|
|
recSkill: 1,
|
|
|
|
|
sector: 1,
|
2022-01-28 00:57:28 +01:00
|
|
|
idSector: 1,
|
2021-12-16 10:56:57 +01:00
|
|
|
idSkill: 1,
|
2021-12-31 01:44:16 +01:00
|
|
|
idSubSkill: 1,
|
2021-12-16 10:56:57 +01:00
|
|
|
idStatusSkill: 1,
|
2021-12-17 18:30:18 +01:00
|
|
|
idContribType: 1,
|
2021-12-16 10:56:57 +01:00
|
|
|
idCity: 1,
|
|
|
|
|
numLevel: 1,
|
|
|
|
|
photos: 1,
|
|
|
|
|
note: 1,
|
|
|
|
|
subTitle: 1,
|
|
|
|
|
date_created: 1,
|
|
|
|
|
date_updated: 1,
|
|
|
|
|
userId: 1,
|
|
|
|
|
username: 1,
|
|
|
|
|
name: 1,
|
2022-01-20 00:38:49 +01:00
|
|
|
surname: 1,
|
|
|
|
|
comune: 1,
|
2022-01-24 23:48:52 +01:00
|
|
|
mycities: 1,
|
2022-01-20 00:38:49 +01:00
|
|
|
'profile.img': 1,
|
|
|
|
|
'profile.qualifica': 1,
|
2021-12-16 10:56:57 +01:00
|
|
|
}
|
2021-12-17 18:30:18 +01:00
|
|
|
},
|
|
|
|
|
lookup3: {
|
|
|
|
|
lk_tab: 'sectors',
|
|
|
|
|
lk_LF: 'recSkill.idSector',
|
|
|
|
|
lk_FF: '_id',
|
|
|
|
|
lk_as: 'sector',
|
|
|
|
|
af_objId_tab: '',
|
|
|
|
|
},
|
2021-12-31 01:44:16 +01:00
|
|
|
lookup4: {
|
|
|
|
|
lk_tab: 'subskills',
|
|
|
|
|
lk_LF: 'idSubSkill',
|
|
|
|
|
lk_FF: '_id',
|
|
|
|
|
lk_as: 'myskill',
|
|
|
|
|
af_objId_tab: '',
|
|
|
|
|
},
|
2022-01-20 00:38:49 +01:00
|
|
|
lookup5: {
|
2022-01-24 23:48:52 +01:00
|
|
|
lk_tab: 'cities',
|
|
|
|
|
lk_LF: 'idCity',
|
|
|
|
|
lk_FF: '_id',
|
|
|
|
|
lk_as: 'mycities',
|
2022-01-20 00:38:49 +01:00
|
|
|
af_objId_tab: '',
|
|
|
|
|
},
|
2021-12-11 00:25:35 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-10 19:43:42 +01:00
|
|
|
function doSearch() {
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-11 00:25:35 +01:00
|
|
|
onMounted(mounted)
|
|
|
|
|
|
|
|
|
|
return {
|
2022-02-10 19:43:42 +01:00
|
|
|
t,
|
2021-12-11 00:25:35 +01:00
|
|
|
tools,
|
|
|
|
|
costanti,
|
|
|
|
|
colmySkills,
|
|
|
|
|
getdefaultnewrec,
|
|
|
|
|
extraparams,
|
|
|
|
|
arrfilterand,
|
|
|
|
|
filtercustom,
|
|
|
|
|
searchList,
|
2022-01-28 00:57:28 +01:00
|
|
|
idSector,
|
2022-02-10 19:43:42 +01:00
|
|
|
search,
|
|
|
|
|
doSearch,
|
2021-12-11 00:25:35 +01:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
})
|