Files
myprojplanet_vite/src/components/CSingleMovement/CSingleMovement.ts

94 lines
2.3 KiB
TypeScript
Raw Normal View History

2025-03-01 14:14:43 +01:00
import type { PropType } from 'vue';
import { defineComponent, ref, computed, toRef, onMounted } from 'vue'
import { useUserStore } from '@store/UserStore'
import { useRouter } from 'vue-router'
import { useGlobalStore } from '@store/globalStore'
2025-03-01 14:14:43 +01:00
import { useI18n } from 'vue-i18n'
2025-03-01 14:14:43 +01:00
import { CMyImgUser } from '@src/components/CMyImgUser'
import { CCurrencyValue } from '@src/components/CCurrencyValue'
import { tools } from '@tools'
import type { 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
2025-03-26 23:23:35 +01:00
} else if (mov.tipocontofrom === shared_consts.AccountType.CONTO_DI_GRUPPO) {
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
2025-03-26 23:23:35 +01:00
} else if (mov.tipocontoto === shared_consts.AccountType.CONTO_DI_GRUPPO) {
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(() => {
2025-03-01 14:14:43 +01:00
})
return {
userStore,
tools,
getFromToStr,
t,
navigabyMov,
getUsername,
}
}
})