changes
This commit is contained in:
@@ -403,7 +403,7 @@ export default defineNuxtPlugin(() => {
|
||||
};
|
||||
|
||||
//======================Export===============================
|
||||
const exportExcel = function (data, filename, fields) {
|
||||
const exportExcel = async function (data, filename, fields) {
|
||||
var _filename = filename + ".xlsx";
|
||||
let list = [];
|
||||
data.map((v) => {
|
||||
@@ -414,8 +414,9 @@ export default defineNuxtPlugin(() => {
|
||||
});
|
||||
list.push(ele);
|
||||
});
|
||||
var XLSX = require("xlsx");
|
||||
//workBook class
|
||||
|
||||
const XLSX = await import("xlsx");
|
||||
// WorkBook class
|
||||
function Workbook() {
|
||||
if (!(this instanceof Workbook)) return new Workbook();
|
||||
this.SheetNames = [];
|
||||
|
||||
@@ -20,12 +20,17 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
const { $id, $empty, $store } = nuxtApp;
|
||||
const dialog = function (content, title, type, duration, width, height, vbind) {
|
||||
content = typeof content === "string" ? content : JSON.stringify(content);
|
||||
let vtitle = type === "Success" ? `<span class="has-text-primary">${title}</span>` : title;
|
||||
if (type === "Error") vtitle = `<span class="has-text-danger">${title}</span>`;
|
||||
const vtitle =
|
||||
type === "Success"
|
||||
? `<span class="has-text-primary">${title}</span>`
|
||||
: type === "Error"
|
||||
? `<span class="has-text-danger">${title}</span>`
|
||||
: title;
|
||||
|
||||
let data = {
|
||||
id: $id(),
|
||||
component: `dialog/${type || "Info"}`,
|
||||
vbind: { content: content, duration: duration, vbind: vbind },
|
||||
vbind: { content, duration, vbind },
|
||||
title: vtitle,
|
||||
width: width || "600px",
|
||||
height: height || "100px",
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user