Solucion a comentarios 33
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
carlosfonseca 2024-03-10 21:20:19 -05:00
parent c844d26ccb
commit 5ff90d127b
3 changed files with 203 additions and 138 deletions

View File

@ -59,12 +59,7 @@ const getBankEntities = (data, formData) => {
/> />
</div> </div>
<div class="col"> <div class="col">
<VnInput <VnInput :label="t('Due day')" clearable v-model="data.dueDay" />
:label="t('Due day')"
:rules="validate('client.socialName')"
clearable
v-model="data.dueDay"
/>
</div> </div>
</VnRow> </VnRow>

View File

@ -230,6 +230,18 @@ const onFetch = (data) => {
selection="multiple" selection="multiple"
v-model:selected="selected" v-model:selected="selected"
> >
<template #header="props">
<QTr :props="props" class="bg">
<QTh>
<QCheckbox v-model="props.selected" />
</QTh>
<QTh v-for="col in props.cols" :key="col.name" :props="props">
{{ t(col.label) }}
<QTooltip v-if="col.tooltip">{{ col.tooltip }}</QTooltip>
</QTh>
</QTr>
</template>
<template #body-cell="props"> <template #body-cell="props">
<QTd :props="props"> <QTd :props="props">
<QTr :props="props" class="cursor-pointer"> <QTr :props="props" class="cursor-pointer">

View File

@ -7,25 +7,31 @@ import axios from 'axios';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { useValidator } from 'src/composables/useValidator';
import useNotify from 'src/composables/useNotify';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue'; import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue'; import VnInputDate from 'src/components/common/VnInputDate.vue';
import CustomerSamplesPreview from 'src/pages/Customer/components/CustomerSamplesPreview.vue'; import CustomerSamplesPreview from 'src/pages/Customer/components/CustomerSamplesPreview.vue';
const { notify } = useNotify();
const { t } = useI18n(); const { t } = useI18n();
const { validate } = useValidator();
const quasar = useQuasar(); const quasar = useQuasar();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const state = useState(); const state = useState();
const user = state.getUser(); const user = state.getUser();
const optionsEmailUsers = ref([]); const client = ref({});
const hasChanged = ref(false);
const isLoading = ref(false);
const optionsClientsAddressess = ref([]); const optionsClientsAddressess = ref([]);
const optionsCompanies = ref([]); const optionsCompanies = ref([]);
const optionsEmailUsers = ref([]);
const optionsSamplesVisible = ref([]); const optionsSamplesVisible = ref([]);
const sampleType = ref({ hasPreview: false }); const sampleType = ref({ hasPreview: false });
@ -53,11 +59,9 @@ const filterSamplesVisible = {
const initialData = reactive({}); const initialData = reactive({});
onBeforeMount(async () => { onBeforeMount(async () => {
const { companyFk } = user.value;
const { data } = await axios.get(`Clients/1/getCard`); const { data } = await axios.get(`Clients/1/getCard`);
client.value = data;
initialData.clientFk = route.params.id; initialData.clientFk = route.params.id;
initialData.companyFk = companyFk;
initialData.companyId = companyFk;
initialData.recipient = data.email; initialData.recipient = data.email;
initialData.recipientId = data.id; initialData.recipientId = data.id;
}); });
@ -73,28 +77,27 @@ const setClientsAddresses = (data) => {
}; };
const setSampleType = (sampleId) => { const setSampleType = (sampleId) => {
sampleType.value = optionsSamplesVisible.value.find( hasChanged.value = true;
(option) => option.id === sampleId const { companyFk } = user.value;
); sampleType.value = optionsSamplesVisible.value.find((option) => {
return option.id === sampleId;
});
initialData.companyFk = companyFk;
initialData.companyId = companyFk;
}; };
const onDataSaved = async ({ const setInitialData = () => {
addressId, hasChanged.value = false;
companyFk,
companyId, initialData.addressId = optionsClientsAddressess.value[0].id;
from, initialData.companyFk = null;
recipient, initialData.from = null;
replyTo, initialData.recipient = client.value.email;
}) => { initialData.recipientId = client.value.id;
await axios.post(`Clients/${route.params.id}/incoterms-authorization-email`, { initialData.replyTo = optionsEmailUsers.value[0]?.email;
addressId, initialData.typeFk = '';
companyFk,
companyId, sampleType.value = {};
from,
recipient,
replyTo,
});
toCustomerSamples();
}; };
const getPreview = async () => { const getPreview = async () => {
@ -123,6 +126,43 @@ const getPreview = async () => {
} }
}; };
const onSubmit = async () => {
isLoading.value = true;
try {
const { data } = await axios.patch('ClientSamples', initialData);
notify('globals.dataSaved', 'positive');
onDataSaved(data);
} catch (error) {
notify('errors.create', 'negative');
} finally {
isLoading.value = false;
}
};
const onDataSaved = async ({
addressId,
companyFk,
companyId,
from,
recipient,
replyTo,
}) => {
await axios.post(`Clients/${route.params.id}/incoterms-authorization-email`, {
addressId,
companyFk,
companyId,
from,
recipient,
replyTo,
});
toCustomerSamples();
};
const updateModelValue = () => {
hasChanged.value = true;
};
const toCustomerSamples = () => { const toCustomerSamples = () => {
router.push({ name: 'CustomerSamples' }); router.push({ name: 'CustomerSamples' });
}; };
@ -154,14 +194,8 @@ const toCustomerSamples = () => {
url="Samples/visible" url="Samples/visible"
/> />
<FormModel <Teleport to="#st-actions">
:form-initial-data="initialData" <QBtnGroup push class="q-gutter-x-sm">
:observe-form-changes="false"
@on-data-saved="onDataSaved"
model="samplesCreate"
url-create="ClientSamples"
>
<template #moreActions>
<QBtn <QBtn
:label="t('globals.cancel')" :label="t('globals.cancel')"
@click="toCustomerSamples" @click="toCustomerSamples"
@ -170,7 +204,7 @@ const toCustomerSamples = () => {
icon="close" icon="close"
/> />
<QBtn <QBtn
:disabled="isLoading || !sampleType.hasPreview" :disabled="isLoading || !sampleType?.hasPreview"
:label="t('Preview')" :label="t('Preview')"
:loading="isLoading" :loading="isLoading"
@click.stop="getPreview()" @click.stop="getPreview()"
@ -178,10 +212,30 @@ const toCustomerSamples = () => {
flat flat
icon="preview" icon="preview"
/> />
</template> <QBtn
:disabled="!hasChanged"
:label="t('globals.reset')"
:loading="isLoading"
@click="setInitialData"
color="primary"
flat
icon="restart_alt"
type="reset"
/>
<QBtn
:disabled="!hasChanged"
:label="t('globals.save')"
:loading="isLoading"
@click="onSubmit"
color="primary"
icon="save"
/>
</QBtnGroup>
</Teleport>
<template #form="{ data, validate }"> <div class="full-width flex justify-center">
<VnRow class="row q-gutter-md q-mb-md"> <QCard class="card-width q-pa-lg">
<QForm>
<div class="col"> <div class="col">
<VnSelectFilter <VnSelectFilter
:label="t('Sample')" :label="t('Sample')"
@ -190,106 +244,110 @@ const toCustomerSamples = () => {
hide-selected hide-selected
option-label="description" option-label="description"
option-value="id" option-value="id"
required="true" v-model="initialData.typeFk"
v-model="data.typeFk"
/> />
</div> </div>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md"> <VnRow class="row q-gutter-md q-mb-md">
<div class="col"> <div class="col">
<VnInput <VnInput
:label="t('Recipient')" :label="t('Recipient')"
clearable @update:model-value="updateModelValue"
required="true" clearable
v-model="data.recipient" required="true"
> v-model="initialData.recipient"
<template #append> >
<QIcon name="info" class="cursor-pointer"> <template #append>
<QTooltip>{{ <QIcon name="info" class="cursor-pointer">
t('Its only used when sample is sent') <QTooltip>{{
}}</QTooltip> t('Its only used when sample is sent')
</QIcon> }}</QTooltip>
</template> </QIcon>
</VnInput> </template>
</div> </VnInput>
<div class="col"> </div>
<VnInput <div class="col">
:label="t('Reply to')" <VnInput
clearable :label="t('Reply to')"
required="true" @update:model-value="updateModelValue"
v-model="data.replyTo" clearable
> required="true"
<template #append> v-model="initialData.replyTo"
<QIcon name="info" class="cursor-pointer"> >
<QTooltip>{{ <template #append>
t('To who should the recipient replay?') <QIcon name="info" class="cursor-pointer">
}}</QTooltip> <QTooltip>{{
</QIcon> t('To who should the recipient replay?')
</template> }}</QTooltip>
</VnInput> </QIcon>
</div> </template>
</VnRow> </VnInput>
</div>
</VnRow>
<VnRow <VnRow
class="row q-gutter-md q-mb-md" class="row q-gutter-md q-mb-md"
v-if="sampleType.hasCompany || sampleType.datepickerEnabled" v-if="sampleType?.hasCompany || sampleType?.datepickerEnabled"
> >
<div class="col"> <div class="col">
<VnSelectFilter <VnSelectFilter
:label="t('Company')" :label="t('Company')"
:options="optionsCompanies" :options="optionsCompanies"
:rules="validate('entry.companyFk')" :rules="validate('entry.companyFk')"
hide-selected hide-selected
option-label="code" option-label="code"
option-value="id" option-value="id"
required="true" required="true"
v-model="data.companyFk" v-model="initialData.companyFk"
v-if="sampleType.hasCompany" v-if="sampleType.hasCompany"
/> />
</div> </div>
<div class="col"> <div class="col">
<VnSelectFilter <VnSelectFilter
:label="t('Address')" :label="t('Address')"
:options="optionsClientsAddressess" :options="optionsClientsAddressess"
hide-selected hide-selected
option-label="nickname" option-label="nickname"
option-value="id" option-value="id"
required="true" required="true"
v-model="data.addressId" v-model="initialData.addressId"
v-if="sampleType.id === 20" v-if="sampleType.id === 20"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
<QItemSection> <QItemSection>
<QItemLabel> <QItemLabel>
{{ {{
`${scope.opt.nickname}, ${scope.opt.street}, ${scope.opt.city}, ${scope.opt.province.name} - ${scope.opt.agencyMode.name}` `${scope.opt.nickname}, ${scope.opt.street}, ${scope.opt.city}, ${scope.opt.province.name} - ${scope.opt.agencyMode.name}`
}} }}
</QItemLabel> </QItemLabel>
</QItemSection> </QItemSection>
</QItem> </QItem>
</template> </template>
<template #append> <template #append>
<QIcon name="edit" class="cursor-pointer"> <QIcon name="edit" class="cursor-pointer">
<QTooltip>{{ t('Edit address') }}</QTooltip> <QTooltip>{{ t('Edit address') }}</QTooltip>
</QIcon> </QIcon>
</template> </template>
</VnSelectFilter> </VnSelectFilter>
</div> </div>
</VnRow> </VnRow>
<VnRow class="row q-gutter-md q-mb-md" v-if="sampleType.datepickerEnabled"> <VnRow
<div class="col"> class="row q-gutter-md q-mb-md"
<VnInputDate v-if="sampleType?.datepickerEnabled"
:label="t('Since')" >
required="true" <div class="col">
v-model="data.from" <VnInputDate
/> :label="t('Since')"
</div> required="true"
</VnRow> v-model="initialData.from"
</template> />
</FormModel> </div>
</VnRow>
</QForm>
</QCard>
</div>
</template> </template>
<i18n> <i18n>