This commit is contained in:
Viet An
2026-07-04 13:46:14 +07:00
parent b06907097c
commit b6766ba7d0
19 changed files with 397 additions and 680 deletions

View File

@@ -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;

View File

@@ -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,