HOTFIX: #6943 hotFix_AddressObservation_crud #945
|
@ -23,6 +23,7 @@ const incoterms = ref([]);
|
||||||
const customsAgents = ref([]);
|
const customsAgents = ref([]);
|
||||||
const observationTypes = ref([]);
|
const observationTypes = ref([]);
|
||||||
const notes = ref([]);
|
const notes = ref([]);
|
||||||
|
let originalNotes = [];
|
||||||
const deletes = ref([]);
|
const deletes = ref([]);
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
|
@ -42,7 +43,8 @@ const getData = async (observations) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data.length) {
|
if (data.length) {
|
||||||
notes.value = data
|
originalNotes = data;
|
||||||
|
notes.value = originalNotes
|
||||||
|
|||||||
.map((observation) => {
|
.map((observation) => {
|
||||||
const type = observationTypes.value.find(
|
const type = observationTypes.value.find(
|
||||||
(type) => type.id === observation.observationTypeFk
|
(type) => type.id === observation.observationTypeFk
|
||||||
|
@ -81,14 +83,24 @@ const deleteNote = (id, index) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onDataSaved = async () => {
|
const onDataSaved = async () => {
|
||||||
let payload = {};
|
let payload = {
|
||||||
const creates = notes.value.filter((note) => note.$isNew);
|
creates: notes.value.filter((note) => note.$isNew),
|
||||||
if (creates.length) {
|
deletes: deletes.value,
|
||||||
payload.creates = creates;
|
updates: notes.value
|
||||||
}
|
.filter((note) =>
|
||||||
if (deletes.value.length) {
|
originalNotes.some(
|
||||||
payload.deletes = deletes.value;
|
(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);
|
await axios.post('AddressObservations/crud', payload);
|
||||||
notes.value = [];
|
notes.value = [];
|
||||||
deletes.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