198 lines
5.0 KiB
TypeScript
198 lines
5.0 KiB
TypeScript
import { computed, defineComponent, onMounted, PropType, ref, watch } from 'vue'
|
|
|
|
import { CMyFieldDb } from '@/components/CMyFieldDb'
|
|
import { CTitleBanner } from '@/components/CTitleBanner'
|
|
import { CProfile } from '@/components/CProfile'
|
|
import { CDateTime } from '@/components/CDateTime'
|
|
import { CMyPage } from '@/components/CMyPage'
|
|
import { CMyChipList } from '@/components/CMyChipList'
|
|
import { CMyFieldRec } from '@/components/CMyFieldRec'
|
|
import { CMyUser } from '@/components/CMyUser'
|
|
import { CGalleryImages } from '@/components/CGalleryImages'
|
|
import { CAccomodation } from '@/components/CAccomodation'
|
|
import { tools } from '@store/Modules/tools'
|
|
import { useUserStore } from '@store/UserStore'
|
|
import { useCalendarStore } from '@store/CalendarStore'
|
|
import { useGlobalStore } from '@store/globalStore'
|
|
import { useI18n } from '@/boot/i18n'
|
|
import { toolsext } from '@store/Modules/toolsext'
|
|
import { useQuasar } from 'quasar'
|
|
import { costanti } from '@costanti'
|
|
import { IColGridTable, IImgGallery, IUserFields } from 'model'
|
|
import { shared_consts } from '@/common/shared_vuejs'
|
|
import { colCitys, fieldsTable } from '@store/Modules/fieldsTable'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { useNotifStore } from '@store/NotifStore'
|
|
|
|
export default defineComponent({
|
|
name: 'CMyCardService',
|
|
components: {
|
|
CProfile, CTitleBanner,
|
|
CMyFieldDb, CDateTime, CMyPage, CMyFieldRec, CAccomodation,
|
|
CMyUser, CGalleryImages, CMyChipList
|
|
},
|
|
props: {
|
|
table: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
prop_myrec: {
|
|
type: Object as PropType<any>,
|
|
required: false,
|
|
default: null,
|
|
},
|
|
idRec: {
|
|
type: Number,
|
|
required: false,
|
|
default: 0
|
|
},
|
|
nopopup: {
|
|
type: Boolean,
|
|
required: false,
|
|
default: false
|
|
},
|
|
},
|
|
setup(props) {
|
|
|
|
const userStore = useUserStore()
|
|
const calendarStore = useCalendarStore()
|
|
const notifStore = useNotifStore()
|
|
const globalStore = useGlobalStore()
|
|
const $q = useQuasar()
|
|
const $route = useRoute()
|
|
const { t } = useI18n()
|
|
|
|
const showPic = ref(false)
|
|
|
|
const $router = useRouter()
|
|
|
|
const usersList = ref({ show: false, title: '', list: [] })
|
|
|
|
const myrec = ref(<any>{})
|
|
const col = ref(<IColGridTable>{})
|
|
|
|
const idnotif = computed(() => $route.query.idnotif ? $route.query.idnotif.toString() : '')
|
|
|
|
function profile() {
|
|
return userStore.my.profile
|
|
}
|
|
|
|
function load() {
|
|
// Carica il profilo di quest'utente
|
|
if (props.idRec) {
|
|
userStore.loadGeneric(props.table, props.idRec, idnotif.value).then((ris) => {
|
|
myrec.value = ris
|
|
notifStore.setAsRead(idnotif.value)
|
|
})
|
|
|
|
} else {
|
|
myrec.value = props.prop_myrec
|
|
}
|
|
|
|
col.value = fieldsTable.getArrColsByTable(props.table)
|
|
}
|
|
|
|
watch(() => props.idRec, (to: any, from: any) => {
|
|
load()
|
|
})
|
|
|
|
function mounted() {
|
|
load()
|
|
}
|
|
|
|
function getlinkpage() {
|
|
return self.location.host + tools.getPathByTable(props.table, myrec.value._id)
|
|
}
|
|
function condividipag() {
|
|
const mystr = getlinkpage()
|
|
tools.copyStringToClipboard($q, mystr, true)
|
|
tools.sendMsgTelegramCmd($q, t, shared_consts.MsgTeleg.SHARE_TEXT, false, mystr)
|
|
return true
|
|
}
|
|
|
|
function showBadge() {
|
|
if (shared_consts.TABLES_SHOW_ADTYPE.includes(props.table)) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
function getRecGoodSkillByRec(rec: any) {
|
|
if (props.table === 'myskills')
|
|
return rec.recSkill
|
|
else if (props.table === 'mygoods')
|
|
return rec.recGood
|
|
|
|
return null
|
|
}
|
|
|
|
function getSectorByRec(rec: any) {
|
|
if (props.table === 'myskills')
|
|
return rec.sector
|
|
else if (props.table === 'mygoods')
|
|
return rec.sectorGood
|
|
|
|
return null
|
|
}
|
|
|
|
function clicca(tipo: any, myset: any, title: string) {
|
|
if (myset && tipo === costanti.TIPOFAVBOOK.FAVORITE) {
|
|
userStore.setFavorite($q, t, myrec.value._id, props.table, myrec.value);
|
|
}
|
|
if (myset && tipo === costanti.TIPOFAVBOOK.BOOKMARK) {
|
|
userStore.setBookmark($q, t, myrec.value._id, props.table, myrec.value);
|
|
}
|
|
|
|
if (!myset) {
|
|
usersList.value.show = true;
|
|
usersList.value.title = title;
|
|
usersList.value.list = myrec.value.myfav;
|
|
}
|
|
}
|
|
|
|
function naviga(path: string) {
|
|
$router.push(path)
|
|
}
|
|
|
|
function getTypeHosps() {
|
|
let obj = null
|
|
if (myrec.value.typeHosp) {
|
|
obj = globalStore.getRecordByTableSingle(toolsext.TABTYPEHOSP, myrec.value.typeHosp)
|
|
if (obj)
|
|
return obj.label
|
|
}
|
|
|
|
return obj
|
|
}
|
|
|
|
onMounted(mounted)
|
|
|
|
return {
|
|
profile,
|
|
tools,
|
|
costanti,
|
|
myrec,
|
|
shared_consts,
|
|
globalStore,
|
|
showPic,
|
|
userStore,
|
|
t,
|
|
fieldsTable,
|
|
colCitys,
|
|
toolsext,
|
|
col,
|
|
condividipag,
|
|
showBadge,
|
|
getlinkpage,
|
|
calendarStore,
|
|
getSectorByRec,
|
|
getRecGoodSkillByRec,
|
|
usersList,
|
|
clicca,
|
|
naviga,
|
|
getTypeHosps,
|
|
}
|
|
}
|
|
})
|