changes
This commit is contained in:
@@ -102,7 +102,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
params: { values },
|
||||
});
|
||||
}
|
||||
// update store
|
||||
|
||||
if (api.commit) {
|
||||
if (store[api.commit]) {
|
||||
const copy = $copy(store[api.commit]);
|
||||
@@ -117,6 +117,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
store.commit(api.commit, copy);
|
||||
}
|
||||
}
|
||||
|
||||
if (notify) {
|
||||
$snackbar(
|
||||
store.lang === "en" ? "Data has been successfully saved to the system." : "Dữ liệu đã được lưu vào hệ thống",
|
||||
@@ -138,12 +139,22 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
const api = findapi(name);
|
||||
const curpath = getpath(api.path);
|
||||
const updateUrl = api.url_detail || api.url;
|
||||
let rs;
|
||||
|
||||
const rs = await $fetch(`${curpath}${updateUrl}${data.id}/`, {
|
||||
method: "PATCH",
|
||||
body: data,
|
||||
params: { values: values || api.params?.values },
|
||||
});
|
||||
if (Array.isArray(data)) {
|
||||
const model = api.url.slice(5);
|
||||
rs = await $fetch(`${curpath}import-data/${model}`, {
|
||||
method: "POST",
|
||||
body: data,
|
||||
params: { values, action: "import" },
|
||||
});
|
||||
} else {
|
||||
rs = await $fetch(`${curpath}${updateUrl}${data.id}/`, {
|
||||
method: "PATCH",
|
||||
body: data,
|
||||
params: { values: values || api.params?.values },
|
||||
});
|
||||
}
|
||||
|
||||
if (api.commit) {
|
||||
const index = store[api.commit] ? store[api.commit].findIndex((v) => v.id === rs.id) : -1;
|
||||
|
||||
Reference in New Issue
Block a user