PR-CUSTOMER #186
|
@ -1,57 +1,113 @@
|
|||
<script setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { onBeforeMount, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import FormModel from 'components/FormModel.vue';
|
||||
import axios from 'axios';
|
||||
|
||||
import useNotify from 'src/composables/useNotify';
|
||||
|
||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const { notify } = useNotify();
|
||||
|
||||
const unpaidClient = ref(false);
|
||||
const initialData = reactive({
|
||||
const isLoading = ref(false);
|
||||
jsegarra marked this conversation as resolved
Outdated
|
||||
const amount = ref(null);
|
||||
const dated = ref(null);
|
||||
|
||||
const initialData = ref({
|
||||
dated: '2001-01-01T11:00:00.000Z',
|
||||
clientFk: 1,
|
||||
});
|
||||
|
||||
const onFetch = () => {
|
||||
unpaidClient.value = true;
|
||||
onBeforeMount(async () => {
|
||||
try {
|
||||
const { data } = await axios.get(`ClientUnpaids/${route.params.id}`);
|
||||
amount.value = data.amount;
|
||||
dated.value = data.dated;
|
||||
initialData.value = data;
|
||||
} catch (error) {
|
||||
setInitialData();
|
||||
}
|
||||
});
|
||||
|
||||
const setInitialData = () => {
|
||||
amount.value = initialData.value.amount;
|
||||
dated.value = initialData.value.dated;
|
||||
};
|
||||
|
||||
const onSubmit = async () => {
|
||||
jgallego
commented
salix pone una fecha por defecto, emular comportamiento salix pone una fecha por defecto, emular comportamiento
cfonseca
commented
Corregido: Corregido: 90ee50eab5
jsegarra
commented
Lo veo OK Lo veo OK
|
||||
isLoading.value = true;
|
||||
|
||||
const payload = {
|
||||
amount: amount.value,
|
||||
clientFk: route.params.id,
|
||||
dated: dated.value,
|
||||
};
|
||||
try {
|
||||
await axios.patch('ClientUnpaids', payload);
|
||||
jsegarra marked this conversation as resolved
Outdated
jsegarra
commented
Porque haces un find por id, si ya lo has hecho en la query/filter? Te devoilverá el resultado Porque haces un find por id, si ya lo has hecho en la query/filter? Te devoilverá el resultado
Si filtras por 1101, te llegará [1101]
cfonseca
commented
Corregido: Corregido: 93015d9f98
|
||||
notify('globals.dataSaved', 'positive');
|
||||
jsegarra marked this conversation as resolved
Outdated
jsegarra
commented
Mi propuesta es si data.length>0 Mi propuesta es si data.length>0
cfonseca
commented
Corregido: Corregido: 93015d9f98
|
||||
unpaidClient.value = true;
|
||||
} catch (error) {
|
||||
notify('errors.create', 'negative');
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FormModel
|
||||
:form-initial-data="initialData"
|
||||
:observe-form-changes="true"
|
||||
:url="`ClientUnpaids/${route.params.id}`"
|
||||
@on-fetch="onFetch"
|
||||
url-create="ClientUnpaids"
|
||||
auto-load
|
||||
>
|
||||
<template #form="{ data }">
|
||||
<VnRow class="row q-gutter-md q-mb-md">
|
||||
<div class="col">
|
||||
<QCheckbox :label="t('Unpaid client')" v-model="unpaidClient" />
|
||||
</div>
|
||||
</VnRow>
|
||||
<Teleport to="#st-actions">
|
||||
<QBtnGroup push class="q-gutter-x-sm">
|
||||
jsegarra marked this conversation as resolved
Outdated
jsegarra
commented
No se muestran los botones No se muestran los botones
cfonseca
commented
Los botones siempre estaban visibles, corregí que cuando habían datos no se estaban mostrando adecuadamente y no recargaba la data al cambiar manualmente la url: Los botones siempre estaban visibles, corregí que cuando habían datos no se estaban mostrando adecuadamente y no recargaba la data al cambiar manualmente la url: 7eca27b8af
|
||||
<QBtn
|
||||
:disabled="isLoading"
|
||||
:label="t('globals.reset')"
|
||||
:loading="isLoading"
|
||||
@click="setInitialData"
|
||||
color="primary"
|
||||
flat
|
||||
icon="restart_alt"
|
||||
type="reset"
|
||||
/>
|
||||
<QBtn
|
||||
:disabled="isLoading"
|
||||
:label="t('globals.save')"
|
||||
:loading="isLoading"
|
||||
@click="onSubmit"
|
||||
color="primary"
|
||||
icon="save"
|
||||
/>
|
||||
</QBtnGroup>
|
||||
</Teleport>
|
||||
|
||||
<VnRow class="row q-gutter-md q-mb-md" v-if="unpaidClient">
|
||||
<div class="col">
|
||||
<VnInputDate :label="t('Date')" v-model="data.dated" />
|
||||
</div>
|
||||
<div class="col">
|
||||
<VnInput
|
||||
:label="t('Amount')"
|
||||
clearable
|
||||
type="number"
|
||||
v-model="data.amount"
|
||||
/>
|
||||
</div>
|
||||
</VnRow>
|
||||
</template>
|
||||
</FormModel>
|
||||
<div class="full-width flex justify-center">
|
||||
<QCard class="card-width q-pa-lg">
|
||||
<QForm>
|
||||
<VnRow class="row q-gutter-md q-mb-md">
|
||||
<div class="col">
|
||||
<QCheckbox :label="t('Unpaid client')" v-model="unpaidClient" />
|
||||
</div>
|
||||
</VnRow>
|
||||
|
||||
<VnRow class="row q-gutter-md q-mb-md" v-if="unpaidClient">
|
||||
<div class="col">
|
||||
<VnInputDate :label="t('Date')" v-model="dated" />
|
||||
</div>
|
||||
<div class="col">
|
||||
<VnInput
|
||||
:label="t('Amount')"
|
||||
clearable
|
||||
type="number"
|
||||
v-model="amount"
|
||||
/>
|
||||
</div>
|
||||
</VnRow>
|
||||
</QForm>
|
||||
</QCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
|
|
|
@ -15,8 +15,8 @@ const $props = defineProps({
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<QDialog ref="dialogRef">
|
||||
<QCard class="q-pa-lg">
|
||||
<QDialog ref="dialogRef" full-width>
|
||||
<QCard class="dialog-width q-pa-lg">
|
||||
<QCardSection>
|
||||
<span ref="closeButton" class="row justify-end close-icon" v-close-popup>
|
||||
<QIcon name="close" size="sm" />
|
||||
|
@ -26,3 +26,9 @@ const $props = defineProps({
|
|||
</QCard>
|
||||
</QDialog>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.dialog-width {
|
||||
max-width: 900px !important;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue
TODO, revisar si hay otra opción
Modificado
Commit:
998561badd