Merge branch 'beta' into feature/photo-view
gitea/hedera-web/pipeline/pr-beta This commit looks good
Details
gitea/hedera-web/pipeline/pr-beta This commit looks good
Details
This commit is contained in:
commit
2557e70638
|
@ -1,2 +1,5 @@
|
|||
debian
|
||||
node_modules
|
||||
node_modules
|
||||
.quasar
|
||||
build
|
||||
.vscode
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref, onMounted, inject, onBeforeUnmount } from 'vue';
|
||||
import { ref, onMounted, inject, onBeforeUnmount, h } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
|
@ -12,12 +12,49 @@ import { useAppStore } from 'stores/app';
|
|||
import { storeToRefs } from 'pinia';
|
||||
|
||||
const { t } = useI18n();
|
||||
const jApi = inject('jApi');
|
||||
const api = inject('api');
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
const appStore = useAppStore();
|
||||
const { isHeaderMounted } = storeToRefs(appStore);
|
||||
|
||||
const filter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'visitUser',
|
||||
scope: {
|
||||
include: [
|
||||
{
|
||||
relation: 'visitAccess',
|
||||
scope: {
|
||||
fields: ['id', 'agentFk'],
|
||||
include: [
|
||||
{
|
||||
relation: 'visitAgent',
|
||||
scope: {
|
||||
fields: [
|
||||
'platform',
|
||||
'browser',
|
||||
'version'
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['id', 'nickname', 'name']
|
||||
}
|
||||
}
|
||||
],
|
||||
fields: ['userFk', 'stamp', 'accessFk']
|
||||
}
|
||||
}
|
||||
],
|
||||
order: 'lastUpdate DESC'
|
||||
};
|
||||
const connections = ref([]);
|
||||
const loading = ref(false);
|
||||
const intervalId = ref(null);
|
||||
|
@ -25,20 +62,28 @@ const intervalId = ref(null);
|
|||
const getConnections = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
connections.value = await jApi.query(
|
||||
`SELECT vu.userFk userId, vu.stamp, u.nickname, s.lastUpdate,
|
||||
a.platform, a.browser, a.version, u.name user
|
||||
FROM userSession s
|
||||
JOIN visitUser vu ON vu.id = s.userVisitFk
|
||||
JOIN visitAccess ac ON ac.id = vu.accessFk
|
||||
JOIN visitAgent a ON a.id = ac.agentFk
|
||||
JOIN visit v ON v.id = a.visitFk
|
||||
JOIN account.user u ON u.id = vu.userFk
|
||||
ORDER BY lastUpdate DESC`
|
||||
);
|
||||
loading.value = false;
|
||||
|
||||
const { data } = await api.get('/userSessions', {
|
||||
params: { filter: JSON.stringify(filter) }
|
||||
});
|
||||
|
||||
if (!data) {
|
||||
connections.value = [];
|
||||
return;
|
||||
}
|
||||
|
||||
connections.value = data
|
||||
.map(({ visitUser = {}, ...rest }) => ({
|
||||
...rest,
|
||||
user: visitUser.user,
|
||||
stamp: visitUser.stamp,
|
||||
visitAgent: visitUser.visitAccess?.visitAgent
|
||||
}))
|
||||
.filter(({ user }) => user);
|
||||
} catch (error) {
|
||||
console.error('Error getting connections:', error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -58,6 +103,13 @@ onMounted(async () => {
|
|||
});
|
||||
|
||||
onBeforeUnmount(() => clearInterval(intervalId.value));
|
||||
|
||||
const renderAgentDetails = connection => {
|
||||
const agent = connection.visitAgent;
|
||||
return agent?.platform && agent?.browser && agent?.version
|
||||
? h('span', `${agent.platform} - ${agent.browser} - ${agent.version}`)
|
||||
: null;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -89,11 +141,11 @@ onBeforeUnmount(() => clearInterval(intervalId.value));
|
|||
<CardList
|
||||
v-for="(connection, index) in connections"
|
||||
:key="index"
|
||||
:to="{ name: 'accessLog', params: { id: connection.userId } }"
|
||||
:to="{ name: 'accessLog', params: { id: connection.user?.id } }"
|
||||
>
|
||||
<template #content>
|
||||
<span class="text-bold q-mb-sm">
|
||||
{{ connection.nickname }}
|
||||
{{ connection.user?.nickname }}
|
||||
</span>
|
||||
<span>
|
||||
{{
|
||||
|
@ -107,23 +159,16 @@ onBeforeUnmount(() => clearInterval(intervalId.value));
|
|||
)
|
||||
}}</span
|
||||
>
|
||||
<span
|
||||
v-if="
|
||||
connection.platform &&
|
||||
connection.browser &&
|
||||
connection.version
|
||||
"
|
||||
>
|
||||
{{ connection.platform }} - {{ connection.browser }} -
|
||||
{{ connection.version }}
|
||||
</span>
|
||||
<component :is="renderAgentDetails(connection)" />
|
||||
</template>
|
||||
<template #actions>
|
||||
<QBtn
|
||||
icon="people"
|
||||
flat
|
||||
rounded
|
||||
@click.stop.prevent="supplantUser(connection.user)"
|
||||
@click.stop.prevent="
|
||||
supplantUser(connection.user?.name)
|
||||
"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('supplantUser') }}
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
<script setup>
|
||||
import { ref, onMounted, inject } from 'vue';
|
||||
|
||||
const jApi = inject('jApi');
|
||||
const api = inject('api');
|
||||
|
||||
const links = ref([]);
|
||||
|
||||
const getLinks = async () => {
|
||||
try {
|
||||
links.value = await jApi.query(
|
||||
`SELECT image, name, description, link FROM link
|
||||
ORDER BY name`
|
||||
);
|
||||
const filter = { order: 'name ASC' };
|
||||
const { data } = await api.get('Links', { params: { filter } });
|
||||
links.value = data;
|
||||
} catch (error) {
|
||||
console.error('Error getting links:', error);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import { useI18n } from 'vue-i18n';
|
|||
|
||||
import VnTable from 'src/components/ui/VnTable.vue';
|
||||
|
||||
const jApi = inject('jApi');
|
||||
const api = inject('api');
|
||||
const { t } = useI18n();
|
||||
|
||||
const packages = ref([]);
|
||||
|
@ -43,7 +43,12 @@ const columns = computed(() => [
|
|||
|
||||
const getPackages = async () => {
|
||||
try {
|
||||
const data = await jApi.query('CALL vn.agencyVolume()');
|
||||
const { data } = await api.post(
|
||||
'applications/agencyVolume/execute-proc',
|
||||
{
|
||||
schema: 'vn'
|
||||
}
|
||||
);
|
||||
packages.value = data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
|
|
@ -8,6 +8,7 @@ import VnInput from 'src/components/common/VnInput.vue';
|
|||
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
||||
import VnList from 'src/components/ui/VnList.vue';
|
||||
|
||||
import { onUserId } from 'src/utils/onUserId';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import { currency, formatDateTitle } from 'src/lib/filters.js';
|
||||
import { tpvStore } from 'stores/tpv';
|
||||
|
@ -16,7 +17,7 @@ import { storeToRefs } from 'pinia';
|
|||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const jApi = inject('jApi');
|
||||
const api = inject('api');
|
||||
const { notify } = useNotify();
|
||||
const appStore = useAppStore();
|
||||
const { isHeaderMounted } = storeToRefs(appStore);
|
||||
|
@ -30,8 +31,16 @@ const tpv = tpvStore();
|
|||
onMounted(async () => {
|
||||
await tpv.check(route);
|
||||
|
||||
orders.value = await jApi.query('CALL myTicket_list(NULL, NULL)');
|
||||
debt.value = await jApi.getValue('SELECT -myClient_getDebt(NULL)');
|
||||
const myTickets = await api.post('applications/myTicket_list/execute-proc', {
|
||||
schema: 'hedera',
|
||||
params: [null, null],
|
||||
});
|
||||
orders.value = myTickets.data;
|
||||
});
|
||||
|
||||
onUserId(async (userId) => {
|
||||
const myClientDebt = await api.get(`clients/${userId}/getDebt`);
|
||||
debt.value = -myClientDebt.data;
|
||||
});
|
||||
|
||||
const onPayClick = async () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref, inject, onMounted } from 'vue';
|
||||
import { ref, inject } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
|
@ -11,8 +11,10 @@ import { useVnConfirm } from 'src/composables/useVnConfirm.js';
|
|||
import useNotify from 'src/composables/useNotify.js';
|
||||
import { useAppStore } from 'stores/app';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { onUserId } from 'src/utils/onUserId';
|
||||
|
||||
const jApi = inject('jApi');
|
||||
const api = inject('api');
|
||||
const { t } = useI18n();
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
const { notify } = useNotify();
|
||||
|
@ -23,18 +25,48 @@ const router = useRouter();
|
|||
const loading = ref(false);
|
||||
const orders = ref([]);
|
||||
|
||||
const getOrders = async () => {
|
||||
const getOrders = async (clientFk) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
orders.value = await jApi.query(
|
||||
`SELECT o.id, o.sent, o.deliveryMethodFk, o.taxableBase,
|
||||
a.nickname, am.description agency
|
||||
FROM myOrder o
|
||||
JOIN myAddress a ON a.id = o.addressFk
|
||||
JOIN vn.agencyMode am ON am.id = o.agencyModeFk
|
||||
WHERE NOT o.isConfirmed
|
||||
ORDER BY o.sent DESC`
|
||||
);
|
||||
|
||||
const filter = {
|
||||
where: {
|
||||
clientFk,
|
||||
isConfirmed: false,
|
||||
source_app: 'WEB',
|
||||
},
|
||||
include: [
|
||||
{
|
||||
relation: 'address',
|
||||
scope: {
|
||||
fields: ['nickname', 'city'],
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'agencyMode',
|
||||
scope: {
|
||||
fields: ['description'],
|
||||
}
|
||||
},
|
||||
],
|
||||
fields: [
|
||||
'id',
|
||||
'landed',
|
||||
'delivery_method_id',
|
||||
'taxableBase',
|
||||
'addressFk',
|
||||
'agencyModeFk'
|
||||
]
|
||||
};
|
||||
|
||||
const { data: salixOrders } = await api.get('Orders', {
|
||||
params: {
|
||||
filter: JSON.stringify(filter)
|
||||
}
|
||||
});
|
||||
|
||||
orders.value = salixOrders;
|
||||
|
||||
loading.value = false;
|
||||
} catch (error) {
|
||||
console.error('Error getting orders:', error);
|
||||
|
@ -43,14 +75,7 @@ const getOrders = async () => {
|
|||
|
||||
const removeOrder = async (id, index) => {
|
||||
try {
|
||||
await jApi.execQuery(
|
||||
`START TRANSACTION;
|
||||
DELETE FROM hedera.myOrder WHERE ((id = #id));
|
||||
COMMIT`,
|
||||
{
|
||||
id
|
||||
}
|
||||
);
|
||||
await api.delete(`Orders/${id}`);
|
||||
orders.value.splice(index, 1);
|
||||
notify(t('dataSaved'), 'positive');
|
||||
} catch (error) {
|
||||
|
@ -63,9 +88,8 @@ const loadOrder = orderId => {
|
|||
router.push({ name: 'catalog' });
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
getOrders();
|
||||
});
|
||||
onUserId(getOrders);
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -93,11 +117,11 @@ onMounted(async () => {
|
|||
>
|
||||
<template #content>
|
||||
<QItemLabel class="text-bold q-mb-sm">
|
||||
{{ formatDateTitle(order.sent) }}
|
||||
{{ formatDateTitle(order.landed) }}
|
||||
</QItemLabel>
|
||||
<QItemLabel> #{{ order.id }} </QItemLabel>
|
||||
<QItemLabel>{{ order.nickname }}</QItemLabel>
|
||||
<QItemLabel>{{ order.agency }}</QItemLabel>
|
||||
<QItemLabel>{{ order.address.nickname }}</QItemLabel>
|
||||
<QItemLabel>{{ order.agencyMode.description }}</QItemLabel>
|
||||
<QItemLabel>{{ currency(order.taxableBase) }}</QItemLabel>
|
||||
</template>
|
||||
<template #actions>
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
import { watch } from 'vue';
|
||||
|
||||
import { useUserStore } from 'stores/user';
|
||||
|
||||
const userStore = useUserStore();
|
||||
|
||||
export const onUserId = (cb) => watch(
|
||||
() => userStore?.user?.id,
|
||||
async userId => {
|
||||
if (!userId) return;
|
||||
try {
|
||||
await cb(userId);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
Loading…
Reference in New Issue