#8745 - fixCustomer #1588

Open
carlossa wants to merge 9 commits from 8745-fixCustomer into master
4 changed files with 71 additions and 116 deletions

View File

@ -6,6 +6,7 @@ import { useAcl } from 'src/composables/useAcl';
import axios from 'axios';
import { useQuasar } from 'quasar';
import { getClientRisk } from '../composables/getClientRisk';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import { toCurrency, toDate, toDateHourMin } from 'src/filters';
import { useState } from 'composables/useState';
@ -89,15 +90,7 @@ const columns = computed(() => [
{
align: 'left',
label: t('Employee'),
columnField: {
component: 'userLink',
attrs: ({ row }) => {
return {
workerId: row.workerFk,
name: row.userName,
};
},
},
name: 'workerFk',
cardVisible: true,
},
{
@ -256,6 +249,12 @@ const showBalancePdf = ({ id }) => {
<template #column-balance="{ rowIndex }">
{{ toCurrency(balances[rowIndex]?.balance) }}
</template>
<template #column-workerFk="{ row }">
<span class="link" @click.stop>
{{ row?.userName }}
<WorkerDescriptorProxy :id="row?.workerFk" />
</span>
</template>
<template #column-description="{ row }">
<span class="link" v-if="row.isInvoice" @click.stop>
{{ t('bill', { ref: row.description }) }}

View File

@ -6,13 +6,14 @@ import { toCurrency } from 'src/filters';
import { toDateTimeFormat } from 'src/filters/date';
import VnTable from 'components/VnTable/VnTable.vue';
import FetchData from 'components/FetchData.vue';
const entityId = computed(() => route.params.id);
import VnUserLink from 'src/components/ui/VnUserLink.vue';
const { t } = useI18n();
const route = useRoute();
const entityId = computed(() => route.params.id);
carlossa marked this conversation as resolved Outdated
Outdated
Review

En computed millor

En computed millor
const totalAmount = ref();
const tableRef = ref();
const filter = computed(() => {
return {
const filter = {
include: [
{
relation: 'greugeType',
@ -30,8 +31,7 @@ const filter = computed(() => {
where: {
clientFk: entityId,
},
};
});
};
const columns = computed(() => [
{
@ -48,14 +48,7 @@ const columns = computed(() => [
{
align: 'left',
label: t('Created by'),
component: 'userLink',
attrs: ({ row }) => {
return {
defaultName: true,
workerId: row.user?.id,
name: row.user?.name,
};
},
name: 'userFk',
},
{
align: 'left',
@ -97,13 +90,13 @@ const columns = computed(() => [
:url="`Greuges/${entityId}/sumAmount`"
auto-load
@on-fetch="({ sumAmount }) => (totalAmount = sumAmount)"
></FetchData>
/>
<VnTable
ref="tableRef"
data-key="Greuges"
url="Greuges"
search-url="greuges"
:filter="filter"
:user-filter="filter"
:order="['shipped DESC', 'amount']"
:columns="columns"
:right-search="false"
@ -124,6 +117,9 @@ const columns = computed(() => [
{{ t('Total') }}: {{ toCurrency(totalAmount) }}
</QCard>
</template>
<template #column-userFk="{ row }">
<VnUserLink :worker-id="row.userFk" :name="row.user.name" />
</template>
</VnTable>
</template>

View File

@ -2,6 +2,7 @@
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import VnTable from 'components/VnTable/VnTable.vue';
import FetchData from 'src/components/FetchData.vue';
@ -12,6 +13,7 @@ import CustomerCheckIconTooltip from '../components/CustomerCheckIconTooltip.vue
const { t } = useI18n();
const route = useRoute();
const tableRef = ref();
const rows = ref([]);
@ -26,43 +28,21 @@ const filter = {
};
const ClientDmsRef = ref(false);
const tableColumnComponents = {
state: {
component: CustomerCloseIconTooltip,
props: ({ row }) => ({ transaction: row }),
event: () => {},
},
id: {
component: 'span',
props: () => {},
event: () => {},
},
date: {
component: 'span',
props: () => {},
event: () => {},
},
amount: {
component: 'span',
props: () => {},
event: () => {},
},
validate: {
component: CustomerCheckIconTooltip,
props: ({ row }) => ({
transaction: row,
promise: () => ClientDmsRef.value.fetch(),
}),
event: () => {},
},
};
const columns = computed(() => [
{
align: 'left',
field: '',
label: t('State'),
name: 'state',
component: CustomerCloseIconTooltip,
columnField: {
component: CustomerCloseIconTooltip,
attrs: ({ row }) => {
return {
id: row.state,
};
},
},
},
{
align: 'left',
@ -75,14 +55,14 @@ const columns = computed(() => [
field: 'created',
label: t('Date'),
name: 'date',
format: (value) => toDateHourMin(value),
format: (row) => toDateHourMin(row.created),
},
{
align: 'left',
field: 'amount',
label: t('Amount'),
name: 'amount',
format: (value) => toCurrency(value),
format: (row) => toCurrency(row.amount),
},
{
align: 'left',
@ -93,42 +73,26 @@ const columns = computed(() => [
</script>
<template>
<FetchData
ref="ClientDmsRef"
:filter="filter"
@on-fetch="(data) => (rows = data)"
auto-load
<VnTable
ref="tableRef"
data-key="WebPayments"
url="Clients/transactions"
/>
<QPage class="card-width q-pa-lg">
<QTable
:user-filter="filter"
:columns="columns"
:pagination="{ rowsPerPage: 12 }"
:rows="rows"
class="full-width q-mt-md"
row-key="id"
v-if="rows?.length"
:right-search="false"
:is-editable="false"
:use-model="true"
:column-search="false"
:disable-option="{ card: true }"
auto-load
>
<template #body-cell="props">
<QTd :props="props">
<QTr :props="props">
<component
:is="tableColumnComponents[props.col.name].component"
@click="tableColumnComponents[props.col.name].event(props)"
class="rounded-borders q-pa-sm"
v-bind="tableColumnComponents[props.col.name].props(props)"
>
{{ props.value }}
</component>
</QTr>
</QTd>
<template #column-state="{ row }">
<CustomerCloseIconTooltip :transaction="row" />
</template>
</QTable>
<h5 class="flex justify-center color-vn-label" v-else>
{{ t('globals.noResults') }}
</h5>
</QPage>
<template #column-validate="{ row }">
<CustomerCheckIconTooltip :transaction="row" :promise="tableRef.reload" />
</template>
</VnTable>
</template>
<i18n>

View File

@ -16,15 +16,11 @@ const $props = defineProps({
},
});
const setClientsConfirmTransaction = async () => {
try {
async function setClientsConfirmTransaction() {
const payload = { id: $props.transaction.id };
await axios.post('Clients/confirmTransaction', payload);
$props.promise();
} catch (error) {
return error;
}
};
await $props.promise();
}
</script>
<template>