forked from verdnatura/salix-front
Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 6643-VnUserLink
This commit is contained in:
commit
647bb58148
|
@ -62,7 +62,7 @@ async function getData() {
|
|||
filter: $props.filter,
|
||||
skip: 0,
|
||||
});
|
||||
const { data } = await arrayData.fetch({ append: false });
|
||||
const { data } = await arrayData.fetch({ append: false, updateRouter: false });
|
||||
entity.value = data;
|
||||
emit('onFetch', data);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<script setup>
|
||||
import { useSession } from 'src/composables/useSession';
|
||||
import WorkerDescriptorProxy from 'pages/Worker/Card/WorkerDescriptorProxy.vue';
|
||||
const $props = defineProps({
|
||||
worker: { type: Number, required: true },
|
||||
description: { type: String, default: null },
|
||||
clickable: { type: Boolean, default: false },
|
||||
});
|
||||
const session = useSession();
|
||||
const token = session.getToken();
|
||||
|
@ -22,5 +24,6 @@ const token = session.getToken();
|
|||
</p>
|
||||
</slot>
|
||||
</div>
|
||||
<WorkerDescriptorProxy :v-if="$props.clickable" :id="$props.worker" />
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
<script setup>
|
||||
import { onBeforeMount } from 'vue';
|
||||
import { date } from 'quasar';
|
||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||
import VnAvatar from '../ui/VnAvatar.vue';
|
||||
|
||||
const $props = defineProps({
|
||||
url: { type: String, default: null },
|
||||
where: { type: Object, default: () => {} },
|
||||
});
|
||||
|
||||
const filter = {
|
||||
fields: ['smsFk'],
|
||||
include: {
|
||||
relation: 'sms',
|
||||
scope: {
|
||||
fields: [
|
||||
'senderFk',
|
||||
'sender',
|
||||
'destination',
|
||||
'message',
|
||||
'statusCode',
|
||||
'status',
|
||||
'created',
|
||||
],
|
||||
include: {
|
||||
relation: 'sender',
|
||||
scope: {
|
||||
fields: ['name'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
onBeforeMount(() => (filter.where = $props.where));
|
||||
|
||||
function formatNumber(number) {
|
||||
if (number.length <= 10) return number;
|
||||
return number.slice(0, 4) + ' ' + number.slice(4);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="column items-center">
|
||||
<div class="list">
|
||||
<VnPaginate
|
||||
:data-key="$props.url"
|
||||
:url="$props.url"
|
||||
:filter="filter"
|
||||
order="smsFk DESC"
|
||||
:offset="100"
|
||||
:limit="5"
|
||||
auto-load
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<QCard
|
||||
flat
|
||||
bordered
|
||||
class="card q-pa-md q-mb-sm smsCard"
|
||||
v-for="row of rows"
|
||||
:key="row.smsFk"
|
||||
>
|
||||
<QItem>
|
||||
<QItemSection side top>
|
||||
<VnAvatar
|
||||
class="cursor-pointer"
|
||||
:worker="row.sms.senderFk"
|
||||
:title="row.sms.sender.name"
|
||||
:clickable="true"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QSeparator />
|
||||
<QItemSection>
|
||||
<QItemLabel caption>{{
|
||||
formatNumber(row.sms.destination)
|
||||
}}</QItemLabel>
|
||||
<QItemLabel>{{ row.sms.message }}</QItemLabel>
|
||||
</QItemSection>
|
||||
<QItemSection side>
|
||||
<QItemLabel caption>{{
|
||||
date.formatDate(
|
||||
row.sms.created,
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
)
|
||||
}}</QItemLabel>
|
||||
<QItemLabel class="row center">
|
||||
<QChip
|
||||
:color="
|
||||
row.sms.status == 'OK'
|
||||
? 'positive'
|
||||
: 'negative'
|
||||
"
|
||||
>
|
||||
{{ row.sms.status }}
|
||||
</QChip>
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</QCard>
|
||||
</template>
|
||||
</VnPaginate>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<style lang="scss" scoped>
|
||||
.q-item__section--side {
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
|
@ -58,7 +58,7 @@ export function useArrayData(key, userOptions) {
|
|||
}
|
||||
}
|
||||
|
||||
async function fetch({ append = false }) {
|
||||
async function fetch({ append = false, updateRouter = true }) {
|
||||
if (!store.url) return;
|
||||
|
||||
cancelRequest();
|
||||
|
@ -100,15 +100,12 @@ export function useArrayData(key, userOptions) {
|
|||
|
||||
hasMoreData.value = response.data.length === limit;
|
||||
|
||||
if (append === true) {
|
||||
if (append) {
|
||||
if (!store.data) store.data = [];
|
||||
for (const row of response.data) store.data.push(row);
|
||||
}
|
||||
|
||||
if (append === false) {
|
||||
} else {
|
||||
store.data = response.data;
|
||||
|
||||
updateStateParams();
|
||||
updateRouter && updateStateParams();
|
||||
}
|
||||
|
||||
store.isLoading = false;
|
||||
|
@ -155,7 +152,9 @@ export function useArrayData(key, userOptions) {
|
|||
delete store.userParams[param];
|
||||
delete params[param];
|
||||
if (store.filter?.where) {
|
||||
delete store.filter.where[Object.keys(exprBuilder ? exprBuilder(param) : param)[0]];
|
||||
delete store.filter.where[
|
||||
Object.keys(exprBuilder ? exprBuilder(param) : param)[0]
|
||||
];
|
||||
if (Object.keys(store.filter.where).length === 0) {
|
||||
delete store.filter.where;
|
||||
}
|
||||
|
|
|
@ -114,6 +114,7 @@ export default {
|
|||
createCustomer: 'Create customer',
|
||||
summary: 'Summary',
|
||||
basicData: 'Basic Data',
|
||||
sms: 'Sms',
|
||||
},
|
||||
list: {
|
||||
phone: 'Phone',
|
||||
|
|
|
@ -113,6 +113,7 @@ export default {
|
|||
createCustomer: 'Crear cliente',
|
||||
basicData: 'Datos básicos',
|
||||
summary: 'Resumen',
|
||||
sms: 'Sms',
|
||||
},
|
||||
list: {
|
||||
phone: 'Teléfono',
|
||||
|
|
|
@ -282,6 +282,8 @@ async function importToNewRefundTicket() {
|
|||
selection="multiple"
|
||||
v-model:selected="selectedRows"
|
||||
:grid="$q.screen.lt.md"
|
||||
:pagination="{ rowsPerPage: 0 }"
|
||||
:hide-bottom="true"
|
||||
>
|
||||
<template #body-cell-ticket="{ value }">
|
||||
<QTd align="center">
|
||||
|
@ -335,7 +337,23 @@ async function importToNewRefundTicket() {
|
|||
</QItemSection>
|
||||
<QItemSection side>
|
||||
<QItemLabel v-if="column.name === 'destination'">
|
||||
{{ column.value.description }}
|
||||
<VnSelectFilter
|
||||
v-model="props.row.claimDestinationFk"
|
||||
:options="destinationTypes"
|
||||
option-label="description"
|
||||
option-value="id"
|
||||
:autofocus="true"
|
||||
dense
|
||||
input-debounce="0"
|
||||
hide-selected
|
||||
@update:model-value="
|
||||
(value) =>
|
||||
updateDestination(
|
||||
value,
|
||||
props.row
|
||||
)
|
||||
"
|
||||
/>
|
||||
</QItemLabel>
|
||||
<QItemLabel v-else>
|
||||
{{ column.value }}
|
||||
|
@ -417,25 +435,6 @@ async function importToNewRefundTicket() {
|
|||
</QCardActions>
|
||||
</QCard>
|
||||
</QDialog>
|
||||
<!-- <QDialog v-model="dialogGreuge">
|
||||
<QCardSection>
|
||||
<QItem class="q-pa-sm">
|
||||
<span class="q-pa-sm q-dialog__title text-white">
|
||||
{{ t('dialogGreuge title') }}
|
||||
</span>
|
||||
<QBtn class="q-pa-sm" icon="close" flat round dense v-close-popup />
|
||||
</QItem>
|
||||
<QCardActions class="justify-end q-mr-sm">
|
||||
<QBtn flat :label="t('globals.close')" color="primary" v-close-popup />
|
||||
<QBtn
|
||||
:label="t('globals.save')"
|
||||
color="primary"
|
||||
v-close-popup
|
||||
@click="onUpdateGreugeAccept"
|
||||
/>
|
||||
</QCardActions>
|
||||
</QCardSection>
|
||||
</QDialog> -->
|
||||
</template>
|
||||
<style lang="scss" scoped>
|
||||
.slider-container {
|
||||
|
|
|
@ -54,6 +54,7 @@ const columns = computed(() => [
|
|||
optionValue: 'id',
|
||||
optionLabel: 'description',
|
||||
tabIndex: 1,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
name: 'claimResult',
|
||||
|
@ -66,6 +67,7 @@ const columns = computed(() => [
|
|||
optionValue: 'id',
|
||||
optionLabel: 'description',
|
||||
tabIndex: 2,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
name: 'claimResponsible',
|
||||
|
@ -78,6 +80,7 @@ const columns = computed(() => [
|
|||
optionValue: 'id',
|
||||
optionLabel: 'description',
|
||||
tabIndex: 3,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
name: 'worker',
|
||||
|
@ -89,6 +92,7 @@ const columns = computed(() => [
|
|||
optionValue: 'id',
|
||||
optionLabel: 'nickname',
|
||||
tabIndex: 4,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
name: 'claimRedelivery',
|
||||
|
@ -101,6 +105,7 @@ const columns = computed(() => [
|
|||
optionValue: 'id',
|
||||
optionLabel: 'description',
|
||||
tabIndex: 5,
|
||||
align: 'left',
|
||||
},
|
||||
]);
|
||||
</script>
|
||||
|
@ -158,6 +163,7 @@ const columns = computed(() => [
|
|||
hide-pagination
|
||||
v-model:selected="selected"
|
||||
:grid="$q.screen.lt.md"
|
||||
table-header-class="text-left"
|
||||
>
|
||||
<template #body-cell="{ row, col }">
|
||||
<QTd
|
||||
|
@ -165,7 +171,6 @@ const columns = computed(() => [
|
|||
@keyup.ctrl.enter.stop="claimDevelopmentForm.saveChanges()"
|
||||
>
|
||||
<VnSelectFilter
|
||||
:label="col.label"
|
||||
v-model="row[col.model]"
|
||||
:options="col.options"
|
||||
:option-value="col.optionValue"
|
||||
|
|
|
@ -132,7 +132,7 @@ const developmentColumns = ref([
|
|||
{
|
||||
name: 'worker',
|
||||
label: 'claim.summary.worker',
|
||||
field: (row) => row.worker.user.nickname,
|
||||
field: (row) => row.worker?.user.nickname,
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -38,15 +38,6 @@ function viewSummary(id) {
|
|||
},
|
||||
});
|
||||
}
|
||||
|
||||
function viewDescriptor(id) {
|
||||
quasar.dialog({
|
||||
component: CustomerDescriptorProxy,
|
||||
componentProps: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<script setup>
|
||||
import { useRoute } from 'vue-router';
|
||||
import VnSms from 'src/components/ui/VnSms.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const id = route.params.id;
|
||||
|
||||
const where = {
|
||||
clientFk: id,
|
||||
ticketFk: null,
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<div class="column items-center">
|
||||
<VnSms url="clientSms" :where="where" />
|
||||
</div>
|
||||
</template>
|
|
@ -1,118 +1,16 @@
|
|||
<script setup>
|
||||
import { date } from 'quasar';
|
||||
import { computed } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useRoute } from 'vue-router';
|
||||
import VnSms from 'src/components/ui/VnSms.vue';
|
||||
|
||||
import { useSession } from 'src/composables/useSession';
|
||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||
import WorkerDescriptorProxy from 'pages/Worker/Card/WorkerDescriptorProxy.vue';
|
||||
const route = useRoute();
|
||||
const id = route.params.id;
|
||||
|
||||
const router = useRouter();
|
||||
const session = useSession();
|
||||
const token = session.getToken();
|
||||
|
||||
const entityId = computed(function () {
|
||||
return router.currentRoute.value.params.id;
|
||||
});
|
||||
|
||||
const filter = {
|
||||
fields: ['ticketFk', 'smsFk'],
|
||||
include: {
|
||||
relation: 'sms',
|
||||
scope: {
|
||||
fields: [
|
||||
'senderFk',
|
||||
'sender',
|
||||
'destination',
|
||||
'message',
|
||||
'statusCode',
|
||||
'status',
|
||||
'created',
|
||||
],
|
||||
include: {
|
||||
relation: 'sender',
|
||||
scope: {
|
||||
fields: ['name'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
where: {
|
||||
ticketFk: entityId,
|
||||
},
|
||||
const where = {
|
||||
ticketFk: id,
|
||||
};
|
||||
|
||||
function formatNumer(number) {
|
||||
if (number.length <= 10) return number;
|
||||
return number.slice(0, 4) + ' ' + number.slice(4);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="column items-center">
|
||||
<div class="list">
|
||||
<VnPaginate
|
||||
data-key="TicketSms"
|
||||
url="TicketSms"
|
||||
:filter="filter"
|
||||
order="smsFk DESC"
|
||||
:offset="100"
|
||||
:limit="5"
|
||||
auto-load
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<QCard
|
||||
flat
|
||||
bordered
|
||||
class="card q-pa-md"
|
||||
v-for="row of rows"
|
||||
:key="row.smsFk"
|
||||
>
|
||||
<QItem>
|
||||
<QItmSection top avatar>
|
||||
<QItemLabel class="column items-center">
|
||||
<QAvatar>
|
||||
<QImg
|
||||
:src="`/api/Images/user/160x160/${row.sms.senderFk}/download?access_token=${token}`"
|
||||
spinner-color="white"
|
||||
/>
|
||||
</QAvatar>
|
||||
<span class="link">
|
||||
{{ row.sms.sender.name }}
|
||||
<WorkerDescriptorProxy :id="row.sms.senderFk" />
|
||||
</span>
|
||||
</QItemLabel>
|
||||
</QItmSection>
|
||||
<QSeparator spaced inset="item" />
|
||||
<QItemSection>
|
||||
<QItemLabel caption>{{
|
||||
formatNumer(row.sms.destination)
|
||||
}}</QItemLabel>
|
||||
<QItemLabel>{{ row.sms.message }}</QItemLabel>
|
||||
</QItemSection>
|
||||
<QItemSection side top>
|
||||
<QItemLabel caption>{{
|
||||
date.formatDate(
|
||||
row.sms.created,
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
)
|
||||
}}</QItemLabel>
|
||||
<QItemLabel>
|
||||
<QChip
|
||||
:color="
|
||||
row.sms.status == 'OK'
|
||||
? 'positive'
|
||||
: 'negative'
|
||||
"
|
||||
>
|
||||
{{ row.sms.status }}
|
||||
</QChip>
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</QCard>
|
||||
</template>
|
||||
</VnPaginate>
|
||||
</div>
|
||||
<VnSms url="clientSms" :where="where" />
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -11,7 +11,7 @@ export default {
|
|||
redirect: { name: 'CustomerMain' },
|
||||
menus: {
|
||||
main: ['CustomerList', 'CustomerPayments'],
|
||||
card: ['CustomerBasicData'],
|
||||
card: ['CustomerBasicData', 'CustomerSms'],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
|
@ -66,6 +66,15 @@ export default {
|
|||
component: () =>
|
||||
import('src/pages/Customer/Card/CustomerBasicData.vue'),
|
||||
},
|
||||
{
|
||||
path: 'sms',
|
||||
name: 'CustomerSms',
|
||||
meta: {
|
||||
title: 'sms',
|
||||
icon: 'sms',
|
||||
},
|
||||
component: () => import('src/pages/Customer/Card/CustomerSms.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import VnSms from 'src/components/ui/VnSms.vue';
|
||||
|
||||
describe('VnSms', () => {
|
||||
let vm;
|
||||
|
||||
beforeAll(() => {
|
||||
vm = createWrapper(VnSms, {
|
||||
global: {
|
||||
stubs: ['VnPaginate'],
|
||||
mocks: {},
|
||||
},
|
||||
}).vm;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should format number correctly', () => {
|
||||
const formattedNumber = vm.formatNumber('123456789012');
|
||||
expect(formattedNumber).toBe('1234 56789012');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue