Files
newfreeplanet_OLD/src/components/CSingleMovement/CSingleMovement.ts
Surya Paolo e29de7e0f6 - Fare LISTA MOVIMENTI più comprensibile
- Grafica Circuiti
2024-10-02 03:46:40 +02:00

93 lines
2.3 KiB
TypeScript
Executable File

import { defineComponent, ref, computed, PropType, toRef, onMounted } from 'vue'
import { useUserStore } from '@store/UserStore'
import { useRouter } from 'vue-router'
import { useGlobalStore } from '@store/globalStore'
import { useI18n } from '@/boot/i18n'
import { CMyImgUser } from '@/components/CMyImgUser'
import { CCurrencyValue } from '@/components/CCurrencyValue'
import { tools } from '@store/Modules/tools'
import { IMovQuery, IMovement } from '@src/model'
import { shared_consts } from '@src/common/shared_vuejs'
export default defineComponent({
name: 'CSingleMovement',
components: { CMyImgUser, CCurrencyValue },
props: {
mov: {
type: Object as PropType<IMovement>,
required: true,
},
index: {
type: Number,
required: true,
},
visu: {
type: Number,
required: false,
default: 0,
}
},
setup(props, { emit }) {
const userStore = useUserStore()
const $router = useRouter()
const globalStore = useGlobalStore()
const { t } = useI18n();
function getFromToStr(mov: any) {
let mystr = ''
if (mov) {
mystr += mov.str
}
return mystr
}
function navigabyMov(mov: IMovQuery, from: boolean) {
let link = ''
if (from) {
if (mov.tipocontofrom === shared_consts.AccountType.USER) {
link = `/my/` + mov.userfrom.username
} else if (mov.tipocontofrom === shared_consts.AccountType.COLLECTIVE_ACCOUNT) {
link = tools.getPathByGroup(mov.groupfrom)
} else if (mov.tipocontofrom === shared_consts.AccountType.COMMUNITY_ACCOUNT) {
link = '' // mov.contocomfrom.name
}
} else {
if (mov.tipocontoto === shared_consts.AccountType.USER) {
link = `/my/` + mov.userto.username
} else if (mov.tipocontoto === shared_consts.AccountType.COLLECTIVE_ACCOUNT) {
link = tools.getPathByGroup(mov.groupto)
} else if (mov.tipocontoto === shared_consts.AccountType.COMMUNITY_ACCOUNT) {
link = ''
}
}
$router.push(link)
}
function getUsername(user: any) {
if (user && user.username) {
return user.username
}
return user
}
onMounted(() => {
})
return {
userStore,
tools,
getFromToStr,
t,
navigabyMov,
getUsername,
}
}
})