This commit is contained in:
Viet An
2026-05-14 17:00:03 +07:00
parent 1f44f9e6bf
commit 400bbf242e
5 changed files with 76 additions and 71 deletions

View File

@@ -27,7 +27,7 @@ export default defineNuxtPlugin((nuxtApp) => {
? `<span class="has-text-danger">${title}</span>`
: title;
let data = {
const data = {
id: $id(),
component: `dialog/${type || "Info"}`,
vbind: { content, duration, vbind },
@@ -35,17 +35,24 @@ export default defineNuxtPlugin((nuxtApp) => {
width: width || "600px",
height: height || "100px",
};
$store.commit("showmodal", data);
};
const snackbar = function (content, title, type, width, height) {
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>`;
let data = {
const vtitle =
type === "Success"
? `<span class="has-text-primary">${title}</span>`
: type === "Error"
? `<span class="has-text-danger">${title}</span>`
: title;
const data = {
id: $id(),
component: `snackbar/${type || "Info"}`,
vbind: { content: content },
component: type || "Info",
vbind: { content },
title: vtitle,
width: width || "600px",
height: height || "100px",
@@ -54,13 +61,14 @@ export default defineNuxtPlugin((nuxtApp) => {
};
const getLink = function (val) {
if (val === undefined || val === null || val === "" || val === "") return "";
let json = val.indexOf("{") >= 0 ? JSON.parse(val) : { path: val };
if ($empty(val)) return "";
const json = val.indexOf("{") >= 0 ? JSON.parse(val) : { path: val };
return json;
};
const errPhone = function (phone) {
var text = undefined;
let text;
if ($empty(phone)) {
text = "Số điện thoại di động không được bỏ trống.";
} else if (isNaN(phone)) {
@@ -74,7 +82,7 @@ export default defineNuxtPlugin((nuxtApp) => {
const errEmail = function (email) {
const re =
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var text = undefined;
let text = undefined;
if ($empty(email)) {
text = "Email không được bỏ trống.";
} else if (!re.test(String(email).toLowerCase())) {
@@ -86,7 +94,7 @@ export default defineNuxtPlugin((nuxtApp) => {
const errPhoneEmail = function (contact) {
const re =
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var text = undefined;
let text = undefined;
if ($empty(contact)) {
text = "Số điện thoại di động hoặc Email không được bỏ trống.";