refactor: refs #8372 update FormModelPopup to enhance save and continue logic with state management
gitea/salix-front/pipeline/pr-test This commit looks good
Details
gitea/salix-front/pipeline/pr-test This commit looks good
Details
This commit is contained in:
parent
fbce97dd01
commit
659d87020f
|
@ -1,6 +1,7 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { ref, computed, useAttrs, nextTick } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useState } from 'src/composables/useState';
|
||||
|
||||
import FormModel from 'components/FormModel.vue';
|
||||
|
||||
|
@ -22,17 +23,22 @@ const props = defineProps({
|
|||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const attrs = useAttrs();
|
||||
const state = useState();
|
||||
const formModelRef = ref(null);
|
||||
const closeButton = ref(null);
|
||||
const isSaveAndContinue = ref(props.showSaveAndContinueBtn);
|
||||
const isLoading = computed(() => formModelRef.value?.isLoading);
|
||||
const reset = computed(() => formModelRef.value?.reset);
|
||||
|
||||
const onDataSaved = (formData, requestResponse) => {
|
||||
const onDataSaved = async (formData, requestResponse) => {
|
||||
if (!isSaveAndContinue.value) closeButton.value?.click();
|
||||
emit('onDataSaved', formData, requestResponse);
|
||||
if (isSaveAndContinue.value) {
|
||||
await nextTick();
|
||||
state.set(attrs.model, attrs.formInitialData);
|
||||
}
|
||||
isSaveAndContinue.value = props.showSaveAndContinueBtn;
|
||||
emit('onDataSaved', formData, requestResponse);
|
||||
};
|
||||
|
||||
const onClick = async (saveAndContinue) => {
|
||||
|
|
Loading…
Reference in New Issue