This commit is contained in:
parent
ceb0c1fc75
commit
eabb71834f
|
@ -97,7 +97,7 @@ const $props = defineProps({
|
|||
});
|
||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||
const modelValue = computed(
|
||||
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`
|
||||
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`,
|
||||
).value;
|
||||
const componentIsRendered = ref(false);
|
||||
const arrayData = useArrayData(modelValue);
|
||||
|
@ -106,7 +106,7 @@ const isLoading = ref(false);
|
|||
const isResetting = ref(false);
|
||||
const hasChanges = ref(!$props.observeFormChanges);
|
||||
const originalData = ref({});
|
||||
const formData = computed(() => getValue(state.get(modelValue)));
|
||||
const formData = computed(() => state.get(modelValue));
|
||||
const defaultButtons = computed(() => ({
|
||||
save: {
|
||||
dataCy: 'saveDefaultBtn',
|
||||
|
@ -148,7 +148,7 @@ onMounted(async () => {
|
|||
JSON.stringify(newVal) !== JSON.stringify(originalData.value);
|
||||
isResetting.value = false;
|
||||
},
|
||||
{ deep: true }
|
||||
{ deep: true },
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -156,7 +156,7 @@ onMounted(async () => {
|
|||
if (!$props.url)
|
||||
watch(
|
||||
() => arrayData.store.data,
|
||||
(val) => updateAndEmit('onFetch', val)
|
||||
(val) => updateAndEmit('onFetch', val),
|
||||
);
|
||||
|
||||
watch(
|
||||
|
@ -165,7 +165,7 @@ watch(
|
|||
originalData.value = null;
|
||||
reset();
|
||||
await fetch();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
onBeforeRouteLeave((to, from, next) => {
|
||||
|
@ -192,7 +192,7 @@ async function fetch() {
|
|||
let { data } = await axios.get($props.url, {
|
||||
params: { filter: JSON.stringify($props.filter) },
|
||||
});
|
||||
data = getValue(data);
|
||||
if (Array.isArray(data)) data = data[0] ?? {};
|
||||
|
||||
updateAndEmit('onFetch', data);
|
||||
} catch (e) {
|
||||
|
@ -254,7 +254,7 @@ function filter(value, update, filterOptions) {
|
|||
(ref) => {
|
||||
ref.setOptionIndex(-1);
|
||||
ref.moveOptionSelection(1, true);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ function trimData(data) {
|
|||
}
|
||||
|
||||
function getValue(data) {
|
||||
return Array.isArray(data) ? data[0] : data ?? {};
|
||||
return Array.isArray(data) ? data[0] : (data ?? {});
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
|
|
Loading…
Reference in New Issue