0
0
Fork 0

Solucion a comentarios 6

This commit is contained in:
carlosfonseca 2024-02-13 12:50:00 -05:00
parent c0a9835e80
commit d0e98010a5
3 changed files with 97 additions and 3 deletions

View File

@ -15,6 +15,7 @@ const route = useRoute();
const { notify } = useNotify(); const { notify } = useNotify();
let notes = reactive([]); let notes = reactive([]);
let deletes = reactive([]);
const isLoading = ref(false); const isLoading = ref(false);
@ -51,14 +52,16 @@ const addNote = ({ id, name, phone, isNew }) => {
} }
}; };
const deleteNote = (index) => { const deleteNote = (note, index) => {
deletes.push(note.id);
notes.splice(index, 1); notes.splice(index, 1);
}; };
const onSubmit = async () => { const onSubmit = async () => {
isLoading.value = true; isLoading.value = true;
const payload = { const payload = {
creates: notes.filter((element) => element.$isNew), creates: notes.filter((element) => element.$isNew) || null,
deletes: deletes || null,
}; };
try { try {
await axios.post('ClientContacts/crud', payload); await axios.post('ClientContacts/crud', payload);
@ -91,7 +94,7 @@ const onSubmit = async () => {
<div class="flex items-center"> <div class="flex items-center">
<QIcon <QIcon
@click.stop="deleteNote(index)" @click.stop="deleteNote(note, index)"
class="cursor-pointer" class="cursor-pointer"
color="primary" color="primary"
name="delete" name="delete"

View File

@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import axios from 'axios'; import axios from 'axios';
import { useQuasar } from 'quasar';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
@ -13,8 +14,10 @@ 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';
const { t } = useI18n(); const { t } = useI18n();
const quasar = useQuasar();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const state = useState(); const state = useState();
@ -57,6 +60,7 @@ onBeforeMount(async () => {
initialData.companyFk = companyFk; initialData.companyFk = companyFk;
initialData.companyId = companyFk; initialData.companyId = companyFk;
initialData.recipient = data.email; initialData.recipient = data.email;
initialData.recipientId = data.id;
}); });
const setEmailUser = (data) => { const setEmailUser = (data) => {
@ -88,6 +92,32 @@ const onDataSaved = async ({
}); });
router.push({ name: 'CustomerSamples' }); router.push({ name: 'CustomerSamples' });
}; };
const getPreview = async () => {
const { addressId, companyId, recipientId } = initialData;
const path = `Clients/${route.params.id}/incoterms-authorization-html`;
const params = {
addressId,
companyId,
recipientId,
};
const queryParams = Object.keys(params)
.map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`)
.join('&');
const url = `${path}?${queryParams}`;
try {
const { data } = await axios.get(url);
quasar.dialog({
component: CustomerSamplesPreview,
componentProps: {
htmlContent: data,
},
});
} catch (error) {
return error;
}
};
</script> </script>
<template> <template>
@ -117,6 +147,7 @@ const onDataSaved = async ({
/> />
<FormModel <FormModel
:default-actions="false"
:form-initial-data="initialData" :form-initial-data="initialData"
:observe-form-changes="false" :observe-form-changes="false"
@on-data-saved="onDataSaved" @on-data-saved="onDataSaved"
@ -226,6 +257,34 @@ const onDataSaved = async ({
/> />
</div> </div>
</VnRow> </VnRow>
<div class="q-mt-lg row justify-end">
<QBtn
:disabled="isLoading"
:label="t('globals.cancel')"
:loading="isLoading"
class="q-mr-sm"
color="primary"
flat
type="reset"
v-close-popup
/>
<QBtn
:disabled="isLoading"
:label="t('Preview')"
:loading="isLoading"
@click.stop="getPreview()"
class="q-mr-sm"
color="primary"
/>
<QBtn
:disabled="isLoading || canChangePassword"
:label="t('globals.save')"
:loading="isLoading"
color="primary"
type="submit"
/>
</div>
</template> </template>
</FormModel> </FormModel>
</template> </template>
@ -240,4 +299,5 @@ es:
Since: Desde Since: Desde
Its only used when sample is sent: Se utiliza únicamente cuando se envía la plantilla Its only used when sample is sent: Se utiliza únicamente cuando se envía la plantilla
To who should the recipient replay?: ¿A quien debería responder el destinatario? To who should the recipient replay?: ¿A quien debería responder el destinatario?
Preview: Vista previa
</i18n> </i18n>

View File

@ -0,0 +1,31 @@
<script setup>
import { ref } from 'vue';
import { useDialogPluginComponent } from 'quasar';
const { dialogRef } = useDialogPluginComponent();
const closeButton = ref(null);
const $props = defineProps({
htmlContent: {
type: String,
required: true,
},
});
</script>
<template>
<QDialog ref="dialogRef">
<QCard class="q-pa-lg">
<QCardSection>
<span ref="closeButton" class="row justify-end close-icon" v-close-popup>
<QIcon name="close" size="sm" />
</span>
<div>{{ $props.htmlContent }}</div>
<template>
<div v-html="$props.htmlContent"></div>
</template>
</QCardSection>
</QCard>
</QDialog>
</template>