Merge pull request '#6943 - customer_migration_subsection' (!570) from 6943-customer_migration_subsection into dev
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #570
Reviewed-by: Jorge Penades <jorgep@verdnatura.es>
This commit is contained in:
Alex Moreno 2024-07-30 12:02:31 +00:00
commit c10e05396d
25 changed files with 526 additions and 906 deletions

View File

@ -7,9 +7,11 @@ import { dashIfEmpty } from 'src/filters';
import VnSelect from 'components/common/VnSelect.vue'; import VnSelect from 'components/common/VnSelect.vue';
import VnSelectCache from 'components/common/VnSelectCache.vue'; import VnSelectCache from 'components/common/VnSelectCache.vue';
import VnInput from 'components/common/VnInput.vue'; import VnInput from 'components/common/VnInput.vue';
import VnInputNumber from 'components/common/VnInputNumber.vue';
import VnInputDate from 'components/common/VnInputDate.vue'; import VnInputDate from 'components/common/VnInputDate.vue';
import VnInputTime from 'components/common/VnInputTime.vue'; import VnInputTime from 'components/common/VnInputTime.vue';
import VnComponent from 'components/common/VnComponent.vue'; import VnComponent from 'components/common/VnComponent.vue';
import VnUserLink from 'components/ui/VnUserLink.vue';
const model = defineModel(undefined, { required: true }); const model = defineModel(undefined, { required: true });
const $props = defineProps({ const $props = defineProps({
@ -66,7 +68,7 @@ const defaultComponents = {
}, },
}, },
number: { number: {
component: markRaw(VnInput), component: markRaw(VnInputNumber),
attrs: { attrs: {
disable: !$props.isEditable, disable: !$props.isEditable,
class: 'fit', class: 'fit',
@ -98,14 +100,14 @@ const defaultComponents = {
}, },
checkbox: { checkbox: {
component: markRaw(QCheckbox), component: markRaw(QCheckbox),
attrs: (prop) => { attrs: ({ model }) => {
const defaultAttrs = { const defaultAttrs = {
disable: !$props.isEditable, disable: !$props.isEditable,
'model-value': Boolean(prop), 'model-value': Boolean(model),
class: 'no-padding fit', class: 'no-padding fit',
}; };
if (typeof prop == 'number') { if (typeof model == 'number') {
defaultAttrs['true-value'] = 1; defaultAttrs['true-value'] = 1;
defaultAttrs['false-value'] = 0; defaultAttrs['false-value'] = 0;
} }
@ -126,6 +128,9 @@ const defaultComponents = {
icon: { icon: {
component: markRaw(QIcon), component: markRaw(QIcon),
}, },
userLink: {
component: markRaw(VnUserLink),
},
}; };
const value = computed(() => { const value = computed(() => {
@ -163,14 +168,14 @@ const components = computed(() => $props.components ?? defaultComponents);
v-if="col.before" v-if="col.before"
:prop="col.before" :prop="col.before"
:components="components" :components="components"
:value="model" :value="{ row, model }"
v-model="model" v-model="model"
/> />
<VnComponent <VnComponent
v-if="col.component" v-if="col.component"
:prop="col" :prop="col"
:components="components" :components="components"
:value="model" :value="{ row, model }"
v-model="model" v-model="model"
/> />
<span :title="value" v-else>{{ value }}</span> <span :title="value" v-else>{{ value }}</span>
@ -178,7 +183,7 @@ const components = computed(() => $props.components ?? defaultComponents);
v-if="col.after" v-if="col.after"
:prop="col.after" :prop="col.after"
:components="components" :components="components"
:value="model" :value="{ row, model }"
v-model="model" v-model="model"
/> />
</div> </div>

View File

@ -10,6 +10,8 @@ import VnInputDate from 'components/common/VnInputDate.vue';
import VnInputTime from 'components/common/VnInputTime.vue'; import VnInputTime from 'components/common/VnInputTime.vue';
import VnTableColumn from 'components/VnTable/VnColumn.vue'; import VnTableColumn from 'components/VnTable/VnColumn.vue';
defineExpose({ addFilter });
const $props = defineProps({ const $props = defineProps({
column: { column: {
type: Object, type: Object,
@ -32,7 +34,7 @@ const model = defineModel(undefined, { required: true });
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl }); const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
const columnFilter = computed(() => $props.column?.columnFilter); const columnFilter = computed(() => $props.column?.columnFilter);
const updateEvent = { 'update:modelValue': addFilter }; const updateEvent = { 'update:modelValue': addFilter, remove: () => addFilter(null) };
const enterEvent = { const enterEvent = {
'keyup.enter': () => addFilter(model.value), 'keyup.enter': () => addFilter(model.value),
remove: () => addFilter(null), remove: () => addFilter(null),

View File

@ -323,6 +323,7 @@ defineExpose({
v-bind="$attrs" v-bind="$attrs"
:limit="20" :limit="20"
ref="CrudModelRef" ref="CrudModelRef"
@on-fetch="(...args) => emit('onFetch', ...args)"
:search-url="searchUrl" :search-url="searchUrl"
:disable-infinite-scroll="isTableMode" :disable-infinite-scroll="isTableMode"
@save-changes="reload" @save-changes="reload"
@ -360,7 +361,7 @@ defineExpose({
<template #top-left v-if="!$props.withoutHeader"> <template #top-left v-if="!$props.withoutHeader">
<slot name="top-left"></slot> <slot name="top-left"></slot>
</template> </template>
<template #top-right> <template #top-right v-if="!$props.withoutHeader">
<VnVisibleColumn <VnVisibleColumn
v-if="isTableMode" v-if="isTableMode"
v-model="splittedColumns.columns" v-model="splittedColumns.columns"
@ -388,7 +389,7 @@ defineExpose({
<div <div
class="column self-start q-ml-xs ellipsis" class="column self-start q-ml-xs ellipsis"
:class="`text-${col?.align ?? 'left'}`" :class="`text-${col?.align ?? 'left'}`"
style="height: 75px" :style="$props.columnSearch ? 'height: 75px' : ''"
> >
<div <div
class="row items-center no-wrap" class="row items-center no-wrap"
@ -429,7 +430,7 @@ defineExpose({
</VnTableChip> </VnTableChip>
</QTd> </QTd>
</template> </template>
<template #body-cell="{ col, row }"> <template #body-cell="{ col, row, rowIndex }">
<!-- Columns --> <!-- Columns -->
<QTd <QTd
auto-width auto-width
@ -442,7 +443,12 @@ defineExpose({
rowCtrlClickFunction($event, row) rowCtrlClickFunction($event, row)
" "
> >
<slot :name="`column-${col.name}`" :col="col" :row="row"> <slot
:name="`column-${col.name}`"
:col="col"
:row="row"
:row-index="rowIndex"
>
<VnTableColumn <VnTableColumn
:column="col" :column="col"
:row="row" :row="row"
@ -462,7 +468,6 @@ defineExpose({
> >
<QBtn <QBtn
v-for="(btn, index) of col.actions" v-for="(btn, index) of col.actions"
v-show="btn.show ? btn.show(row) : true"
:key="index" :key="index"
:title="btn.title" :title="btn.title"
:icon="btn.icon" :icon="btn.icon"
@ -473,6 +478,11 @@ defineExpose({
? 'text-primary-light' ? 'text-primary-light'
: 'color-vn-text ' : 'color-vn-text '
" "
:style="`visibility: ${
(btn.show && btn.show(row)) ?? true
? 'visible'
: 'hidden'
}`"
@click="btn.action(row)" @click="btn.action(row)"
/> />
</QTd> </QTd>
@ -530,7 +540,9 @@ defineExpose({
:class="$props.cardClass" :class="$props.cardClass"
> >
<div <div
v-for="col of splittedColumns.cardVisible" v-for="(
col, index
) of splittedColumns.cardVisible"
:key="col.name" :key="col.name"
class="fields" class="fields"
> >
@ -551,6 +563,7 @@ defineExpose({
:name="`column-${col.name}`" :name="`column-${col.name}`"
:col="col" :col="col"
:row="row" :row="row"
:row-index="index"
> >
<VnTableColumn <VnTableColumn
:column="col" :column="col"
@ -610,16 +623,23 @@ defineExpose({
> >
<template #form-inputs="{ data }"> <template #form-inputs="{ data }">
<div class="grid-create"> <div class="grid-create">
<VnTableColumn <slot
v-for="column of splittedColumns.create" v-for="column of splittedColumns.create"
:key="column.name" :key="column.name"
:column="column" :name="`column-create-${column.name}`"
:row="{}" :data="data"
default="input" :column-name="column.name"
v-model="data[column.name]" :label="column.label"
:show-label="true" >
component-prop="columnCreate" <VnTableColumn
/> :column="column"
:row="{}"
default="input"
v-model="data[column.name]"
:show-label="true"
component-prop="columnCreate"
/>
</slot>
<slot name="more-create-dialog" :data="data" /> <slot name="more-create-dialog" :data="data" />
</div> </div>
</template> </template>

View File

@ -30,12 +30,12 @@ function mix(toComponent) {
mixed = { mixed = {
component: customComponent?.component ?? component, component: customComponent?.component ?? component,
attrs: { attrs: {
...toValueAttrs(attrs),
...toValueAttrs(customComponent?.attrs), ...toValueAttrs(customComponent?.attrs),
...toComponent,
...toValueAttrs(customComponent?.forceAttrs), ...toValueAttrs(customComponent?.forceAttrs),
...toComponent,
...toValueAttrs(attrs),
}, },
event: event ?? customComponent?.event, event: { ...customComponent?.event, ...event },
}; };
return mixed; return mixed;
} }

View File

@ -0,0 +1,8 @@
<script setup>
import VnInput from 'src/components/common/VnInput.vue';
const model = defineModel({ type: [Number, String] });
</script>
<template>
<VnInput v-bind="$attrs" v-model.number="model" type="number" />
</template>

View File

@ -2,7 +2,7 @@
import { ref, toRefs, computed, watch, onMounted } from 'vue'; import { ref, toRefs, computed, watch, onMounted } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import FetchData from 'src/components/FetchData.vue'; import FetchData from 'src/components/FetchData.vue';
const emit = defineEmits(['update:modelValue', 'update:options']); const emit = defineEmits(['update:modelValue', 'update:options', 'remove']);
const $props = defineProps({ const $props = defineProps({
modelValue: { modelValue: {
@ -159,7 +159,10 @@ async function filterHandler(val, update) {
let newOptions; let newOptions;
if (!$props.defaultFilter) return update(); if (!$props.defaultFilter) return update();
if ($props.url) { if (
$props.url &&
($props.limit || (!$props.limit && Object.keys(myOptions.value).length === 0))
) {
newOptions = await fetchFilter(val); newOptions = await fetchFilter(val);
} else newOptions = filter(val, myOptionsOriginal.value); } else newOptions = filter(val, myOptionsOriginal.value);
update( update(
@ -208,7 +211,12 @@ async function filterHandler(val, update) {
<QIcon <QIcon
v-show="value" v-show="value"
name="close" name="close"
@click.stop="value = null" @click.stop="
() => {
value = null;
emit('remove');
}
"
class="cursor-pointer" class="cursor-pointer"
size="xs" size="xs"
/> />

View File

@ -28,8 +28,8 @@ function handleKeyUp(event) {
} }
async function insert() { async function insert() {
const body = $props.body; const body = $props.body;
Object.assign(body, { text: newNote.value }); const newBody = { ...body, ...{ text: newNote.value } };
await axios.post($props.url, body); await axios.post($props.url, newBody);
await vnPaginateRef.value.fetch(); await vnPaginateRef.value.fetch();
newNote.value = ''; newNote.value = '';
} }

View File

@ -115,8 +115,8 @@ watch(
); );
watch( watch(
() => props.url, () => [props.url, props.filter],
(url) => fetch({ url }) ([url, filter]) => fetch({ url, filter })
); );
const addFilter = async (filter, params) => { const addFilter = async (filter, params) => {

View File

@ -18,4 +18,3 @@ const { t } = useI18n();
</slot> </slot>
<WorkerDescriptorProxy v-if="$props.workerId" :id="$props.workerId" /> <WorkerDescriptorProxy v-if="$props.workerId" :id="$props.workerId" />
</template> </template>
<style scoped></style>

View File

@ -1,120 +1,191 @@
<script setup> <script setup>
import { computed, onBeforeMount, ref, watch } from 'vue'; import { computed, onBeforeMount, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useRole } from 'src/composables/useRole';
import axios from 'axios'; import axios from 'axios';
import { QCheckbox, QBtn, useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import { toCurrency, toDate, toDateHourMin } from 'src/filters'; import { toCurrency, toDate, toDateHourMin } from 'src/filters';
import { useState } from 'src/composables/useState'; import { useState } from 'composables/useState';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { useValidator } from 'src/composables/useValidator'; import { usePrintService } from 'composables/usePrintService';
import { usePrintService } from 'src/composables/usePrintService'; import { useSession } from 'composables/useSession';
import { useSession } from 'src/composables/useSession'; import { useVnConfirm } from 'composables/useVnConfirm';
import VnPaginate from 'src/components/ui/VnPaginate.vue'; import VnTable from 'components/VnTable/VnTable.vue';
import FetchData from 'components/FetchData.vue'; import VnInput from 'components/common/VnInput.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnSubToolbar from 'components/ui/VnSubToolbar.vue';
import VnFilter from 'components/VnTable/VnFilter.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import CustomerNewPayment from 'src/pages/Customer/components/CustomerNewPayment.vue'; import CustomerNewPayment from 'src/pages/Customer/components/CustomerNewPayment.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue'; import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
const session = useSession();
const tokenMultimedia = session.getTokenMultimedia();
const { openConfirmationModal } = useVnConfirm();
const { sendEmail } = usePrintService(); const { sendEmail } = usePrintService();
const { t } = useI18n(); const { t } = useI18n();
const { validate } = useValidator(); const { hasAny } = useRole();
const session = useSession();
const tokenMultimedia = session.getTokenMultimedia();
const quasar = useQuasar(); const quasar = useQuasar();
const route = useRoute(); const route = useRoute();
const state = useState(); const state = useState();
const stateStore = useStateStore(); const stateStore = useStateStore();
const user = state.getUser(); const user = state.getUser();
const clientRisks = ref(null); const clientRisk = ref([]);
const clientRisksRef = ref(null); const tableRef = ref();
const companiesOptions = ref([]); const companyId = ref();
const companyId = ref(null); const companyLastId = ref(user.value.companyFk);
const receiptsRef = ref(null); const balances = ref([]);
const receiptsData = ref([]); const vnFilterRef = ref({});
const filter = computed(() => {
return {
clientId: route.params.id,
companyId: companyId.value ?? user.value.companyFk,
};
});
const filterCompanies = { order: ['code'] }; const companyFilterColumn = {
const userParams = { align: 'left',
clientId: route.params.id, name: 'companyId',
companyId: user.value.companyFk, label: t('Company'),
component: 'select',
attrs: {
url: 'Companies',
optionLabel: 'code',
sortBy: 'code',
limit: 0,
},
columnFilter: {
event: {
remove: () => (companyId.value = null),
'update:modelValue': (newCompanyFk) => {
if (!newCompanyFk) return;
vnFilterRef.value.addFilter(newCompanyFk);
companyLastId.value = newCompanyFk;
},
blur: () =>
!companyId.value &&
(companyId.value = companyLastId.value ?? user.value.companyFk),
},
},
visible: false,
create: true,
}; };
const filter = { const referenceColumn = {
include: { relation: 'company', scope: { fields: ['code'] } }, align: 'left',
where: { clientFk: route.params.id, companyFk: user.value.companyFk }, name: 'description',
label: t('Reference'),
};
const onlyCreate = {
visible: false,
columnFilter: false,
create: true,
}; };
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
field: 'payed', name: 'payed',
format: (value) => toDate(value),
label: t('Date'), label: t('Date'),
name: 'date', format: ({ payed }) => toDate(payed),
cardVisible: true,
create: true,
columnCreate: {
component: 'date',
},
}, },
{ {
align: 'left', align: 'left',
field: 'created', name: 'created',
format: (value) => toDateHourMin(value),
label: t('Creation date'), label: t('Creation date'),
name: 'creationDate', format: ({ created }) => toDateHourMin(created),
cardVisible: true,
}, },
{ {
align: 'left', align: 'left',
field: 'userName', name: 'workerFk',
label: t('Employee'), label: t('Employee'),
name: 'employee', columnField: {
component: 'userLink',
attrs: ({ row }) => {
return {
workerId: row.workerFk,
name: row.userName,
};
},
},
cardVisible: true,
}, },
{ ...referenceColumn, isTitle: true, class: 'extend' },
companyFilterColumn,
{ {
align: 'left', align: 'right',
field: 'description', name: 'bankFk',
label: t('Reference'),
name: 'reference',
},
{
align: 'left',
field: 'bankFk',
label: t('Bank'), label: t('Bank'),
name: 'bank', cardVisible: true,
create: true,
},
{
align: 'right',
name: 'amountPaid',
label: t('Amount'),
component: 'number',
...onlyCreate,
}, },
{ {
align: 'right', align: 'right',
field: 'debit',
format: (value) => value && toCurrency(value),
label: t('Debit'),
name: 'debit', name: 'debit',
label: t('Debit'),
format: ({ debit }) => debit && toCurrency(debit),
isId: true,
}, },
{ {
align: 'right', align: 'right',
field: 'credit', name: 'credit',
format: (value) => value && toCurrency(value),
label: t('Havings'), label: t('Havings'),
name: 'havings', format: ({ credit }) => credit && toCurrency(credit),
cardVisible: true,
}, },
{ {
align: 'right', align: 'right',
field: 'balance',
format: (value) => value && toCurrency(value),
label: t('Balance'),
name: 'balance', name: 'balance',
label: t('Balance'),
format: ({ balance }) => toCurrency(balance),
cardVisible: true,
}, },
{ {
align: 'left', align: 'left',
field: 'isConciliate', name: 'isConciliate',
label: t('Conciliated'), label: t('Conciliated'),
name: 'conciliated', cardVisible: true,
}, },
{ ...referenceColumn, ...onlyCreate },
{ {
align: 'left', align: 'left',
field: 'totalWithVat', name: 'tableActions',
label: '', actions: [
name: 'actions', {
title: t('globals.downloadPdf'),
icon: 'cloud_download',
show: (row) => row.isInvoice,
action: (row) => showBalancePdf(row),
},
{
title: t('Send compensation'),
icon: 'outgoing_mail',
show: (row) => !!row.isCompensation,
action: ({ id }) =>
openConfirmationModal(
t('Send compensation'),
t('Do you want to report compensation to the client by mail?'),
() => sendEmail(`Receipts/${id}/balance-compensation-email`)
),
},
],
}, },
]); ]);
@ -123,254 +194,154 @@ onBeforeMount(() => {
companyId.value = user.value.companyFk; companyId.value = user.value.companyFk;
}); });
watch( async function getClientRisk(reload = false) {
() => route.params.id, if (reload || !clientRisk.value?.length) {
(newValue) => { const { data } = await axios.get(`clientRisks`, {
if (!newValue) return; params: {
userParams.clientId = newValue; filter: JSON.stringify({
filter.where.clientFk = newValue; include: { relation: 'company', scope: { fields: ['code'] } },
getData(); where: { clientFk: route.params.id, companyFk: user.value.companyFk },
}),
},
});
clientRisk.value = data;
} }
); return clientRisk.value;
}
const getData = () => { async function getCurrentBalance() {
receiptsRef.value?.fetch(); const currentBalance = (await getClientRisk()).find((balance) => {
clientRisksRef.value?.fetch();
};
const getCurrentBalance = () => {
const currentBalance = clientRisks.value.find((balance) => {
return balance.companyFk === companyId.value; return balance.companyFk === companyId.value;
}); });
return currentBalance && currentBalance.amount; return currentBalance && currentBalance.amount;
}; }
const onFetch = (balances) => { async function onFetch(data) {
balances.forEach((balance, index) => { balances.value = [];
for (const [index, balance] of data.entries()) {
if (index === 0) { if (index === 0) {
balance.balance = getCurrentBalance(); balance.balance = await getCurrentBalance();
} else { continue;
let previousBalance = balances[index - 1];
balance.balance =
previousBalance.balance -
(previousBalance.debit - previousBalance.credit);
} }
}); const previousBalance = data[index - 1];
balance.balance =
receiptsData.value = balances; previousBalance?.balance - (previousBalance?.debit - previousBalance?.credit);
}; }
balances.value = data;
}
// BORRAR COMPONENTE Y HACER CON VNTABLE
const showNewPaymentDialog = () => { const showNewPaymentDialog = () => {
quasar.dialog({ quasar.dialog({
component: CustomerNewPayment, component: CustomerNewPayment,
componentProps: { componentProps: {
companyId: companyId.value, companyId: companyId.value,
totalCredit: clientRisks.value[0]?.amount, totalCredit: clientRisk.value[0]?.amount,
promise: getData, promise: getClientRisk(true),
}, },
}); });
}; };
const updateCompanyId = (id) => { const showBalancePdf = ({ id }) => {
if (id) { const url = `api/InvoiceOuts/${id}/download?access_token=${tokenMultimedia}`;
companyId.value = id;
userParams.companyId = id;
filter.where.companyFk = id;
}
getData();
};
const saveFieldValue = async (row) => {
try {
const payload = { description: row.description };
await axios.patch(`Receipts/${row.id}`, payload);
} catch (err) {
return err;
}
};
const sendEmailAction = () => {
sendEmail(`Suppliers/${route.params.id}/campaign-metrics-email`);
};
const showBalancePdf = (balance) => {
const url = `api/InvoiceOuts/${balance.id}/download?access_token=${tokenMultimedia}`;
window.open(url, '_blank'); window.open(url, '_blank');
}; };
</script> </script>
<template> <template>
<FetchData <VnSubToolbar class="q-mb-md">
:filter="filter" <template #st-data>
@on-fetch="(data) => (clientRisks = data)" <div class="column justify-center q-px-md q-py-sm">
auto-load <span class="text-bold">{{ t('Total by company') }}</span>
ref="clientRisksRef" <div class="row justify-center" v-if="clientRisk?.length">
url="ClientRisks" {{ clientRisk[0].company.code }}:
/> {{ toCurrency(clientRisk[0].amount) }}
<FetchData </div>
:filter="filterCompanies" </div>
@on-fetch="(data) => (companiesOptions = data)" </template>
auto-load <template #st-actions>
url="Companies" <div>
/> <VnFilter
ref="vnFilterRef"
<VnPaginate v-model="companyId"
auto-load data-key="CustomerBalance"
:column="companyFilterColumn"
search-url="balance"
/>
</div>
</template>
</VnSubToolbar>
<VnTable
ref="tableRef"
data-key="CustomerBalance" data-key="CustomerBalance"
url="Receipts/filter" url="Receipts/filter"
:user-params="userParams" search-url="balance"
ref="receiptsRef" :user-params="filter"
:columns="columns"
:right-search="false"
:is-editable="false"
:column-search="false"
@on-fetch="onFetch" @on-fetch="onFetch"
:create="{
urlCreate: `Clients/${route.params.id}/createReceipt`,
mapper: (data) => {
data.companyFk = data.companyId;
delete data.companyId;
return data;
},
title: t('New payment'),
onDataSaved: () => tableRef.reload(),
formInitialData: { companyId },
}"
auto-load
> >
<template #body="{ rows }"> <template #column-balance="{ rowIndex }">
<QTable {{ toCurrency(balances[rowIndex]?.balance) }}
:columns="columns"
:no-data-label="t('globals.noResults')"
:rows-per-page-options="[0]"
:rows="rows"
class="full-width q-mt-md"
row-key="id"
>
<template #body-cell-employee="{ row }">
<QTd auto-width @click.stop>
<QBtn color="blue" flat no-caps>{{ row.userName }}</QBtn>
<WorkerDescriptorProxy :id="row.workerFk" />
</QTd>
</template>
<template #body-cell-reference="{ row }">
<QTd auto-width @click.stop v-if="row.isInvoice">
<QBtn color="blue" dense flat>
{{ t('bill', { ref: row.description }) }}
</QBtn>
<InvoiceOutDescriptorProxy :id="row.id" />
</QTd>
<QTd v-else>
<VnInput
@keyup.enter="saveFieldValue(row)"
autofocus
clearable
dense
v-model="row.description"
/>
</QTd>
</template>
<template #body-cell-conciliated="{ row }">
<QTd align="center">
<QCheckbox :model-value="row.isConciliate === 1" disable />
</QTd>
</template>
<template #body-cell-actions="{ row }">
<QTd align="center">
<QIcon
@click.stop="showDialog = true"
class="q-ml-md fill-icon"
color="primary"
name="outgoing_mail"
size="sm"
v-if="row.isCompensation"
>
<QTooltip>
{{ t('Send compensation') }}
</QTooltip>
</QIcon>
<QIcon
@click="showBalancePdf(row)"
class="q-ml-md fill-icon"
color="primary"
name="cloud_download"
size="sm"
v-if="row.hasPdf"
>
<QTooltip>
{{ t('globals.downloadPdf') }}
</QTooltip>
</QIcon>
<QDialog v-model="showDialog">
<QCard class="q-pa-sm">
<QCardSection>
<span
ref="closeButton"
class="flex justify-end color-vn-label"
v-close-popup
>
<QIcon name="close" size="sm" />
</span>
<div class="text-h6">
{{ t('Send compensation') }}
</div>
</QCardSection>
<QCardSection>
<div>
{{
t(
'Do you want to report compensation to the client by mail?'
)
}}
</div>
</QCardSection>
<QCardActions class="flex justify-end q-mb-sm">
<QBtn
:label="t('globals.cancel')"
color="primary"
flat
v-close-popup
/>
<QBtn
:label="t('globals.save')"
@click="sendEmailAction"
class="q-ml-sm"
color="primary"
/>
</QCardActions>
</QCard>
</QDialog>
</QTd>
</template>
</QTable>
</template> </template>
</VnPaginate> <template #column-description="{ row }">
<div class="link" v-if="row.isInvoice">
<QDrawer :width="256" show-if-above side="right" v-model="stateStore.rightDrawer"> {{ row.description }}
<div class="q-mt-xl q-px-md"> <InvoiceOutDescriptorProxy :id="row.description" />
</div>
<span v-else class="q-pa-xs dotted rounded-borders" :title="row.description">
{{ row.description }}
</span>
<QPopupEdit
v-model="row.description"
v-slot="scope"
@save="
(value) =>
value != row.description &&
axios.patch(`Receipts/${row.id}`, { description: value })
"
>
<VnInput
v-model="scope.value"
:disable="!hasAny(['administrative'])"
@keypress.enter="scope.set"
autofocus
/>
</QPopupEdit>
</template>
<template #column-create-bankFk="{ data, columnName, label }">
<VnSelect <VnSelect
:label="t('Company')" url="Accountings"
:options="companiesOptions" :label="label"
@update:model-value="updateCompanyId($event)" :limit="0"
hide-selected option-label="bank"
option-label="code" sort-by="id"
option-value="id" v-model="data[columnName]"
v-model="companyId" >
:rules="validate('entry.companyFk')" <template #option="scope">
/> <QItem v-bind="scope.itemProps">
</div> <QItemLabel>
#{{ scope.opt?.id }}: {{ scope.opt?.bank }}
<QCard class="q-ma-md q-pa-md q-mt-lg" v-if="receiptsData?.length"> </QItemLabel>
<QCardSection> </QItem>
<div class="flex justify-center text-subtitle1 text-bold"> </template>
{{ t('Total by company') }} </VnSelect>
</div> </template>
<div class="flex justify-center"> </VnTable>
<div class="q-mr-sm" v-if="clientRisks?.length">
{{ clientRisks[0].company.code }}:
</div>
<div v-if="clientRisks?.length">
{{ toCurrency(clientRisks[0].amount) }}
</div>
</div>
</QCardSection>
</QCard>
</QDrawer>
<QPageSticky :offset="[18, 18]">
<QBtn @click.stop="showNewPaymentDialog()" color="primary" fab icon="add" />
<QTooltip>
{{ t('New payment') }}
</QTooltip>
</QPageSticky>
</template> </template>
<i18n> <i18n>
@ -393,3 +364,12 @@ es:
Send compensation: Enviar compensación Send compensation: Enviar compensación
Do you want to report compensation to the client by mail?: ¿Desea informar de la compensación al cliente por correo? Do you want to report compensation to the client by mail?: ¿Desea informar de la compensación al cliente por correo?
</i18n> </i18n>
<style lang="scss" scoped>
.dotted {
border: 1px dotted var(--vn-header-color);
}
.dotted:hover {
border: 1px dotted $primary;
}
</style>

View File

@ -8,65 +8,27 @@ import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnImg from 'src/components/ui/VnImg.vue'; import VnImg from 'src/components/ui/VnImg.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const workers = ref([]);
const workersCopy = ref([]);
const businessTypes = ref([]); const businessTypes = ref([]);
const contactChannels = ref([]); const contactChannels = ref([]);
function setWorkers(data) {
workers.value = data;
workersCopy.value = data;
}
const filterOptions = {
options: workers,
filterFn: (options, value) => {
const search = value.toLowerCase();
if (value === '') return workersCopy.value;
return options.value.filter((row) => {
const id = row.id;
const name = row.name.toLowerCase();
const idMatches = id === search;
const nameMatches = name.indexOf(search) > -1;
return idMatches || nameMatches;
});
},
};
</script> </script>
<template> <template>
<fetch-data <FetchData
url="Workers/activeWithInheritedRole"
:filter="{ where: { role: 'salesPerson' } }"
@on-fetch="setWorkers"
auto-load
/>
<fetch-data
url="ContactChannels" url="ContactChannels"
@on-fetch="(data) => (contactChannels = data)" @on-fetch="(data) => (contactChannels = data)"
auto-load auto-load
/> />
<fetch-data <FetchData
url="BusinessTypes" url="BusinessTypes"
@on-fetch="(data) => (businessTypes = data)" @on-fetch="(data) => (businessTypes = data)"
auto-load auto-load
/> />
<fetch-data
:filter="filter"
@on-fetch="(data) => (clients = data)"
auto-load
url="Clients"
/>
<FormModel :url="`Clients/${route.params.id}`" auto-load model="customer"> <FormModel :url="`Clients/${route.params.id}`" auto-load model="customer">
<template #form="{ data, validate, filter }"> <template #form="{ data, validate }">
<VnRow> <VnRow>
<VnInput <VnInput
:label="t('globals.name')" :label="t('globals.name')"
@ -75,7 +37,6 @@ const filterOptions = {
clearable clearable
v-model="data.name" v-model="data.name"
/> />
<QSelect <QSelect
:input-debounce="0" :input-debounce="0"
:label="t('customer.basicData.businessType')" :label="t('customer.basicData.businessType')"
@ -126,30 +87,26 @@ const filterOptions = {
/> />
</VnRow> </VnRow>
<VnRow> <VnRow>
<QSelect <VnSelect
:input-debounce="0" url="Workers/activeWithInheritedRole"
:label="t('customer.basicData.salesPerson')" :filter="{ where: { role: 'salesPerson' } }"
:options="workers" option-filter="firstName"
:rules="validate('client.salesPersonFk')"
@filter="(value, update) => filter(value, update, filterOptions)"
emit-value
map-options
option-label="name"
option-value="id"
use-input
v-model="data.salesPersonFk" v-model="data.salesPersonFk"
:label="t('customer.basicData.salesPerson')"
:rules="validate('client.salesPersonFk')"
:use-like="false"
> >
<template #prepend> <template #prepend>
<QAvatar color="orange"> <QAvatar color="orange">
<VnImg <VnImg
v-if="data.salesPersonFk" v-if="data.salesPersonFk"
:id="user.id" :id="data.salesPersonFk"
collection="user" collection="user"
spinner-color="white" spinner-color="white"
/> />
</QAvatar> </QAvatar>
</template> </template>
</QSelect> </VnSelect>
<QSelect <QSelect
v-model="data.contactChannelFk" v-model="data.contactChannelFk"
:options="contactChannels" :options="contactChannels"

View File

@ -1,8 +1,7 @@
<script setup> <script setup>
import { computed } from 'vue'; import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { QBtn } from 'quasar';
import { toCurrency, toDateHourMin } from 'src/filters'; import { toCurrency, toDateHourMin } from 'src/filters';
import VnTable from 'components/VnTable/VnTable.vue'; import VnTable from 'components/VnTable/VnTable.vue';
import VnUserLink from 'src/components/ui/VnUserLink.vue'; import VnUserLink from 'src/components/ui/VnUserLink.vue';
@ -10,21 +9,23 @@ import VnUserLink from 'src/components/ui/VnUserLink.vue';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const filter = { const filter = computed(() => {
include: [ return {
{ include: [
relation: 'worker', {
scope: { relation: 'worker',
fields: ['id'], scope: {
include: { relation: 'user', scope: { fields: ['name'] } }, fields: ['id'],
include: { relation: 'user', scope: { fields: ['name'] } },
},
}, },
}, ],
], where: { clientFk: +route.params.id },
where: { clientFk: +route.params.id }, };
order: ['created DESC'], });
limit: 20,
};
const tableRef = ref();
const tableData = ref([]);
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
@ -43,39 +44,44 @@ const columns = computed(() => [
name: 'amount', name: 'amount',
format: ({ amount }) => toCurrency(amount), format: ({ amount }) => toCurrency(amount),
}, },
{
label: t('Credit'),
name: 'credit',
create: true,
visible: false,
attrs: {
autofocus: true,
},
},
]); ]);
</script> </script>
<template> <template>
<!-- Column titles are missing -->
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="ClientCredit" data-key="ClientCredit"
url="ClientCredits" url="ClientCredits"
search-url="credits"
:filter="filter" :filter="filter"
:order="['created DESC']"
:columns="columns" :columns="columns"
default-mode="table"
auto-load auto-load
:right-search="false" :right-search="false"
:is-editable="false" :is-editable="false"
:use-model="true" :use-model="true"
:column-search="false" :column-search="false"
:disable-option="{ card: true }" :disable-option="{ card: true }"
@on-fetch="(data) => (tableData = data)"
:create="{
urlUpdate: `Clients/${route.params.id}`,
title: t('New credit'),
onDataSaved: () => tableRef.reload(),
formInitialData: { credit: tableData.at(0)?.amount },
}"
> >
<template #column-employee="{ row }"> <template #column-employee="{ row }">
<VnUserLink :name="row?.worker?.user?.name" :worker-id="row.worker?.id" /> <VnUserLink :name="row?.worker?.user?.name" :worker-id="row.worker?.id" />
</template> </template>
</VnTable> </VnTable>
<QPageSticky :offset="[18, 18]">
<QBtn
@click.stop="$router.push({ name: 'CustomerCreditCreate' })"
color="primary"
fab
icon="add"
/>
<QTooltip>
{{ t('New credit') }}
</QTooltip>
</QPageSticky>
</template> </template>
<i18n> <i18n>
es: es:

View File

@ -98,15 +98,12 @@ function handleLocation(data, location) {
:options="postcodesOptions" :options="postcodesOptions"
v-model="data.postcode" v-model="data.postcode"
@update:model-value="(location) => handleLocation(data, location)" @update:model-value="(location) => handleLocation(data, location)"
> />
</VnLocation>
</VnRow> </VnRow>
<VnRow> <VnRow>
<QCheckbox :label="t('Active')" v-model="data.isActive" /> <QCheckbox :label="t('Active')" v-model="data.isActive" />
<QCheckbox :label="t('Frozen')" v-model="data.isFreezed" /> <QCheckbox :label="t('Frozen')" v-model="data.isFreezed" />
</VnRow> </VnRow>
<VnRow> <VnRow>
<QCheckbox :label="t('Has to invoice')" v-model="data.hasToInvoice" /> <QCheckbox :label="t('Has to invoice')" v-model="data.hasToInvoice" />
<div> <div>

View File

@ -2,101 +2,86 @@
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { QBtn } from 'quasar';
import { useStateStore } from 'src/stores/useStateStore';
import { toCurrency } from 'src/filters'; import { toCurrency } from 'src/filters';
import { toDateTimeFormat } from 'src/filters/date'; import { toDateTimeFormat } from 'src/filters/date';
import FetchData from 'components/FetchData.vue'; import VnTable from 'components/VnTable/VnTable.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const stateStore = computed(() => useStateStore());
const rows = ref([]); const rows = ref([]);
const totalAmount = ref(); const totalAmount = ref();
const tableRef = ref();
const filter = { const filter = computed(() => {
include: [ return {
{ include: [
relation: 'greugeType', {
scope: { relation: 'greugeType',
fields: ['id', 'name'], scope: {
fields: ['id', 'name'],
},
}, },
}, {
{ relation: 'user',
relation: 'user', scope: {
scope: { fields: ['id', 'name'],
fields: ['id', 'name'], },
}, },
],
where: {
clientFk: route.params.id,
}, },
], };
order: 'shipped DESC, amount', });
where: {
clientFk: `${route.params.id}`,
},
limit: 20,
};
const tableColumnComponents = {
date: {
component: 'span',
props: () => {},
event: () => {},
},
createdBy: {
component: QBtn,
props: () => ({ flat: true, color: 'blue', noCaps: true }),
event: () => {},
},
comment: {
component: 'span',
props: () => {},
event: () => {},
},
type: {
component: 'span',
props: () => {},
event: () => {},
},
amount: {
component: 'span',
props: () => {},
event: () => {},
},
};
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
field: 'shipped',
label: t('Date'), label: t('Date'),
name: 'date', name: 'shipped',
format: (value) => toDateTimeFormat(value), format: ({ shipped }) => toDateTimeFormat(shipped),
create: true,
columnCreate: {
component: 'date',
autofocus: true,
},
}, },
{ {
align: 'left', align: 'left',
field: (value) => value?.user?.name, name: 'userFk',
label: t('Created by'), label: t('Created by'),
name: 'createdBy', component: 'userLink',
attrs: ({ row }) => {
return {
defaultName: true,
workerId: row.user?.id,
name: row.user?.name,
};
},
}, },
{ {
align: 'left', align: 'left',
field: 'description', name: 'description',
label: t('Comment'), label: t('Comment'),
name: 'comment', create: true,
}, },
{ {
align: 'left', align: 'left',
field: (value) => value?.greugeType?.name, name: 'greugeTypeFk',
format: ({ greugeType }) => greugeType?.name,
label: t('Type'), label: t('Type'),
name: 'type', create: true,
columnCreate: {
component: 'select',
url: 'greugeTypes',
limit: 0,
},
}, },
{ {
align: 'left', align: 'left',
field: 'amount',
label: t('Amount'),
name: 'amount', name: 'amount',
format: (value) => toCurrency(value), label: t('Amount'),
format: ({ amount }) => toCurrency(amount),
create: true,
}, },
]); ]);
@ -107,60 +92,33 @@ const setRows = (data) => {
</script> </script>
<template> <template>
<FetchData :filter="filter" @on-fetch="setRows" auto-load url="greuges" /> <VnTable
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="300" show-if-above> ref="tableRef"
<QCard class="full-width q-pa-sm"> data-key="Greuges"
<h6 class="flex justify-end q-my-lg q-pr-lg" v-if="totalAmount !== undefined"> url="Greuges"
<span class="color-vn-label q-mr-md">{{ t('Total') }}:</span> search-url="greuges"
{{ toCurrency(totalAmount) }} :filter="filter"
</h6> :order="['shipped DESC', 'amount']"
<QSkeleton v-else type="QInput" square /> :columns="columns"
</QCard> :right-search="false"
</QDrawer> :is-editable="false"
<div class="full-width flex justify-center"> :use-model="true"
<QPage class="card-width q-pa-lg"> :column-search="false"
<QCard class="q-pa-sm q-mt-md"> @on-fetch="(data) => setRows(data)"
<QTable :create="{
:columns="columns" urlCreate: `Greuges`,
:no-data-label="t('globals.noResults')" title: t('New credit'),
:pagination="{ rowsPerPage: 12 }" onDataSaved: () => tableRef.reload(),
:rows="rows" formInitialData: { shipped: new Date(), clientFk: route.params.id },
class="full-width q-mt-md" }"
row-key="id" auto-load
> >
<template #body-cell="props"> <template #top-left>
<QTd :props="props"> <QCard class="q-px-md q-py-sm">
<QTr :props="props" class="cursor-pointer"> {{ t('Total') }}: {{ toCurrency(totalAmount) }}
<component
:is="tableColumnComponents[props.col.name].component"
class="col-content"
v-bind="
tableColumnComponents[props.col.name].props(props)
"
@click="
tableColumnComponents[props.col.name].event(props)
"
>
{{ props.value }}
<WorkerDescriptorProxy
:id="props.row.userFk"
v-if="props.col.name === 'createdBy'"
/>
</component>
</QTr>
</QTd>
</template>
</QTable>
</QCard> </QCard>
</QPage> </template>
</div> </VnTable>
<QPageSticky :offset="[18, 18]">
<QBtn color="primary" fab icon="add" :to="{ name: 'CustomerGreugeCreate' }" />
<QTooltip>
{{ t('New greuge') }}
</QTooltip>
</QPageSticky>
</template> </template>
<style lang="scss"> <style lang="scss">

View File

@ -1,14 +1,8 @@
<script setup> <script setup>
import { useI18n } from 'vue-i18n'; import { useRoute } from 'vue-router';
import { useRoute, useRouter } from 'vue-router'; import VnNotes from 'src/components/ui/VnNotes.vue';
import { toDateTimeFormat } from 'src/filters/date';
import VnPaginate from 'src/components/ui/VnPaginate.vue';
const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const router = useRouter();
const noteFilter = { const noteFilter = {
order: 'created DESC', order: 'created DESC',
@ -16,68 +10,14 @@ const noteFilter = {
clientFk: `${route.params.id}`, clientFk: `${route.params.id}`,
}, },
}; };
const toCustomerNoteCreate = () => {
router.push({ name: 'CustomerNoteCreate' });
};
</script> </script>
<template> <template>
<div class="full-width flex justify-center"> <VnNotes
<QCard class="card-width q-pa-lg"> url="clientObservations"
<VnPaginate :add-note="true"
data-key="CustomerNotes" :filter="noteFilter"
url="clientObservations" :body="{ clientFk: route.params.id }"
auto-load style="overflow-y: auto"
:filter="noteFilter" />
>
<template #body="{ rows }">
<div v-if="rows.length">
<QCard
v-for="(item, index) in rows"
:key="index"
class="q-pa-md q-rounded custom-border"
:class="{ 'q-mb-md': index < rows.length - 1 }"
>
<div class="flex justify-between">
<p class="color-vn-label">
{{ item.worker.user.nickname }}
</p>
<p class="color-vn-label">
{{ toDateTimeFormat(item?.created) }}
</p>
</div>
<h6 class="q-mt-xs q-mb-none">{{ item.text }}</h6>
</QCard>
</div>
<div v-else>
<h5 class="flex justify-center color-vn-label">
{{ t('globals.noResults') }}
</h5>
</div>
</template>
</VnPaginate>
</QCard>
</div>
<QPageSticky :offset="[18, 18]">
<QBtn @click.stop="toCustomerNoteCreate()" color="primary" fab icon="add" />
<QTooltip>
{{ t('New note') }}
</QTooltip>
</QPageSticky>
</template> </template>
<style lang="scss">
.custom-border {
border: 2px solid var(--vn-accent-color);
border-radius: 10px;
padding: 10px;
}
</style>
<i18n>
es:
New note: Nueva nota
</i18n>

View File

@ -106,9 +106,9 @@ const columns = computed(() => [
component: null, component: null,
after: { after: {
component: markRaw(VnLinkPhone), component: markRaw(VnLinkPhone),
attrs: (prop) => { attrs: ({ model }) => {
return { return {
'phone-number': prop, 'phone-number': model,
}; };
}, },
}, },

View File

@ -1,67 +0,0 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue';
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const initialData = ref({});
const setClient = (data) => {
initialData.value.credit = data.credit;
};
const toCustomerCredits = () => {
router.push({
name: 'CustomerCredits',
params: {
id: route.params.id,
},
});
};
</script>
<template>
<FetchData
:filter="filter"
@on-fetch="setClient"
auto-load
:url="`Clients/${route.params.id}/getCard`"
/>
<FormModel
:form-initial-data="initialData"
:observe-form-changes="false"
:url-update="`/Clients/${route.params.id}`"
@on-data-saved="toCustomerCredits()"
>
<template #moreActions>
<QBtn
:label="t('globals.cancel')"
@click="toCustomerCredits"
color="primary"
flat
icon="close"
/>
</template>
<template #form="{ data }">
<QInput
:label="t('Credit')"
clearable
type="number"
v-model.number="data.credit"
/>
</template>
</FormModel>
</template>
<i18n>
es:
Credit: Crédito
</i18n>

View File

@ -1,97 +0,0 @@
<script setup>
import { onMounted, reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnInputDate from 'components/common/VnInputDate.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const initialData = reactive({
shipped: '2001-01-01T11:00:00.000Z',
});
const greugeTypes = ref([]);
onMounted(() => {
initialData.clientFk = `${route.params.id}`;
});
const toCustomerGreuges = () => {
router.push({
name: 'CustomerGreuges',
params: {
id: route.params.id,
},
});
};
</script>
<template>
<fetch-data @on-fetch="(data) => (greugeTypes = data)" auto-load url="greugeTypes" />
<FormModel
:form-initial-data="initialData"
:observe-form-changes="false"
@on-data-saved="toCustomerGreuges()"
model="client"
url-create="Greuges"
>
<template #moreActions>
<QBtn
:label="t('globals.cancel')"
@click="toCustomerGreuges"
color="primary"
flat
icon="close"
/>
</template>
<template #form="{ data }">
<VnRow>
<VnInput
:label="t('Amount')"
clearable
type="number"
v-model="data.amount"
/>
<VnInputDate :label="t('Date')" v-model="data.shipped" />
</VnRow>
<VnRow>
<VnInput :label="t('Comment')" clearable v-model="data.description" />
<VnSelect
:label="t('Type')"
:options="greugeTypes"
hide-selected
option-label="name"
option-value="id"
v-model="data.greugeTypeFk"
/>
</VnRow>
</template>
</FormModel>
</template>
<style lang="scss" scoped>
.add-icon {
cursor: pointer;
background-color: $primary;
border-radius: 50px;
}
</style>
<i18n>
es:
Amount: Importe
Date: Fecha
Comment: Comentario
Type: Tipo
</i18n>

View File

@ -11,12 +11,10 @@ import VnRow from 'components/ui/VnRow.vue';
import VnInputDate from 'components/common/VnInputDate.vue'; import VnInputDate from 'components/common/VnInputDate.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import { useState } from 'src/composables/useState';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const { dialogRef } = useDialogPluginComponent(); const { dialogRef } = useDialogPluginComponent();
const state = useState();
const user = state.getUser();
const $props = defineProps({ const $props = defineProps({
companyId: { companyId: {
@ -40,7 +38,7 @@ const bankOptions = ref([]);
const clientFindOne = ref([]); const clientFindOne = ref([]);
const deliveredAmount = ref(null); const deliveredAmount = ref(null);
const amountToReturn = ref(null); const amountToReturn = ref(null);
const viewRecipt = ref(true); const viewReceipt = ref();
const sendEmail = ref(false); const sendEmail = ref(false);
const isLoading = ref(false); const isLoading = ref(false);
@ -57,24 +55,46 @@ const filterClientFindOne = {
id: route.params.id, id: route.params.id,
}, },
}; };
const initialData = reactive({ const initialData = reactive({
amountPaid: $props.totalCredit, amountPaid: $props.totalCredit,
clientFk: route.params.id, clientFk: route.params.id,
companyFk: $props.companyId, companyFk: $props.companyId,
email: clientFindOne.value.email, email: clientFindOne.value.email,
bankFk: user.value.localBankFk,
}); });
onBeforeMount(() => { onBeforeMount(() => {
urlCreate.value = `Clients/${route.params.id}/createReceipt`; urlCreate.value = `Clients/${route.params.id}/createReceipt`;
}); });
const setPaymentType = (id) => { const setPaymentType = (value) => {
initialData.payed = '2001-01-01T11:00:00.000Z'; // if (id === 1) initialData.description = 'Credit card';
if (id === 1) initialData.description = 'Credit card'; // if (id === 2) initialData.description = 'Cash';
if (id === 2) initialData.description = 'Cash'; // if (id === 3 || id === 3117) initialData.description = '';
if (id === 3 || id === 3117) initialData.description = ''; // if (id === 4) initialData.description = 'Transfer';
if (id === 4) initialData.description = 'Transfer'; // const CASH_CODE = 2;
// // const CASH_CODE = 2
// if (!value) return;
// const accountingType = CASH_CODE;
// initialData.description = '';
// viewReceipt.value = value == CASH_CODE;
// if (accountingType.code == 'compensation') this.receipt.description = '';
// else {
// if (
// accountingType.receiptDescription != null &&
// accountingType.receiptDescription != ''
// )
// this.receipt.description.push(accountingType.receiptDescription);
// if (this.originalDescription)
// this.receipt.description.push(this.originalDescription);
// this.receipt.description = this.receipt.description.join(', ');
// }
// this.maxAmount = accountingType && accountingType.maxAmount;
// this.receipt.payed = Date.vnNew();
// if (accountingType.daysInFuture)
// this.receipt.payed.setDate(
// this.receipt.payed.getDate() + accountingType.daysInFuture
// );
}; };
const calculateFromAmount = (event) => { const calculateFromAmount = (event) => {
@ -207,7 +227,6 @@ const onDataSaved = async () => {
<div class="q-mt-lg" v-if="data.bankFk === 2"> <div class="q-mt-lg" v-if="data.bankFk === 2">
<div class="text-h6">{{ t('Cash') }}</div> <div class="text-h6">{{ t('Cash') }}</div>
<VnRow> <VnRow>
<VnInput <VnInput
:label="t('Delivered amount')" :label="t('Delivered amount')"
@ -224,13 +243,11 @@ const onDataSaved = async () => {
v-model="amountToReturn" v-model="amountToReturn"
/> />
</VnRow> </VnRow>
<VnRow> <VnRow>
<QCheckbox v-model="viewRecipt" /> <QCheckbox v-model="viewReceipt" />
<QCheckbox v-model="sendEmail" /> <QCheckbox v-model="sendEmail" />
</VnRow> </VnRow>
</div> </div>
<div class="q-mt-lg row justify-end"> <div class="q-mt-lg row justify-end">
<QBtn <QBtn
:disabled="isLoading" :disabled="isLoading"

View File

@ -1,57 +0,0 @@
<script setup>
import { onMounted, reactive } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const initialData = reactive({});
onMounted(() => {
initialData.clientFk = `${route.params.id}`;
});
const toCustomerNotes = () => {
router.push({
name: 'CustomerNotes',
params: {
id: route.params.id,
},
});
};
</script>
<template>
<FormModel
:form-initial-data="initialData"
:observe-form-changes="false"
@on-data-saved="toCustomerNotes()"
url-create="ClientObservations"
>
<template #moreActions>
<QBtn
:label="t('globals.cancel')"
@click="toCustomerNotes"
color="primary"
flat
icon="close"
/>
</template>
<template #form="{ data }">
<VnRow>
<QInput :label="t('Note')" type="textarea" v-model="data.text" />
</VnRow>
</template>
</FormModel>
</template>
<i18n>
es:
Note: Nota
</i18n>

View File

@ -18,9 +18,9 @@ const columns = [
name: 'itemFk', name: 'itemFk',
columnField: { columnField: {
component: VnImg, component: VnImg,
attrs: (id) => { attrs: ({ row }) => {
return { return {
id, id: row.id,
size: '50x50', size: '50x50',
width: '50px', width: '50px',
}; };

View File

@ -192,7 +192,7 @@ onMounted(async () => {
:filter="entryFilter" :filter="entryFilter"
:create="{ :create="{
urlCreate: 'Entries', urlCreate: 'Entries',
title: 'Create entry', title: t('Create entry'),
onDataSaved: ({ id }) => tableRef.redirect(id), onDataSaved: ({ id }) => tableRef.redirect(id),
formInitialData: {}, formInitialData: {},
}" }"
@ -210,4 +210,5 @@ es:
Virtual entry: Es una redada Virtual entry: Es una redada
Search entries: Buscar entradas Search entries: Buscar entradas
You can search by entry reference: Puedes buscar por referencia de la entrada You can search by entry reference: Puedes buscar por referencia de la entrada
Create entry: Crear entrada
</i18n> </i18n>

View File

@ -70,9 +70,9 @@ const columns = computed(() => [
name: 'image', name: 'image',
columnField: { columnField: {
component: VnImg, component: VnImg,
attrs: (id) => { attrs: ({ row }) => {
return { return {
id, id: row.id,
width: '50px', width: '50px',
}; };
}, },

View File

@ -221,9 +221,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
:find="['agencyModeFk', 'agencyModeName']" :find="['agencyModeFk', 'agencyModeName']"
v-model="row.agencyModeFk" v-model="row.agencyModeFk"
@update:model-value="onUpdate(row.ticketFk, 'agencyModeFk', $event)" @update:model-value="onUpdate(row.ticketFk, 'agencyModeFk', $event)"
> />
{{ console.log('row: ', row) }}
</VnSelectCache>
</template> </template>
<template #column-clientFk="{ row }"> <template #column-clientFk="{ row }">
<span class="link" @click.stop> <span class="link" @click.stop>

View File

@ -187,87 +187,32 @@ export default {
}, },
{ {
path: 'notes', path: 'notes',
name: 'CustomerNotesCard', name: 'CustomerNotes',
redirect: { name: 'CustomerNotes' }, meta: {
children: [ title: 'notes',
{ icon: 'vn:notes',
path: '', },
name: 'CustomerNotes', component: () => import('src/pages/Customer/Card/CustomerNotes.vue'),
meta: {
title: 'notes',
icon: 'vn:notes',
},
component: () =>
import('src/pages/Customer/Card/CustomerNotes.vue'),
},
{
path: 'create',
name: 'CustomerNoteCreate',
meta: {
title: 'note-create',
},
component: () =>
import(
'src/pages/Customer/components/CustomerNoteCreate.vue'
),
},
],
}, },
{ {
path: 'credits', path: 'credits',
name: 'CreditsCard', name: 'CustomerCredits',
redirect: { name: 'CustomerCredits' }, meta: {
children: [ title: 'credits',
{ icon: 'vn:credit',
path: '', },
name: 'CustomerCredits', component: () =>
meta: { import('src/pages/Customer/Card/CustomerCredits.vue'),
title: 'credits',
icon: 'vn:credit',
},
component: () =>
import('src/pages/Customer/Card/CustomerCredits.vue'),
},
{
path: 'create',
name: 'CustomerCreditCreate',
meta: {
title: 'credit-create',
},
component: () =>
import(
'src/pages/Customer/components/CustomerCreditCreate.vue'
),
},
],
}, },
{ {
path: 'greuges', path: 'greuges',
name: 'GreugesCard', name: 'CustomerGreuges',
redirect: { name: 'CustomerGreuges' }, meta: {
children: [ title: 'greuges',
{ icon: 'vn:greuge',
path: '', },
name: 'CustomerGreuges', component: () =>
meta: { import('src/pages/Customer/Card/CustomerGreuges.vue'),
title: 'greuges',
icon: 'vn:greuge',
},
component: () =>
import('src/pages/Customer/Card/CustomerGreuges.vue'),
},
{
path: 'create',
name: 'CustomerGreugeCreate',
meta: {
title: 'greuge-create',
},
component: () =>
import(
'src/pages/Customer/components/CustomerGreugeCreate.vue'
),
},
],
}, },
{ {
path: 'balance', path: 'balance',