HOTFIX: #6943 hotFix_AddressObservation_crud #945
|
@ -23,6 +23,7 @@ const incoterms = ref([]);
|
|||
const customsAgents = ref([]);
|
||||
const observationTypes = ref([]);
|
||||
const notes = ref([]);
|
||||
let originalNotes = [];
|
||||
const deletes = ref([]);
|
||||
|
||||
onBeforeMount(() => {
|
||||
|
@ -42,7 +43,8 @@ const getData = async (observations) => {
|
|||
});
|
||||
|
||||
if (data.length) {
|
||||
notes.value = data
|
||||
originalNotes = data;
|
||||
notes.value = originalNotes
|
||||
|
||||
.map((observation) => {
|
||||
const type = observationTypes.value.find(
|
||||
(type) => type.id === observation.observationTypeFk
|
||||
|
@ -81,14 +83,24 @@ const deleteNote = (id, index) => {
|
|||
};
|
||||
|
||||
const onDataSaved = async () => {
|
||||
let payload = {};
|
||||
const creates = notes.value.filter((note) => note.$isNew);
|
||||
if (creates.length) {
|
||||
payload.creates = creates;
|
||||
}
|
||||
if (deletes.value.length) {
|
||||
payload.deletes = deletes.value;
|
||||
}
|
||||
let payload = {
|
||||
creates: notes.value.filter((note) => note.$isNew),
|
||||
deletes: deletes.value,
|
||||
updates: notes.value
|
||||
.filter((note) =>
|
||||
originalNotes.some(
|
||||
(oNote) =>
|
||||
oNote.id === note.id &&
|
||||
(note.description !== oNote.description ||
|
||||
note.observationTypeFk !== oNote.observationTypeFk)
|
||||
)
|
||||
)
|
||||
.map((note) => ({
|
||||
data: note,
|
||||
where: { id: note.id },
|
||||
})),
|
||||
};
|
||||
|
||||
await axios.post('AddressObservations/crud', payload);
|
||||
notes.value = [];
|
||||
deletes.value = [];
|
||||
|
|
Loading…
Reference in New Issue
notes.value y originalNotes tendran la misma refernacia. Por tanto cuando modifiques uno se modifican los dos no=?
Entiendo que ya que uno es ref y el otro no.
He podido eleminar, modificar, tipo y descripción y todo el rato la propiedad updates me aparecia un registro.
Voy a probar