This commit is contained in:
Viet An
2026-05-14 09:11:18 +07:00
parent 336c8c9036
commit 4d37397ee4
25 changed files with 450 additions and 209 deletions

View File

@@ -1108,13 +1108,18 @@ export default defineNuxtPlugin((nuxtApp) => {
sort: "capacity",
},
},
{
name: "IMEI",
url: "data/IMEI/",
url_detail: "data-detail/IMEI/",
params: {},
},
];
const { $copy, $clone, $updateSeriesFields, $snackbar, $store, $remove, $dialog } = nuxtApp;
const requestLogin = function () {
$store.commit("login", undefined);
$store.commit("layersetting", undefined);
$store.commit("lastlegendfiltertab", "Giỏ hàng");
window.location.href = `https://${mode === "dev" ? "dev." : ""}login.utopia.com.vn/signin?module=${module}&link=${window.location.origin}`;
};
@@ -1178,7 +1183,7 @@ export default defineNuxtPlugin((nuxtApp) => {
const insertapi = async function (name, data, values, notify) {
try {
let found = findapi(name);
let curpath = found.path ? paths.find((x) => x.name === found.path).url : path;
const curpath = found.path ? paths.find((x) => x.name === found.path).url : path;
let rs;
if (!Array.isArray(data)) {
rs = await $fetch(`${curpath}${found.url}`, {
@@ -1190,15 +1195,15 @@ export default defineNuxtPlugin((nuxtApp) => {
rs = await $fetch(`${curpath}import-data/${found.url.substring(5, found.url.length - 1)}/`, {
method: "POST",
body: data,
params: { action: "import", values },
params: { values, action: "import" },
});
}
// update store
if (found.commit) {
if ($store[found.commit]) {
let copy = $copy($store[found.commit]);
let rows = Array.isArray(rs) ? rs : [rs];
rows.map((v) => {
const copy = $copy($store[found.commit]);
const rows = Array.isArray(rs) ? rs : [rs];
rows.forEach((v) => {
if (v.id && !v.error) {
let idx = copy.findIndex((x) => x.id === v.id);
if (idx >= 0) copy[idx] = v;
@@ -1441,16 +1446,15 @@ export default defineNuxtPlugin((nuxtApp) => {
// delete data
const deleteapi = async function (name, id) {
try {
var rs;
let found = findapi(name);
if (!Array.isArray(id))
const found = findapi(name);
let rs;
if (!Array.isArray(id)) {
rs = await $fetch(`${path}${found.url_detail}${id}`, {
method: "delete",
});
else {
let params = { action: "delete" };
} else {
rs = await $fetch(`${path}import-data/${found.url.substring(5, found.url.length - 1)}/`, id, {
params,
params: { action: "delete" },
});
}
if (found.commit) {
@@ -1465,13 +1469,12 @@ export default defineNuxtPlugin((nuxtApp) => {
});
}
$store.commit(found.name, copy);
console.log("copy", copy);
}
return id;
} catch (err) {
console.log(err);
if (err.response) {
let content = `<span class="has-text-danger">Đã xảy ra lỗi, xóa dữ liệu không thành công</span>`;
let content = `<span>Đã xảy ra lỗi, xóa dữ liệu không thành công</span>`;
if (err.response.data)
content += `<p class="mt-2 has-text-grey-dark">
<sapn class="icon-text">Chi tiết<SvgIcon class="ml-1" v-bind="{name: 'right.svg', type: 'dark', size: 20}"></SvgIcon></span></p>