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;
|
||||
|
||||
@@ -28,6 +28,9 @@ import CustomerForm from "~/components/customer/CustomerForm.vue";
|
||||
import Dashboard from "~/components/dashboard/Dashboard.vue";
|
||||
import Orders from "~/components/orders/Orders.vue";
|
||||
import Inventory from "~/components/inventory/Inventory.vue";
|
||||
import InventoryItemName from "~/components/inventory/InventoryItemName.vue";
|
||||
import IMEICountByWarehouse from "~/components/inventory/IMEICountByWarehouse.vue";
|
||||
import Status from "~/components/inventory/Status.vue";
|
||||
import Rights from "~/components/rights/Rights.vue";
|
||||
import POS from "~/components/pos/POS.vue";
|
||||
import ChooseIMEIButton from "~/components/pos/ChooseIMEIButton.vue";
|
||||
@@ -80,6 +83,9 @@ const components = {
|
||||
Dashboard,
|
||||
Orders,
|
||||
Inventory,
|
||||
InventoryItemName,
|
||||
IMEICountByWarehouse,
|
||||
Status,
|
||||
Rights,
|
||||
POS,
|
||||
ChooseIMEIButton,
|
||||
|
||||
Reference in New Issue
Block a user