forked from verdnatura/salix-front
fear: refs #6942 save and continue btn
This commit is contained in:
parent
2e19194a08
commit
9cbffff627
|
@ -1,6 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { useValidator } from 'src/composables/useValidator';
|
import { useValidator } from 'src/composables/useValidator';
|
||||||
|
@ -10,6 +11,7 @@ import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
import SkeletonTable from 'components/ui/SkeletonTable.vue';
|
import SkeletonTable from 'components/ui/SkeletonTable.vue';
|
||||||
import { tMobile } from 'src/composables/tMobile';
|
import { tMobile } from 'src/composables/tMobile';
|
||||||
|
|
||||||
|
const { push } = useRouter();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -56,6 +58,11 @@ const $props = defineProps({
|
||||||
type: Function,
|
type: Function,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
goTo: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
description: 'It is used for redirect on click "save and continue"',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
@ -122,6 +129,11 @@ async function onSubmit() {
|
||||||
await saveChanges();
|
await saveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onSumbitAndGo() {
|
||||||
|
await onSubmit();
|
||||||
|
push({ path: $props.goTo });
|
||||||
|
}
|
||||||
|
|
||||||
async function saveChanges(data) {
|
async function saveChanges(data) {
|
||||||
if ($props.saveFn) return $props.saveFn(data, getChanges);
|
if ($props.saveFn) return $props.saveFn(data, getChanges);
|
||||||
const changes = data || getChanges();
|
const changes = data || getChanges();
|
||||||
|
@ -298,7 +310,25 @@ watch(formUrl, async () => {
|
||||||
:title="t('globals.reset')"
|
:title="t('globals.reset')"
|
||||||
v-if="$props.defaultReset"
|
v-if="$props.defaultReset"
|
||||||
/>
|
/>
|
||||||
|
<QBtnDropdown
|
||||||
|
v-if="$props.goTo && $props.defaultSave"
|
||||||
|
@click="onSubmit"
|
||||||
|
:label="tMobile('globals.save')"
|
||||||
|
:disable="!hasChanges"
|
||||||
|
color="primary"
|
||||||
|
icon="save"
|
||||||
|
split
|
||||||
|
>
|
||||||
|
<QList>
|
||||||
|
<QItem color="primary" clickable v-close-popup @click="onSumbitAndGo">
|
||||||
|
<QItemSection>
|
||||||
|
<QItemLabel>{{ t('globals.saveAndContinue') }}</QItemLabel>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
</QList>
|
||||||
|
</QBtnDropdown>
|
||||||
<QBtn
|
<QBtn
|
||||||
|
v-else-if="!$props.goTo && $props.defaultSave"
|
||||||
:label="tMobile('globals.save')"
|
:label="tMobile('globals.save')"
|
||||||
ref="saveButtonRef"
|
ref="saveButtonRef"
|
||||||
color="primary"
|
color="primary"
|
||||||
|
@ -306,7 +336,6 @@ watch(formUrl, async () => {
|
||||||
@click="onSubmit"
|
@click="onSubmit"
|
||||||
:disable="!hasChanges"
|
:disable="!hasChanges"
|
||||||
:title="t('globals.save')"
|
:title="t('globals.save')"
|
||||||
v-if="$props.defaultSave"
|
|
||||||
/>
|
/>
|
||||||
<slot name="moreAfterActions" />
|
<slot name="moreAfterActions" />
|
||||||
</QBtnGroup>
|
</QBtnGroup>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { onMounted, onUnmounted, computed, ref, watch, nextTick } from 'vue';
|
import { onMounted, onUnmounted, computed, ref, watch, nextTick } from 'vue';
|
||||||
import { onBeforeRouteLeave } from 'vue-router';
|
import { onBeforeRouteLeave, useRouter } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
|
@ -11,6 +11,7 @@ import useNotify from 'src/composables/useNotify.js';
|
||||||
import SkeletonForm from 'components/ui/SkeletonForm.vue';
|
import SkeletonForm from 'components/ui/SkeletonForm.vue';
|
||||||
import VnConfirm from './ui/VnConfirm.vue';
|
import VnConfirm from './ui/VnConfirm.vue';
|
||||||
|
|
||||||
|
const { push } = useRouter();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
|
@ -65,6 +66,11 @@ const $props = defineProps({
|
||||||
type: Function,
|
type: Function,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
goTo: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
description: 'It is used for redirect on click "save and continue"',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||||
|
@ -174,6 +180,11 @@ async function save() {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function saveAndGo() {
|
||||||
|
await save();
|
||||||
|
push({ path: $props.goTo });
|
||||||
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
state.set($props.model, originalData.value);
|
state.set($props.model, originalData.value);
|
||||||
originalData.value = JSON.parse(JSON.stringify(originalData.value));
|
originalData.value = JSON.parse(JSON.stringify(originalData.value));
|
||||||
|
@ -241,7 +252,27 @@ watch(formUrl, async () => {
|
||||||
:disable="!hasChanges"
|
:disable="!hasChanges"
|
||||||
:title="t('globals.reset')"
|
:title="t('globals.reset')"
|
||||||
/>
|
/>
|
||||||
|
<QBtnDropdown
|
||||||
|
v-if="$props.goTo"
|
||||||
|
@click="save"
|
||||||
|
:label="tMobile('globals.save')"
|
||||||
|
:disable="!hasChanges"
|
||||||
|
color="primary"
|
||||||
|
icon="save"
|
||||||
|
split
|
||||||
|
>
|
||||||
|
<QList>
|
||||||
|
<QItem color="primary" clickable v-close-popup @click="saveAndGo">
|
||||||
|
<QItemSection>
|
||||||
|
<QItemLabel>{{
|
||||||
|
t('globals.saveAndContinue')
|
||||||
|
}}</QItemLabel>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
</QList>
|
||||||
|
</QBtnDropdown>
|
||||||
<QBtn
|
<QBtn
|
||||||
|
v-else
|
||||||
:label="tMobile('globals.save')"
|
:label="tMobile('globals.save')"
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="save"
|
icon="save"
|
||||||
|
|
|
@ -26,6 +26,7 @@ export default {
|
||||||
create: 'Create',
|
create: 'Create',
|
||||||
edit: 'Edit',
|
edit: 'Edit',
|
||||||
save: 'Save',
|
save: 'Save',
|
||||||
|
saveAndContinue: 'Save and continue',
|
||||||
remove: 'Remove',
|
remove: 'Remove',
|
||||||
reset: 'Reset',
|
reset: 'Reset',
|
||||||
close: 'Close',
|
close: 'Close',
|
||||||
|
|
|
@ -26,6 +26,7 @@ export default {
|
||||||
create: 'Crear',
|
create: 'Crear',
|
||||||
edit: 'Modificar',
|
edit: 'Modificar',
|
||||||
save: 'Guardar',
|
save: 'Guardar',
|
||||||
|
saveAndContinue: 'Guardar y continuar',
|
||||||
remove: 'Eliminar',
|
remove: 'Eliminar',
|
||||||
reset: 'Restaurar',
|
reset: 'Restaurar',
|
||||||
close: 'Cerrar',
|
close: 'Cerrar',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
@ -14,8 +14,7 @@ import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const route = useRoute();
|
const { currentRoute } = useRouter();
|
||||||
const router = useRouter();
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const dms = ref({});
|
const dms = ref({});
|
||||||
|
@ -23,6 +22,7 @@ const editDownloadDisabled = ref(false);
|
||||||
const arrayData = useArrayData('InvoiceIn');
|
const arrayData = useArrayData('InvoiceIn');
|
||||||
const invoiceIn = computed(() => arrayData.store.data);
|
const invoiceIn = computed(() => arrayData.store.data);
|
||||||
const userConfig = ref(null);
|
const userConfig = ref(null);
|
||||||
|
const invoiceId = currentRoute.value.params.id;
|
||||||
|
|
||||||
const expenses = ref([]);
|
const expenses = ref([]);
|
||||||
const currencies = ref([]);
|
const currencies = ref([]);
|
||||||
|
@ -182,12 +182,10 @@ async function upsert() {
|
||||||
/>
|
/>
|
||||||
<FormModel
|
<FormModel
|
||||||
v-if="invoiceIn"
|
v-if="invoiceIn"
|
||||||
:url="`InvoiceIns/${route.params.id}`"
|
:url="`InvoiceIns/${invoiceId}`"
|
||||||
model="invoiceIn"
|
model="InvoiceIn"
|
||||||
|
:go-to="`/invoice-in/${invoiceId}/vat`"
|
||||||
auto-load
|
auto-load
|
||||||
@on-data-saved="
|
|
||||||
router.push({ name: 'InvoiceInVat', params: { id: route.params.id } })
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<template #form="{ data }">
|
<template #form="{ data }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
@ -11,13 +11,13 @@ import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
|
||||||
import CrudModel from 'src/components/CrudModel.vue';
|
import CrudModel from 'src/components/CrudModel.vue';
|
||||||
import VnCurrency from 'src/components/common/VnCurrency.vue';
|
import VnCurrency from 'src/components/common/VnCurrency.vue';
|
||||||
|
|
||||||
const route = useRoute();
|
const { currentRoute } = useRouter();
|
||||||
const router = useRouter();
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
|
|
||||||
const arrayData = useArrayData('InvoiceIn');
|
const arrayData = useArrayData('InvoiceIn');
|
||||||
const invoiceIn = computed(() => arrayData.store.data);
|
const invoiceIn = computed(() => arrayData.store.data);
|
||||||
|
const invoiceId = currentRoute.value.params.id;
|
||||||
|
|
||||||
const expenses = ref([]);
|
const expenses = ref([]);
|
||||||
const sageTaxTypes = ref([]);
|
const sageTaxTypes = ref([]);
|
||||||
|
@ -108,7 +108,7 @@ const filter = {
|
||||||
'transactionTypeSageFk',
|
'transactionTypeSageFk',
|
||||||
],
|
],
|
||||||
where: {
|
where: {
|
||||||
invoiceInFk: route.params.id,
|
invoiceInFk: invoiceId,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -177,12 +177,10 @@ const getTotalRate = (rows) => rows.reduce((acc, cur) => acc + taxRate(cur), 0);
|
||||||
data-key="InvoiceInTaxes"
|
data-key="InvoiceInTaxes"
|
||||||
url="InvoiceInTaxes"
|
url="InvoiceInTaxes"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
:data-required="{ invoiceInFk: route.params.id }"
|
:data-required="{ invoiceInFk: invoiceId }"
|
||||||
auto-load
|
auto-load
|
||||||
v-model:selected="rowsSelected"
|
v-model:selected="rowsSelected"
|
||||||
@save-changes="
|
:go-to="`/invoice-in/${invoiceId}/due-day`"
|
||||||
router.push({ name: 'InvoiceInDueDay', params: { id: route.params.id } })
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<template #body="{ rows }">
|
<template #body="{ rows }">
|
||||||
<QTable
|
<QTable
|
||||||
|
|
Loading…
Reference in New Issue